LabView button for a double-acting cylinder

Good morning.

We’ve got a double-acting cylinder in our pneumatic system. In our test code, we have two separate buttons that electrify either end of the SMC double solenoid. So, when we press one button, the cylinder extends. The other button causes the cylinder to retract. So far so good.

We’re trying to think of a way to program that all into one button. So that, assuming it’s retracted at the start, pressing the button once would extend it. The next press would retract it. Etc etc etc.

Is there any way to use a toggle button feature to accomplish this? Or some sort of Boolean expression chain?

This code keeps track of the button value between loops, and checks if it’s true and different. If it is, it goes to the true part of the case switch.

In the true part of the case switch is where you switch the state of solenoid .


So, because I don’t have any other idea how to do it, I was going to wire (electrically) the two red/black sides of the two solenoids to two seperate connections. Either two of the “pneumatic bumper” relays or two Spike relays.

Where do I put those two connections, in this LabView code, and how does it differentiate which one to energize/fire?

You keep track between loops which one was the last one to fire. You can have something like the code I posted before keep inverting a boolean value, and depending on that value, power the solenoid (in a case statement).

Like, if value is true, power A and not B. If value is false, power B not A.

And then you use the button code to change the value back and forth between true and false.

It hard part it wrap your mind around is using a momentary button as a latching switch…