LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Maximum number of loops

NI-ers:

I have my main program loop indefinite until pressing stop.  I am using my .vi to control a Pulse Generator which is controlling a plasma drive engine.  I would like to "measure" the number of plasma firing events by simply taking the frequency and known amount of time between pressing start and pressing stop on my .vi.  The easiest way I know to measure this time is using the knowledge that I have a 100ms delay on the loop, and that the start and stop buttons run within the loop so the device is fairly well limited to running in 100ms increments.  The plan is to catch the difference in value between when the user presses "Start" and "Stop," then multiply by 100ms to get the time, multiplying by the drive's rep rate will give me number of firing events.  There is not a lot going on inside the loop once you set parameters and press start, so it should be running at the delay of 100ms per cycle - I will attempt to actually measure this maybe programmatically or through the creative use of some VISA writes and an o-scope tapped into the com-line.  My main problem with this method is what if this thing is left running for a day at a time or more (as may be the case with testing).  Even if the drive isn't running, but the program is that means the loop number keep son going up... what is it's limit, do you get some overflow value at the limit.  My other alternative is to start a new number at "Start" and increment that with each iteration - but I still might run into an overflow problem.  Help?!

Any thoughts on:
A) A better way to measure number of shots fired?
B) A better way to measure the amount of time per iteration?
C) The worry of "overflow" of the loop increment number?

Thanks for your help in advance!

-Jon
0 Kudos
Message 1 of 7
(4,707 Views)
Maye you should attach a simplified version of your code. I am not very good understanding longwinded text. 😉
  • Use a timed loop to get the exact time and possibly take evasive action if the code is too slow.
  • The loop iteration terminal is I32. How long is your loop supposed to run? You can use a shift register containing a DBL or U64 to increment only if you need to.
  • You can meaure elapsed time accurately with timestamp and tick count primitives, for example.
Message 2 of 7
(4,692 Views)

The loop iteration counter is an I32, which means it is a signed 32 bit integer, which means it can go up to 2^31, which means that at ten iterations a second you can run it for roughly 6.8 years before you get to the limit.

As for better ways of measuring, I didn't understand exactly what it is you are doing, but I suggest you use two shift registers - one for counting the number of pulses (increment it by one each time there is a pulse and don't increment when there is none) and one for monitoring the time. You can use the Tick Count to get the value of the OS ms timer and pass that through. You can then substract the old value (passed through the shift register) from the current value to get the number of ms which passed. You should find some examples about using SRs in the example finder (Help>>Find Examples)

To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here, here, here, here, here and here are a few you can start with and here are some tutorial videos. You can also contact your local NI office and join one of their courses.
In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).


___________________
Try to take over the world!
Message 3 of 7
(4,690 Views)
Thanks altenbach and tst.  I appreciate the help.  Seeing as the range allows 6.8 years of continued use I think I'll just go with my original idea.  I'm going to programatically measure the time it takes to run the loop as a double check.  I think what I will acutally do to check that is check the timer just prior to entering the loop, let the loop run for some time, and upon exiting the loop I'll check the timer again and compare it with the iteration number to get a good, long average. I'll double check that against a single measurement. 

This thing ain't gotta be rocket science accurate despite, it's use a form of space propulsion, LOL ;).   Currently it's R&D, we just want to be able to tell some folks that it has pulsed N million times. 

Thanks again for all your help. 

Do you guys work these forums full time?!?!
0 Kudos
Message 4 of 7
(4,666 Views)
Everyone here has regular jobs and we volunteer to answer these questions as time and work load permits.  If you see a name in blue, that person works for NI.  All the others are non-NI volunteers.  In my case, I subscirbe to the forum and get email everytime a new post is made.  I choose to respond depending on subject matter and time permitting.
- tbob

Inventor of the WORM Global
Message 5 of 7
(4,659 Views)

By the way,


@Radiance_Jon wrote:

do you get some overflow value at the limit.

I tried it once and the answer is no, the counter just stops.


___________________
Try to take over the world!
0 Kudos
Message 6 of 7
(4,631 Views)
In addition to what tst said about the counter stoppping, the loop continues to run. This can create interesting consequences if the i value is being used inside the loop. If a loop will possibly run more than 2^31 iterations, it is probably best not to use the i terminal at all.

Lynn
0 Kudos
Message 7 of 7
(4,619 Views)