DAQ National Instruments counting

조회 수: 3 (최근 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.

제품


릴리스

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by