LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Output Sampling Rate and Loop Time

Solved!
Go to solution

Hi you guys,

 

I'm pretty new to LabVIEW and I have a probably stupid question. How do I control the output signal rate? For example, an IV sweep. Each while loop will output a voltage value (calculated from the direction and step size), but loop execution time may vary. So how do I keep an ACCURATE SWEEP RATE? You can input a sampling rate in DAQmx Timing VI, but how does it work with a loop(which is actually calculating the output value for each step)?  It's all a bit confusing... Thank you so much if anyone shed some light for me!! Thanks!

 

 

0 Kudos
Message 1 of 9
(4,898 Views)

First, describe what equipment you use. Most likely, there is no direct solution to your problem. The delays between setting the frequency and its actual change are not described and their stability is not guaranteed. The most reliable solution is to change the duration of the signal with constant frequent sampling

Labview 4.0, 5.0, 6.1, 8.6, 2009, 2011, 2012, 2014
If you do not know something, ask me.
0 Kudos
Message 2 of 9
(4,877 Views)
Solution
Accepted by topic author alexalexalexalex

When doing I/O, it is (often) better to let the DAQ Hardware handle the timing issues rather than the PC/LabVIEW/While loop.  Thus if you want to output a frequency sweep, one method might be to first generate all of the points of the sweep (for example, you want to sweep from 10 to 1000 Hz over a period of 10 seconds, and you have a DAQ device that can output data at 10KHz, so you generate 10 * 10000 = 100,000 points representing the entire waveform, set you DAQ Output device to accept 100,000 points and output at 10KHz, feed it the points, and let it go!

 

If it can't take that many points all at once, you simply tell it to take, say, 1000 points and output at 10KHz, then set it for "continuous sampling" and (using a For loop) feed it 1000 points at a time (for 100 repetitions to get the entire waveform) -- the DAQ device should be able to "keep up" with you (after all, you are only updating it 10 times a second, very slow in CPU terms).

 

Bob Schor

0 Kudos
Message 3 of 9
(4,860 Views)

Got you. That's probably the way to go.

 

Is there a limitation on how fast a loop can execute, I guess it depends on the CPU? Like, if use the For loop (or while loop), to repetitively output points like you mentioned, will there be a gap if the loop can't keep up (say desired update was too fast compare to the loop speed)? Is there a highest updating rate below which is safe?

 

On the other hand, I wonder, if I can use a timed loop for controlling the rate of outputting voltage signals or reading in signals. Or is it not very precise? Like, if the execution time is longer than the set time period, then it won't go to the next iteration till everything is finished?

 

Thank you very much!!!

 

 

 

 

0 Kudos
Message 4 of 9
(4,848 Views)

Yes, everything has to complete in your diagram to move to the next iteration. That's true for a while loop, a timed loop, a for loop, etc. I probably would want a real time system for a loop rate faster than like 5 updates per second. Otherwise, OS stuff will get in the way and introduce massive jitter.

0 Kudos
Message 5 of 9
(4,843 Views)

Also, if outputting a large amount of points using the DAQ write instead of loops, is there a way to stop it somewhere in the middle before it's finished?

0 Kudos
Message 6 of 9
(4,829 Views)

@alexalexalexalex wrote:

Also, if outputting a large amount of points using the DAQ write instead of loops, is there a way to stop it somewhere in the middle before it's finished?


Yes, DAQmx Abort Task.vi will do that


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 9
(4,819 Views)

Cool! Thank you guys for all the help! 🙂

0 Kudos
Message 8 of 9
(4,808 Views)

Thank you! 🙂

0 Kudos
Message 9 of 9
(4,806 Views)