LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Button as a switch with logic gates.

Solved!
Go to solution

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 🙂

 

 

0 Kudos
Message 1 of 24
(5,132 Views)

You will need to store the value you need and simply negate it when you detect the button has been pressed.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 24
(5,126 Views)

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.

0 Kudos
Message 3 of 24
(5,124 Views)

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.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 24
(5,119 Views)

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.

0 Kudos
Message 5 of 24
(5,113 Views)

This might help

 

Simple Shift Register (FIRST).png



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 6 of 24
(5,069 Views)

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.

0 Kudos
Message 7 of 24
(5,039 Views)

That is the basic idea. The false case would simply wire the value through.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 8 of 24
(5,022 Views)

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

--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 9 of 24
(5,017 Views)

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?

0 Kudos
Message 10 of 24
(4,992 Views)