![]() |
button Switch
Is there anyway so that when you press a button on a joystick it starts a motor, when you let go it continues going. And then when you press it again the motor stops. Is there a way to do this?
|
Re: button Switch
This is actually a really simple issue for programming. The exact implementation depends on your programming environment. Here is how you would do it in C/C++:
Code:
bool motorIsRunning = falseGood luck, Paul |
Re: button Switch
Our team uses Labview. That's where the issue is because there isn't a "toogle" vi there
|
Re: button Switch
Our team has hit a snag here, too. We're trying to run a Victor whenever we push a button, but Labview doesn't seem to have an easy way of doing this, unfortunately.
|
Re: button Switch
I don't know how to use LabView (to me it's a waste of time) and I'm not involved with the programming on my team. However, you can still create a variable in labview (make it a boolean, an integer, a double, who cares). And then make it TRUE or 1 when you press the button and flip it each successive press. And then assign the motor value based on that.
-Paul |
Re: button Switch
To remember something from one time you process joystick data to the next you need to use either a shift register, a feedback node, a local variable, or a global variable. Any of these will work. Then you do to that storage what the code above showed. You sometimes flip it, and use its value to affect the motor speed.
Greg McKaskle |
Re: button Switch
I'm not sure exactly what to use but I think it would involve shift registers or select vi's
|
Re: button Switch
1 Attachment(s)
I made a primitive toggle switch. But it will only activate/deactivate at a precise time. Probably like every millisecond or something. This is a picture of what we have. The only issue is the starting and stopping at the right time.
|
Re: button Switch
You would use shift registers.
Create a false constant outside of your loop, and feed it to the shift register initializer, then have your joystick button feed the case indicator of a case structure. in the true case, put an inverter (NOT gate, on the Boolean tab), in the line, in the false case, just run it straight through. now feed that to the shift register output. tee the motor on/off into that wire now. I hope that made sense, I'd make a simple vi and show you, but i dont have LabVIEW on this pc. |
Re: button Switch
1 Attachment(s)
Here is a code that I made for our team. I used a flag to prevent the switch from switching back and forth. FYI, you might have to change things a bit(even though there's not many stuff) for your project.
|
Re: button Switch
2 Attachment(s)
Hey,
Good idea that, using a sleep timer to keep from reading the joystick button press over and over. Here's my solution. |
| All times are GMT -5. The time now is 08:55. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi