필터 지우기
필터 지우기

NI Instruments USB 6221 - Edge Counter

조회 수: 3 (최근 30일)
Christos
Christos 2012년 6월 14일
Hi!
i can get the edge counter value when start the motor manually. but when i tried to start the motor using a MATLAB programme, the edge counter value is always zero.
i try to use startForeground function and get the following error
The startForeground/startBackground methods are clocked operations. To use the session object in clocked mode with the counter input edge count channel 'ctr0', an external clock must be supplied. If the USB-6221 has an analog subsystem, add any analog input/output channel belonging this device (Dev1) to allow the session object to automatically configure itself to internally share this device's source clock.
i write the following matlab function: function counterValue = getCounterValue(ny)
daq.getVendors();%get vendor device details s = daq.createSession('ni');%create session using daq commant
s.addCounterInputChannel('Dev1', 'ctr0', 'EdgeCount'); %create channel fro inpurting the counter value s.resetCounters;%clear the counter channel s.Channels(1);%get information about the open channel data = s.startForeground; data counter = 1; while(counter < ny) counter = counter + 1; end counterValue = s.inputSingleScan; %store the counter value in return variable s.resetCounters; delete(s);%delete session
i hope there is someone that can help me about this.
Thanks a lot
Christos

답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Acquisition Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by