12-09-2011 11:02 AM
A bit of a puzzlement here, even after reading all of the posts on the infamous -50103 error.
I'm debugging a data acquisition task, in LabWindows/CVI, for a PC with an E-series PCI board (PCI-6032E, I think). There are two analog channels: one is a photosensor ("Receiver") that is read in bursts, the other ("Power") is a power meter that is read occasionally. I set up two tasks in MAX, with the appropriate timing and trigger settings; load them in my program using DAQmxLoadTask() and such, and off we go. Where I run into problems is when I need to restart the "Receiver" task and re-allocate the buffer according to some run-time settings. When I do this, the DAQmxStartTask() call fails.
If, as I understand, the problem is that you can't have two concurrently running tasks on the same board, then why don't I get the -50103 error when I first start up the two tasks?
The basic sequence looks like this:
Init() //called once at start of program to init both tasks
DAQmxLoadTask(&Receiver_handle)
DAQmxSetTrigAttribute(&Receiver_handle)
AllocateBuffers()
DAQmxLoadTask(&Power_handle)
DAQmxSetTrigAttribute(&Power _handle)
AllocateBuffers()
InitTask(&handle) //called to stop and restart the Receiver task with new buffer settings
CloseTask(&handle)
StopDAQ(&handle)
DAQmxStopTask(&handle)
DeallocateBuffers()
DAQmxClearTask(&handle)
DAQmxLoadTask(&handle)
DAQmxCFGInputBuffer(&handle)
DAQmxRegisterEveryNSamplesEvent(&handle) //register data handler (receiver task only)
AllocateBuffers(&handle)
StartDAQ(&handle) //called once for each task, called again after call to InitTask()
DAQmxStartTask(&handle) [fails]
The program successfully calls StartDAQ twice initially, and starts each of the two tasks without error. I only get the -50103 at the DAQmxStartTask () call the second time I call StartDAQ() for the receiver task, after stopping, reallocating buffers, and re-loading the task (which happens without error). Any help greatly appreciated.
Solved! Go to Solution.
12-22-2011 10:24 AM
Hi pblase,
In the tutorial Causes of NI-DAQmx Error -50103 "The Specified Resource is Reserved" I think your situation falls under Case 7: Failing to properly clear a task and release its resources. I think if you use the DAQmxClearTask command or similar to release the resources, you will not get that error. You see other example codes that you can reference here.
12-22-2011 02:10 PM
Yes. It is not immediatly clear that you can't run two tasks at the same time on the same board; I rewrote the code so that I'm running one task with two channels.
12-27-2011 11:33 AM
Hello,
I hope you had a wonderful holiday season, looking at your code I am thinking that we need to make sure you have only one task running, below I think would be the best way to initialize the task at hand and see if it works.
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai1","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",10000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000));
If that does not solve your problems I would check the example finder and see if any of that code is able to help you out.
Lastly I would have both channels sample data at the same rate and then if you have too many samples on one line you can throw away most of those samples.
I hope that helps,
Daniel