02-20-2016 05:06 PM
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!
Solved! Go to Solution.
02-20-2016 05:29 PM
02-20-2016 06:27 PM
02-20-2016 07:23 PM
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?
02-20-2016 09:10 PM
02-20-2016 09:40 PM
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!
02-20-2016 09:45 PM
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!
02-20-2016 11:28 PM
02-21-2016 01:46 AM
02-21-2016 12:15 PM
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.