LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAqmx in timed while loop, measurements are lagging behind?

I have an DAq MX which reads a voltage. The aquistion part is a while loop which has a 'Wait Until Next ms Multiple Function'  which is set to 100ms. The loop should thus run at 10 Hz. I wired a constant of 10 to the rate channel of the 'DAQmx Timing (VI)'.  But I think there is a synchronisation issue. If I run the program and let the voltage increase than I see the readings change but not increase. When I stop the program and start it again the readings are suddly a lot higher.

Is the buffer to big in this case or something? How do I synchronize the loop with the aquistion? So that it gets the latest reading?

0 Kudos
Message 1 of 20
(3,912 Views)

For a DAQmx read you don't need a wait in the loop.  Read a fixed number of samples (say 0.10 seconds worth) and the DAQmx read will never fall out of synch.  What you are seeing is the difference between your PC Clock and the devices timebase.  Over time the buffer may actually fill up and report an error.  So, don't use timing functions in a DAQmx acquisition loop

 

For example look at "Voltage - Continuous Input.vi" from the shipping examples

Capture.PNG


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 20
(3,903 Views)

Thanks for the response. The voltage readout is part of a bigger loop which controls something at a fixed rate. Which is also important to at a fixed rate.

Is there a way to combine the readout of the voltages with a timed loop?

0 Kudos
Message 3 of 20
(3,870 Views)

Typically you would run the acquisition and control sections in seperate loops.


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 20
(3,845 Views)

How would you do that then? Please explain 🙂

But what if you base the control on the reading of the DaqMX (the aquistion)? Than you would base the time increments on the Daq speed? It is not possible to force the aquisiton to run at the same rate?

 

This is what I tried:

 

 example.png

0 Kudos
Message 5 of 20
(3,835 Views)

1. Do NOT wire up the Samples Per Channel on the DAQmx Timing VI.  You are just limiting the buffer and are likely to cause errors.

2. Do NOT use a wait inside of your acquisition loop.  As Jeff said, the DAQmx Read will wait for the next sample to come in.  So that VI will limit your loop rate.  The DAQ will sample at the rate you tell it to with the DAQmx Timing VI.

3. Use a queue to send the data from your acquisition loop to your control loop.


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
0 Kudos
Message 6 of 20
(3,821 Views)
First of all, you don't have a Timed Loop. That is s very specific type of loop. Second, it is silly to specify timing and then use 1Samp acquisition mode. You switch to software timed acquisition when you do this and that is not very accurate and is subject to jitter. If you want to acquire x number of samples at an exact rate, do what Jeff recommended in the example.
0 Kudos
Message 7 of 20
(3,816 Views)

I implemented it now like this. But I don't get a fixed timestep between the log points..The upper loop runs at 1 Khz while the log interval is set to 100 ms (10 Hz).  The odd thing is also that I get the timestamps double in the log. What could cause this?

 

acquisition.png

 

 

log.png

 

0 Kudos
Message 8 of 20
(3,668 Views)
Of course you don't have consistent timestamps because you have not changed your acquisition type as previously told.
0 Kudos
Message 9 of 20
(3,654 Views)

Thanks for your reply!

 

But implementation is the same as that of the example 'Voltage - Continuous Input.vi' right? What is wrong with my variant? Or should I use  100 sample aquistion mode.

With the timed loop you mean this one: http://zone.ni.com/reference/en-XX/help/371361H-01/glang/timed_loop/

But won't you get problems with the buffer then? That the buffer is filled faster then it is cleared?

0 Kudos
Message 10 of 20
(3,642 Views)