Configurable PWM frequency, full-duty MAX_PWM default, track voltage warning (v2.4.0)#9
Open
yamanote1138 wants to merge 3 commits into
Open
Configurable PWM frequency, full-duty MAX_PWM default, track voltage warning (v2.4.0)#9yamanote1138 wants to merge 3 commits into
yamanote1138 wants to merge 3 commits into
Conversation
… track voltage - Motor PWM frequency now comes from PWM_FREQ in secrets.ini instead of a hardcoded 20kHz, following the existing MAX_PWM build-flag pattern. - Add a compile-time ceiling (#error above 40kHz) since analogWrite on ESP8266 is software PWM sharing one timer across all 4 active channels (motor + R/G/B status LED) — too high starves the WiFi/WebSocket stack. - Bump MAX_PWM 500 -> 1000 in secrets.ini.example for full duty resolution. - Debug panel: bold/red Track Voltage when it exceeds 10V.
Most users won't open the debug view unless something's already wrong. Extracted trackVoltage/trackVoltageDanger as shared computeds in useTrainController so the "Track:" readout in SpeedController and the debug panel's row both derive from one source of truth instead of each reimplementing the 12V * speed and >10V threshold logic.
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
PWM_FREQ) is now asecrets.inibuild flag instead of a hardcoded 20kHz, following the existingMAX_PWMpattern. Currently testing at 32kHz on hardware.#errorabove 40kHz, sinceanalogWriteon ESP8266 is software PWM sharing one hardware timer across all 4 active channels (motor + R/G/B status LED) — too high starves the WiFi/WebSocket stack.MAX_PWMdefault raised 500 → 1000 (full duty resolution / full track voltage) insecrets.ini.example.trackVoltage/trackVoltageDangerare shared computeds inuseTrainControllerso both spots derive from one source of truth.docs/BUILD.mdupdated to document bothPWM_FREQand the newMAX_PWMdefault.VERSIONmacro + frontendpackage.json/package-lock.json).Test plan
pio test -e native— 38/38 passedpio run -e d1_mini— builds clean atPWM_FREQ=32000#error)npm test(frontend) — 13/13 passednpm run build(frontend) — builds clean