The Omron CP1H programmable logic controller has several different table data processing instructions. These instructions are used to handle table data, stacks and other ranges of data.
We can define a stack of data. With this data we can then do the following: add new data by pushing onto the stack, use FIFO (First In First Out), use LIFO (Last In First Out), find the current stack size and read, overwrite, insert or delete from the stack.
Dimension record tables are used to define the length of each record and the number of records. We can then write and read these records. This is ideal for data acquisition projects.
Other instructions found in the table data processing instructions include searching, summing and finding minimum and maximum values.
We will be looking at these instructions in the Omron CP1H PLC. Examples of the instructions will be presented.
Previously in this CP1H series we have discussed:
Setting, Forcing and Online Editing
Numbering Systems and Addressing
Data Shifting Instructions
Data Conversion Instructions
Program Control Instructions
Several different table data processing instructions are available in the CP1H. A full explanation can be obtained by using the help menu in the CX-Programmer software or the Programming Manual for the CP1H. Links are provided at the end of this post.
Instructions can have different variations.
Let’s look at when this instruction will execute:
SSET(630) when used will be scanned and executed every cycle of the PLC that the input condition is on.
@ SSET(630) when used will be executed when the input condition turns from off to on. This will trigger the instruction to happen only once.
Please refer to the programming manual or help file in CX-Programmer for different variations of the instructions that you want to use. We will now go over some of the table data processing instructions in the Omron CP1H. This will give you a general idea of the instructions available.
Table Data Processing Instructions
This list gives you all of the table data processing instructions in the CP1H. All of the instructions will work with a group of consecutive memory areas that we will call a table. Let’s look at these instructions.
SET STACK: SSET(630)
This instruction will initialize and establish a stack. This is a group of addresses (consecutive) that will contain data.
The first two registers contain the memory location for the last word in the stack. The stack pointer is in the following two memory locations. When we first initialize this instruction, the value will be TB+4.
We can now use additional commands to work with this group of data. (Stack)
In this example we are specifying our stack that we defined at D0. We are writing the value at D20 into the stack and then increment the stack pointer by one.
FIRST IN FIRST OUT: FIFO(633)
The first in first out instruction moves the first data in the stack (Oldest Data) to the destination location. The stack pointer will be decremented by one. All of the stack information will get moved in the stack back one address.
LAST IN FIRST OUT: LIFO(634)
The last in first out instruction will move the last data in the stack (Newest Data) to the destination location. The stack pointer will be decremented by one. The data will not be erased that is moved until the next piece of data is pushed onto the stack. (The pointer will point to this old data and erase it by copying over it.)
DIMENSION RECORD TABLE: DIM(631)
This instruction is used to define a customized record table. We do this by declaring the length of each record and the number of records for the table. 16 record tables can be programmed. We use this instruction to simplify the calculation of addresses in a data table. The table is usually a collection of specific data for a machine. An example would be a recipe for temperature, pressures, etc.
SET RECORD LOCATION: SETR(635)
This instructions will write the location of the specified record in the Index Register. (,IR) Remember that the index registers act as pointers to get or retrieve information in the PLC. You must immediately use this information before another instruction sets different information in the IR word.
DATA SEARCH: SRCH(181)
The SRCH will look for specific data within a specified range. It will then set the index register to the location that it finds the first matched data.
The control word is used to establish how many words to search.
In this example we are seaching for the value 1234 in the first 100 words of data starting at D0. The result location is then loaded into IR0. We then use this to move the value into D302.
SWAP BYTES: SWAP(637)
Usually when we are dealing with communication to another device and sharing information, this is done on a byte level. (8 bits) The PLC is usually working with 16 bit words at a time. Information such as numbers can mix around the bytes in the word. This instruction switches the leftmost and rightmost bytes in all of the words in the range.
FIND MAXIMUM: MAX(182)
This instruction will find the maximum value of a word in the specified range.
The instruction uses a control word to specify the number of words to look in the range and the type of data. The location of the maximum value can be then transferred to the IR0.
FIND MINIMUM: MIN(183)
This instruction will find the minimum value in the specified range.
Just like the maximum instruction, this uses a control word. We specify the number of words to search and indicate if the location address is set in IR0.
The bytes or words in the specified range will be added and the result will be written to two words.
This instruction will use a control word to specify the table length and type of data to add.
FRAME CHECKSUM: FCS(180)
This instruction calculates the FCS value for the specified range and outputs the result in
ASCII. Serial communication will utilize this calculation to determine if the message has not lost any information from when it was sent to when it is received. See the following post: How to implement the Omron Host Link Protocol (VB.net) for a demonstration on how the FCS is used in transmission.
STACK SIZE READ: SNUM(638)
We now return to the stack that we first looked at in this post. The following five instructions will also manipulate the information on the stack that was set.
This instruction will count the amount of stack data (number of words) in the specified stack. You can calculate this by the beginning of the stack (TB+4) – Stack pointer position -1.
STACK DATA READ: SREAD(639)
This instruction reads the data from the specified data element in the stack. The offset value indicates the location of the desired data element (how many data elements before the current pointer position).
STACK DATA OVERWRITE: SWRIT(640)
This instruction writes the source data to the specified data element in the stack (overwriting
the existing data). The offset value indicates the location of the desired data element (how many data elements before the current pointer position).
STACK DATA INSERT: SINS(641)
Inserts the source data at the specified location in the stack and shifts the rest of the data in the stack downward. The offset value indicates the location of the desired data element (how many data elements before the current pointer position).
STACK DATA DELETE: SDEL(642)
Deletes the data element at the specified location in the stack, outputs that data to the specified destination word, and shifts the remaining the data in the stack upward. The offset value indicates the location of the desired data element (how many data elements before the current pointer position).
You can see that we have many different table data instructions in the Omron CP1H. This should give you a good idea of what is possible.
See the YouTube video below on table data processing instructions in the Omron CP1H PLC.
The following is a list of manuals associated with the CP1H programmable logic controller. See the descriptions for each of these manuals in the first post: Omron CP1H System Hardware
W450 – SYSMAC CP Series CP1H CPU Unit Operation Manual
W451 – SYSMAC CP Series CP1H CPU Unit Programming Manual
W342 – SYSMAC CS/CJ series Communications Commands Reference Manual
W446 – SYSMAC CX-Programmer Ver. 6.1 Operation Manual
W447 – SYSMAC CX-Programmer Ver. 6.1 Operation Manual Function Blocks
W444 – CX-One FA Integrated Tool Package Setup Manual
W445 – CX-Integrator Operation Manual
W344 – CX-Protocol Operation Manual
You can download the PLC program as discussed above here.
Next time we will look at data control instructions in the Omron CP1H PLC.
Watch on YouTube : Omron CP1H Table Data Instructions
If you have any questions or need further information please contact me.
If you’re like most of my readers, you’re committed to learning about technology. Numbering systems used in PLC’s are not difficult to learn and understand. We will walk through the numbering systems used in PLCs. This includes Bits, Decimal, Hexadecimal, ASCII and Floating Point.
To get this free article, subscribe to my free email newsletter.
Use the information to inform other people how numbering systems work. Sign up now.
The ‘Robust Data Logging for Free’ eBook is also available as a free download. The link is included when you subscribe to ACC Automation.