Omron CP1H Data Shifting Instructions

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 product or information. As this information is triggered to shift to a new location we can use this to activate items latter 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
CX-Programmer
Establishing Communication
Setting, Forcing and Online Editing
Numbering Systems and Addressing
Timers
Counters
Data Movement
Compare Instructions

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.

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)

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.

REVERSIBLE SHIFT REGISTER: SFTR(084)

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.

ASYNCHRONOUS SHIFT REGISTER: ASFT(017)

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)

The instruction uses a control word that will determine the shifting direction, shift enable and the reset bit.

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

WORD SHIFT: WSFT(016)

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 passed 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.

ARITHMETIC SHIFT LEFT: ASL(025)

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.

DOUBLE SHIFT LEFT: ASLL(570)

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

ARITHMETIC SHIFT RIGHT: ASR(026)

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)

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

ROTATE LEFT: ROL(027)

This will shift all bits to the left in the word including the carry. (Carry Flag (CY))

DOUBLE ROTATE LEFT: ROLL(572)

This will shift all bits to the left in the output word and the next word including the carry. (32 bits)

ROTATE RIGHT: ROR(028)

This will shift all bits to the right in the word including the carry. (Carry Flag (CY))

DOUBLE ROTATE RIGHT: RORL(573)

This will shift all bits to the right in the output word and the next word including the carry. (32 bits)

ROTATE LEFT WITHOUT CARRY: RLNC(574)

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.


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)

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.

ROTATE RIGHT WITHOUT CARRY: RRNC(575)

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.

DOUBLE ROTATE RIGHT WITHOUT CARRY: RRNL(577)

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.

ONE DIGIT SHIFT LEFT: SLD(074)

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.

ONE DIGIT SHIFT RIGHT: SRD(075)

The instruction will shift 4 bits (Digit) to the right from the end word to the starting word.

SHIFT N-BIT DATA LEFT: NSFL(578)

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.

SHIFT N-BIT DATA RIGHT: NSFR(579)

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.

SHIFT N-BITS LEFT: NASL(580)

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.

DOUBLE SHIFT N-BITS LEFT: NSLL(582)

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


We are shifting 4 bits to the left. This is like the digit shift left instruction.

SHIFT N-BITS RIGHT: NASR(581)

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.

DOUBLE SHIFT N-BITS RIGHT: NSRL(583)

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


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.

It's only fair to share...Email this to someoneShare on LinkedInShare on FacebookShare on Google+Digg thisPin on PinterestShare on StumbleUponShare on TumblrTweet about this on TwitterShare on RedditPrint this page

Leave a Reply

Your email address will not be published. Required fields are marked *