03-16-2015 11:14 AM
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?
03-16-2015 11:42 AM - edited 03-16-2015 11:47 AM
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
03-17-2015 03:30 AM
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?
03-17-2015 08:44 AM
Typically you would run the acquisition and control sections in seperate loops.
03-17-2015 08:52 AM - edited 03-17-2015 08:54 AM
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:
03-17-2015 09:21 AM
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.
03-17-2015 09:25 AM
05-06-2015 04:32 AM - edited 05-06-2015 04:33 AM
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?
05-06-2015 05:16 AM
05-06-2015 06:32 AM
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?