LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make LED flash until reset button is pressed

Solved!
Go to solution

Hi, I am creating an alarm system. But I am struggling to see how I create a latch where I make my system latch onto local trigger until a master reset button is pressed. I have tried doing it through select functions but can't get my head round it. Any help would be useful.

0 Kudos
Message 1 of 6
(4,365 Views)

Select should work.  Wire a false constant into the false input to the select.  Wire a shift register into the input and have that same value feed a NOT and back into the shift register to alternate values each iteration.  Use a switch (not latch) or the input.

 

Simple solution to alternate from true to false when the button is pressed and always be false when it isn't.

0 Kudos
Message 2 of 6
(4,317 Views)
Solution
Accepted by topic author EJBB

One way to do this is to take advantage of the properties of the Controls, one of which is "Blinking".  Judging by the VI you attached (thanks for doing that -- it enabled me to make this Demo using the version of LabVIEW, 2015, that you are using), some of these concepts may be slightly "advanced", so I'll explain a bit.

Alarm.png

This is something called an Event Loop -- a While Loop with an Event Structure inside it.  This "picture" is something called a LabVIEW Snippet -- see the LabVIEW symbols at the upper left, and the LabVIEW Version (2015) on the upper right?  Open LabVIEW, type Ctrl-N to bring up a new VI, Ctrl-E to get to the (empty) Block Diagram, then click-drag this image from your Web Browser to the Block Diagram and, by NI Magic, it will become a LabVIEW VI.  If you switch to the Front Panel, you will see a Green LED Alarm Button, a Reset control, and a Stop Button.

 

Resize things so you can see both the Front Panel and the Block Diagram.  The Event Loop structure responds to "Events" -- here, it shows the Event "Alarm":Value Change.  This means when the value of the Alarm Control changes (such as when you push it), this piece of code will execute (otherwise the loop just sits there, doing nothing, but not taking up any CPU time, either).

 

So what happens?  Well, what you see inside the Event is a Property Node for the Alarm Control.  Controls and Indicators have a list of properties that you can see by right-clicking the Control (or indicator) and choosing "Properties".  Among them is a Blinking Property and a Disabled Property.  So when you push Alarm (turning it on), you trigger this Event, which sets the Blinking Property to "True" and sets the Disabled Property to "Disabled".  Why?  So you can't push Alarm again and turn it off!

 

Examine the other two Events.  You'll see that pushing Reset also changes the Alarm Properties -- it turns Blinking Off, sets Disabled to "Enabled", and sets the Value of Alarm to "False", turning off the Alarm.  The last Event handles pushing the Stop button -- it could have been wired directly to the Stop indicator of the While loop, but I prefer to use the Event Structure.

 

You might not like the Blink color.  Don't worry about it -- changing it is much more advanced (and represents some early, possibly unfortunate, Design Decisions that are now difficult to change ...).

 

Bob Schor

Message 3 of 6
(4,316 Views)

Hi Bob,

 

Could you please post the vi as I cant get the snippet function to work ( wont drag and drop

 

Thanks

0 Kudos
Message 4 of 6
(4,054 Views)

Hi Loppy,

 

save the image to your harddrive, then drag&drop into the block diagram…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 6
(4,051 Views)

Sweet 

Everything is easy when you know how

 

Thanks a mill

0 Kudos
Message 6 of 6
(4,048 Views)