Shift Register Help Wanted

SLaubach

Member
Join Date
Apr 2002
Location
PA
Posts
152
I am pondering the use of a shift register in a program. I understand what they do but not sure how to write the code to use them, specifacally BSR & BSL Allen-Bradley. I have read the help index about both but am still a little fuzzy. Is there an easy way to explain how-to much like the forum did when I had a PID question.

thanks in advance,
SLaubach
 
In general,

For a Bit Shift Right Function...

You have a bit on the rung to activate the function.

The function looks for an OFF-to-ON transition of that bit.

When that transition happens, the function takes the least significant bit and drops it into the "Bit-Bucket" (more discussion on this later).

The function then goes through the exercise of copying the next-least-significant bit into the least-significant position. Then the next-to-the-next-least-significant bit is copied into the next-to-the-least-significant bit. Repeating so until it comes to the most significant bit.

When the function copies the most significant bit into the next-to-most-significant bit position, the function then looks to the Shift-In bit value. If the value at that location is "zero", then a "zero" gets written to the most significant position. Otherwise, the value is "one", and so a "one" gets written to the most significant position.

"Bit-Bucket"
The bit that was "Shifted Out" goes to the OUTPUT. You can define that Output in a meaningful way, or you can define the Output as "Dummy". If the Output is defined in a meaningful way, then you can use the value of the bit to do something! If the Output was defined as a dummy bit, then you have no use for the bit and simply want to lose it. In that case, it's just another bit that gets added to the "Bit-Bucket". The term "Bit-Bucket" is just a figure of speech. You don't HAVE to do any maintenance on it.

The Bit Shift Left Function operates the same way, except, the most significant bit goes into the "Bit-Bucket" and the Shift-In bit is loaded into the Least Significant bit location.

Again, the bit that is shifted into the "Bit-Bucket" can be used or ignored, as you wish.
 
I am pondering the use of a shift register in a program. I understand what they do but not sure how to write the code to use them, specifacally BSR & BSL Allen-Bradley. I have read the help index about both but am still a little fuzzy. Is there an easy way to explain how-to much like the forum did when I had a PID question.
If you give some info on what you want to accomplish or how you are contemplating using them, the help can be more focussed.
 
Bit Shifts

If find that the trickiest thing to program can be that transition bit.

As Terry said, it needs to go from OFF-to-ON for the BSL to activate and move everyone over one. But it needs to go from ON-to-OFF in order that the BSL will recognize the next OFF-to-ON.

In that respect, it works like a counter, except instead of incrementing a number, it shoves bits over by one.

They are most frequently used to represent a physical object in the PLC that exists in the real world. Let's say it's bottles on a conveyor line, and you've got a "checking station" at one location, and a "reject station" at a different one. If the "checking station" detects a problem, it sets a bit in the shift register. When the bit shifts down to the position represented by the "reject station", the reject station ejects the bottle. Sounds simple, and I've used a shift register for exactly that application.

Buy if you are using a photoeye to generate the "shift" pulse, it had better see a gap between every bottle, or you'll reject the wrong one.

Sometimes you use a timer generate the "shift" pulse. But if the bottles slip on the conveyor, the reject station might miss. The problem becomes even trickier if you've got a variable speed drive controlling the conveyor. Adjust the time between "shift" pulses based on the speed? Doesn't work well.


A few things that may be AB specific:

