From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

PCI 6601 counter - resource reserved while debugging in Visual Studio

Hi,

 

I'm trying to debug an application which uses counter1 on the PCI 6601 bord to create a continous pulse train. The application is in VB and with Visual Studio 2012 I always get the Error: -50103 specified recource is reserved. This error occurs right after the application is loaded to VS, so no task is created at that time. Has anybody experienced a similar behaviour?

I would be thankful for any ideas.

 

Thanks in advance

 

 

0 Kudos
Message 1 of 6
(4,877 Views)

Hi BMU_user,

 

there are two possible reasons for the issue I know:

 

If you use more than one counter of the device in your application, this error is seen, as described in the following link:

 

Counters 2 and Above Do Not Function Properly When Performing Digital I/O on a NI 6601 or 6602 - National Instruments
http://digital.ni.com/public.nsf/allkb/43F71527765EEC3886256E93006CD00C

 

Another possible reason can be, that the counter is reserved from the last execution. Then please go into MAX and reset the device to resolve this.

 

Best regards,

Melanie

Best regards,
Melanie Eisfeld
Senior Applications Engineer, National Instruments Germany
Certified LabVIEW Developer
Certified TestStand Architect
0 Kudos
Message 2 of 6
(4,840 Views)

Hi Melanie,

 

thanks for your reply. You are right, I'm using more than 1 counter.

 

I've already checked http://digital.ni.com/public.nsf/allkb/43F71527765EEC3886256E93006CD00C . To my knowledge it can't be that issue. I'm using counter0 to count the pulses of an encoder wheel and counter1 to output an continious pulse train.

 

Even a reset in MAX didn't work.

 

While loading the form on startup, a routine is called to start the pulse train. The device should not be reserved at that time, but that's the point where I got the error. My procedure is like this:

 

Private myTask As Task = Nothing
Public Const IO_COUNTERNAME = "Dev1/ctr1"
...
'start Pulse train Dim frequency As Double = 4 Dim dc As Double = 0.5 'stop possible Task first If IsNothing(myTask) Then Exit Sub StatusCheckTimer.Enabled = False myTask.Stop() myTask.Dispose() myTask = Nothing 'create Task myTask = New Task()
myTask.COChannels.CreatePulseChannelFrequency(IO_COUNTERNAME, "ContinuousPulseTrain", COPulseFrequencyUnits.Hertz, idleState, 0.0, frequency, dc)
myTask.Timing.ConfigureImplicit(SampleQuantityMode.ContinuousSamples, 1000) 'verifiy Task myTask.Control(TaskAction.Verify) 'start Task myTask.Control(TaskAction.Start)

The exception is thrown at the last statement. I really don't know what's wrong.

 

Best regards,

 

Helge

 

0 Kudos
Message 3 of 6
(4,835 Views)

Hi Helge,

 

seems ok to to me at first sight.

 

Could you try the DAQmx example from the following folder on your machine, please?

 

C:\Users\Public\Documents\National Instruments\NI-DAQ\Examples\DotNET4.0\Counter\Generate Pulse\GenDigPulseTrain_Continuous\VB

 

If this example works, could you try to comment out the part "Stop possible task first".

 

Let me know, if this works.

 

Best regards,

Melanie

Best regards,
Melanie Eisfeld
Senior Applications Engineer, National Instruments Germany
Certified LabVIEW Developer
Certified TestStand Architect
0 Kudos
Message 4 of 6
(4,816 Views)

Hi Melanie,

 

thanks for your reply. This example is working, but I found a behavior that is really strange:

 

If I first open my application (without starting) and then open&start the example, I got the error -50103 (resource is reserved) on Dev1/ctr1 - so it is not working. If I do it reverse, my application is not opend, the example works on each of the counters in the example.

 

It seems like just opening my application reserves ctr1 somehow. I really don't know what to try next. Commenting out the "Stop possible task first" doesn't change the behavior.

 

Best regards,

 

Helge

0 Kudos
Message 5 of 6
(4,787 Views)

Hi Helge,

 

thank you for your answer.

 

The counter is reserved when the following line of your code is executed:

 

myTask.COChannels.CreatePulseChannelFrequency(IO_COUNTERNAME, "ContinuousPulseTrain", COPulseFrequencyUnits.Hertz, idleState, 0.0,  frequency, dc)

 Normally you execute a clear task at the end of your code, but when an error occurs before, it is possible that the task and its ressource counter 1 is not freed again.

 

The solution can be to explicitly reserve and unreserve the ressource in the task using the

 

Task.Control(TaskAction.Reserve)

and

Task.Control(TaskAction.Unreserve)

 

functions.

 

Please try to reserve the first counter directly after creating and configuring the task as CO.

 

Please ensure also, that your CO task is the one started fist in your code. Use a trigger, if you need to start the starts in another order, but have the CO tasks start function the first in the code.

 

Best regards,

Melanie

Best regards,
Melanie Eisfeld
Senior Applications Engineer, National Instruments Germany
Certified LabVIEW Developer
Certified TestStand Architect
0 Kudos
Message 6 of 6
(4,772 Views)