05-12-2015 05:29 AM
Hello
I'm a beginner with labview and I'm trying to make a measurement program for my setup (sensor data -> file). I have the USB-6008 and I'm trying to save data from a digital counter and 3 analog ports. The counter is for RPM and the number of revolutions. Analog is used for force, potential voltage and temperature. Currently data from the analog ports is written to a file normally but all the data from the digital side is lost. So in the measurement text file columns for the digital data are empty.
The DAQ assist for the counter is set "on demand" but the analog DAQ assist has a sampling rate of 1k (continous). My problem propably comes from the different sampling rates. I could set analog sampling to "on demand" but I need the 1k rate for the measurements. Also making two different measurements files works but it's very inconvinient.
Am I right about the sampling rate and how would I fix this?
05-12-2015 10:48 AM
Have you played around much with the "write to report" express VI? It looks like you have selected "If a file already exists >> Use next available filename". Also "X Value (Time) Columns >> One column only". Perhaps you can play with those settings to get the desired result, but I don't have experience with this express VI.
05-13-2015 01:40 AM
I tried what you suggested but I don't think the problem is with the "write to" VI itself. "If a file already exists >> Use next available filename" is used because I need a new file for every measurement and adding more time columns of course added just more of them.
What I get in the actual measurement file is something like this (values simplified):
time RPM Force etc.
1 0,000 2
2 3
3 2
4 3
Time and all analog data (force etc.) records normally but digital data column for example for RPM just reads zero in the beginning and empty after that. The RPM and number of revolutions are measured correctly since the front panel shows them to be correct while measuring.
05-13-2015 03:11 AM - edited 05-13-2015 03:12 AM
Hi Pylzy,
What I get in the actual measurement file is something like this (values simplified)
Yes, it is expected!
You create an array of values by building it from scalar values mixed with DDT/waveforms. This works without runtime errors as you use that dreaded DDT and ExpressVIs.
But this does not create useful results - as you use that dreaded DDT and ExpressVIs…
Stay away from DDT, use "normal" functions/VIs and everything will fall into place!
05-26-2015 03:40 AM
Hello again!
I got rid of most of the express VIs but now I'm having different trouble with the new program.
I'm trying to get a 1k sampling rate for the three analog channels. For some reason the data is written on a rate of ~200 Hz. Also after I stop the measurement an error about "attempted to read samples that are no longer available" pops up. I'm assuming that "samples per channel" in the "sample clock" is the buffer size but changing it didn't help.
Secondly the digital counter loop writes only a single row of data (single time, RPM and total revolutions). I'm trying to save the data as often as possible.
05-26-2015
07:16 AM
- last edited on
05-11-2025
09:30 PM
by
Content Cleaner
Read more than 1 sample at a time. Read more like 500 samples at a time. Your software will not be able to keep up with the data coming in at 1 sample per loop. And saving the data to file can be really slow. You may need to go to a Producer/Consumer to offload the logging to disk to another loop so you can make sure you are reading the data fast enough.
05-26-2015 07:18 AM
Think Data Flow. For a Loop to "loop", everything inside the loop must execute. Furthermore, since your loop starts with "Acquire one sample" and ends with "write one sample", the time for the loop to execute will be the sum of the times to sample (1 msec) + write (??).
Take advantage of the fact that LabVIEW in inherently parallel. Instead of taking one sample/loop, take (say) 1000, but do not write them in the same loop. Instead, "export" them to a parallel loop (via a Queue) so that when the 1000 samples arrive, they are written all at once. While it is true that to acquire 1000 samples at 1KHz will take 1 second, most of that time will be spent "waiting" for the next sample to be taken (it takes almost no time to put a point on a Queue). Similarly, if I have a whole second to write 1000 points to a file, that's more than enough time.
Separating "serial" tasks into parallel streams is a common LabVIEW Design Pattern called the Producer/Consumer pattern. There are numerous examples of this pattern, including a template that will write the basics of the code for you (open the File menu, choose "New...", From Template, Frameworks, Design Patterns, Producer/Consumer Design Pattern (Data)). A slightly more sophisticated example can be found by starting LabVIEW, New Project, Continuous Measurement and Logging.
Bob Schor
05-27-2015 04:30 AM
I made a simple queue for the analog measuremets. Data is now being saved to the .txt but now there's no time column in the file. How I can I add the corresponding time (elapsed time from 0 s) to each row?
05-27-2015 06:44 AM
Your logging loop needs to truely run IN PARALLEL with your other two loops. You currently have data dependencies that will cause the logging loop to run AFTER the other two loops.
05-27-2015 12:45 PM
How can I do that? In the most recent .vi I have ignored the counter loop completely and just tried to make the analog inputs work with the queue.