The PWM class in 4.2 and pin selection with a Cerbuino Bee

Hello,

I’m trying to use the Microsoft.SPOT.Hardware.PWM class in the 4.2 framework, and the constructor takes a CPU.PwmChannel. This enum includes PWM_NONE, and PWM_0 through PWM_7. I’m using a Cerbuino Bee, which has several PWM channels, but they’re not numbered 0-7 in the schematic. The pin I was thinking of using is PB13, which i believe is 0x1D according to another post I saw around here somewhere. Can I just cast 0x1D to a CPU.PwmChannel and pass that to the constructor of the PWM class, or is there some mapping somewhere that will tell me that PB13 maps to PWM_5 or whatever? I would just try it but I’m afraid I’ll break something.

BTW, I’m trying to use this to drive a servo. Is there a better way? All the info I’ve come across uses the old GHIElectronics PWM class which has been replaced in 4.2 with this Microsoft PWM class so it looks like none of the ways I’ve found will work.

Thanks,
Scott

Use casting

(CPU.PwmChannel)123
//123 can be any number, channel number

We will have a DLL with all channels and IOs in next release.

Thanks for the quick reply! I know how to cast it, I’m just not sure which number to use when I cast it to the CPU.PwmChannel. In this case would it be 0x1D, (taken from the code below)?

public const Cpu.Pin D8 = (Cpu.Pin)0x1D; // PB13/SP2_SCK/CAN2_TX/PWM

This is the pin I want to use, there just seem to be so many numbering systems (D8, 0x1D, PB13, SP2, CAN2, etc.) that I’m not sure which value to pass into the ctor of the PWM class.

Hello,

You can’t use Cpu.Pin for casting to CPU.PwmChannel. For Cerberus (i guess it is same also for cerberus derivates) you can get translation table on GHI Electronics – Where Hardware Meets Software in section Motor Driver L298 Module. For pin PB0 you use Cpu.PWMChannel.PWM_4 or (Cpu.PWMChannel)4.

I looked at the chart you referred me to, and apparently it’s not the same for Cerbuino. Most (or maybe all?) of those pins in the PWM table don’t even have PWM support according to the Cerbuino schematic. Is there a page like the Cerberus page you mentioned that has all the details for the Cerbuino instead?

Thanks,
Scott