Closed ardeal closed 6 years ago
if I change sample rate to 2000Hz, t2-t1 is still 770ms.... it seems that setting sample rate doesn't take effect.
DAQmx hardware cannot support an infinite range of rates and the supported rates vary based on your hardware's capabilities. DAQmx ends up coercing the supplied rate to a supported value.
You can see this by calling:
print(task.timing.samp_clk_rate)
Tip
AnalogSingleChannelReader
to read numpy data natively rather than task.read(...)
which returns python lists.Thanks!
I don't know how to initialize the class:
nidaqmx.stream_readers
Do you have exampele code?
Thanks!
I eventually got to know how to read data by stream_reader. It looks like there is no difference between stream_reader and task. The only difference might be the type of output data.
with nidaqmx.Task() as read_task:
read_task.ai_channels.add_ai_voltage_chan("Dev1/ai0", terminal_config=TerminalConfiguration.RSE, min_val=-5.0, max_val=5.0, units=VoltageUnits.VOLTS)
read_task.timing.cfg_samp_clk_timing(fs, active_edge=Edge.RISING, sample_mode=AcquisitionType.CONTINUOUS, samps_per_chan=nfft)
reader = AnalogSingleChannelReader(read_task.in_stream)
values_read = numpy.zeros(nfft, dtype=numpy.float64)
reader.read_many_sample(values_read, number_of_samples_per_channel=nfft, timeout=2)
I use the following code to configure usb6009, and the printed time(ms) is:
My intention is set the sample rate as 1000Hz. so to read 1024 sample points should need around 1024ms. the printed t2-t1 is around 770ms.
if I change sample rate to 2000Hz, t2-t1 is still 770ms.... it seems that setting sample rate doesn't take effect.
code to configure and acqure data: