feat(v2): stabilize VBUS readout filtering#95
Merged
Conversation
Display jittered under V_SENSE divider noise and dropped after the output toggle. ADC oversamples 64 samples per read for sqrt(N) noise reduction. EMA gains an optional snap threshold so PDO step transitions bypass smoothing. On OFF->ON, the load reading seeds from the supply value and the next two INA226 samples are discarded while a fresh conversion completes.
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.
Summary
The supply readout jittered under V_SENSE divider noise, and the load readout twitched downward after the output toggled on. This PR adds three layered fixes so the displayed voltage stays steady at rest and snaps cleanly on PDO transitions.
Filter::emagains an optional snap threshold so deltas above the threshold (PDO step changes) bypass smoothing and replace the prior value. EMA methods now live onLoadReading/SupplyReadingwith their own tuned constants.Also inlines the pin map into
pocketpd.h(drops thePocketPDPinOutdependency) and renamesevt→eventin two stage handlers.Linked issues
Hardware tested
How tested: Flashed HW1_3. Confirmed supply readout no longer jitters at rest. Toggled output OFF→ON across 5 V and 20 V profiles. Display now seeds to the supply value and converges to the load reading without the previous downward droop. PDO switching still snaps to the new voltage immediately.
Breaking change / migration
Details:
Notes
The
.clang-formatchange addsPenaltyReturnTypeOnItsOwnLine: 1000to keep return types on the same line as the function name. Carry-over from local config, included for consistency with how the touched files are now formatted.