Extender trouble

Hello, i have made code to program a button to and extender, can any of you help me

Expander.vi (10.3 KB)

Expander.vi (10.3 KB)

The SubVI inside the while loop will be called repeatedly with whatever values the buttons had when the loop began. The loop will never end, so it will never provide a value to the Arcade Drive function. Whatever vi this code is in will hang. If it’s in Teleop, your robot will be disabled almost immediately by the communication watchdog.

Tell us what you intend it to do and we can probably tell you a good way to make it happen.

I wanted a motor to push a metal bar out of the robot to block other robots

Then why not do yourself a favor and let the hardware do most (if not all) the work for you. In your code (the software side), all you need is to watch the value of a trigger on your joystick (or another button of your choice); once pressed, just tell your motor to “go” - don’t worry about telling it to stop, let the hardware handle that for you. On the hardware side, use limit switches plugged into the Jags as stops on your bar; if done correctly, the limit switches will be normally-closed while the Bar is on your robot, and they will be open once your bar extends as far out as it needs to be. The open limit switch will cause the Jag to brake (not “break”) the motor, acting as your stop.

There ya go, an incredibly simple mechanism to code and set up.


What kind of control do you need on the bar? Does it have to move at different speeds at different times, or can it always move at the same configured speed? Does it have to stop in the middle of its travel, or can it always move fully to one end of the other before stopping? Do you want it to extend when a joystick button is pressed and return when the button is released, or do you want it to extend based on one button and return based on a different button? How far do you want the bar to move?

The answers to these questions might point to a solution you aren’t thinking of: use a pneumatic cylinder instead of a motor.