|
Like the Rolling Stones said: "You can't always get what you
want!" The toolbox is forced to adjust the user's requested
sample rate based on the clock resolutions of the board.
They should either use SETVERIFY or GET the SampleRate after
they set it to determine the actual sample rate that was
selected. The number of channels added may affect the rate
that is selected.
The reason for this comes back to hardware clocks on the
boards. Most cards offer a number of fixed speed base
hardware clocks that are used to drive the timing of
acquisition. For instance, the NI E-series cards have 5 base
clocks, including a 20MHz and a 100KHz clock. In order to
reach a given sample rate, there is a programmable divider
that can be set from 1 to 65536. This gives the 20MHz clock
a range of 20 million samples/sec (20e6/1) down to ~305.18
samples/sec (20e6/65536). But, these possible rates are
quantized: there are only 65534 possible values between
those two extremes. So, if you want 1,570,000 samples per
second on a single channel, you'll have to choose between
1,666,666.67 (20e6/12) and 1,538,461.54 (20e6/13).
This gets more complex what you add multiple channels to the
mix. Now, you need to find the nearest clock rate that is
the requested per channel rate times the number of channels
you want. So, if you want 80000 samples/sec on 7 channels
with a 10MHz base clock, you can only get 84033.61. How'd we
get that? 80000 samples/second/channel * 7 channels = 560000
samples/second. The base clock divided by the requested rate
gives the ideal divider: 10000000/560000 = ~17.8. The
divisor must always be an integer, so we truncate to the
lower value (so the sample rate chosen is always higher than
requested), which is 17. We then calculate the actual sample
rate the card can deliver: 10000000 samples/second divided
by the divider of 17 divided by the number of channels 7:
10000000/17/7 = 84033.61.
|