In a bit shift, you can use multiple consecutive words (B or N), and there is no "word-boundary" between the bits. (in a 2-word (e.g., 32-bit ==> R6:0.Len=32) "bit bucket" as Terry calls it, using File #N7:0, N7:1/0 is the bit that N7:0/15 would be shifted into (I always forget if this is considered "Left" or "Right" however).

For this reason, I prefer to use B-type registers for the File, and set up RSlogix to display Binary files as /Bit, instead of Word/Bit. I'll set up a register specifically for the shift register. This way, I can see that B17/22 is the 22nd position in the bit bucket (I prefer calling it a Bit String, since it acts like a string of beads)

(I thing it was Ron B who "discovered" the following:) Even if you only use 8 bits in a shift register, the PLC will actually shift every bit in the word. If you use other bits in that word in your logic, they will be affected by the shifting.
 
Gerry said:
If you give some info on what you want to accomplish or how you are contemplating using them, the help can be more focussed.

i guess a BIT shift wont work for what i am trying to do. heres the problem....i measure the length of several (lets say 5)rolls of paper, sometimes all differnt cuts 8" to 60". they then move into a wrapping machine where the operator must manually using a 4 didgit thumbwheel input the size so the wrapper can center the roll in the machine. i would like to track these rolls since i found the size earlier and again use the size to center the rolls. so really what i need is an INTEGER shift? i guess put each value in a register and step through them as each roll is finished.


SL
 
...said WHAT???

I could GUESS at what the hell you are trying to say... but, why the hell should I have to GUESS???

Why is it that so many, so-called "Programmers", programmers that should have a sense of organized thinking, are such lousy writers???

If you can't pose a question reasonably, how the hell do you expect to THINK reasonably???

Programming is based on Rational Thinking! Rational Thinking is based on Rational Questions! Rational Questions are based on Rational Thinking !!! Yeah, It's a circle thing, but the point in common is RATIONALITY!!!

Just one of my peeves.... take it or leave it. (No, I haven't had THAT much MGD !!!)

Please, Try again! And, using Paragraphs is really not a crime! High School English... For Pete's Sake!!!
 
After re-reading Scott's post a few times, I'm pretty sure I understand what he's doing (his writing style is similar to mine (too many asides, too much information))(like that). I've cut toilet paper from "logs", and it sounds similar (except the TP is uniform in length)



But I'm not sure that even a FIFO is going to do what he wants. There are lots of questions that he needs to answer so that we don't guess at a solution:

Does the operator use the thumbwheel to change the wrapping size for every cut paper roll? Or do the rolls come in lots ("Now we are running 8" rolls. In an hour we'll run 22" rolls.")?

If it's the former, and the operators are constantly entering new sizes, I pity your operators and then, yes, a FIFO may help.

If there's just a batch size, why not just send over current batch size - is there that much of a delay between the slicer and the wrapper?

Are there the same number of rolls (of whatever size) between the slicer and the wrapper?

Do you have a method to determine how fast (in terms of "There goes a roll. There goes another one") the rolls are travelling? A FIFO is going to need the same sort of "shift" pulse that the bit shift had. Can you provide it with one?

All of these will factor into your code design. Do as Terry said and write a slow description of what you are trying to accomplish. Don't worry about getting it all in in 50-words-or-less. But if a paragraph runs for more than 5 lines, consider adding 2 carriage returns (a "carriage" on a PC - yeah, right) and making a new paragraph.
 
Scott,

Seems to me that a FIFO is probably what you want. From your description, it seems that what you want to do is track the order (or sequence) of the different-sized rolls as they move from their origin to the wrapping machine.

The FIFO, sometimes called an asynchronous shift register or a queueing register because data is shifted in and out separately, is made for that type of application.

There's no explicit 'word shift' instruction (unless you're working with a PLC2 or PLC3) but the operation is easily implemented using the COP instruction. However, you would only need to use that technique if you had to track position as well as sequence.

Be aware that with FIFO's, if you change the order of the rolls after they've been loaded or a roll falls off the conveyor, etc., things very quickly get fubar.
 
Terry Woods said:
...said WHAT???

I could GUESS at what the hell you are trying to say... but, why the hell should I have to GUESS???

Why is it that so many, so-called "Programmers", programmers that should have a sense of organized thinking, are such lousy writers???

If you can't pose a question reasonably, how the hell do you expect to THINK reasonably???

Programming is based on Rational Thinking! Rational Thinking is based on Rational Questions! Rational Questions are based on Rational Thinking !!! Yeah, It's a circle thing, but the point in common is RATIONALITY!!!

Just one of my peeves.... take it or leave it. (No, I haven't had THAT much MGD !!!)

Please, Try again! And, using Paragraphs is really not a crime! High School English... For Pete's Sake!!!

Terry
If you have nothing constructive about my PLC problem please do not respond. This is still a PLC Q&A and not grammer class right? Do you still raise your hand when you want to ****?

Thank those who did respond with recommendations.
 
If you have nothing constructive about my PLC problem please do not respond.
Scott
Please do not take offense.
Remember there is such a thing as constructive criticism.
Sometimes it smarts.
Hey TW doesn't need me to go to bat for him, but I think that he is right.

i guess a BIT shift wont work for what i am trying to do. heres the problem....i measure the length of several (lets say 5)rolls of paper, sometimes all differnt cuts 8" to 60". they then move into a wrapping machine where the operator must manually using a 4 didgit thumbwheel input the size so the wrapper can center the roll in the machine. i would like to track these rolls since i found the size earlier and again use the size to center the rolls. so really what i need is an INTEGER shift? i guess put each value in a register and step through them as each roll is finished.

The question is kinda hard to follow.

You may ask "Hey what's it to you?"

Well I just love to read the responses.
I can't tell you how much I have learned from other peoples problems.
Maybe the answer that Terry does not give (because you told him not to post) is something that I could have used on a future project of mine.

Good luck on your project.
George Bradley
 
Personally I think Terry has offered constructive assistance with both posts. Everyone is guessing because you havent stated a clear question, Terry was just trying to get you to clarify what your question is in a professional manner.

On a day to day basis most can understand why the students dont express or state theirselves properly, they havent learned yet. You I think have shown to be an engineer or in a professional position that is the equivalent and should be able to state the problem/question in a clear and precise manner.

Yes it is a PLC Q&A forum BUT its also people so just like in real life you have to deal with personalities.
 
Here are the machine steps:

1. the slitting machine cuts 5 rolls off a large roll they are 10",20",30",40"an 50".

2. the rolls are then transported to the wrapping machine trolley, where the operator will enter the lengths of each cut on an OIT.
the OIT will allow each roll to either be sent directly to the wrapper or staged in an orphan bin to be wrapped together later with other same size rolls.

3. lets say the 10" roll will go to orphan bin #1 and wait until onother 10" roll is cut.

4. the other 4 rolls go dirctly to the wrapper and are wrapped seperatly. in order from small to big.

5. just before the roll inters the wrapping conveyor the operator will enter the length on the thumbwheel 20. 30, 40, or 50.

6. it will then jog the staging and wrapping convey fwd for a short period decided by the thumbwheel.

7. after this short time base the staging conveyor will stop to allow the rolls to be split and just the 20" to continue on to the center of the wrapper, also a function of the thumbwheel.

8. the machine will continue untill all are wrapped, remember the 10" roll is still in orphan 1.

9. by this time a new set of rolls are ready to be wrapped, the NEW 10" roll is dropped off at the orphan bin 1 and the rest of the rolls are wrapped again.

10. now the cart will go pick up both 10" rolls and wrap them together as one 20" bundle.


11. the whole process will begin again.

Sorry terry for they reply, BAD DAY and its ony 11am
 
I have a question, is it possible to eliminate the thumbwheel/operator action if you used photoelectric sensors to "measure" the rolls on the conveyor? Working with multiple lengths seems to require alot of actions via the operator, if the system knew the lengths then it could act/react on its on.

I have more questions if that is ok, I work in a paper converting industry too. We make rolls that are 24 to 40 inches wide but length of the paper can vary from a few inches to hundreds of inches. Some are wrapped individually and some in multiroll packages. I want to make sure I understand your centering process. When you state 10 or 20" is that the length of paper on the roll or the width/length of the roll itself? Since you mentioned centering the rolls for the wrapper and it had to be told the length to center properly (plus the use of a slitter machine) I take it the rolls are different in width/length not the paper length.

I think a photo sensor array could be used to measure the lengths and automatically adjust to center the rolls. Seems to me this offers best option not to get lost in a cycle because of missing roll etc.

Seems an indexing (or would that be sequencing) routine could be created using the OIT to enter the variables (roll lengths) and/or order they appear.

I cant wait to see the answers, I try to come up with things that will work in scenarios like this and then wait to see what the pros come up with and the details of implementation.
 
Ron's idea is great, but since you already have the size information, there should be no need to re-measure the rolls. Might be a good QC tool though!

Here's yet another idea... :rolleyes:

If you have a reasonably small "fixed" number of possible roll lengths, you may be able to use a plain ol' shift register. IOW, let's say you have 10 possible roll lengths. Just set up 10 shift registers (one for each roll length).

When the slitting machine cuts a 10" roll, you put a "1" in the "10 inch roll" shift register. A 20" roll sets a "1" in the "20 inch roll" shift register. Same for the rest of the sizes. All shift registers get shifted together.

When you reach the trolley, whichever shift register has a "1" at that location will be the roll size at that location.

If you need a large number of different sizes, this method would not be worthwhile. Stick with the FFL/FFU instructions (if your processor supports them).

beerchug

-Eric
 
In your current system, you're using the operator to measure the width of the rolls just prior to the wrapping operation. Presumably, you want to eliminate the need for the operator to have to enter the width of every roll. It should be a fairly straightforward process using a FIFO load/unload routine to use the predicted pattern of widths as the setpoints for the wrapper. If I understood properly, for the example you gave, the sequence of roll widths should be 20, 30, 40, 50, 20, 30, 40, 50, 20 (two 10s).

You also will need to consider how the system will behave if the the rolls don't show up at the wrapper in the predicted sequence. Suppose the mechanism kicks both the 10 inch roll and a 20 inch roll into the holding bin? Suppose somebody decides to kick one of the 30 inch rolls off the conveyor?

If the roll conveyor runs at a fixed speed, might be able to time the passage of a roll past a fixed point to give a go/no-go measurement. Compare the width calculated from the time of passage to the expected width based on which roll in the sequence is being wrapped. If the measured time of passage falls outside of an acceptable range, stop the line and alert the operator. This approach should work for the width variations you gave as examples.
 

Similar Topics

Hi everyone I am completely new to using shift registers and am a bit stuck, my shift register works as should, it is for an overhead conveyor...
Replies
55
Views
15,361
Hi I am fairly new to codesys 3 but I'm currently trying to make a little project using 4 cameras, a sensor and a conveyor belt each camera take...
Replies
7
Views
3,640
Posted previously but had the wrong info, hoping to get new advice. Being a mechanical engineer, I'm not very experienced with PLCs, and what...
Replies
7
Views
2,429
I'd like to start by saying that my background in engineering is mostly mechanical, and I have a tiny bit of experience with AB and RSLogix (to...
Replies
10
Views
2,620
Hello dear experts! just started learning STL and tried writing a program that writes the status of a particular bit M0.1 on 80 bits of...
Replies
2
Views
1,744
Back
Top Bottom