Programming loop for limiter swith

Hi All:

We are working with a slingshot solution that is tied to a motor control. The motor only needs to turn in one direction. The tensioner that winds back our slingshot will automatically release or fire if there is no way to stop the action unless we stop pressing the button. So, we are programming a swith that will be triggered to tell the motor to stop just short of firing. The puzzle here is that the switch must be triggered twice before stopping the motor before re-firing.

Once the driver presses the trigger button, the ball should fire, then automatically recoil, count two switch counts and stop. Then fire next time the same button is pressed.

Any ideas? Thanks in advance!

Try setting the switch input as a Counter in LabVIEW. Then you can stop the motor when its value reaches 2. Use a press of the joystick button to start the motor and reset the counter to zero when you want to fire again.

Here’s another way to keep count.

Count.png


Count.png

Thank you for your responses! I am looking for the controls in the function palette to call out the counters but do not see anything that resembles the count and keep count objects from the example. Where would I find this?

Mark’s example uses feedback nodes (they’re in the programming subpalette). If the switch stays active for a long enough time, what he suggests will work. If the switch is just a very brief contact that might get missed between loops of the code, you should definitely use the FPGA counter.

I tend to use polling for slow sensors like mechanical limit switches. It helps debounce them to sample at the 20ms Teleop rate (or greater in Periodic Tasks). Mechanical switches tend to flicker a little as they are engaging and can produce phantom counts if your data acquisition is too fast.

The Counters are a necessity for fast sensors, like a light sensor watching a spinning shooter wheel.
Be aware there have been some issues reported with Counters that haven’t been tracked down, so test the application if you use them. If they pass a test they should be fine.