Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read multiple channels simultaneously with minimum delay

Solved!
Go to solution

Hi all,

 

Please look at the attached file. Actually this is a simplified example of my actual application, I have not included the second half of it  to decrease the complexity.

As demonstrated I have two analago inputs that I need to read (position and acceleration) with SPECIFIC requirement which is:

 

At the same time I do make certain decisions based on the most recently acquired data in the "timed loop". The decision making part is not included in this vi. for the sake of simplicity. But the point is that I just need the most recent data (like online) to make some sort of decisions. 

 

Everything looks fine and it looks that I am collecting data in a desired way at 1msec interval. BUT I just found that the data I am reading (in the timed-loop) is not the most recent one comparing to the actual sensors. In other words there is a delay in this acquisition process. The value in the timed-loop is like 100 msec delayed from the actual sensor output, which is generated by the sensor and acquired by DAQ card. 

This problem makes my decision making part to constantly decide based on the value of 100-msec before. Unfortunately this is terrible to my application, i.e. this is an intolerable delay for the process.

 

Are my DAQ parameters like Samples per channel, Number of samples per channel or sampling rate right? I appreciate if someone can help me with this application. I just need to collect data at 1KHz, as close as possible to real-time (online) or with minimum delay, not 100 msec. 

 

Thanks.

Amir
0 Kudos
Message 1 of 19
(4,203 Views)

Hello Ballbouncing

 

Which device are you using?? I took a look at your VI and I am wondering why are you using a Timed loop?? The acquisition speed is not determined by the while loop execution speed.

 

Warm regards

 

Mart G

 

 

0 Kudos
Message 2 of 19
(4,187 Views)

Hi Mart,

 

I am using NI-USB 6229. I am using the Timed loop because I need the minimum 1-msec sampling rate. Also I have several loops that I need to synchronize them with a "Ceare 1KHz Source". I write this data (sampled at 1-msec) into a file for further processing as well.

 

Thanks.

Amir

Amir
0 Kudos
Message 3 of 19
(4,174 Views)

Hello BallBouncing

 

AS I told you before the sampling rate is not determined by the timed while loop, is determined by the timing VI, so you can adjust these parameters to read one sample / msec. However windows is not very deterministic and with a USB DAQ the time it takes for a reading to move from the ADC to the DAQ read VI is not accurate. If you are doing some automatic control you may consider the option to use a real time controller.

 

Regards

 

Mart G

0 Kudos
Message 4 of 19
(4,156 Views)

Hi Mart,

 

I am pretty new to Labview and of course I don't know many points that I need to learn.

I understood that my sampling rate is not set by the timed while loop. but is there any problem associated with using that? does that cause the delay?

If that's the csae could you please tell me what structure I should use?

I appreciate if you could give me an example, or ...

 

Amir

 

 

Amir
0 Kudos
Message 5 of 19
(4,149 Views)

Hello Amir,

 

Just use a normal while loop, and do not set any value in the number of samples per channel in the DAQmx READ VI inside the while loop, just set the sample rate to sample one sample per milisecond = 1kHz and the samples per channel can be set to 100. however as you are using a USB device and windows there will be always a delay between when the valeu is read by the DAQ and can be processed.

 

Regards,

 

Mart G

 

0 Kudos
Message 6 of 19
(4,144 Views)

Hello Mart,

 

Thank you for your reponse. But as I said I have several loops that they work together and I they must be synchronized. Could you please let me know how I can synchronize them as well.

 

Thanks.

Amir
0 Kudos
Message 7 of 19
(4,113 Views)

Mart,

 

Also, I have changed the code as you suggested. Unfortunately I am recieving the following error. 

Error -201002 occurred at DAQmx Start Task.vi:1

Sample Clock Rate must match the frequency of the internal timebase specified as the Sample Clock Source.

 

Could you please help me a little bit further.

 

P.S: I attached the revised code as well.

 

Thanks.

Amir
0 Kudos
Message 8 of 19
(4,032 Views)

What is the purpose of specifying a 100kHz timebase instead of the default? What are you attempting to do?

 

Why are you using a timed loop to read the local variables. Better to use a producer/consumer architecture. Your idea of synchronization and data flow is flawed.

0 Kudos
Message 9 of 19
(4,019 Views)

I agree with Dennis if you choose the onboard clock instead of the 100 kHz time base that will remove the error you are getting, and the idea of the producer consumer loop is that the master loop read the data from the DAQ device and the slave loop process the information, they are not really synchronized in a direct way, but this architecture will prevent the loss of data if the acquisition is faster than the processing of the data.

 

Regards

 

Mart G

0 Kudos
Message 10 of 19
(4,015 Views)