|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
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.
![]() all 3 are of the same code but it is showing what is inside the case structures Do you guys have a solution to this specific code, or a new code that works better for what I need? Thanks |
|
#2
|
|||
|
|||
|
Re: Toggle Motor Using Button
You could use a global that turns on/off with each press of the button, then check to see if the global is true/false when the button is pressed and then start or stop the motors depending on that.
|
|
#3
|
|||
|
|||
|
Re: Toggle Motor Using Button
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. Greg McKaskle |
|
#4
|
||||
|
||||
|
Re: Toggle Motor Using Button
Quote:
![]() I noticed that the stop on the while loop was set to false so I switched that to true and nothing changed. Please give it to me straight, doc. |
|
#5
|
||||
|
||||
|
Re: Toggle Motor Using Button
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.
|
|
#6
|
|||
|
|||
|
Re: Toggle Motor Using Button
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. Greg McKaskle |
|
#7
|
||||
|
||||
|
Re: Toggle Motor Using Button
Quote:
|
|
#8
|
||||
|
||||
|
Re: Toggle Motor Using Button
Okay so a follow up question I have would be:
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)? Thanks |
|
#9
|
||||
|
||||
|
Re: Toggle Motor Using Button
Do you mean proportional scaling of the motor speed?
|
|
#10
|
|||||
|
|||||
|
Re: Toggle Motor Using Button
Read the Attack 3 joystick's throttle button as "axis 3 (throttle)". It'll give a value between +1 (full back/down) and -1 (full forward/up).
If you want to turn that into a value between 0 and 1, just subtract one and divide by negative two. Is that enough information? I'm not sure if you're asking how to read the throttle control, or how to set the speed of a motor, or something else. |
|
#11
|
|||
|
|||
|
Re: Toggle Motor Using Button
Quote:
http://www.chiefdelphi.com/forums/at...5&d=1360018159 |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|