LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

If Switch is on, toggle action/led once.

Solved!
Go to solution

I'm trying to make it so that if I turn a switch to the on(true) position, then an led toggles on just once before turning back off. I can't figure out how to have it toggle rather than just stay on. also, I cannot change the action of the switch to only turn on while the switch is being held closed as I need that switch to work with other parts of my code. Any advice?

0 Kudos
Message 1 of 9
(3,411 Views)
Solution
Accepted by topic author riahim

Hi riahim,

 

search for the Pt-By-Pt-BooleanCrossing function…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 9
(3,401 Views)

Shift register or feedback node.  Compare new state of switch versus previous state.

 

Or use the Boolean Crossing Pt by Pt subVI.

0 Kudos
Message 3 of 9
(3,399 Views)

Thanks, I'll take a look into the boolean crossing.

 

edit: Am I missing something? Currently, I can see the input toggle inside the boolean crossing function, but nothing is triggered...

crossing.PNG

0 Kudos
Message 4 of 9
(3,382 Views)

Hi riahim,

 

why do you constantly reset the boolean crossing function?

(What is this boolean TRUE constant good for?)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 9
(3,365 Views)

I don't want to constantly reset the function. I figured I needed a way to initialize the boolean crossing, but now you bring up a good point. Do I only need to initialize it once or can I leave this disconnected...

0 Kudos
Message 6 of 9
(3,362 Views)

Hi riahim,

 

you have several options:

- leave it unwired

- init by comparing loop iterator "i" for "=0"

 

You should also put a small delay (aka Wait function) into the loop. No need to iterate as fast as your CPU allows…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 9
(3,337 Views)

Thank you! It is now working

0 Kudos
Message 8 of 9
(3,334 Views)

If you don't need all that extra functionality of the ptbypt subVI, all you need is a simple feedback node as follows.

(That's what I typically do :D)

 

SenseFalseToTrue.png

 

 

 

 

Message 9 of 9
(3,320 Views)