I’m having some problems with PWM and NETMF 4.2 on the Hydra.
One problem is that it looks like the Invert parameter of the PWM instantiation doesn’t have any effect.
Another is the Gadgeteer code for PWM.
Gadgeteer 4.1 had this code for PWM:
public void Set(int frequency, byte dutyCycle)
{
this.pwm.Set(frequency, dutyCycle);
}
This was fine and worked like a charm.
But Gadgeteer 4.2 has this code:
public void Set(int frequency, double dutyCycle)
{
if (frequency < 0) throw new ArgumentException("frequency");
if (dutyCycle < 0 || dutyCycle > 1) throw new ArgumentException("dutyCycle");
if (pwm == null)
{
pwm = new PWM(pwmChannel, frequency, dutyCycle, invert);
pwm.Start();
started = true;
}
else
{
if (started) pwm.Stop();
pwm.Frequency = frequency;
pwm.DutyCycle = dutyCycle;
pwm.Start();
started = true;
}
}
My problem is the pwm.Stop() and pwm.Start(). This causes BAD glitches on the PWM in that the PWM pin goes low for a few milliseconds everytime the Set is called. On my MegaMoto module a low on the PWM pin means full speed. This causes audible ticks.