Bit shift registers, and the conveyor they were made for
BSL, BSR, the shift bit that must be a one shot, and why the pitch of the conveyor decides the length of the register.
Short answer
A bit shift register holds one bit per physical position on a conveyor and shifts every bit one place each time the conveyor advances one pitch. The bit shifted in at the input end represents the item just loaded; the bit shifted out at the other end drives the reject or diverter. The shift must be triggered by a one shot on the position sensor, or a slow conveyor shifts the register many times per index.
A bottle is inspected at one point on a conveyor and rejected at another, a metre and eleven positions downstream. Something has to remember, for each bottle, whether it failed.
That is a shift register, and it is one of the few ladder idioms that maps exactly onto a physical thing.
The model
One bit per pitch position on the conveyor. Bit 0 is the position under the inspection head, bit 11 is the position at the reject.
Each time the conveyor advances one pitch, every bit moves one place. The bit that falls off the end is the decision for the bottle now at the reject.
The register is a picture of the conveyor, and the arithmetic works because the conveyor and the register step together.
The one shot
The single most common bug in the whole idiom, and worth stating plainly.
The shift is triggered by something that says the conveyor has moved one pitch: an index sensor, an encoder pulse, a servo in position bit.
That signal is true for as long as the sensor is blocked, which might be twenty scans. Without a one shot, the register shifts twenty times for one pitch, and every bit in it is now meaningless.
A shift register that appears to work at low speed and fails at high speed, or the reverse, is nearly always this. Put a one shot on the shift condition, always, and treat its absence as the first thing to check.
Counting the positions
The length is not a design choice, it is a measurement.
Count the physical pitch positions from the inspection point to the reject point. If the answer is eleven, the register is eleven bits, and the reject fires on the bit shifted out after eleven shifts.
Being one out gives a machine that rejects the bottle before or after the bad one, every time. On a line running ten a second the symptom looks like intermittent random rejection, and the cause is an integer.
Loading the decision
Load the input bit at the moment the decision is made, into the position that corresponds to where the part is at that moment.
The awkward case is when the decision arrives late. A vision system that takes eighty milliseconds to answer is two positions behind by the time it does, so the bit belongs at position two rather than position zero. Getting this wrong is the same class of error as getting the length wrong.
When the conveyor runs backwards
Jogging back for a clear or a changeover shifts the physical positions backwards and the register does not follow.
Two workable answers. Clear the register on any reverse and let the operator re-inspect, which is honest and slightly wasteful. Or shift the other way on reverse, using BSR against BSL, which is correct and requires the reverse to be detected reliably.
The wrong answer is to ignore it, which produces a machine that rejects at random after every jog.
Where a shift register stops being the answer
Two cases, and both are common enough to check for at the design stage.
- Parts can overtake or be removed, so position no longer implies order. Use a FIFO with identity or timestamps.
- Each position needs more than one bit. Two shift registers for two flags is workable; five is a sign the model should be an array of structures shifted as records.
Common questions
- Why does my shift register skip positions?
- Almost always a missing one shot. The shift instruction is edge triggered by convention but the condition driving it is often a photocell that stays true for several scans, so the register shifts once per scan rather than once per part. Put a one shot between the sensor and the shift.
- How long should the shift register be?
- Exactly the number of pitch positions between the point where the decision is made and the point where it is acted on. Count them physically. One position wrong and every part is rejected one place early or late, which looks like a random reject problem.
- What is the difference between BSL and BSR?
- BSL shifts left, from the lowest bit towards the highest, and BSR shifts right. Which one to use depends on which end of your array represents the infeed. Both unload the bit that falls off the end into a status bit, and that bit is what drives the actuator.
Keep reading
- Safety
SIL or PL: which one does your machine need?
Two standards, two scales, and one machine. Which one applies, how they map to each other, and why the answer is usually ISO 13849.
- Safety
Categories B, 1, 2, 3 and 4, in plain terms
Five architectures, what a single fault does to each, and the practical wiring that goes with them.
- Safety
Safety relay or safety PLC: how to decide
One is a wiring decision, the other is a programming one. The count of safety functions, not the size of the machine, is what settles it.