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

Set non-periodical external sampling clock nidaqmx python package

$
0
0

Hello everyone ! I am new with the nidaqmx python package and acquisition measurement devices and have some problems to set a specific external sampling clock for the acquisition of data (NI cDAQ-9185 chassis with NI 9775 device). 

 

Until now, I have used the internal clock of my DAQ in order to configure the acquisition of the data for my three voltage channels and everything works without problem. In order to improve the setup, I tried to add on the 4-th channel a pulsed voltage signal with non-periodical behavior and try to define it as the new sampling clock for the data measurement. The goal is that the DAQ only acquires data on the three other channel when the 4-th channel detects a rising edge and stop after a certain number of data, which is known. The tricky part is that the pulsed signal begins when the script is launched and the number of pulses is known, but not the duration of the signal. For that, I used a simple python script like :

 

import nidaqmx sample_rate = #known_value num_data_points = #known_value with nidaqmx.Task() as task_1: #use voltage channel of acquisiton card task_1.ai_channels.add_ai_voltage_chan("cDAQ9185-1E47CA7Mod1/ai0") task_1.ai_channels.add_ai_voltage_chan("cDAQ9185-1E47CA7Mod1/ai1") task_1.ai_channels.add_ai_voltage_chan("cDAQ9185-1E47CA7Mod1/ai2") task_1.ai_channels.add_ai_voltage_chan("cDAQ9185-1E47CA7Mod1/ai3") task_1.timing.cfg_samp_clk_timing(sample_rate,source="cDAQ9185-1E47CA7Mod1/ai3", active_edge=nidaqmx.constants.Edge.RISING, sample_mode=nidaqmx.constants.AcquisitionType.FINITE, samps_per_chan=num_data_points) task_1.start()

 

Each time I run the script, I end up with an error like :

DaqError: Requested sample clock source is invalid. Property: DAQmx_SampClk_Src Corresponding Value: cDAQ9185-1E47CA7Mod1/ai3 Device: cDAQ9185-1E47CA7 Task Name: _unnamedTask<D> Status Code: -200414

 

I have also try to replace the task_1.timing.cfg_samp_clk_timing(...) function with :

task_1.timing.samp_clk_rate = 1e6 task_1.timing.samp_clk_active_edge = nidaqmx.constants.Edge.RISING task_1.timing.samp_timing_type = nidaqmx.constants.SampleTimingType.SAMPLE_CLOCK # 10388 task_1.timing.samp_clk_src="cDAQ9185-1E47CA7Mod1/ai3"

to define everything manually but end up with the same error.

 

But trying to look a bit in the documentation, I have found that it is normally possible to define a method like this one (using a specific pulsed signal as a sampling clock) but didn't find any answer for my problem. Does anybody have an idea if this method is possible and how to implement it in python ?

 

As I am new in the domain, it is clearly possible (a without contest probable) that I have made an error in the understanding of the package, or just miss something. So don't be afraid if something seem completely strange !

 

Thanks everybody for the future answer !

 

 - Adrien


Viewing all articles
Browse latest Browse all 1271

Trending Articles



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