05-20-2019 03:39 PM
Hi there,
I'm conducting an experiment which uses a capactitive displacement sensor (Displacment Graph Voltage Data in VI) which is moved with a motor (Motor Voltage graph in VI). I have set up a loop such that the voltage of the motor increases from 0-10V and decreases back down to 0V, in order to conduct an indentation experiment. The displacement sensor changes voltage according to the indentation that is occuring. I would like to ouput the motor voltage and displacmenet sensor reading continously (currently at 500Hz) into an excel file.However, I have found that a delay occurs! The loop that supplies the motor voltage value is updated at a rate faster than the ouput data, causing the excel sheet to show something along the lines of (1V input motor voltage; recorded motor voltage 0.3V, and displacmenet sensor is XX V), I'm would just like there to be no delay between the output motor voltage and the read motor/sensor voltage. I have attached the excel file which shows that Column F does not at all match up with Column B when they SHOULD be the same.
Many Thanks and I hope the above makes sense 🙂
Solved! Go to Solution.
05-21-2019 04:41 AM
Hello imperialmanoj,
I looked into your files, however I could not fully understand what to look at. In the Excel file you attached I found that the time stamps or all 20k samples in columns A and C perfectly match up (from the first row to the last), however column F has just one sample. When you write "they should be the same" - do you refer to the time stamps (column A, C, E) or to your measured voltage (column B, D, F)?
05-21-2019 05:20 AM
Hi ikaiser,
Thanks for taking a look! Just to clarify I'm expecting column B and column F to be the same or at the very least approximately the same. Column F is the input motor voltage and column B is the read motor voltage. Hence, when I input a motor voltage of 0.1V I'd expect the read motor voltage to also be 0.1V, however the rate the motor voltage increases is far slower than the rate I'm sending the input voltage (eg I'm telling it to increase be 0.1V till it reaches 10 and then back down to 0) this means that over time the discrepancy between the read motor voltage and the input motor voltage grows bigger and bigger. I'd like them to be roughly the same, the easiest way for me to convey what's happening is if you scroll all the way to the bottom of the data set you can see that the input motor voltage is 0V (at which point the while loop meets its condition to terminate) however the READ motor voltage (Column B) is close to 3V, this discrepancy is the thing I'm trying to address. I believe it might be due to delays being missing or somehting along those lines?
Many Thanks!
05-21-2019
06:32 AM
- last edited on
11-30-2024
06:15 PM
by
Content Cleaner
I just found that there is more than one value in columns E and F. Had missed those before. What modules are you using in your cDAQ? How have you connected your Voltage out to the Voltage in? Just a wire between ao0 and ai0? Or also GND?
You LabVIEW code could produce the behavior you see. I never use ExpressVIs, so I am not fully aware of potential side-effect. However, I'd assume that your DAQ Assistant (for acquiring) sets up a hardware task to acquire at exactly 500Hz, whereas DAQ Assistant2 starts and stops a new software-timed task each iteration - that could be indeed behind the data your LabVIEW code on your PC generates and logs.
Consider moving to the real DAQmx API: Learn 10 Functions in NI-DAQmx and Handle 80 Percent of Your Data Acquisition Applications. You have much more control about what is happening with these. There are many examples shipped with LabVIEW that you can use as a start as well. (menu Help » Find Examples » Hardware Input and Output » DAQmx.
Edit:
I just noticed your output task is configured as Differential, your input task as RSE. When I set both to RSE, and execute using my NI-9263 and NI-9201, it works as expected. Displacement is <0.01 all the time.
(I replaced the Write to File with the Graph bottom right.)
05-21-2019 06:50 AM
I'm using the NI 9125 for the displacement sensor readings and the motor output readings, the motor input is on the NI 9263, however they all share the same ground. I'm not too familiar with the DAQmx API however when I change the "Sample to Read" value within the DAQ Assistant (Increase it) it seems to decrease the discrepancy. If I were to change it to the DAQmx API would you mind showing me what this looks like?
In addition, I can't change the configuration from Differential to RSE or vice verse on either assistant (the option itself is blurred out).
Many Thanks
05-21-2019 07:33 AM
I think I figured out the cause. I used a cDAQ-9178 with NI-9215 as output (9125 was a typo, right?) and a NI-9263. The actual hardware should however not make a difference. When I just run the I/O, it works as expected. When I write to a LVM file instead of Excel, it works as expected as well.
When I write to an XLSX file, I notice the Front Panel update slower and slower (starting at once every 200ms which is what you configured, but then going down to maybe once every 500ms). It seems that the Write to Measurement file cannot keep up when appending to big excel files.
As your voltage output is coupled to the file write performance in your code, this leads to the delay you noticed. I'd decouple these two. I'll make a demo for you, give me some minutes.
05-21-2019 07:57 AM
Wow, I was not aware how slow ActiveX(?) access to Excel is - this is what the ExpressVI has to rely on when writing to Excel.
Attached I have one potential solution for you. I use a Queue to pass all data from the acquisition loop (where you need good timing) to a logging loop (which can hang behind). So the measurement data is buffered inside the queue until it has all been written.
When testing on my PC, it has piled up 34 sample waveforms when reaching 0V again, and then needs some additional seconds to write them.
Is this a suitable solution for you?
Please note that your output will always lag behind your input as the input is a hardware timed task running on your cDAQ, but the output task is controlled by your PC.
05-22-2019 05:17 AM
Thank you, I'll give this a go and let you know how I get on! As long as the delay isn't majorly significant then it should be fine for my purposes 🙂
05-22-2019 05:41 AM
That works great! Thank you!
05-22-2019 06:14 AM
Hey ikaiser,
Really appreciate your help! I was wondering if you could help me out on one further thing, since your code has essentially removed the delay in read/write I was hoping to use a simple triangle generated waveform to be input into the motor instead of the convoluted increment system I have. However, upon execution it says there is a difference in the channels of the in the task (which is 1) and in the data (which it says to be 128), any idea how to resolve this issue ? Many Thanks!