Closed phord closed 5 years ago
It works with software pwm a little bit different. Please check:
Instead of limit the value, softpwm will smoothly factorize the values. E.g. having a max value of 128 and sending 255, the result is 128. Sending 127 the result is ~64.
You're right, of course. I did just notice that. Sorry about the noise.
It feels like the hardware pwm should also be scaled in a common location rather than down in the chip-specific code (e.g. heater-avr.c).
Also, why does the soft-pwm scale differently than the hardware pwm? Shouldn't they both scale the same?
I'm not 100% sure how it works with hardware pwm.
When I'm programming the soft pwm code I found the special behaviour with the max value and don't think to implement the same on hardware side. But this scaled view could be probably better.
If a heater is driven by hardware pwm, the max_value field is able to limit the current sent to that heater by limiting the max pwm value used. If software pwm is used, the max_value field is ignored. This could even be dangerous since software pwm may be chosen without the user's awareness; e.g. if the pin chosen doesn't support pwm, uses Timer0 or if a bug in the header has it configured wrong.