12-12-2011 03:18 PM
Hi
I'm making a program to make voltage measurements with a PCI 6221 37 pin board and temperature measurements with a USB TC01. I use Labview 2009 SP1, and basically my program reads the data, shows it in a chart, and saves it to a file, all within a While loop which runs until I stop the program.
The program is enclosed. I wasn't too sure about timing with the 2 devices. The TC01 runs at a fixed rate, so I set DAQmx read to 1 Chan 1 Samp. On the 6221, I set a sample rate and chose "continuous samples", set DAQmx read to 1Chan Nsamp, and set "samples to read" to "-1". And it seems to work fine, but just setting "samples to read" to -1 seems too easy. Am I missing something. What determines the speed at which the loop runs ?
Thanks
Solved! Go to Solution.
12-12-2011 03:57 PM
The speed of the loop is determined by the time it takes all the code inside the loop to execute. The Write to File VIs may be the slowest elements. As the file grows the OS may need to re-allocate file space which could take some time.
The temperature measurement device may run at a fixed rate, but does the AI read wait for a new result or just repeat the previous result if you try to read again before new data is available? Does it make sense to write one sample to the file at a time? Perhaps accumulating data for some period of time and then writing a "chunk" of data might be more effective.
There are a variety of ways to set the timing on a loop. What do you want the timing to be?
Lynn
12-12-2011 04:06 PM
I'll be measuring low frequency signals (about 0.5 Hz). My only constraint for timing is that the graph should be updated fairly often, so that the user can observe the measurements in almost real time. So 1 loop could take say between 100 ms and 1s.
12-12-2011 07:02 PM
Try putting a Wait (ms) function in the loop. Set the wait value to 100 to 1000 ms. If everything else happens faster than that, then the wait will determine the loop rate.
Lynn
12-12-2011 07:47 PM
Yes that works. Thanks !