I'm getting close to being done with a complete rewrite of the code. I'm pretty sure there's a bug in the original software for the pwm filter. It tries to take sort of a running average for pwm, but look at this:
pwmAverage = (127*pwmAverage + 1*pwmNewValue)/128
Let's say, for instance, pwmAverage is 10, and pwmNewValue is 20. pwmAverage will never be able to creep toward 20. If the new value of pwm average is 10 < pwmAverage < 11, it will be truncated to 10, and won't ever get to 20.
|