My aim is to use Spider with IO60P16 (on socket X) to drive servos. I’m at the earliest steps, just using an oscilloscope to prove if the PWM is set up correctly. Using one PWM worked fine (producing a 1ms to 2ms pulse every 10ms). I added a second PWM and the first PWM stopped working - i.e. no PWM output. I’ve reduced this to as simple a program as I can.
private const byte PERIOD = 234; // ticks for 10ms period
private IO60P16.PWM servo0;
private IO60P16.PWM servo1;
private void ProgramStarted()
{
this.servo0 = new IO60P16.PWM(IO60P16.PWMPin.PWM0, IO60P16.PWM.TickWidth.TickWidth_Servo_23438hz_42666ns);
this.servo0.SetPulse(36, PERIOD);
this.servo0.SetPulse(24, PERIOD); // breakpoint here and step to see change
this.servo1 = new IO60P16.PWM(IO60P16.PWMPin.PWM1, IO60P16.PWM.TickWidth.TickWidth_Servo_23438hz_42666ns);
this.servo1.SetPulse(24, PERIOD);
// try to change servo0 and it fails to change
this.servo0.SetPulse(48, PERIOD);
Using the debugger, I put a breakpoint on the last statement - the scope showed 1.5ms pulse (correct for setting of 36) - then execute the statement and the pulse doesn’t change.
If I swap the servo creation statements then changing the pulse does work.
// swapped order of creation....
private void ProgramStarted()
{
this.servo1 = new IO60P16.PWM(IO60P16.PWMPin.PWM1, IO60P16.PWM.TickWidth.TickWidth_Servo_23438hz_42666ns);
this.servo1.SetPulse(24, PERIOD);
this.servo0 = new IO60P16.PWM(IO60P16.PWMPin.PWM0, IO60P16.PWM.TickWidth.TickWidth_Servo_23438hz_42666ns);
this.servo0.SetPulse(36, PERIOD);
this.servo0.SetPulse(24, PERIOD); // breakpoint here and step to see change
this.servo0.SetPulse(48, PERIOD); // step again to see change
A bit of experimenting showed me that it didn’t matter which PWM pins I used, but whichever PWM I created last was the one that worked (for changes) and the other won’t change.
I hope I’m using the latest and greatest drivers because I downloaded and installed them yesterday:
Microsoft .Net Micro Framework SDK 4.2 (QDE2)
GHI .Net Gadgeteer SDK 1.6.10.0
Any suggestions as to why the order of creation makes a difference?