Cobra 3 pwm

Hello,
I need 2 pwm’s but see that 6 are not usable as they are used by the display.
So, that leaves pwm 7 and pwm 8.
pwm1 = new PWM(Microsoft.SPOT.Hardware.Cpu.PWMChannel.PWM_7, 10000, 0.1, false);
The above call to new PWM(…) requires a Microsoft.SPOT.Hardware.Cpu.PWMChannel type). I’m using VB.net.

I am able to use pwm 7 but microsoft.spot.hardware doesn’t support pwm 8:
public enum PWMChannel
{
PWM_NONE = -1,
PWM_0 = 0,
PWM_1 = 1,
PWM_2 = 2,
PWM_3 = 3,
PWM_4 = 4,
PWM_5 = 5,
PWM_6 = 6,
PWM_7 = 7,
}
What is the right way to use PWM_8? Should/Can I add PWM_8 to a MIcrosoft.SPOT.Hardware class? I’m thinking doesn’t make sense.

thanks!

You can just cast the literal 8 to PWMChannel.

var pwm = new PWM((PWMChannel)8, 10_000, 0.1, false);

Instead of that though, take a look at the GHI.Pins assembly. GHI.Pins.FEZCobraIII.PwmOutput has a list of all PWM channels available on the board.

1 Like

Thanks for the info. I didn’t realize I could cast 8 to PWMChannel, I’ll give that a try.

Also, I’ll take a look at the assembly today & try to see the list but I had already
looked at the specification & schematic and could see that Cobra supports
7 pwms, however, I’m using a display and 5 of those pwm outputs get used by the
display (connected on ribbon cable) so I think only pwm7 & pwm8 are available.

But maybe if I understand you, you are saying those 5 outputs by display may not be the 5 used by Cobra, so maybe there are other pwm’s available to me - that’s why to look at assembly.

Thanks again for the good information, appreciate the help! When I get to the office, if the cast works, then I think my problem is solved (but will still look at the assembly to just understand what you’re saying).

Both the assembly and the schematic should have the same information. It does look like the only two PWMs not on the display header are indeed channel 7 and 8 on D6 and D5 respectively.