01-20-2013 08:37 PM - edited 01-20-2013 08:40 PM
Hello, I am a student using LabVIEW 2012 as an FRC competitor, and I have a request/question for anybody willing.
I cannot find a non-buggy solution to getting a button to work exactly like a switch. Either the solution is laggy, or doesn't connect.
I tried D-type Flip Flop's of many kinds, and !Q cannot connect to D in LabVIEW (LabVIEW pulls up "More than one data source" errors, so a lot of logic functions that are available with other solutions, don't work on LabVIEW)
NAND gate-types were tried aswell, no dice.
So if anybody would like to help me, this is what I am looking for:
When button is clicked, it sends out a constant true function until the button is clicked again.
-I can't use anything that messes with functions if the button is held.
-I just need a basic on/off switch, nothing that goes "around" what is currently available and makes a buggy solution. There should be some sort of correct way to do this.
-An attachment of a VI would be nice, and what goes where.
Thank you 🙂
Solved! Go to Solution.
01-20-2013 08:42 PM
You will need to store the value you need and simply negate it when you detect the button has been pressed.
01-20-2013 08:43 PM
So how do I store that value? I thought Arrays did that, but I couldn't figure out exactly how to do it.
Sorry, still learning my way around what nodes do what.
01-20-2013 08:46 PM
I would need to see you code . There are several methods to store the value. The easiest is to use a shift register (or a feed back node if you don't have a loop). That will retain the last value you insert into it.
01-20-2013 09:02 PM
Well the first issue is I don't exactly know which nodes to start with. Are you talking about actual numerical values or boolean?
Even if I store a Boolean with a feed back node, what do I then do with that? I mean, after storing it, I don't know what boolean functions to then do with it.
I tried out a latch control, but even if you latch a input, trying to then reset that value to get a off/on function seemed to be out of reach.
01-21-2013 09:17 AM
This might help
01-21-2013 11:32 PM
Ah, so may something like this work?
And what has to be under false when the loops are false? I just connected them straight through so it didn't show an error.
This basically is "supposed" to set the output to a single motor only when the switch is on.
01-22-2013 10:28 AM
That is the basic idea. The false case would simply wire the value through.
01-22-2013 10:42 AM
Ah, FIRST. In my experience, with code akin to that you are going to see multiple flips since the loop will likely iterate more than once per press. If I recall correctly there is some code in one of the Examples in Example Finder to help mitigate this problem using an XOR
01-23-2013 01:38 AM
Although, I'm having a major issue with this. I know it's basic, but what else could be done to make it work?
Any time this is included in the programming when dumped to the robot; the robot wont drive and the camera won't work.
Although, without that snippet of code, everything will work fine. I've done this multiple times and confirmed that it's this code that's doing it.
Is something misplaced somewhere? I added a Close to the right of the outer loop and that did nothing. It seems like the code is overwriting everything else and only letting that be processed.
Any ideas on how to fix this?