Unable to set precise sample rates when acquiring data using NI cDAQ-9171 USB chassis

1 view (last 30 days)
I'm writing a program for acquiring analogue data using a NI cDAQ-9171 USB chassis. I'd like to have the flexibility to acquire data at a range of sample rates, however I'm unable to set the sample rates precisely at certain sample frequencies.
Here is the code I'm using to configure the data acquisition object:
d = daqlist;
d = d(1,:);
s = daq('ni');
ch = addinput(s, d{1,2}, 0:31, 'Voltage');
s.Rate = sampleRate;
For some sample rates (100, 200, 400, 800, 1000Hz), I am able to set the sample rate precisely. E.g. if I set sampleRate=500; and then I view the s object in the command window, I can see that the s.Rate property is exactly equal to sampleRate (i.e. 500)
However, for other sample rates (300, 600, 900, 1100, 1200Hz etc.), the s.Rate property can't be set precisely to these frequencies. E.g. if I set sampleRate=600; and I view the s object, I see that s.Rate=600.0015Hz
If anyone could explain what's happening here to me, or knows a way around this problem, it would be much appreciated!
(The code uses the Data Acquisition toolbox and is based on this example Capture Data with Software-Analog Triggering - MATLAB & Simulink - MathWorks United Kingdom)
  4 Comments

Sign in to comment.

Answers (0)

Categories

Find more on Simultaneous and Synchronized Operations in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!