bit shifting

exiled

Member
Join Date
Jun 2002
Location
England
Posts
131
hi there guys i know this will be easy for you
as a newbie here could someone explain the operation of the (AB) bit shift left and bit shift right instructions

many thanks in advance
 
The bit shift left function will shift all the bits in a matrix (register, DW ) left, towards the most significant bit.

The shift bit right will shift them towards the least significant bit.

You would usually specify how many places left or right the bits should be shifted.

I do not know AB PLC's so I can't give you specifics on this, but we use this function within our GE series six for tagging.

The first 5 bits on a 16 input block are the bits used for the tagging, so we use a shift right, 11 times to be left with the 5 bits that we need, we then shift left 11 times to bring the 5 bits back to least significant bits, as this function shifts in 0's we have a 16 bit register with 11 0's and the 5 bits that we require.

I am not very good at explaining this, but I hope this goes someway to answering your question.

Paul
 
The previous response is a pretty good definition of a BSL or BSR. However to help you a little more I can offer you an example of where I have used them. We have high speed wrapping machines that hold several pieces of product in the machine at any given moment. If a defect is detected in a piece of product a *1* is loaded into the BSL instruction. Each time the wrapper completes one cycle the product and the BSL are advanced one step. When the defective product reaches the reject point, the *1* has reached the last bit in the BSL and that bit address is used to switch on the output for the reject. That way even though the defect was detected many machine cycles ago the defective product is tracked until it can be removed from the process. In the right application this instruction is very nice to use.

I hope that helps you out.

Good Luck
 
Bit shifting is a very interesting topic. I regularly use shift registers (SFT) in Omron PLCs for switching in loads (diesel generator work) or for switching patterns for features in public swimming pools, in conjunction with set & reset timers. I also use a reversible shift register (SFTR) in Omron PLCs for load control for diesel generator systems in conjunction with zone compare (ZCMP), a very usefull function with a built in differential, for load control on diesel systems. ZCMP has the lower set point bit on when out of the differential band on the lower side and the higher set point bit when the load goes over the set limit. These two bits then step the shift register in a forward on reverse direction to maintain the load within the differential set points in the ZCMP instruction.
Luverly. Not for a newbie one may suggest.
Cheers beerchug
 
A simple explanation of shift registers is; they are used for tracking events so that some action further down the line can be implemented.
Each time a signal is given to the sht reg, the bits are moved to the left or to the right by how many places you have stipulated.
An example would be a bottling line in a factory.
The bottles move in a straight line down a conveyor, a machine screws caps on them. Then a sensor checks that each bottle HAS a cap on it. Each time a cap is detected a 1 is entered into the sft reg and the sft reg is moved on one place. each time a cap is not detected a 0 is entered.
Further down the line, a reject arm is reading the sft regs and each time it sees a 0 it rejects the bottle.
 
Another funny thing is the mathematics side of it.
If you break a number to binary and operate a bit shift left, you divide by 2; a bit shift right will multiply by 2; one bit further will multiply by 4 and so on...
Be careful if your MSB comes back to the LSB, you may need to mask it with a logical AND.
 
And this tidbit was passed on to me by someone here and I lost who that was but I saved the advice...

It may be as few bits as you want, so, if the file bit is #b10:0 (you must use the #), and the length is 5, the value pushed from b3:10/4 is the value of the .ul bit.

However, the instruction only shifts on the word level, so the bits in the entire b10:0 shift all the way to b10:0/15 after the .ul is dealt with. Even though the instruction shifts through the whole word, it ignores the value of bits 5-15. But this phenomenon prevents you from using 5-15 elsewhere in your code, as they WILL be manipulated by the BSL.

The same holds true if the length were 25--you must not use the last 7 bits of the second word elsewhere--the instruction shifts the remaining bits of the highest word included in the file.

The best thing to do is create a b file for each BSL in the program.

This is just nice to know stuff--I learned the hard way.
 
I use bit shifts almost everyday in tracking product on an index table or walking beam as I call it. I use it to track the status of the part based on a multistation operation. Let's say that station number #1 is a stake head, and station #2 is a load cell head, and station #3 is a hipot. If your part at station #2 fails the load cell, alot times in my machines, I don't need to test it or run anymore heads down stream. So I use bit shifts to track this. I have an example program you can download here:

http://www.mrplc.com/cgi-bin/code/filedisplay.cgi?category=machab

Scroll down to:

Complete Index Table 1.0
RSS, Panel View file

Complete Index Table - PDF Version 1.0
Just PDF

Bit Shift Example 1.0

Good luck
 

Similar Topics

Hello all, What I want to do is take a word of data and move the bits over 1 bit. So to keep it simple: 0001 0011 1100 0110 and move into...
Replies
2
Views
1,508
Hi, I need to bit-shift a block of words in an Omron PLC by a certain amount. Is SFTR the only way to do this? I've tried NSFR/NSFL but from...
Replies
11
Views
3,657
I am looking for an instruction similar to the RS Logix BTD instruction. I need to be able to strip bits in the middle of a 32 bit double word...
Replies
1
Views
1,888
Getting closer to understanding BSR/BSL but I still cannot understand the "CONTROL" address function. I am using R6:10 and I can see the 0's amd...
Replies
2
Views
1,929
Hello, I have a project at work where I am to set up an alarm sequence. What they want is to have the last two alarm lights that came on to be...
Replies
17
Views
18,688
Back
Top Bottom