03-03-2010 01:52 PM - edited 03-03-2010 01:53 PM
Hi all,
I'm working with (several) timed loops and have pretty complex vi's inside them.
The longest dt = 180000, i.e. run the loop each half an our.
This works just fine, but i have one problem. I would like the first iteration to start immediately and then repeate the timed loop accordingly to the set dt.
Se the enclosed .vi that start the first iteration after 10 seconds. Is it possible to modify this so the first run starts at once?
Many thanks!
LW 8.5
03-03-2010 01:58 PM
Thusly
03-03-2010 04:19 PM - edited 03-03-2010 04:22 PM
Izze,
The initial iteration of the timed loop does run with zero delay. (Numeric is immediately set to zero). It is the next iteration that is delayed by the dt time.
Jeff's idea looks right, but there is one problem with the implementation of it. It actually winds up doing the same thing as yours. Why? Writing the new value to the dt in the initial iteration seems to affect the iteration that it is still in. To truly only affect subsequent iterations, you need to do this.
Here iteration 0 starts at t=0
Iteration 1 starts at t=0 (more or less)
Iteration 2 starts at t=5 seconds.
Iteration 3 starts at t=10 seconds.
03-03-2010 04:22 PM
03-03-2010 04:30 PM
Jeff Bohrer wrote:
thats what I get for not testing![]()
The way you coded is the way I would have thought to do it. I originally wanted to post a message to try to clarify what the OP wanted. They said
"This works just fine, but i have one problem. I would like the first iteration to start immediately and then repeat the timed loop accordingly to the set dt.
See the enclosed .vi that start the first iteration after 10 seconds. Is it possible to modify this so the first run starts at once?"
I wanted to state that the first iteration of a loop always starts right away. It may be semantics, because the first iteration of the loop is i=0, the second iteration is i=1, and so on.
So I figured that based on what you coded (which sure looked OK to me, but I just wanted to test things before I wrote anything) was that the OP mean that the "first" iteration was the i=1 iteration. Then when I tested your VI, I found it didn't work like I expected. And that the dt in the loop must have affected the current iteration of the loop rather than acting like a shift register to only affect later iterations. I don't know if there is any documentation that clearly states that. The context help for period for the timed loop really didn't say anything.
03-04-2010 02:05 PM
Raven, Jeff, thanks!
But how very odd, the timed loop actaully works as i want it to do just drawn as my original .vi
The first iteration with zero delay and the rest delayed accordingly to dt.
The strange thing is in my complex timed loop, the first iteration is actually delayed for some strange reason, i can see that there is no activity (not related to counting the loopnumber)?
When i strip it down it starts to work exactly as you described above.
Anyway thanks for helping me understand how the timed loop works and now i need to do some debugging!
Cheers
03-04-2010 02:12 PM
03-04-2010 02:24 PM - edited 03-04-2010 02:25 PM
Not really, the only thing i have tied is the dt and the name of the loop.
In the timed loop I also talk via virtual COM port, use mixed graps and some other stuff. Perhaps something strange happends here, but i cannot understand how it would relate to just delay the timed loop excatly the time i haved defined in dt?
hum hum...