LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Non-Uniformed Sampling Rate Problem

Hi All,

I have 2 analog inputs being sampled at 500 Hz.  But after looking at the plot of my samples, it doesn't seemed like the intervals are of the same size?  Can any one tell me what might cause that and how I can make them all the same?

Thanks much.


hellolv
0 Kudos
Message 1 of 8
(3,153 Views)
Got something even funnier here.  I ran a 120 sec test but the test actually lasted for 230 seconds. 

So it's probably still a problem built into my code. 


0 Kudos
Message 2 of 8
(3,146 Views)

hellolv,

I have taken a look at your program, and I have made a few modifications.  I have found a couple problems with the code.  First, you are performing your DAQmx read in two positions inside your while loop.  This means that for every loop iteration you read in two samples (not one).  This makes the logic you use to stop the loop incorrect because it assumes that one sample per loop iteration is read.  I have modified the VI so that only 1 DAQmx read is used.  I also changed how many samples you pass to the DAQmx timing.  In this application it only takes 120 seconds to acquire 60 000 samples (at 500 Hz). 

Next, the interval between samples should be constant.  The DAQmx device will acquire data at the specified sampling rate and store the data in the PC buffer.  The graph will display data based upon waveform data type.  This data type only has a t0 (start time), dt (period between each sample), and the data.  I do not know how the graph would display data points that are not spaced equally based upon only having this data.  If you still see this in the code I posted, can you please explain what you are seeing?

Regards,

Jesse O.
Applications Engineering
National Instruments
Jesse O. | National Instruments R&D
0 Kudos
Message 3 of 8
(3,119 Views)
Jesse,

Thanks a whole lot!

The VI looks whole lot better, but for a 20 sec test, it actually only lasted for 11 seconds, and a 40 second run took 35 seconds.  I am trying to figure out what actually happened there.

The non-uniformed interval problem has been beautifully solved.  Where can I check to see what the clock source the VI is using when sampling inputs?



hellolv
0 Kudos
Message 4 of 8
(3,114 Views)
Just tested it again, it's just way way way too fast.

Should it be some sort of clock or timing issue?



0 Kudos
Message 5 of 8
(3,111 Views)
also, is it usually a bad idea to use 2 DAQmx Read's within the same loop?
0 Kudos
Message 6 of 8
(3,110 Views)

hellolv,

I have modified the VI one more time to help demonstrate that it is working correctly.  In the first application I posted, the task has started (and data was being converted) while the save dialog box is visible.  In the new version I posted, I added several more sequence steps and now the task is started only after you specify which file to use. 

I have confirmed that this code does take 30 seconds to run for 30 seconds of data.  I have also added a few other items to your front panel.  The first is the actual rate data is acquired at.  For example if you specify 503 Hz you might get 503.005Hz.  The second is the approximate time the task took to execute. 

I hope after looking through this code you understand what you were seeing before.  I believe you probably started your timing after you pressed the ok/save button in the save dialog box, when in fact the task was already started at this point.

Regards,

Jesse O.
Applications Engineering
National Instruments



Jesse O. | National Instruments R&D
Message 7 of 8
(3,100 Views)
It runs perfectly, you the man!
0 Kudos
Message 8 of 8
(3,090 Views)