Omron CP1H Table Data Instructions

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:
System Hardware – Video
CX-Programmer – Video
Establish Communication – Video
Setting, Forcing and Online Editing – Video
Numbering System and Addressing – Video
CP1H Timers – Video
Counters – Video
Data Movement – Video
Compare Instructions – Video
Data Shift Instructions
Video Part 1
Video Part 2
Math Instructions – Video
Data Conversion – Video
Program Control Instructions – Video
Table Data Instructions – Video
Data Control Instructions – Video
AdvancedHMI Communication – Video

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 – Omron CP1H

Omron CP1H Table Data 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) – Omron CP1H

Omron CP1H Table Data Instructions
This instruction will initialize and establish a stack. This is a group of addresses (consecutive) that will contain data.
Omron CP1H Table Data Instructions
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.

Omron CP1H Table Data Instructions
We can now use additional commands to work with this group of data. (Stack)

PUSH ONTO STACK: PUSH(632) – Omron CP1H

Omron CP1H Table Data Instructions
The push instruction will write one word of data to the specified stack. The stack pointer will be incremented by one.

Omron CP1H Table Data Instructions

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) – Omron CP1H

Omron CP1H Table Data Instructions
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.

Omron CP1H Table Data Instructions

LAST IN FIRST OUT: LIFO(634) – Omron CP1H

Omron CP1H Table Data Instructions
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.)

Omron CP1H Table Data Instructions

DIMENSION RECORD TABLE: DIM(631) – Omron CP1H

Omron CP1H Table Data Instructions
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.

Omron CP1H Table Data Instructions

SET RECORD LOCATION: SETR(635) – Omron CP1H

Omron CP1H Table Data Instructions
This instruction 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.

Omron CP1H Table Data Instructions

GET RECORD NUMBER: GETR(636) – Omron CP1H

Omron CP1H Table Data Instructions
The instruction will return the record number of the record at the PLC memory address contained in the specified index register. (,IR)

Omron CP1H Table Data Instructions

DATA SEARCH: SRCH(181) – Omron CP1H

Omron CP1H Table Data Instructions
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.

Omron CP1H Table Data Instructions
In this example, we are searching 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) – Omron CP1H

Omron CP1H Table Data Instructions
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.
Omron CP1H Table Data Instructions

FIND MAXIMUM: MAX(182) – Omron CP1H

Omron CP1H Table Data Instructions
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.

Omron CP1H Table Data Instructions

FIND MINIMUM: MIN(183) – Omron CP1H

Omron CP1H Table Data Instructions
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.

Omron CP1H Table Data Instructions

SUM: SUM(184) – Omron CP1H

Omron CP1H Table Data Instructions
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.
Omron CP1H Table Data Instructions

FRAME CHECKSUM: FCS(180) – Omron CP1H

Omron CP1H Table Data Instructions
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.
Omron CP1H Table Data Instructions

A control word is used in the instruction to indicate how many words/bytes are in the range. If bytes are specified, then you can also indicate the starting byte in each word. (Leftmost or Rightmost)

Omron CP1H Table Data Instructions

STACK SIZE READ: SNUM(638) – Omron CP1H

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.
Omron CP1H Table Data Instructions
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.

Omron CP1H Table Data Instructions

STACK DATA READ: SREAD(639) – Omron CP1H

Omron CP1H Table Data Instructions
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).

Omron CP1H Table Data Instructions

STACK DATA OVERWRITE: SWRIT(640) – Omron CP1H

Omron CP1H Table Data Instructions
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).

Omron CP1H Table Data Instructions

STACK DATA INSERT: SINS(641) – Omron CP1H

Omron CP1H Table Data Instructions
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).

Omron CP1H Table Data Instructions

STACK DATA DELETE: SDEL(642) – Omron CP1H

Omron CP1H Table Data Instructions
Deletes the data element at the specified location in the stack, outputs that data to the specified destination word, and shifts the remaining 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).

Omron CP1H Table Data Instructions

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.
Thank you,
Garry



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.


2 thoughts on “Omron CP1H Table Data Instructions”

  1. Hello Gary, do you know if it is possible to store 25 floating values in the SSET function and if so, can you help me to implement such a feature?
    I’m trying to develop a planimeter for the company I work for and I don’t know how to get these values saved in the SSET function.
    But I tell you that I am a self-taught, industrial electrical technician and I study plc’s by myself with the help of very good people I meet on the internet.
    I thank you in advance for any and all help you can give me.
    carefully
    Rui Silva

    Reply

Leave a Comment