fix pwm overflow - #2
Open
bugparty wants to merge 2 commits into
Open
Conversation
merge lastest progress
On the Fnirsi HS-02 the tip PWM period (powerPWM) is 395, but the watts-to-PWM pipeline was typed uint8_t end to end: X10WattsToPWM() -> uint8_t (clamps to powerPWM=395, then truncates) setTipPWM(const uint8_t pulse) Any demand that scaled the PWM value above 255 wrapped modulo 256, so the duty cycle collapsed. Concretely a full-power request of 395 truncated to 139, i.e. ~35% duty. This is why a power limit of <=90 W reached the setpoint from cold but 100 W only delivered ~40-60 W. Widen the value path to uint16_t (X10WattsToPWM return, setTipPWM pulse across all BSPs, plus PWMToX10Watts / shouldBeUsingFastPWMMode). The internally scaled value still fits uint8_t pendingPWM, and every other device has powerPWM <= 255 so they are unaffected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixing pwm overflow bug, when you set the max power limit to 100W
if you set the max power to 100w, you can actually get 10-60w(depending on the overflowed values)
Nope