06-12-2018 06:21 PM
Hello,
In the attached VI I'm trying to write a program that moves two sliders. Slider 1 is controlled by force output and slider 2 is controlled by a sine wave oscillating at a set frequency of 0.2Hz. The task is a force tracking task where the user has to modulate force output to keep the object above the water.
The problem I'm having has to do with timing. If I include a wait ms function in my loop to acquire data at 100 Hz, my target slider oscillates at the correct frequency, however, data is not acquired using daqmx read. I understand that a wait ms function should not be used in a while loop with dawmx read. Can anyone help be acquire the target force sine wave (slider 2) and force output (slider 1) at 100 Hz?
Regards,
Daniel
Solved! Go to Solution.
06-13-2018 01:23 AM
Hi Liddy,
If I include a wait ms function in my loop to acquire data at 100 Hz, my target slider oscillates at the correct frequency, however, data is not acquired using daqmx read.
- You should not put a wait function in the DAQmx acquire loop, the DAQmx task will determine the loop timing.
- Why don't you get DAQmx readings when you add a wait function? Do you get an error?
Have you tried any of those DAQmx example VIs coming with LabVIEW? They usually explain such simple tasks (like reading a single sensor at 100Hz) very well…
06-13-2018 12:16 PM
Hi Gerd,
The load cell has a serious delay in response (>3 sec) when I put a waitms function in the while loop. I've been reading documentation on daqmx timing. How should I configure it to set the while loop sample rate at 100Hz?
Regards,
Daniel
06-13-2018 01:53 PM
Hi Liddy,
How should I configure it to set the while loop sample rate at 100Hz?
You already set the DAQmx task for a sample rate of 100Hz (S/s) with the DAQmxTiming function.
All you need to ensure is one iteration of the loop will be finished within 10ms (to not fill the DAQmx internal sample buffer)…
06-13-2018 02:46 PM
Thank you Gerd. How do I ensure that each iteration is completed in 10ms?
06-13-2018 03:06 PM
Hi Liddy,
right now there is not much code in the DAQ loop, but you could simplify it to this:
The only problem is the huge slider with its giant images: this may take a while to update the GUI. Test for your self!
On your VI: I would use a statemachine instead of all those sequence frames inside the overall FOR loop…
06-13-2018 03:27 PM
I tried the for loop with 2000 iterations and the loop completed in 1.2047 seconds. The problem is the loop is running faster than it should. There has to be something wrong with my daqmx timing. Should it be in my for loop?
06-13-2018 04:14 PM
I also tried a simple double slider and have the same problem with the loop running faster than it should and taking over 30,000 data points when it should only be 2000.
06-13-2018 06:53 PM
I should also mention I'm acquiring data using an NI 9237.
06-14-2018 01:08 AM
Hi Liddy,
I should also mention I'm acquiring data using an NI 9237.
Yes, you should have done this right from the beginning!
Did you read the manual for your DAQ device? Did you read the specs in this manual? Especially page 9?
Come on: RTFM! (Read the fine manual! :D)
the loop completed in 1.2047 seconds.
The specs say: min sample rate 1613Hz. Reading 2000 samples at 1613 S/s takes exactly 1.239s…