How do I use a Counter input to acquire frequency data that is slower than my sample rate?
조회 수: 2 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
답변 (2개)
Stephan Stranick
2020년 10월 12일
You need to have your input connected to the right terminal. You need to use counter 0's gate input, not the source input.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Acquisition Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!