![]() |
Toggle switch problems
I've been working with lab view for maybe a year now and I've been talking with a programmer for a couple of months trying to get a toggle switch to work. I have what I believe is correct for the programming wiring in labview. I've set up a ref num in begin .vi and set up a back ref to begin .vi in a new vi I made. But yet when I deploy it I can't control the motor.
|
Re: Toggle switch problems
Quote:
|
Re: Toggle switch problems
What do you mean by a "toggle switch"? I can think of at least three things you might be referring to, and they're all completely different.
What do you want to do with the switch? Be as specific as you can. |
Re: Toggle switch problems
By a toggle switch I mean you press a button on a joystick once and the motor turns on. You press the same button again and it turns off.
|
Re: Toggle switch problems
Quote:
|
Re: Toggle switch problems
If you set it up like this, you can make it a SubVI with an input and output instead. This is useful if you want to have multiple toggles in your code, so that your Teleop.vi doesn't get as cluttered.
http://i.imgur.com/GVxbv.png |
Re: Toggle switch problems
Oh wow. ok this is so much more complicated then I've been told. I've been told by someone on FIRST forums that it was a lot simpler. http://forums.usfirst.org/showthread...8107#post58107
That was the forum with everything I've been using, and what you posted there is so much different then what I've seen. :/ |
Re: Toggle switch problems
a much easier way would be to have a local/global variable , and when you click a joystick button, in a case structure read the value, wire it to a not, and write the value to the variable. It is a lot less confusing then the previous posts and just as effective
|
Re: Toggle switch problems
Actually, the previous post is the more professional way of doing it. Globals and locals, in almost any language, are the least common denominator and often not the best approach. Next time you write a simple expression that has localized state data, try using a shift register. Next time you have an expression needed in multiple places, try using a subVI.
Greg McKaskle |
Re: Toggle switch problems
1 Attachment(s)
Here are a couple subvi's we have made to help with these issues.
TON.vi is "Timer On delay" takes a Boolean input and delays TRUE in milli-seconds. TOF.vi is "Timer Off delay" takes a Boolean input and delays the on to off transition by milliseconds. TOF_Toggle.vi takes a Boolean input, TOF's signal and then toggles output state. In PLC code, TOF is used to de-bounce signals, limit switches. Many game controllers will double trip when pressed or released, using the TOF will mask those events. We typically use 100 ms for the delays for joystick buttons. All of these do not stall code with waits, it will take a snapshot of current time and set the future time to look for the delay, and are re-entrant mode, so many in the vi will not conflict with each other. |
Re: Toggle switch problems
lorem3k, in the code you sent me the node right after your button 1 unbundle value what would that be and where would i find it? Anyone can answer if need be. :D
|
Re: Toggle switch problems
Quote:
|
Re: Toggle switch problems
The input and output for the subvi. You connect it to the greater than node. their green, where would i find these??
|
Re: Toggle switch problems
Quote:
|
| All times are GMT -5. The time now is 04:04. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi