LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

countdown alarm

Solved!
Go to solution

Good Morning, 

 

I'm working on a design to countdown the time / every 2 hours. 

i need this vi to run continuously, the default time is 2 hours, but if the user changed the control to something else like 3 hours, i need this counter to repeat itself when it met the condition.

 

i tried several ways to run it all the time, but still can't figure it out.

 

how can i run my vi every 2 hours/ i don't need the vi to shutdown unless if i pressed the shutdown button.

 

also i need to make a small delay of 30 msec between each running timer, i mean when the first 2 hours finished, rest for 30 msec then run again 2 hours unless the user changed to 3 hours for example.

 

i tried to use the property node for the alarm (Boolean button) to make it fluctuated when the alarm finished counting / or before finishing the countdown by 10 sec. but also couldn't  make it right (property node -  blinking )

 

 

any suggesting please 

0 Kudos
Message 1 of 9
(4,034 Views)

Hi N.,

 

i mean when the first 2 hours finished, rest for 30 msec then run again 2 hours

Sounds like you have certain states to process: implement a state machine!

 

i need this counter to repeat itself when it met the condition.

Well, with a state machine this would be very easy…

Otherwise: when you want to repeat some code several times then that code belongs into a loop!

 

but also couldn't  make it right (property node -  blinking )

Then you made something wrong.

But as there is no property node used in your VI we cannot tell what you made wrong…

 

On your VI:

- you don't need to convert the timestamps to DBL…

- there should be a wait in your loop, it doesn't need to check the timestamp each microsecond!

Best regards,
GerdW


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

Hi GerdW, 

 

i implemented the state machine as you advised  me. however, i found a problem in the resetting. 

 

what i did is declaring 3 states, start, wait and reset. 

 

now my vi is running continuously which is perfect, but after finish counting for one minutes (default time) the time start counting in negative way. please see the attachment. 

 

i tried to use the Invoke node to reset the value to default but it didn't work. 

i'd like to start count from zero again (00:00:00) not going negative

 

can you please advice me how i can solve this problem. 

 

 

 

Regards,

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

Can you share the code?

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

i'm trying to solve it but up to the minute still have this issue and i'm inside the forums reading and exploring ideas 

0 Kudos
Message 5 of 9
(3,967 Views)

Hi N.,

 

you need to define the next state in each of your states!

How should the state machine move on when you don't define which state to execute next?

Best regards,
GerdW


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

Thanks for replying GerdW, 

 

i already did, but still when the counter finish, and the next state is start again. 

 

the counter still decreasing. so the time will be (-1:59:59) i want to make it (00:00:00) then count second time and so on. 

 

 

thanks 

0 Kudos
Message 7 of 9
(3,958 Views)
Solution
Accepted by N.Ghrayeb

This is a little closer to what I think you want. As GerdW said, the problem mainly related to the states you were using and the connections (or lack) on the output tunnel.

 

Generally, with a State Machine, it's clearest if you avoid using the "Use Default when Unwired" option with the state output tunnel - you should be explicit about where you're going next from each state.

 

I set some default values for a short (12s) wait and 500ms pause between resets.

 

The problem with the negative value still appears, but now it resets properly. This is due to the fact that you're checking if the time value is less than zero, unconditionally writing to the indicators, and then (in the new VI I upload) pausing for some short time, during which the negative value will be displayed.

 

To avoid this, you should consider moving the indicator writes into the false case of the Less than Zero case structure. Then, they will hold the old values once it becomes true. However, there are probably better (and clearer!) solutions available!


GCentral
0 Kudos
Message 8 of 9
(3,940 Views)

Good Morning cbutcher

 

first of all thanks for the amazing description and explaining the situation of my vi.

 

i noticed the changed that you did it in the Start state, the idea of passing the wait state through case structure is very useful, i didn't think about it in this way. 

 

my problem was in the reset, and when i designed that state i didn't think that i need to add the function out of the while loop, as i said take me to start state. but now is much better and i understand what have you done there. 

 

 

I do appreciate mate. 

thank you. 

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