Quantcast
Channel: Counter/Timer topics
Viewing all articles
Browse latest Browse all 1271

Synchronous sampling of analog voltage and digital encoder

$
0
0

My setup involves the cDAQ-9185 Chassis and NI-9401 and NI-9220 modules.
My intent is to have high frequency (2 kHz) sampling of analog voltage channels on NI-9220, and to have position encoder sampled using counter on NI-9401. 
I want to have synchronous sampling of analog voltages and the position encoder.

On the SW side, I am using the Python NIDAQmx package.

 

  • Is it possible to achieve true synchronous sampling of analog voltage and position encoder (counter) ? From what I have read, we have to use Implicit clock source for the counter whereas the analog values will be sampled using internal AI timing engine.
  • In the meanwhile, I tried standalone high frequency buffered sampling of position encoder. I understand that since counters don't have an internal clock by themselves, we have to use one of the other onboard clocks. So I chose to setup an "unused" digital input (DI) port and then use it's clock as a source for the counter. See code below.
    unused_digital_task.di_channels.add_di_chan("cDAQMod1/line7", line_grouping=nidaqmx.constants.LineGrouping.CHAN_PER_LINE) unused_digital_task.timing.cfg_samp_clk_timing(rate=self.config.load_cell_sample_rate, sample_mode=AcquisitionType.CONTINUOUS,) angular_position_task.timing.cfg_samp_clk_timing( rate=self.config.angular_position_sample_rate, source="/cDAQMod1/di/SampleClock", active_edge=nidaqmx.constants.Edge.RISING, sample_mode=AcquisitionType.CONTINUOUS, samps_per_chan = 2 * self.config.angular_position_batch_size(), # 2x oversized, as it determines the size of internal buffer on the DAQ card )​


    I then RESERVE the "unused_digital_task" and "angular_position_task". When I run it, I get the error 

    nidaqmx.errors.DaqError: Source terminal to be routed could not be found on the device. Make sure the terminal name is valid for the specified device. Refer to Measurement & Automation Explorer for valid terminal names. Property: DAQmx_SampClk_Src Property: DAQmx_SampClk_ActiveEdge Source Device: cDAQMod1 ol Source Terminal: di/SampleClock​

    I don't understand what's wrong in my specification of the Source Terminal.


Viewing all articles
Browse latest Browse all 1271

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>