This year with shooting something again I promised my team the ability to simply press a button on the joystick and a motor will run until pressed again (essentially a latch) as opposed to last year the motor being controlled by a joystick itself. I thought I had finally figured out the solution which I have a screenshot of below, but it doesn’t seem to work right. When the button is pressed, the motor starts up for about a second, then shuts off. This repeats indefinitely until I press the button again to stop (or disable the robot). There are rare chances I can spam the button in certain ways and get it to run forever, but that is really inconsistent.
The attached image shows some of the useful techniques that may help. You can even make some of these into subVIs for use elsewhere.
I’d encourage you to build this with the button, right click on the button and change the mechanical action to a “switch until released”, and run it on the My Computer. You can place probes on any of the wires or add indicators to them to understand how the values change when you interact. Then, when you understand and trust it, move it to the robot simply by retargeting it or by copying the code or using the subVIs.
Ask questions if parts of it don’t make sense or you want to compare it to your approach.
I either copied it wrong or I guessed what was in the case and diagram disable structures incorrectly because after many a run through it seemed ok but when I actually tested it the motor didn’t move. Here is what I made:
I noticed that the stop on the while loop was set to false so I switched that to true and nothing changed.
As I explained in this thread, our team developed a very simple VI to toggle a boolean input, essentially making any input act like a latching button. I’ve attached both the VI and a screenshot of how you could use it in your particular situation.
I forgot to point out that you just want to place the code from inside the loop into your TeleOp. If you put an infinite while loop in Teleop, it messes with the framework and you won’t process joysticks or move as you are supposed to.
And the Toggle VI worked well and is simpler than what I wrote. They are equivalent functionally.
How would I be able to control the speed of a motor using the “precise throttle” feature on the, specifically, Attack3 joystick (the little knob in the front that would be fantastic for constant control but in increments, unlike using the joystick itself)?
What you can do to take it a step further is something like this VI I designed for my team. The 4 can be changed to any number you want and it controls the fraction (in this case, 1/4) that putting the throttle all the way down will give while keeping the top value at 1.