Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

daqmx error num: -50103 with message: The specified resource is reserved. The operation could not be completed as specified.

Hi, I am running a program where I have 4 nidaq cards on a single machine, all connected. I am trying to start a counter and keep getting that error (daqmx error num: -50103 with message: The specified resource is reserved. The operation could not be completed as specified.) in two places in my code. I understand what the error means (you can only have one task of a type per card), but I don't see where that is occuring in my code.
See below for code. I noted the two places where the error is occuring. I am debugging someone else's code, which is part of the problem.
Thanks!

 

counterTask = 0;
daq_err_check( DAQmxCreateTask( "counter_generation_task",
&(counter_generation_task) ));
daq_err_check( DAQmxCreateTask("counter_count_task",
&(counter_count_task) ));
char co_chan_name[40];
char ci_chan_name[40];
char ci_trig_chan_name[40];
sprintf( co_chan_name, "%s/ctr0", niDev);
sprintf( ci_chan_name, "%s/ctr1", niDev);
sprintf( ci_trig_chan_name, "/%s/PFI9", niDev); 

printf("OK1");fflush(stdout);
daq_err_check( DAQmxCreateCOPulseChanTicks( counter_generation_task,
co_chan_name, "", "ai/SampleClock",
DAQmx_Val_Low, 32,16,16) );
daq_err_check( DAQmxCfgImplicitTiming( counter_generation_task,
DAQmx_Val_ContSamps, 1000) );

daq_err_check( DAQmxCreateCICountEdgesChan( counter_count_task,
ci_chan_name, "", 
DAQmx_Val_Rising, 0, DAQmx_Val_CountUp) );
daq_err_check( DAQmxCfgSampClkTiming( counter_count_task,
"Ctr0InternalOutput", 1000.0, DAQmx_Val_Rising,
DAQmx_Val_ContSamps, 1000) );

daq_err_check( DAQmxSetRefClkSrc( counter_generation_task, "OnboardClock") );
daq_err_check( DAQmxSetRefClkSrc( counter_count_task, "OnboardClock") );

printf("abt to start counter_count\n"); fflush(stdout);
daq_err_check ( DAQmxStartTask( counter_count_task ) ); // ERROR OCCURS HERE
printf("abt to start counter_gen\n"); fflush(stdout);
daq_err_check ( DAQmxStartTask( counter_generation_task ) ); // ERROR OCCURS HERE

fflush(stdout);


Thanks again for your patience!

0 Kudos
Message 1 of 2
(4,982 Views)

Please review this information 

 

 

Case 1:
Running a DAQmx application after a Traditional DAQ application without first resetting the Traditional DAQ driver.  Follow the steps below to reset the Traditional DAQ driver:

  1. Go to Measurement & Automation Explorer
  2. Expand Devices and Interfaces
  3. Right Click Traditional NI-DAQ (Legacy) Devices
  4. Select Reset driver for Traditional NI-DAQ

This releases the resources previously reserved for Traditional DAQ, and lets you use the DAQmx driver for your data acquisition

Case 2: Continuously starting and clearing a DAQmx task (in a loop) for an extended period of time.  To avoid this problem, configure and start your task once, then call the read/write function in the loop as needed. 

For an example on how to do this, take a look at the simple Cont Acq&Graph - Int Clk.vi example.  To find the example, launch LabVIEW and go to Help»Find Examples.  Browse by task to Hardware Input and Output»DAQmx»Analog Measurements»Voltage.

Case 3: Generating a finite pulse train and another counter task on the same device in LabVIEW with NI-DAQmx.  For any device which uses the STCII chip (CompactDAQ, E and M Series) a finite pulse train generation reserves both counters.

When performing a finite pulse train generation, one counter generates the pulse train, and the other counter generates a pulse that acts as a gate for the first counter. If you change the pulse train to generate continuously or only generate one pulse, you can run two counter tasks at the same time without error.

The following three cases for the error can happen due to improper programming practice.  Generally speaking there are two ways you can resolve this error.  You can either run each task in series, or combine all channels of the same acquisition type into a single task.  In order to run the tasks in series make sure to stop each task before starting the next.  If you decide you want to use a single task there are two options.  If all physical channels are doing the same type of acquisition you can just combine the physical channel lists of the two tasks.  If you have two analog input tasks that are of different types (i.e. AI Voltage and AI Current) you can call multiple DAQmx Create Channel VIs and wire the task out of the first into the task in of the second to configure each physical channel or group of channels individually.

Case 4: Using multiple DAQ Assistant Express VIs to access channels on the same data acquisition board can cause this error because each Express VI creates a separate task.  It is not possible to have multiple DAQmx tasks attempting to access the same physical device. Thus it is necessary to clear each task after the data acquisition has completed. The stop input of the DAQ Assistant Express VI stops the task and releases device resources when the Express VI completes execution. For single point or finite data acquisition the default value for the stop input is true so you do not need to wire a True Boolean constant to this input.  For single point input/output (I/O), wiring False to the stop input optimizes performance, but it does not release the device's resources. Error -50103 will be thrown if you are using multiple DAQ Assistant Express VIs with single point or finite data acquisition in a loop with a False constant wired into the stop input. For continuous acquisition, the default value is False. To avoid this error, be sure to pass a True to the stop input on the last iteration of your loop.
Note that it is critical to properly set the execution order of both Express VIs if they occur within the same loop. This will prevent both DAQmx tasks from running concurrently and generating an error. You can establish order of execution by wiring the Error Out terminal of one DAQ Assistant to the Error Interminal of the second DAQ Assistant. However, when performing multiple instances of the same type of measurement within the same while loop, it is not necessary to use multiple DAQ Assistants. Instead, you can simply use a single DAQ Assistant configured for multiple channels.

Case 5: Using multiple SubVIs that run without any error independently, but generate an error when called from a top-level VI. Error -50103is likely to occur when you have multiple NI-DAQmx VI's that call the same task again without clearing the previously opened task. If at any given time you try to open a task that already is being used, you might receive an error "resource is reserved".
To prevent this error from occurring, clear the task before you open it again in another SubVI, or just pass the DAQmx task from one SubVI to another to avoid having to open the task again.

Case 6: Concurrently running two analog input or two analog output tasks.  This error can also be thrown when a program explicitly calls multiple tasks performing the same type of operation at the same time. As with the other two cases, this produces a situation where multiple independent tasks are concurrently attempting to access the same resource. Even though the tasks might be using different channels, this is still a conflict because they require use of the same analog to digital converter and sample clock. To resolve this issue, combine all operations of the same type into the same task. For DAQmx 7.3 and later, it is possible to do this even with multiple types of analog input if you use multiple DAQmx Create Channel VIs.

Note: Case 6 is common when trying to perform multiple tasks of the same type using a cDAQ chassis.  Keep in mind that the chassis only has one timing engine.  To avoid this problem, consolidate all of your analog acquisition into a single task to make proper use of the single timing engine.

0 Kudos
Message 2 of 2
(4,889 Views)