Omron CP1H Data Shifting Instructions

We will now look at data shifting instructions in the Omron CP1H controller. PLC programming is all about how we can manipulate the information stored in the PLC. We have already looked at timers, counters, moves, and comparison instructions. Data shifting is a different concept that will move bits and words around in memory. This is necessary usually for tracking purposes. The word or bit will represent the product or information. As this information is triggered to shift to a new location we can use this to activate items later in the process. A typical example of this would be parts on a conveyor belt. As the part is detected on one end it will turn on a bit in a register. The conveyor movement is usually picked put by an encoder and shifts this bit in the register in sync with the conveyor movement. At the other end of the conveyor belt, we can see the bit position and do something with this information. We can use this information to count, reject, etc. Looking at the entire register full of bits, we can determine everything on the conveyor and its position.
We will be looking at the data shifting instructions in the Omron CP1H PLC. Examples of some of the instructions will be presented. The instructions are used to shift data within or between words, but in different amounts and directions.

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 data shifting 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.
Omron CP1H Data Shifting Instructions
Instructions can have different variations.
Let’s look at a couple of instructions:
SFT(010) when used will be scanned and executed every cycle of the PLC that the input condition is on.
@SFT(010) 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 quickly go over the data shifting instructions in the Omron CP1H.

See the YouTube videos below on data shifting in the Omron CP1H PLC.

SHIFT REGISTER: SFT(010) – Omron CP1H Data Shifting

Omron CP1H Data Shifting Instructions
When the shift input condition is true the data input (1 or 0) will be put in bit 00 of the starting word and all of the previous bits are shifted to the left.

Omron CP1H Data Shifting Instructions

REVERSIBLE SHIFT REGISTER: SFTR(084) – Omron CP1H Data Shifting

Omron CP1H Data Shifting Instructions
The reversible shift register uses a control word to get the inputs required.

This instruction is similar to the precious, but now we can choose a direction of the shifting.

Omron CP1H Data Shifting Instructions

ASYNCHRONOUS SHIFT REGISTER: ASFT(017) – Omron CP1H Data Shifting

Omron CP1H Data Shifting Instructions
This instruction will shift words (16bits) at a time. Asynchronous means that information will be shifted to the end of the shift register as long as the word in front of it is empty. (“0000” Hex)
Omron CP1H Data Shifting Instructions
The instruction uses a control word that will determine the shifting direction, shift enable and the reset bit.

When the instruction has executed the information in the words is shifted in the direction set. Shifting continues until the non zero words are stacked together.
Omron CP1H Data Shifting Instructions

WORD SHIFT: WSFT(016) – Omron CP1H Data Shifting

Omron CP1H Data Shifting Instructions
The word shift (16 bits) instruction will take the source word and move it into the start location each time the instruction is executed. Previous information is shifted from the start word to the end word. Information shifted past the end word is lost.

You will notice that in our example we are using a differentiated up on the 1-second clock pulse bit. This is used to trigger the instruction.
Omron CP1H Data Shifting Instructions


ARITHMETIC SHIFT LEFT: ASL(025) – Omron CP1H Data Shifting

Omron CP1H Data Shifting Instructions
Bits (00 to 15) in the word are shifted to the left. When shifting bits to the left you are multiplying the word by 2.

In the following example, we are using the @ASL instruction. This means that the instruction will execute once during an input transition from off to on.
Omron CP1H Data Shifting Instructions

DOUBLE SHIFT LEFT: ASLL(570) – Omron CP1H Data Shifting

Omron CP1H Data Shifting Instructions
This is the same as the ASL instruction, except that we now have two words. (32 bits)

Omron CP1H Data Shifting Instructions

ARITHMETIC SHIFT RIGHT: ASR(026) – Omron CP1H Data Shifting

Omron CP1H Data Shifting Instructions
Bits (00 to 15) in the word are shifted to the right. When shifting bits to the right you are dividing the word by 2.

DOUBLE SHIFT RIGHT: ASRL(571) – Omron CP1H Data Shifting

Omron CP1H Data Shifting Instructions
This is the same as the ASR instruction, except that we now have two words. (32 bits)

Omron CP1H Data Shifting Instructions

ROTATE LEFT: ROL(027) – Omron CP1H Data Shifting

Omron CP1H Data Shifting Instructions
This will shift all bits to the left in the word including the carry. (Carry Flag (CY))

Omron CP1H Data Shifting Instructions

DOUBLE ROTATE LEFT: ROLL(572) – Omron CP1H Data Shifting

Omron CP1H Data Shifting Instructions
This will shift all bits to the left in the output word and the next word including the carry. (32 bits)

Omron CP1H Data Shifting Instructions

ROTATE RIGHT: ROR(028) – Omron CP1H Data Shifting

Omron CP1H Data Shifting Instructions
This will shift all bits to the right in the word including the carry. (Carry Flag (CY))

