Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

cDAQ 9174 Counter Frequency Measurement

Hello,

 

I'm currently struggling to set up my cDAQ 9174 with a NI 9402 digital module for a sample clock buffered frequency measurement. I can get this to work fine with my NI 9215 installed and referencing the ai sample clock as shown below, this gives me no errors and properly displays the frequency I am trying to measure (frequency varying 16 - 83 Hz) at a sample rate of 32 Hz: 

 

self.ai_task = nidaqmx.Task()
self.ci_task = nidaqmx.Task()

self.ai_task.timing.cfg_samp_clk_timing(
rate=32,
sample_mode=nidaqmx.constants.AcquisitionType.CONTINUOUS
)

ai_channel = self.ai_task.ai_channels.add_ai_voltage_chan(f"cDAQ1Mod1/ai0")

ci_channel = self.ci_task.ci_channels.add_ci_freq_chan(
counter='cDAQ1/ctr0',
min_val=1,
max_val=1000,
units=FrequencyUnits.HZ,
edge=Edge.RISING,
meas_method=CounterFrequencyMethod.LOW_FREQUENCY_1_COUNTER,
)
ci_channel.ci_freq_term = "/cDAQ1Mod2/PFI0"
ci_channel.ci_freq_enable_averaging = True

self.ci_task.timing.cfg_samp_clk_timing(
rate=32,
source='/cDAQ1/ai/SampleClock',
sample_mode=nidaqmx.constants.AcquisitionType.CONTINUOUS
)

 

However when I try to set up the NI 9402 to measure a sample clock buffered frequency measurement by itself, I have problems. I think I am missing something obvious here but I'm not seeing it:

 

self.clock_task = nidaqmx.Task()
self.ci_task = nidaqmx.Task()

self.clock_task.co_channels.add_co_pulse_chan_freq(
counter="/cDAQ1/ctr1",
freq=32,
)

self.clock_task.timing.cfg_implicit_timing(
sample_mode=AcquisitionType.CONTINUOUS
)

ci_channel = self.ci_task.ci_channels.add_ci_freq_chan(
counter='cDAQ1/ctr0',
min_val=1,
max_val=1000,
units=FrequencyUnits.HZ,
edge=Edge.RISING,
meas_method=CounterFrequencyMethod.LOW_FREQUENCY_1_COUNTER,
)
ci_channel.ci_freq_term = "/cDAQ1Mod2/PFI0"
ci_channel.ci_freq_enable_averaging = True

self.ci_task.timing.cfg_samp_clk_timing(
rate=32,
source='/cDAQ1/Ctr1InternalOutput',
sample_mode=nidaqmx.constants.AcquisitionType.CONTINUOUS
)

 

Here is the error I get, and no data is returned even when a TTL signal is supplied:

 

nidaqmx.errors.DaqError: Multiple Sample Clock pulses were detected within one period of the input signal. Use a Sample Clock rate that is slower than the input signal. If you are using an external Sample Clock, ensure that clock signal is within the jitter and voltage level specifications and without glitches.

Task Name: _unnamedTask<0>

Status Code: -201314

 

I can lower my sample rate and get data to appear, but the question is why does issue only occur with the 9402 module only? When I use the ai sample clock this issue doesn't occur. Is there a way I can mimic the behavior of the ai sample clock with another counter?

0 Kudos
Message 1 of 3
(236 Views)

Ok after investigating further, I think the issue was with the order the tasks were started, now I'm consistently having issues with both methods stemming from my sample rate being higher than my measured frequency.

 

The strange thing is my USB-6212 seems to not have this issue at all, I can measure a large range of frequencies and it will still acquire data without error. What is the main difference between the USB-6212 and the cDAQ 9174 that allows for this?

 

Unfortunately all of my measuring applications for frequency require measuring a once per rev pulse of a shaft that is starting and stopping so I need a way to measure frequency without throwing an error. I also need to synchronize this with an analog input with a sample rate that could range from 32-5000 hz depending on the application.

 

Is there a best practice for solving this problem? I feel like a starting and stopping shaft frequency measurement should be a very common application.

0 Kudos
Message 2 of 3
(194 Views)

Error -201314 Counter Sample Clock Buffered Pulse Measurements

 

If synchronization with AI task is required, use the sample clock from AI.

Otherwise, use Implicit Timing instead. This allows the input signal itself determine when samples are taken and avoids sample clock conflicts when the shaft stops.

-------------------------------------------------------
Applications Engineer | TME Systems
https://tmesystems.net/
-------------------------------------------------------
https://github.com/ZhiYang-Ong
Message 3 of 3
(161 Views)