Error When Using Multiple Tasks with the NI-9361

Updated Mar 31, 2025

Reported In

Hardware

  • NI-9361

Software

  • LabVIEW

Issue Details

When I measure the counter input signal from multiple channels, I get Error -50103 randomly and only one channel works. How can I use multiple counters or channels with the NI 9361?
 

Solution

The NI-9361 only supports a single task, so all the counter channels need to be on the same task. This can be done in NI MAX, LabVIEW or any other programming language that supports NI-DAQmx. 

NI MAX: 

You can create the NI-DAQmx Task with multiple channels, as shown below. 

Create New NI-DAQmx Task... >> Acquire Signals>>Counter Input >> [Select your Measurement Type] >> [select your module] >> [select your counter number].

Here is an example with Period and Pulse Width channel types:

Figure 1. Creating a DAQmx task on NI MAX.


LabVIEW

Option 1 (recommended): You can create multiple channels for the NI-9361 directly in LabVIEW by adding channels to the same task. As a reference, you can consult the example Encoder Velocity Measurements and the NI 9361 - NI Community.

  • The example can be modified according to each user's needs and measurement type (frequency measurement, period, encoder, etc). More channels can be added one after the other, as far as the same structure of the example is followed. Notice that the property "ActiveChans" is used on top of each property node to determine which channel you are configuring (as shown in the example). 

Option 2 (less Recommended): Once you have your task in NI MAX, you can call the task directly in LabVIEW as in this example:

Figure 2. Calling the NI MAX task from LabVIEW.

C/C++

Here is a snippet of code for this language so that we can read two encoders simultaneously using the same NI-9361. As you may infer, it follows the same structure as the previous recommendations, including both encoders in the same DAQmx session. 

DAQmxErrChk(DAQmxCreateTask(NULL, &taskHandle));

// Configure first encoder (Counter 0)
DAQmxErrChk(DAQmxCreateCIAngEncoderChan(taskHandle, "cDAQ1Mod1/ctr0", "Encoder1", 
    DAQmx_Val_X4, 1, 0, DAQmx_Val_AHighBHigh, DAQmx_Val_Degrees, 32768, 0, ""));
DAQmxErrChk(DAQmxSetCIEncoderAInputTerm(taskHandle, "cDAQ1Mod1/ctr0", "/cDAQ1Mod1/PFI0"));
DAQmxErrChk(DAQmxSetCIEncoderBInputTerm(taskHandle, "cDAQ1Mod1/ctr0", "/cDAQ1Mod1/PFI1"));
DAQmxErrChk(DAQmxSetCIEncoderZInputTerm(taskHandle, "cDAQ1Mod1/ctr0", "/cDAQ1Mod1/PFI2"));

// Configure second encoder (Counter 1)
DAQmxErrChk(DAQmxCreateCIAngEncoderChan(taskHandle, "cDAQ1Mod1/ctr1", "Encoder2", 
    DAQmx_Val_X4, 1, 0, DAQmx_Val_AHighBHigh, DAQmx_Val_Degrees, 32768, 0, ""));
DAQmxErrChk(DAQmxSetCIEncoderAInputTerm(taskHandle, "cDAQ1Mod1/ctr1", "/cDAQ1Mod1/PFI3"));
DAQmxErrChk(DAQmxSetCIEncoderBInputTerm(taskHandle, "cDAQ1Mod1/ctr1", "/cDAQ1Mod1/PFI4"));
DAQmxErrChk(DAQmxSetCIEncoderZInputTerm(taskHandle, "cDAQ1Mod1/ctr1", "/cDAQ1Mod1/PFI5"));

// Start the task
DAQmxErrChk(DAQmxStartTask(taskHandle));

// Read both encoder values
double motorAngle1 = 0.0, motorAngle2 = 0.0;
int32 read = 0;
double motorAngles[2] = {0}; // Array to store both readings

DAQmxErrChk(DAQmxReadCounterF64(taskHandle, DAQmx_Val_Auto, 10.0, motorAngles, 2, &read, NULL));

// Store the values
motorAngle1 = motorAngles[0];
motorAngle2 = motorAngles[1];

motorAnglesVec1[loop_counter] = motorAngle1;
motorAnglesVec2[loop_counter] = motorAngle2;

 

Additional Information

There are some more reasons to face Error -50103. Please refer Related Links below in case the previous suggestions don't fix it.