LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQ data synchronization with file read

Solved!
Go to solution

Hi,

I am trying to do data acquisition using DAQ in real time and reading data from already existing file (which contains signal of 1000 samples per second for a certain time). I am not able to achieve data acquisition at 1000 samples/sec but its able to read signals at 1000 samples per second but 1 sample each loop. In that way the frequency of both the signals are not matching with each other. How synchronize both the signals in terms of frequency.

0 Kudos
Message 1 of 14
(3,438 Views)

Well, there are numerous tutorials on DAQmx (and on the Dreaded DAQ Assistant) on how to acquire data (from what?  Analog or Digital?  Voltage, temperature, pressure, what?) at various data rates (1KHz is fairly slow, even inexpensive DAQ devices can do that).  You've shown us no code (don't attach a picture, but rather attach your VI, and tell us about the device you are using), so we don't know what you've tried and don't really understand what you are trying to do.

 

Bob Schor

0 Kudos
Message 2 of 14
(3,423 Views)

@Bob_Schor wrote:

Well, there are numerous tutorials on DAQmx (and on the Dreaded DAQ Assistant) on how to acquire data (from what?  Analog or Digital?  Voltage, temperature, pressure, what?) at various data rates (1KHz is fairly slow, even inexpensive DAQ devices can do that).  You've shown us no code (don't attach a picture, but rather attach your VI, and tell us about the device you are using), so we don't know what you've tried and don't really understand what you are trying to do.

 

Bob Schor


I have uploaded my program here and a sample output. The white plot is also supposed to look like red curve. But white curve is acquired at 1000 samples/sec before running the code.

Download All
0 Kudos
Message 3 of 14
(3,415 Views)

Could you let us know what hardware you are using?

 

Regardless, you should take a look at the Help >> Find Examples section in Labview. Look at, for instance, the Voltage Input - Finite Samples example.

 

A couple other things, if you wants an array full of Not A Numbers, you can actually type NaN right into the double constant. 

 

You have Indexing for an array on your while loop active. It's generally not a good idea to mix indexing of an array on a while loop boundary with the conditional terminal. Do one or the other.

 

The Analog 1D BDL NChan 1Samp you have feeds into a summation node. Not sure if you're gonna wanna do this or the motivation behind it. What I imagine you'll want to do, once you look at the example, is get all your samples at once and stick them into your array immediately. This summation node provides questionable value unless you intend to average them or something. However, you need to setup your clock and buffers right first, so refer to the example.

0 Kudos
Message 4 of 14
(3,407 Views)

OK.  You configure an analog acquisition task, don't specify the acquisition rate (I'm going to assume that you want 1KHz, maybe 1000 samples at a time), then configure a DAQ Acquisition Loop where you take a single sample and put a 10 msec Wait function inside the loop to slow the DAQ down to 100 Hz.  This makes no sense (to me).

 

LabVIEW is pretty good about handling Time.  It has a special data format, called a Waveform (as in "Waveform Graph" and "Waveform Chart"), designed to handle "Time" as a data primitive.  By using Arrays of Reals, you are throwing away the Timing information LabVIEW works so hard to collect for you, and your plots show the results (namely what appear to be vastly different time scales because you've removed the time information).

 

Learn about Waveforms.  Take a vow to never use Dynamic Data Wires (which encourage "sinful" behavior).  Learn how to acquire data and process it properly (you don't necessarily want Data Acquisition, which has time constraints, in the same loop with Data Processing, which will take all the time it needs). 

 

Learn the First Principle of LabVIEW, namely what Data Flow is/means, and get rid of the Sequence Structure (the Error Line provides the sequencing that you need).

 

Bob Schor

0 Kudos
Message 5 of 14
(3,406 Views)

@majoris wrote:

Could you let us know what hardware you are using?

 

Regardless, you should take a look at the Help >> Find Examples section in Labview. Look at, for instance, the Voltage Input - Finite Samples example.

 

A couple other things, if you wants an array full of Not A Numbers, you can actually type NaN right into the double constant. 

 

You have Indexing for an array on your while loop active. It's generally not a good idea to mix indexing of an array on a while loop boundary with the conditional terminal. Do one or the other.

 

The Analog 1D BDL NChan 1Samp you have feeds into a summation node. Not sure if you're gonna wanna do this or the motivation behind it. What I imagine you'll want to do, once you look at the example, is get all your samples at once and stick them into your array immediately. This summation node provides questionable value unless you intend to average them or something. However, you need to setup your clock and buffers right first, so refer to the example.


The problem is I want the data to be read in real time. Regarding taking summation is to sum the single scalar values read in each loop.  

0 Kudos
Message 6 of 14
(3,390 Views)

When I took out the delay component from loop and I am not doing writing operation, the program is running in the desired way. But when I am giving file to write on it in every loop I am getting the DAQ values after a delay. Is there any way to write the data out side the while loop? I have tried write to spreadsheet and write to measurement file outside the loop. But its not writing any values.

0 Kudos
Message 7 of 14
(3,389 Views)

There is a way to write the files outside of the loop. You do this using the producer consumer architecture.

http://www.ni.com/white-paper/3023/en/

0 Kudos
Message 8 of 14
(3,384 Views)

@majoris wrote:

There is a way to write the files outside of the loop. You do this using the producer consumer architecture.

http://www.ni.com/white-paper/3023/en/


I went through the link. But I think that deals with minimizing the data loss due to two processes working at different speed. My problem is synchronizing both the processes.

Example:- If we are acquiring sine wave at 1000 samples/sec and store it in a file. Then read the file along with acquiring sine wave. Both of them should have same number of cycles but with a phase lag or lead.

 

0 Kudos
Message 9 of 14
(3,333 Views)

I think I see the problem -- you are reading one A/D value at a time and are trying to update a Waveform Graph in real time with every point.

 

What is your Sampling Rate?  If it is something like 1KHz, then your eye can't "see" changes that fast.  If you sampled at, say, 1KHz, and took 20 samples at a time, you'd get 20 points every 20 msec, could average (or select a point) and display 50 times a second (which is plenty fast for most things).  You definitely want the Display code out of the Producer loop -- it should only have the A/D stuff in it.  Everything else (including reading/plotting the data from file) should be in the Consumer.

 

Bob Schor

 

Message 10 of 14
(3,322 Views)