Today is...
Monday, August 20, 2018
Welcome to, the global online
community of automation professionals.
Featured Video...
Featured Video
A tutorial introduction to programming using the QuickBuilder Programming Environment.
Our Advertisers
Help keep our servers running...
Patronize our advertisers!
Visit our Post Archive
Ladder Logic Help with Bit Shift Left
Having problems doing both a Bit Shift Left operation on an array, and editing the contents of the array.

I had an idea that I thought would be easy to add into existing ladder logic, but I am finding it very hard. Maybe someone who enjoys a challenge can help.

I have a conveyor that holds 3 items between 2 stations. Station1 produces the item, and places it onto the conveyor. Station1 also notes whether that item is good or bad. Once placed on the conveyor, the conveyor indexes once, moving the last item into Station2. Station2 basically performs either a "reject action" or "no action" depending on whether or not the item was good or bad.

I currently have a bit array for the pass/fail status of the items on each position. bit0 is the new item's position. bit3 is the station2 position. Good item is a low bit. Bad item is a high bit. The bit array is Bit Shift Left when the conveyor indexes.

I also currently have a button that overrides the reject action of the item heading to or already in station2. For example, if bit3 is high and the operator pushes the button, station2 will not perform the reject action that it otherwise would have.

My new idea is to have 4 buttons instead of just 1 button, allowing the operator the option to flip the fate of any of the 4 items at any time. For example, pushing button2 will make the item currently in position2 the opposite of what it currently is. If it currently is bad, it will be treated as good when it reaches station2. If it currently is good, it will be treated as bad when it reaches station2.

Sounds easy, but it's not.

I'm trying to make another 4-bit array. This array carries whether each position has been flipped. The buttons are normal open momentary, performing a "push on push off" action for the appropriate bit. The final action of station2 will be the XOR of the 3rd bit of both arrays (my flip array and the original good/bad array).

The problem I am having is the writing ladder that can both edit the contents of a bit array and also Bit Shift. The 2 things I am trying to do are fighting one another.

Can anyone help? I am using RSLogix 5000, but will accept answers in any variation of ladder logic.

That is not something a human operator can reliably do for any extended period of time.

You either divert the questionable item for further checking or simply divert it off the line for recycling.

This is almost comparable to a conveying system we commissioned as system builders some time ago. Each container had a bar code which entered the top of a stack of shift registers as each passed the bar code reader.

As each container entered a divert station for one of several heat shrink wrapping machines, the code either let the container continue on the conveyor or be diverted towards the wrapping machine. If a container missed all wrapping machines it continued to a palletiser. If its code failed to match the palletiser then a gate stopped it and a visual alarm flashed for manual intervention. It worked very well and probably still is operating.

The stack was around 250 registers deep; and the essence was that of exact timing at each divert gate.

Your system/ideas would be very prone to errors due to manual intervention as indicated above, and having a simple accept/reject system with so many variations with multiple arrays appear to me to be unworkable.

A perfect example of how properly integrated controls and manufacturing equipment can work!

My application is slow. The items sit on the conveyor for over a minute before they make it to the next station. Sometimes bad items say they passed, or good items say they failed. These would need to be manually diverted (particularly the bad items). Currently, this can only be done live when the questionable item is entering station2. This puts a timing burden on our operators, who are responsible for managing more than one machine.

It might not be true for all applications, but for mine it would be a good thing to give the operator the ability to schedule an item to be diverted in the future when it reaches station2.

Anyways, I've had all weekend to think about it. I'll give it another try today.

I think my question comes down to this:

How do you write the below into ladder?

//declare bits
bool button, flip;

if button

By Ken Emmons Jr. on 31 July, 2018 - 3:41 pm

There are many other ways to do this but here is one.


Button Flip Flip Button
|------| |----------|/|---------(SET)---------(RES)-----------|
| Flip Flip Button
-----| |----------(RES)---------(RES)----------|

Ken Emmons Jr.
Electrical Engineer
QA Technology Company, Inc.

I probably have figured it out, though I only drew it out on paper and haven't edited the program yet. It should work though.

Basically, I made several sequence steps. I think that's the only way to keep the code from fighting itself. I also switched to an integer (rather than a bit) to express the pass/fail status per item. This lets me use the Move commands instead of having to manage latching/unlatching.


By Ken Emmons Jr. on 1 August, 2018 - 9:12 am

I find sequencing with Ladder to be the most straight forward approach for most things.

Ken Emmons Jr.
Electrical Engineer
QA Technology Company, Inc.