Invalid PWM Channel Index

We have been trying to get our pwms working for our drive and other motors.

The error I get is Invalid PWM Index…I have a feeling i am setting the PWM channels wrong in the motor initialization.
The most odd of all is the different channels seem to work randomly when I change the PWM channel it should be working on.

The error is attached below.





One more thing. We’re also getting a PWM Channel Already allocated error. I’m including a screenshot.





From the probe, the value in the channel is indeed invalid.

The PWM stuff is used for both servo and motor, and of course drive uses motor. So, one of those opens either has nothing wired to it and it defaults to the invalid channel, or it has a constant wired up with invalid.

Also, make sure you are calling opens and you aren’t just typing stuff into a PWM reference.

Greg McKaskle

Could you explain what you mean by:

So, one of those opens either has nothing wired to it and it defaults to the invalid channel, or it has a constant wired up with invalid.

Also, make sure you are calling opens and you aren’t just typing stuff into a PWM reference.

Is it possible to talk with you or someone from NI over phone or IM

Actually, the open requires the channel to be wired. Check each Motor open and see that you have the channels wired that you meant to.

If you are using the drive VIs, check those opens. If using servos, check those too.

Finally, the next time you run, make sure the dashboard is open. It will show you if you have errors. I suspect that you have an issue where a channel is already in use, produces an error, and then the refnum is invalid.

Greg McKaskle

Preface: I am a Certified LabVIEW Architect.

In our Teleop/Init I’ve placed a routine that allocates 8 channels in a row (inside a For Loop) to allocate 8 Servos. I’m converting the iteration terminal of the loop to a U8 then typecasting it to the PWMChannel.ctl typedef enum prior to the value entering the Servo/Open.vi. We’re receiving the -44037 (PWM Channel is already allocated) error … but only on the 1st two of the eight channels. The last 6 are allocating just fine and in operation work perfectly.

Any ideas what’s going on here?

The servo VIs use the PWM outputs (and are shared between the Jaguar, Victor, Servo, PWM, and Robot Drive libraries). The default code uses PWM 1 and 2 for the Robot Drive Library, could you be trying to reallocate them?

So you’re saying that PWM Channels 1 & 2 cannot be used for servos? (or: only 3-10 can … ?)

You can use PWM channels 1 & 2 for servos, you just have to delete the Robot Drive VIs (or change which PWM channels they use).

If you look at a digital sidecar, it has a row of PWM connectors. Each connector can be used for motors or servos depending on if they are jumpered. The SW API needs to deal with this HW resource limitation.

So, once you’ve designated a PWM channel is used for one thing, it is reserved and cannot be reopened for the other purpose. What Joe is pointing out is that the template code already reserves the first couple channels as being for motors. That means that until they are closed, they cannot be opened for servos and will return an error.

Greg McKaskle

I found the source of the error. It was all the way back in the Begin.vi within Robot Main.vi. I didn’t know (until I just now found it) that the main drive motors are being initialized within Begin.vi. I’m making my modifications now and will test tomorrow afternoon when we continue with our testing.