Repository navigation
feat: anti-jitter on the lever position, and 0.6.0 - #17
Merged
Merged
Conversation
The lever's hall sensor reads about 2 units of noise in x and y even when the lever is still, and z flickers by one step, which can drop gear 7 at its edge. Anti-jitter (none, low, medium, high) steadies x, y and z before anything is worked out from them: gears, shifts, the handbrake axis, report 0x24 and calibration. Each runs through a short running average and holds inside a band; a still lever settles on its average after 128 ms, large moves pass at once, and a single frame far from the last is skipped as a bad read. None (the default) gives the raw values. While anti-jitter is on, input report 0x26 carries the raw x and y in every other report 0x24 slot. The web tool's new Anti-jitter section draws the position games see over the raw reading, live. Settings writes now take no USB packet and no interrupt while the flash is busy. A unit froze when control requests arrived during an erase. The emulator now models erase and program time and flags both. Also: openshifter_ctl anti-jitter, docs, wiki, version 0.6.0.
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.
Problem
The lever's hall sensor reads noise even when the lever is still. Measured on a unit: x and y move by about 2 units (sd), up to 18 peak to peak, about 330 times a second at rest, and z flickers by one step of its high byte. The handbrake axis twitches by up to 2 % while held, and gear 7, which is held by field strength, can drop and come back right at its edge.
Approach
Firmware (
sensor_mathinshifter.c). Anti-jitter (24 36 v: 0 none, 1 low, 2 medium, 3 high; saved in option bits 5 and 6) steadies x, y and z (s14) before anything is worked out from them, so it covers gears, sequential shifts, the handbrake axis, report 0x24 and calibration. For each value:None gives stock's raw values.
Raw report. While anti-jitter is on, input report 0x26 (
26 x y, big-endian) takes every other report 0x24 slot. The host gets no more reports than before, and report 0x24 comes every 4 ms instead of 2. Two earlier designs failed on the unit:Freeze fix (
flash.c,usb.c). Control requests arriving during a settings erase locked up the unit: no USB, no LEDs, no watchdog. It also happened with interrupts off. Settings writes andenter_bootloadernow keep interrupts off and pause the USB block while the flash is busy, about 25 ms:The emulator now models erase and program time, and flags any interrupt or USB packet taken while the flash is busy. That check failed on the build that froze. The differential tests turn the timing off, because stock writes for about 70 ms and its timing would no longer line up.
Web tool. A new Anti-jitter section has four choices and a live trace: Lever x and Lever y (plus the handbrake axis in handbrake mode), with the position games see in colour over the raw reading in grey. Each lane zooms in on its own range. The page sends nothing to the shifter for the trace.
CLI and docs.
openshifter_ctl.py anti-jitter none|low|medium|high, plusdocs/protocol.md,docs/testing.md, the wiki and the README. Version 0.6.0.Cost: about 900 bytes of code and 28 bytes of RAM.
Automated validation
make -C firmwarebuilds without warningsmake -C firmware testpasses: 94 tests, differential tests ran (stock image), nothing skippedNew tests:
test_shifter.AntiJitter(9):test_emulated(3):test_ctl.test_anti_jitter, and a web test for the session and the simulatorReplaying this unit's real recordings through the C core:
Hardware testing
Limitations and follow-up