LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simple analog data to file timing problem

Hello
 

I am using a NI USB-6211 with a simple sin wave as my analog signal. I am recording data at 100 - 500 Hz (100Hz for the attached file) but when I save the data to a file it becomes obvious that it is not recording the data at a constant time step. Sometimes it records the same time for two analog readings. I don't understand what is causing this. I have attached my VI so if anyone could take a look and help me out I would really appreciate it.

 
Thank you very much
Noel
 
An example of the file output.
Time            Voltage
0 1.225818
0.015625 1.360143
0.015625 1.489208
0.03125 1.612682
0.046875 1.730073
0.046875 1.839737
0.0625 1.942496
0.0625 2.03802
0.078125 2.124502
0.09375 2.203914
0.09375 2.273461
0.109375 2.334458
0.125 2.38592
0.125 2.428668
0.140625 2.461386
 
 
0 Kudos
Message 1 of 10
(3,126 Views)
I haven't used the Write to Measurement file that much to really understand all that is coigin on inside (I prefer to use low level functions) but I don't know where it's getting the time stamp at all. You are not providing it to the write function. Instead of getting an analog dbl, change the DAQmx Read to get a waveform. The waveform data type includes a timestamp. see if that makes a difference.
0 Kudos
Message 2 of 10
(3,104 Views)

Thank you very much. I tried changing it to a waveform and that took care of that problem. Now I am curious that if I want to write the angular position from an encoder to a file how would I provide that with a time stamp? The counter read option does not offer a waveform option.

Noel

0 Kudos
Message 3 of 10
(3,087 Views)
Hi Noel,

it seems you're using Windows and the "wrong" time function.
Some of the time functions are based on Windows internal timer - and they run with limited resolution of ~16ms as shown in your first post!

So you either should use other time functions or stick with (uniformly timed) waveforms.

At the moment I don't have LV at hand, so can't provide examples... You will find discussions on this topic here in the forum!
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 10
(3,082 Views)
No, the DAQmx Read Counter does not have a waveform data type option. I don't think you can do anything else except use the Get Date/Time function and create your own waveform.
 


Message Edited by Dennis Knutson on 03-17-2008 07:37 AM
0 Kudos
Message 5 of 10
(3,079 Views)
Thank you, what is that symbol between the DAQmx read and the Build waveform and where can I find it? Also does this have to take place in a Flat Sequence or can it work in a while loop?
0 Kudos
Message 6 of 10
(3,065 Views)
Hi Noel,

that node is a "build array" from the array palette.

The sequence frame is needed to get the time when starting the DAQmx read operation. Without the frame you would (most probably) get the time when calling the init function... Think dataflow Smiley Wink
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 10
(3,062 Views)
It's the Build Array function and it's on the Array palette. It's there because in thje example I used, the DAQmx Read returns a scalar and the Waveform data type requires an array for the y data. I used the sequence structure just to try to get the timestamp at about the same time the DAQmx Read is executed. It's not going to be extremely precise but if you have a lot of other things going on in the loop, it's going to be a bit more accurate. The entire thing could be placed in a while loop.
0 Kudos
Message 8 of 10
(3,059 Views)

Hello Dennis.

Would you be able to expand the above VI to write to a spreadsheet without using the Write to Measurement File? I've tried using that but it only records the position and not the time for some reason. And thank you for your earlier post.

Noel

0 Kudos
Message 9 of 10
(3,054 Views)
Hi Noel,

Try double clicking the Write to Measurement File express VI and select One column only in the X Value Columns section. The timestamp of your waveform should show up in your text file.

Regards,
Stanley Hu
National Instruments
Applications Engineering
http://www.ni.com/support
0 Kudos
Message 10 of 10
(3,045 Views)