Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Daq Sample Rate Question

Solved!
Go to solution

Hello,

 

I have been trying to understand how the "number of samples" and "rate" controls affect the sample rate for DAQ equipment. For instance, say I want to acquire data from a pressure transducer at a rate of 10Hz. Intuitively I would think all I would have to do is set the "rate" control to the desired sample rate, in this case 10hz, from trying this I know that this is not true. I have read that the "number of samples" control affects the sample rate by setting a buffer value that must be achieved before the VI will process the acquired data. So I have also tried setting the "number of samples" control to 1 and the "rate" to 10, thinking this would results in a 10hz sample rate and again it does not. The only way I know of to control the sample rate is by using Wait (ms) function, but then i always get buffer overflow errors. 

 

Can somone please explain to me the error in my thought process as well as tell me the best way to control the sample rate? Attached is a simple VI I've been using to measure my actual sample rate and compare it to the sample rate I'm trying to achieve.

 

The VI uses DAQ assistant to acquire pressure data, inserts the data into an array, and measures the array size. I am then dividing the array size by the elapsed time in seconds to get sample/sec (I am also dividing the # of loop iterations by seconds and using it as a comparison). I am comparing this value to my inputs for the "number of samples" and "rate" controls in an attempt to make some sense of the role they play in sample rate. The VI also allows you to choose to utilize the Wait (ms) function as well, using this function is the only way I can control the actual sample rate but then i always get buffer overflow errors. Any information would be helpful, thanks!

0 Kudos
Message 1 of 11
(7,669 Views)
you use convert dynamic signal in wrong way
use it as an array for one channel
when you choose 10 hz you have 10 data in second so if you want to see sample with rate of 2 every time
you have to select sample to read 2 and also try to read from DAq once every 200ms
in this case every loop irritation you have 2 data and every second you have 10 (your rate)
0 Kudos
Message 2 of 11
(7,672 Views)
I can't look at your VI right now but I'm guessing you are selecting only 1 sample. That means that you have reverted to software timed acquisition and the rate is meaningless. Some devices have single sample hardware timing but you have to explicitly select that mode. As long as you specify more than 1 sample, your rate will be exactly what you specify and the number of samples will have no affect at all on the actual rate. Do NOT use a wait in your loop.
0 Kudos
Message 3 of 11
(7,666 Views)

Thanks for the quick responses! I guess i should have mentioned that i have the acquisition mode set to continuous.

 

Dennis,

 

I have varied the value at which i set the sample to, my array size and rate at which i am acquiring data (1600 hz, even though im setting the rate to 10) does not change, but the rate at which the loop executes does. Have I misunderstood your instructions?

 

 

Hatef,

 

I have performed the following steps, it works but i don't understand the last step, below is a more detailed explanation of what im having trouble with.

 

-Changed the "Convert from Dynamic Data" function to "1d array of scalars - single channel".

I originally had this set to "single scalar" and i didn't notice this before but if I run the VI for a specific amount of time (say 3 sec.) the array size would change as i vary the "number of samples" and "rate" controls. If i run the VI for a set amount of time (3 sec.) with the "Convert from Dynamic Data" function set to "1d array of scalars - single channel" the array size is now constant, no matter what i set the "number of samples" and "rate" controls to.

 

-Set the number of samples to 2

 

This makes more sense now.This is controlling the rate at which the loop executes. Since im running this VI for only 3 seconds now, my array size 4800. I see that I am acquiring data at 1600/second (4800 / 3sec.) and the loop execution rate is equal to the rate at which i'm acquiring data / the number of samples, or 1600/2 = 800 loop executions.

 

-Reading daq every 200 ms by using the wait (ms) function

Following these 3 steps has allowed me to achive a rate of 10 hz, but I do not understand how this step pulls everything together, can you please explain this bit futher?

0 Kudos
Message 4 of 11
(7,660 Views)
I don't understand what you have done. If you set the rate to 10 Samples/sec and run it for 3 seconds, you will have 30 samples. You can't be getting 1600. Attach an image of tut block diagram and the DAQ Assistant set-up.
0 Kudos
Message 5 of 11
(7,653 Views)

Dennis I am just as confused as you are.

 

Attached is a pdf with screen shots of the following

 

Block Diagram

Daq Settings

Convert from dynaimc data settings

Screen shots of my results. I am running the VI or 3 seconds, 2 screen shots so my results when samples are set to 1, and the other 2 are the results when my samples are set ot 1. No other changes were made. Thanks again!

0 Kudos
Message 6 of 11
(7,647 Views)

Sorry the last statement didnt make any sense..... Below is what i meant to say.

 

Screen shots of my results. I am running the VI or 3 seconds, 2 screen shots show my results when samples are set to 1, and the other 2 are the results when my samples are set to 2. No other changes were made. Thanks again!

0 Kudos
Message 7 of 11
(7,643 Views)
Solution
Accepted by topic author Mr_Papagorgio
What is the device you are using? My guess is that whatever you have, it does not allow such a slow rate and is defaulting to its minimum.
Message 8 of 11
(7,637 Views)
Mr_Papagorgio what Dennis told is that
if you have daq like NI daq or advantech
there is 3 method to acquisition data
1 sample for any time your system request (your loop speed in your code will be limit amount of data that you can acquire ) so if you want to have data just any time that you order to daq by your code use this
2 N sample by buffer
in this case you select number of data that you want and number of sample to read
so if your code start to run your daq start to acquire that N sample and finished
3 continues acquiring
in this case you select sample to read and rate and your daq will be work continuously
for this case you have to care about the FIFO and overflow data or lack of data
Dennis and me just want to know if you do not use first method to use your daq
and also if your qad could support method 2 and 3?
my English is not so fluent but I hope I could be clear about the subject

0 Kudos
Message 9 of 11
(7,627 Views)

Dennis,

 

I'm using NI-9237 as a DAQmx virtual device, I have been looking around the forums and seen that others have had similiar questions pertaining to this card. It does seem that the min rate is 1600, if i adjust the rate above this value, it matches exactly. Thanks again guys for your help.

0 Kudos
Message 10 of 11
(7,612 Views)