Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

daq won't sample at specified rate

Solved!
Go to solution

Hardware: C-DAQ 9178, 9239 AI module, Potentiometer inside a servo, and a shaft encoder

Setup: I'm using the 9239 to measure the angular position of my servo and shaft encoder by continuously reading the voltage sent from the servo's pot and my shaft encoder. I've set the sample rate on the DAQmx - Timing VI to 100 Hz.

Problem: I don't think my DAQ is sampling data at 100 Hz because my VI records more than 10,000 data points for a 10 second test. Furthermore, whenever I record my data to a text file, the time vector of my test data will reset after a certain number of iterations.

 

To debug, I tried the following setup:

 

I set the sample rate to 100 Hz (or is it S/s?), the samples per channel (buffer size for continuous mode) to 2000 samples, number of samples per channel to 10, and my VI's loop milisecond timer to 10 ms. Accordingly, the DAQ would send 100 samples every second (or 1 sample every 10 ms) to my PC buffer (which could store 20X that amount). Then LabVIEW would read up to 10 samples per loop iteration (which is itself ~ 100 Hz) and work with those 10 samples inside the loop. However, since the loop is itself operating close to the DAQ's sampling frequency, then LV should only be working with 1 sample every loop iteration (100 Hz  / 100 Hz)--not the 10-sample-max that I specified.

 

However, I ran into "Error -200279: The application is not able to keep up with the hardware acquisition" when I ran the program. Why? 

My code and hardware should easily be able to keep up with the DAQ--at least with the way I have it set up

 

This whole situation questions my fundamental understanding of data acquisition timing, so I'd really appreciate an explanation of exactly how DAQmx uses user-specified timing data, why my DAQ won't sample at 100 Hz, and how I can fix the timing issue.

 

Thanks!

 

 

 

 

0 Kudos
Message 1 of 7
(6,144 Views)

You should not have the 10ms wait in your loop.  The DAQmx Read will cause your loop rate.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 7
(6,138 Views)

Don't I need some delay to prevent my program from hogging the CPU?

 

And how does that delay change the 100 vs 1000 sample rate?

0 Kudos
Message 3 of 7
(6,130 Views)

@aeroAggie wrote:

Don't I need some delay to prevent my program from hogging the CPU?

 

And how does that delay change the 100 vs 1000 sample rate?


I'm not sure how your sample rate is getting changed.  But at the 100S/s, to read 10 samples, it will take 100ms.  The DAQmx Read waiting for the 10 samples will not hog the CPU.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 7
(6,128 Views)

crossrulz,

 

Sorry for the radio silence. I implemented what you said on a different DAQ setup (USB-6361 with SC-2345 conditioning block), and I got 1 KHz as specified. However, I do not get the specified sample rate on the C-DAQ 9178. When I specify a sample rate of 1 kHz, I get about 1,612 Hz using the attached VI. I've also attached a spreadsheet with about 10 seconds of arbitrary signal.

 

Does the C-DAQ 9178 have some minimum sampling rate that I'm not meeting?

 

rate_troubleshoot.png

 

 

0 Kudos
Message 5 of 7
(5,864 Views)
Solution
Accepted by topic author aeroAggie

@aeroAggie wrote:

Does the C-DAQ 9178 have some minimum sampling rate that I'm not meeting?


It is actually the 9239 that is limiting your sample rate.  Reading the datasheet, on page 5 it talks about the available data rates.  In short, your allowed data rates are 50kS/s / n, where is is 1 through 31.  50k/31 gives you 1.6kS/s.  So that is the minimum sample rate that can be used.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 7
(5,859 Views)

 

crossrulz,

 

Interesting. I didn't think sensors could have minimum sampling rates. 1 kHz seems like such a "standard" rate that I didn't even bother looking into the spec sheet for the 9239s that I'm using. Thanks for your help!

0 Kudos
Message 7 of 7
(5,845 Views)