Allocation of PWM and GPIO Channels

We have a lot of motors and limit switches on this year’s robot. Is there any reason we cannot use (for example) PWM channels 1-8 and GPIO channels 1-8 from the same digital sidecar?

And if so, how do you address those channels in code?

We’re programming in C++. I’m not a programmer, but I understand that you have to specify a slot and a channel number for each signal. I’m just not sure how you differentiate between a PWM channel and a GPIO channel. Any help would be appreciated.

You can use all of the inputs without having to worry about conflicts. When you specify the slot and channel number (or if you are using the default slots just the channel number) the object you specify it for will tell whether it is a GPIO or a PWM.

Thanks for the reply. Glad there are no conflicts.

the object you specify it for will tell whether it is a GPIO or a PWM.

I’m still not sure how you differentiate between a GPIO and a PWM. Is there a separate “GPIO #” and “PWM #”?

The digital side card has 10 PWM ports for driving victors / jaguars. If you need more PWM ports you can add a second digital side card. If you have some low current motors (CIM or Fisher Price must be connected to a speed control) that run in an on/off fashion you can drive them with a spike according to <R54>.

edit: Also all the Spikes and Speed Controls must be connected to the designated port, you cannot drive them with GPIO.

If you open a Jaguar or Victor or Servo object, it will know that you intend to connect it to a PWM output. If you open a Encoder or switch or etc object, it will know that you intend to connect it to GPIO. If you open a relay object, it will know that you intend to connect it to a relay output.

You differentiate between them by choosing Digital I/O classes vs. PWM (Victor, Jaguar, Servo) classes. There are also separate Relay numbers, Analog numbers, and Solenoid numbers.

Thanks for the help all. We are trying to cut weight where possible, so we’re trying to stick to just one digital sidecar. Looks like we’ll be able make it work.

Well, you are programming in C, so this might be of little help, but this is what I have noticed in LabVIEW:

You can open up the Set and Get VIs (VIs, or SubVIs, are like functions in C) for the PWM input/output plugs and see what they actually do to make controlling the PWM signals. They actually use the Counter VIs to make/read the signal that is going through the pins to sense the ups and downs, ultimately a PWM signal. Then they handle sending/recieving signals through the port similar to a regular digital input-output port.

I would suggest looking into this on the C side and see if you can look into the functions that allow you to control PWM signals. I’ll bet they too use counting processes to read/write a PWM signal from scratch. Then you can make your own code that does the same or copy and paste some of those formulas’ code, but instead modify it so that it is controlling a digital input/output port/slot/pins.

I hope this makes sense. Cheers!