DAQ National Instruments counting

6 ビュー (過去 30 日間)
Matthijs Rietveld
Matthijs Rietveld 2018 年 5 月 15 日
回答済み: Sid Jhaveri 2018 年 5 月 18 日
Dear reader, I am working with a DC motor with encoder. Previously, I have been using an Arduino to control the speed of the motor. However, this hardware isn't reliable enough. Therefore, I am using a National Instruments USB6001 by now.
Right now, I am struggling with reading the encoder. It is possible to use an analog input for that. But, it seems that there is also a counter input available. Can you tell me how to use that? With the following code I get the error "The session contains channels that do not support clocked operations using startForeground and startBackground. Only on-demand operations using inputSingleScan and outputSingleScan can be done."
s_continuous = daq.createSession('ni'); ch_counter = addCounterInputChannel(s_continuous,'Dev1', 'ctr0', 'EdgeCount'); ch_counter.ActiveEdge = 'Falling'; s_continuous.DurationInSeconds = 10; startForeground(s_continuous)
Kind regards, Matthijs

回答 (1 件)

Sid Jhaveri
Sid Jhaveri 2018 年 5 月 18 日
Hi Matthijs,
The error suggests that the counterInput channel you are trying to use does not support clocked operations. Thus, you can't use "startForeground" and "starBackground" operations. Instead of this, you will have to use the on-demand operations like "inputSingleScan" and "outputSingleScan".
If this is not ideal, depending upon the use-case and Hardware's capability, you can you AnalogInput channels to capture the data. That being said, you have to do some data processing if this approach is used. Again, using this approach depends upon the end goal and hardware's capability.

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by