LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Counting down to zero from a specified number

I'm sure this is a very simple thing to do, but I can't figure out how. I want to count down from a specified number to 0, then restart counting at that orginal number. The trick is that I need it to place it in a case structure, and have it restart counting when it switches states (i.e. from TRUE to FALSE and vice versa).

Example: Say I want to count down from 2 (as specified in a constant). Should look like:
FALSE
2
1
0
2
1
0
2
---TRUE
2
1
0
2
1
---FALSE
2
1
0
2
1


I'm sure this is easy to do, but I've been wracking my brain!

Thanks!
-Brendan
0 Kudos
Message 1 of 10
(3,327 Views)
Brendan,

The attached VI is the simplest example I could think of. By default, it counts down from 10. It's saved in LabVIEW 7.0. Hope this helps.

Steven H.
0 Kudos
Message 2 of 10
(3,318 Views)
While I don't know what you mean by "when it switches states", I have attached one solution using an event structure. Here "it" is simply a boolean control that switches states under operator control.

See if this makes sense to you.
0 Kudos
Message 3 of 10
(3,308 Views)
Thanks for your help. Anyway I could get this in Labview 6.1 format (or let me know how to open it in 6.1)?
Thanks so much,
Brendan
0 Kudos
Message 4 of 10
(3,281 Views)
Here's Altenbach's VI in 6.1.

___________________
Try to take over the world!
0 Kudos
Message 5 of 10
(3,243 Views)
Okay, this looks good. I like the event structure's ability to detect a change of state. Here's the problem though: in the examples given, the event structure is always used to detect an action by the user, usually though a boolean control. What I need is a way to trigger the event using a boolean value *internally* generated. I tried just creating a boolean indicator and using that, but it doesn't seem to work. I'm SO close to getting this to work, but I need a way to have the event strcture poll the status of an internally generated boolean value (as opposed to one controlled by the user through the switch in the example).

Thanks!
-Brendan
0 Kudos
Message 6 of 10
(3,206 Views)
You need to create a property node. Right click on the control or the terminal and select Create>>Property Node. Then select the Value (signaling) property. This will trigger the value change event.

___________________
Try to take over the world!
0 Kudos
Message 7 of 10
(3,200 Views)
Where is this value signaling property? I create the property node, then how do I select the signaling property? I'm running LV 6.1 - does that make a difference? If I happen to find it, once I select it that's all I have to do, and my event structure will trigger off the boolean value?
Thanks a lot for your help.
0 Kudos
Message 8 of 10
(3,193 Views)
You are correct in that that is all you have to do, but the fact that you're running 6.1 makes all the difference - that property didn't exist yet. If I remember correctly, dynamic user events weren't available either, so you can't fire an event programmaticaly. Try searching the site for "6.1 event programmatic" or something similar to find alternate solutions (like a queued task handler).

___________________
Try to take over the world!
Message 9 of 10
(3,186 Views)
Great. I got it up and running. I used the event handler 'timeout' function to check periodically if the timer had counted all down and reset it, then I just used nested case structures with shift registers to keep track of boolean state changes. I really appreciate all your help!

Thanks a lot!
-Brendan
Message 10 of 10
(3,162 Views)