10-31-2014 05:33 PM
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.
i am not too familiar with RUN COMMAND. how would i automatically tell it to stop alarming after it was turned on?
Solved! Go to Solution.
11-01-2014 04:11 AM
The attached file contains a simple countdown VI
11-01-2014 08:56 AM
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
11-01-2014 10:38 AM
@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"
11-12-2014 04:43 PM - edited 11-12-2014 04:51 PM
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
11-12-2014 06:22 PM
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
11-12-2014 08:48 PM
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.
11-13-2014 11:45 AM
here you go
11-13-2014 12:55 PM
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
11-13-2014 12:57 PM - edited 11-13-2014 12:59 PM
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