LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

count down time

Solved!
Go to solution

Can someone help me with a count down time.

in 30 secs or so. It will alarm and stopped.

can someone show me how to

1. turn on alarm.

2. stop alarm (automatically)

and repeat count down till stop button is pushed.

 

 

 

Untitled.png

 

 

Untitled1.png

i am not too familiar with RUN COMMAND. how would i automatically tell it to stop alarming after it was turned on?

 

0 Kudos
Message 1 of 13
(6,162 Views)

The attached file contains a simple countdown VI

Message 2 of 13
(6,135 Views)

Use a state machine architecture

state 1: countdown (stop pressed T: stop, F: play alarm if countdown finished)

state 2: play alarm  (stop pressed T: stop, F:countdown)

state 3: stop

 

To play the alarm use Play Sound File.vi from the Graphic and Sound palette (Sound - Output sub-palette). After this vi you can set another countdown for the duration of the alarm and then use the Sound Output Clear.vi to stop the alarm from playing.

 

For the countdown you can also used the Elapsed TIme express vi. For the GUI to be responsive never set a large loop time wait, loop every 100ms and check if stop was pressed or time is elapsed.

 

Ben64

 

 

Message 3 of 13
(6,110 Views)

@ben64 wrote:

Use a state machine architecture

state 1: countdown (stop pressed T: stop, F: play alarm if countdown finished)

state 2: play alarm  (stop pressed T: stop, F:countdown)

state 3: stop

 

To play the alarm use Play Sound File.vi from the Graphic and Sound palette (Sound - Output sub-palette). After this vi you can set another countdown for the duration of the alarm and then use the Sound Output Clear.vi to stop the alarm from playing.

 

For the countdown you can also used the Elapsed TIme express vi. For the GUI to be responsive never set a large loop time wait, loop every 100ms and check if stop was pressed or time is elapsed.

 

Ben64

 

 


for more information see my tag "Grandma"


"Should be" isn't "Is" -Jay
Message 4 of 13
(6,094 Views)

i tried this with what you guys suggested 

but i didnt get the state machine to work as smoothly.

can you sugguest a fix?

 

 

*it doesnt reset back to 10 after 1st loop

 

*the sound doesnt go on after 2nd times around

 

0 Kudos
Message 5 of 13
(5,915 Views)

I don't have LV2014 so I'm just guessing here.

 

If you use the Elapsed Time express vi you need to connect the time has elapsed output to a shift register on the while loop (and also to the loop conditional terminal). Initialize the shift register with a TRUE constant and feed it to the reset input of the Elapsed Time express vi.

 

Ben64

Message 6 of 13
(5,892 Views)

In addition to what the others have said, get out of the habit of using the Sequence Structure.  Nothing in your code remotely required it.  Learn what data flow is and how to use it to control your code.

Message 7 of 13
(5,873 Views)
0 Kudos
Message 8 of 13
(5,822 Views)

There is no difference between this vi and the previous version. You have just unbundle the status boolean from the error cluster which is useless in this case, keep the error cluster connected to the or gate. You didn't add a shift register as I suggested on the elapsed time fonction. You should use the elapsed time fonction for the countdown also and add a while loop around it instead of using the state machine loop. The countdown should be resetted when you enter the countdown state. I also suggest you add a stop state.

 

Ben64

0 Kudos
Message 9 of 13
(5,805 Views)

there isnt'

i just saved it as 2010 so someone can view it.

sorry,

you said you werent able to view it so you were guessing what my code would be. 

but ill try reading over your sugguestion and make corrections

0 Kudos
Message 10 of 13
(5,802 Views)