LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Digital counter data is not written into a file

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?

 

0 Kudos
Message 1 of 16
(4,193 Views)

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.

0 Kudos
Message 2 of 16
(4,148 Views)

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.

0 Kudos
Message 3 of 16
(4,134 Views)

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!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 16
(4,117 Views)

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.

0 Kudos
Message 5 of 16
(4,043 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 16
(3,838 Views)

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

Message 7 of 16
(3,834 Views)

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?

0 Kudos
Message 8 of 16
(3,800 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 9 of 16
(3,789 Views)

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.

0 Kudos
Message 10 of 16
(3,776 Views)