DAQ National Instruments counting

3 次查看(过去 30 天)
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