I recently upgraded my Netduino to 4.2.0 firmware. I'm now updating my code and I'm having an issue with the new PWM class and servos.
Servos expect a PWM with 20ms period and high signal duration from 1 ms to 2ms. I wrote the following using the new native PWM:
var servo = new Microsoft.SPOT.Hardware.PWM(PWMChannels.PWM_PIN_D10, 20000, 1000, PWM.ScaleFactor.Microseconds, false); while (true) { Thread.Sleep(1000); servo.Duration = 2000; // 2 ms Thread.Sleep(1000); servo.Duration = 1000; // 1ms }
And the following using the SecretLabs PWM implementation:
var pwm = new SecretLabs.NETMF.Hardware.PWM(Pins.GPIO_PIN_D10); uint period = 20000; while (true) { pwm.SetPulse(period, 1000); // 1 ms Thread.Sleep(1000); pwm.SetPulse(period, 2000); // 2 ms Thread.Sleep(1000); }
Both examples make the servo move but, it doesn't move 90º and the 2 ms position forces the servo. Am I doing something wrong?
Thanks!