LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Having trouble using a countdown timer vi

Solved!
Go to solution

Hello all.  We are using a state machine that has a delay timer in one of the states.  In the state with the delay timer, we want to show a count down that decreases from the start time to 0.  We are using the CountDown.VI example vi to do the counting.

 

The problem is that we are not able to pass the counting value from the CountDown vi to the front panel of our main vi.  Although we are using a connector pane to connect the countdown.vi output to an indicator on our front panel, the indicator only shows one value. 

 

We used two probes to look for issues.  One probe is on the Countdown.vi, the other probe is on our main vi.   The Countdown.vi probe is on the wire going to the control that is on countdown.vi.  The main vi probe is on the wire coming from the CountDown.vi to our indicator.  We see that the countdown.vi probe runs as we would expect, but the probe on our main vi only shows one value that never changes.

 

We figure the problem is because of the While Loop in Countdown.vi, but we don't know how to get by this.  Is there any way to pass the current value from the CountDown.vi to our front panel instead of just the one value? 

 

Thanks.

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

If you can post both main vi and countdown vi can explore more.

But as i understand you are missing datflow of LabVIEW.

Thanks
uday
0 Kudos
Message 2 of 6
(4,673 Views)

Here is how I usually do a timer

 

CDT.png

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 3 of 6
(4,668 Views)
Solution
Accepted by topic author Dhouston

The problem is that the data is not available from your Countdown Timer until it has completed execution. That is how all SubVIs work, and it is a very good thing because you wouldn't want your program to keep on running while your Countdown Timer is going (in this case).

 

You have a couple of options.

1) Like RTSLVU showed you, do not use a SubVI for your timer, but put it straight into the Main VI.

2) Make the SubVI front panel open while it is running. The timer will be in a different window though, I don't know if this is desired.

3) Pass in a reference to your front panel indicator into the SubVI. Then inside your SubVI (Countdown Timer) you can write to the indicator using a property node.

4) Similar to #2, you can use a Subpanel to display your SubVI on the Main VI.

 

I think #3 will be the easiest for you, I'll show an example if I have time.

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

Here is a quick example for you. Just be careful, because property nodes are quite a bit slower than wiring directly to the indicator. For this option it should be fine, but try to wire directly to the indicator as often as possible.

 

Download Main.vi and Sub.vi to the same folder, then run Main.vi.

Download All
0 Kudos
Message 5 of 6
(4,646 Views)

Thank you to all who responded.  Based on what you gave as option 1, gregoryj, we put the code from the Countdown timer.vi into our code.  The timer worked as we wanted. 

 

RTSLVU's idea is quite interesting.  We may incorporate that into future code.

 

Thanks again all!

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