Clear Filters
Clear Filters

How do I use a Counter input to acquire frequency data that is slower than my sample rate?

6 views (last 30 days)
I am trying to write an application with the Data Acquisition Toolbox that acquires a shaft speed via a counter input. The shaft speed sensor input to the counter channel will vary from 0 (stopped) to 1600 Hz. I will also be acquiring several standard analog inputs simultaneously.
I want to be able to acquire the data at a fixed sample rate of 2000 Hz. Any time my counter input signal frequency is less than my sample rate, I get a hardware error:
"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."
This is of course kicked because there are less than 2 and sometimes no edges counted in the interval of each sample.
It appears that I need to be able to dynamically vary my sample rate as a function of the counter input frequency such that my sample rate is always slightly less than the counter input. This doesn't work for my application since I need to acquire the other analog signals at a higher sample rate.
I could set up a secondary session that only acquires the counter input data at a slower frequency, but then I wouldn't accurately measure transients in the counter frequency that occur quickly.
I also tried using another counter output to generate the sample clock based on the current value of the shaft speed counter input, but I found that counter inputs cannot use an external sample clock.
DAQ hardware is a NI PCIe-6321.
Simple representation (in practice I'm doing this in a GUI via background acquisition)
s = daq.createSession('ni');
s.addAnalogInputChannel('Dev1','ai0','Voltage');
s.addCounterInputChannel('Dev1','ctr0','Frequency');
s.Rate = 2000;
s.DurationInSeconds = 10;
[data,time]=s.startForeground();
Any creative solutions would be appreciated.

Answers (2)

Hans Vertongen
Hans Vertongen on 18 Apr 2016
I got the same problem. Did you find an answer yet?

Stephan Stranick
Stephan Stranick on 12 Oct 2020
You need to have your input connected to the right terminal. You need to use counter 0's gate input, not the source input.

Categories

Find more on Simultaneous and Synchronized Operations in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!