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!