Omron CP1H Data Shifting Instructions

DOUBLE ROTATE RIGHT: RORL(573) – Omron CP1H Data Shifting

Omron CP1H Data Shifting Instructions
This will shift all bits to the right in the output word and the next word including the carry. (32 bits)

Omron CP1H Data Shifting Instructions

ROTATE LEFT WITHOUT CARRY: RLNC(574) – Omron CP1H Data Shifting
Omron CP1H Data Shifting Instructions
This will shift all bits to the left in the word. It does not including the carry flag. Bit 15 of the word gets set in Bit 00 when the shift happens.

Omron CP1H Data Shifting Instructions
You will notice that each instruction is a slight variance from previous ones. Each instruction has its own purpose and application. It is interesting to see how many ways bits and words can be shifted.
DOUBLE ROTATE LEFT WITHOUT CARRY: RLNL(576) – Omron CP1H Data Shifting
Omron CP1H Data Shifting Instructions
This is the same as the RLNC instruction except that we are using two words. (32 bits) When bit 15 of the second word is on it will set bit 00 of the first word.

Omron CP1H Data Shifting Instructions
ROTATE RIGHT WITHOUT CARRY: RRNC(575) – Omron CP1H Data Shifting

Omron CP1H Data Shifting Instructions
This will shift all bits to the right in the word. It does not including the carry flag. Bit 00 of the word gets set in Bit 15 when the shift happens.

Omron CP1H Data Shifting Instructions

DOUBLE ROTATE RIGHT WITHOUT CARRY: RRNL(577) – Omron CP1H Data Shifting

Omron CP1H Data Shifting Instructions
This is the same as the RRNC instruction except that we are using two words. (32 bits) When bit 00 of the first word is on it will set bit 15 of the second word.

Omron CP1H Data Shifting Instructions

ONE DIGIT SHIFT LEFT: SLD(074) – Omron CP1H Data Shifting

Omron CP1H Data Shifting Instructions
A digit is 4 bits long. This is also referred to a nibble in computer language. This instruction will shift 4 bits (Digit) to the left from the staring word to the end word.

Omron CP1H Data Shifting Instructions


ONE DIGIT SHIFT RIGHT: SRD(075) – Omron CP1H Data Shifting

Omron CP1H Data Shifting Instructions
The instruction will shift 4 bits (Digit) to the right from the end word to the starting word.

Omron CP1H Data Shifting Instructions

SHIFT N-BIT DATA LEFT: NSFL(578) – Omron CP1H Data Shifting

Omron CP1H Data Shifting Instructions
This instruction will allow us to specify the number of bits in the word and the beginning bit to shift to the left. It is like having a mini shift register within the 16 bit word.

Omron CP1H Data Shifting Instructions

SHIFT N-BIT DATA RIGHT: NSFR(579) – Omron CP1H Data Shifting

Omron CP1H Data Shifting Instructions
This is the same as the NSFL instruction except we are now shifting to the right. We again specify the number of bits and starting bit to shift within the word.

Omron CP1H Data Shifting Instructions

SHIFT N-BITS LEFT: NASL(580) – Omron CP1H Data Shifting

Omron CP1H Data Shifting Instructions
We specify the number of bits to shift to the left with this instruction.


The control word will indicate the number of bits to shift each time the instruction is executed.
In our example we are shifting 2 bits to the left.
Omron CP1H Data Shifting Instructions

DOUBLE SHIFT N-BITS LEFT: NSLL(582) – Omron CP1H Data Shifting

Omron CP1H Data Shifting Instructions
This is similar to the NASL instruction except we are using 32 bits (2 words) in our shifting.

Omron CP1H Data Shifting Instructions
We are shifting 4 bits to the left. This is like the digit shift left instruction.

SHIFT N-BITS RIGHT: NASR(581) – Omron CP1H Data Shifting

Omron CP1H Data Shifting Instructions
We specify the number of bits to shift to the right with this instruction.

The control word will indicate the number of bits to shift each time the instruction is executed.
In our example we are shifting 2 bits to the right.
Omron CP1H Data Shifting Instructions

DOUBLE SHIFT N-BITS RIGHT: NSRL(583) – Omron CP1H Data Shifting

Omron CP1H Data Shifting Instructions
This is similar to the NASR instruction except we are using 32 bits (2 words) in our shifting.

Omron CP1H Data Shifting Instructions
We are shifting 4 bits to the right. This is like the digit shift right instruction.

You can see that we have many different instructions to shift data in the Omron CP1H. This should give you a good idea of what is possible.

See the YouTube videos below on data shifting 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 math instructions in the Omron CP1H PLC.

Watch on YouTube : Omron CP1H Data Shifting Instructions Part 1

Watch on YouTube : Omron CP1H Data Shifting Instructions Part 2


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.


Leave a Comment