From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I want timer function to control LED ?

I want timer function that control a LED, for example, if I connect 'OR' gate to LED 1 then the 'OR' gate becomes TRUE so the LED 1 is ON, then I want LED 2 become ON up 10 seconds (or any number of seconds) even that the 'OR' gate becomes FALSE that mean the LED 1 becomes OFF, the LED 2 stay ON through the specified number of second.
 
I think the attach very clear than the paragraph....... so please help me and put the function (complete what I want) in the same attach....
0 Kudos
Message 1 of 12
(7,265 Views)

Hi

Look at attached VI's

i have used timed while loop and conditional cases.

In the first VI(test_timed.vi), after waiting for 10 seconds, the led 2 will turn OFF and will not turn ON again if led 1 is on.

In the Second VI(test_timed_1.vi), after the 10 seconds the led 2 will turn OFF. But, if the led 1 is still ON, the led 2 will also become 'ON' for next 10 seconds and so on.

Dev

 

 

 

Download All
0 Kudos
Message 2 of 12
(7,253 Views)
One possibility would use an event structure and manipulate the timeout whenever the switch is changed.
 
If I understand you right, you want LED2 to turn off 10 seconds after the switch (and LED1) has been last turned on. It should go off after 10 seconds even if the switch (and LED1) remains on. If e.g. LED is turned off after 5 seconds, LED 2 should remain on for an additional 5 seconds (for a total of 10 seconds), etc. Is this correct?
 
The attached example show a simple implementation of this idea.
 
The example could be easily adapted for other desired functionality, you just need to define exactly how it should behave ;). If the boolean state is derived programmatically, you could use a signaling property to trigger these events.
0 Kudos
Message 3 of 12
(7,224 Views)

Thanks devchander and altenbach

I realy don't know what I'll do without you !!!!!!!!!!!!!!

Thank you so much.........

0 Kudos
Message 4 of 12
(7,220 Views)
excuse me altenbach ........
yuor VI (testMOD) is very excellent and achieve what I want exactly, but I want from you to explain what happen when the Switch has been turned off. I mean in the case structure, I saw subtracts, In range and coerce and Tick count functions but I dont understan their operation exactly.
 
I'm sorry if I'm boring, but I'm new user in Labview.
0 Kudos
Message 5 of 12
(7,214 Views)
OK, good question! 🙂
 
Whenever the false case is encountered, it means that the timeout got interrupted (e.g. by the "value change" of the switch). If we don't adjust the timeout, it will again wait 10 seconds until it triggers. Subtracting the current tick count from the tick count taken when the switch was turned on gives you the elapsed time between the two events in milliseconds. Subtracting this number from the desired timeout (10s) gives is the remaining time we now have to wait.
 
Example: We turn the switch on and 4 seconds later, we turn the switch off. Since this is also a value change event, the timeout will start again from scratch. We need to set the timeout now to 6 seconds using the above calculation.
 
The corece node just ensure that the timeout has a reasonable value at all times, and you are right, under normal operations we don't really need it. But remember, this event also executes if we change the "off delay". If for example you would wait 5 seconds, then set the "off delay" to 1 seconds, we would get a negative remaining delay and it would never timeout (breaking the desired functionality!), while actually it should timeout immediately. Coercing the timeout to be between the valid range of zero to the current "off delay" ensures that we don't run into trouble under extraordinary circumstances.
 
 
0 Kudos
Message 6 of 12
(7,210 Views)
Greetings everybody,
 
Would you please repost these VIs using LabView 7.0 ..
 
Actually I don't know which VI is what I want !
 
Here is my requirment:
 
I have a switchs A
 
If A = True, the user shouldn't turn A off until a preset timedelay elapsed (say 3 sec)
 
So If he did that , It's OK , the switch will turn Off, but a warning message or Led should tell him that that's not good!
 
The same thing should happes for turnning the switch from Off to ON.
 
Thanks in advance
-----------------------------
Ayman Mohammad Metwally
Automation Engineer
Egypt - Cairo
0 Kudos
Message 7 of 12
(7,208 Views)
Well, this is a simpler problem. Just see how much time has elapsed since the last switch action to decide what message to display.
 
Attached is a simple example (LabVIEW 7.0).
0 Kudos
Message 8 of 12
(7,204 Views)

Greetings altenbach,

Many thanks for this nice example, actually I never used the event structure, and never loved to !

But maybe I'll change my mind this time!!

Thanks again.

Ayman

-----------------------------
Ayman Mohammad Metwally
Automation Engineer
Egypt - Cairo
0 Kudos
Message 9 of 12
(7,194 Views)
Ok altenbach thanks again,
 
But if I want to remove the switch and connect the LED 1 to case selector directly (in this case the LED 1 is local variable) so how the event structure execute when the LED 1 value change ? because I try to do this but the LED 1 (local variable) doesnt change although it changed in the real place (LED 1 indicator).
 
please help me in this case even that you do many changes.
 
 
Thanks a lot altenbach Smiley Wink
0 Kudos
Message 10 of 12
(7,188 Views)