Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

NI 9401 Counter Inputs in Matlab

Hello,

       I'm having trouble getting a DAQ system setup. The system is a cDAQ-9174 with two modules; an NI 9401 and an NI 9220. My coding is being done in MatLab. The 9220 is connected to two force transducers and I'm trying to connect the 9401 to two optical encoders. The problem I'm having is that I get an error whenever I try to add the second encoder channel. The code I'm using to add the channels is:

ch1 = addCounterInputChannel(daq_ses,'cDAQ1Mod1','ctr0','Position'); % optical encoder_1
ch2 = addCounterInputChannel(daq_ses,'cDAQ1Mod1','ctr1','Position'); % optical encoder_2

The error I'm getting is:

Error using LeeDAQConfig_2 (line 9)
NI Error -201133:
Device cannot be configured for input or output because lines and/or terminals on this
device are in use by another task or route. This operation requires temporarily
reserving all lines and terminals for communication, which interferes with the other
task or route.

If possible, use DAQmx Control Task to reserve all tasks that use this device before
committing any tasks that use this device. Otherwise, uncommit or unreserve the other
task or disconnect the other route before attempting to configure the device for input
or output.
Device: cDAQ1Mod1
Digital Port: 0
Lines: 0, 2

Task Name: _unnamedTask<461>

Status Code: -201133

I've used this exact system with Labview in the past with no problems so I'm at a loss. Any insight anyone can provide would be greatly appreciated.

-Dleespot

 

0 Kudos
Message 1 of 2
(2,075 Views)

Hi @dleespot,

 

Are both of the channels on the 9401 being set up as both input (or both output)? Error -201133 with NI 9401 in NI-DAQmx When Running Multiple Digital I/O or Counter Tasks explains why those must be set the same direction. It also explains reservation orders for lines.

 

When you used this exact setup with LabVIEW in the past, did you have a specific order that you explicitly reserved lines on? If so, that could indicate you need to reserve the lines in the same order you were before.

 

Another user on thread  Counter / Timer Error201133 had a similar question - it appears that the answer to their question was they couldn't find a way in MatLab to explicitly reserve the line for their task, so they implemented outside code for that functionality.

Christine B
Technical Support Engineer
National Instruments
0 Kudos
Message 2 of 2
(1,988 Views)