LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you execute a timed loop that exports an iteration per cycle for 24 cycles then resets

Solved!
Go to solution

Good afternoon:

 

I'm kinda stuck on how to put this together: I need to time out 24 hours, 1 loop per hour. Each hour/loop iteration, I will need an output (out of the loop) to activate a particular sequence. I cant figure out how to get the loop to either 1) put out an iteration value per  (ie 1,2,3...24, reset, 1,2,3...24) or 2) reset each hour to deliver an iteration of 1 (1,reset,1,reset,1...) then I would add to it externally to figure out where I am in a 24 hour period. I have been sorting through the examples and a lot of the previous discussions, but cant seem to get my head around it.

 

I appreciate the help

Sig.

0 Kudos
Message 1 of 6
(3,148 Views)

Please post what you have so far.

 

You could use the Quotient and Remainder function on the loop iteration terminal to divide by 24.  The remainder would be 0 through 23 then reset on each iteration.

 

But one loop iteration per hour is rather slow.  If you hit the stop button on your program, you might have to wait for up to two hours for it to stop.  Rather than counting loops, it would probably be better to use the Elapsed time Express VI, or use your own Get Date/Time function in the loop and determine when an hour has passed to execute the code then.

0 Kudos
Message 2 of 6
(3,137 Views)

Sig,

 

Here is one way to get a 1-24 count from loop iteration count.

 

Looks like I was a bit slooooooooooooooooowww.

Message Edited by centerbolt on 12-01-2008 04:19 PM
0 Kudos
Message 3 of 6
(3,135 Views)
Thanks for the help so far. Here is what I have as a working model. Please excuse all of the random bits, it is a test of concept at this point. You are absolutely right on the 1 iteration per hour, I didnt think that way. USing the elapsed time function seems to work about for what I am looking for. I had to create a little counting and reset loop to get the iteration right (unless you can think of a simpler way). THen it gets weird. The long list of comparisons are actions that occur at that particular iteration. However, the same actions happen at iteration 2,4,6,8,10,12,14,16,18,20,22 and a differnt action occurs at iterations 1,9,17 and a third action occurs at iteration 24. 
0 Kudos
Message 4 of 6
(3,127 Views)
Solution
Accepted by topic author ASAT

Instead of multiple comparisons, create a case structure with 3 cases.  The input would be the integer counter.  The first case would be 2,4,6,8,10,12,14,16,18,20,22, the 2nd case would be 1,9,17, the 3rd case would be 24.  A 4th would be default and contain nothing, and should probably never run.

Message Edited by Ravens Fan on 12-01-2008 05:35 PM
Message 5 of 6
(3,112 Views)
Got it, thanks guys. The case structure was the way to go. I also added a pause so the timer can continue to run, and when un paused, it would skip to the most recent iteration.
0 Kudos
Message 6 of 6
(3,104 Views)