-
Notifications
You must be signed in to change notification settings - Fork 13.3k
"Phase Locked" Waveform: fix significant jitter, that stresses servos and is clearly audible in Tone output #7022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
153 commits
Select commit
Hold shift + click to select a range
3f36f6f
Allow 100% high or low periods.
dok-net ee3ca86
Fix serious jitter issues in previous versions.
dok-net 233e5f1
Use ESP.getCycleCount() just like everyone else.
dok-net c462fe0
Highest timer rate at which this runs stable appears to be 2µs (500kHz).
dok-net a97f247
Guard for zero period length undefined waveforms.
dok-net a2c7125
Cycle precision for expiry instead of special treatment for 0 value.
dok-net b2e9ad7
Give expiry proper precedence over updating a waveform
dok-net 6eb28d3
Important comment
dok-net da049c1
Refactored, identical behavior.
dok-net 1178268
Use plural for bit arrays.
dok-net 3fbaaa8
Fix for completely duty or all off cycle period case.
dok-net 01c5f7a
Expiration is explicitly relative to service time.
dok-net b255655
Comment updated, here it's about cycles not usecs.
dok-net 7b99b85
Revert misconception of how waveformToEnable/Disable communicates wit…
dok-net 22556f0
Rewrite to keep phase in sync if period remains same during duty cycl…
dok-net 0f4486b
Rather iterate even if full-duty or no-duty cycle in period, than too…
dok-net 37b0685
Must fire timer early to reach waveform deadlines, otherwise under so…
dok-net 0a2415d
Schedule expiry explicitly, too.
dok-net b595e49
Quick change lets analogWrite keep phase for any duty cycle (includin…
dok-net e0d9a48
Set duration to multiple of period, so tone stops on LOW pin output.
dok-net bb04a02
Improve phase timing
dok-net 8c646f3
Eror causing next Timer IRQ to fail busy-to-off cycle transitions.
dok-net 8ab9975
Regression fix, don't reset timer if pending shortly.
dok-net acd0dcd
Rather reschedule ISR instead of busy looping during permitted maximu…
dok-net 87b71c2
Lead time improved for ISR
dok-net 2bae205
Reduce number of cycle calculations.
dok-net deaf2ec
Reactive the gcc optimize pragmas.
dok-net d8e330e
Simplify calculation.
dok-net da933fd
handles overshoot where an updated period is shorter than the previou…
dok-net 6c7346a
Misleading code, there must ever be only one bit set at a time, start…
dok-net f6fbf80
Prevent missing a duty cycle unless it is overshot already.
dok-net 745c1b2
Continuously remove distant pending waveform edges from the loop, con…
dok-net b877047
Replace volatile for one-way exchange into ISR with memory fence.
dok-net 42983a9
Remove redundant stack object.
dok-net 6aea9d6
Revert pending waveform removal from loop - corrupts continuous next …
dok-net 9245e19
Reduce if/do ... while to while
dok-net 42a065d
Convert relative timings to absolute.
dok-net 02e5233
Relax waveform start to possibly cluster phases into same IRQ interval.
dok-net b68d3cb
max 12us in ISR seems to work best for servo/fan/led/tone combo test.
dok-net 2bc599f
Restructured code in ISR for expiration, this saves 36 byte IRAM, and…
dok-net aab4a49
Simplified overshot detection and 0% / 100% duty cycle.
dok-net 5a91f9f
Leave ISR early if rescheduling is more promising than busy-waiting u…
dok-net 6395373
Stabilized timings.
dok-net 4984f49
Prevent WDT under load.
dok-net eb28b27
Use clock cycle resolution instead of us for analogWrite.
dok-net 3155888
Reduce idle calculations in ISR.
dok-net 6c43c0d
Optimize in-ISR time.
dok-net 14444a9
Support starting new waveform in phase with another running waveform.
dok-net 48f6d85
Align phase for analogWrite PWMs.
dok-net ac832a7
Tune preshoot, add lost period fast forward.
dok-net 94626e8
Adapt phase sync code from analogWrite to Servo
dok-net ef5fdd0
Fix for going off 100% duty cycle period.
dok-net 59d788b
Eschew obfuscation.
dok-net 1057256
Fixed logic for zero duty cycle.
dok-net 3d99249
Determine generator quantum during same IRQ - this is better than tim…
dok-net d92a737
Tune timings, fix write barriers and overshoot logic.
dok-net 560cca7
Migrate Tone to waveform with CPU cycle precision
dok-net c75d1bd
Can do 60kHz PWM.
dok-net a2222e8
Recalibrated timings after performance optimizations.
dok-net 6ab789c
Fix regression for waveform runtime.
dok-net ac21bca
Test cycle duration values for signed arithmetic safety.
dok-net 7a4bb61
Performance tuning.
dok-net ba47d27
Performance tweak, in-ISR quantum is now 1.12µs.
dok-net 1c4de11
Round up duration instead of down - possibly to zero, which means for…
dok-net a9565b2
Extend phase alignment with optional phase offset.
dok-net a3c0dfe
Slightly better in-ISR quantum approximation for steadier increments.
dok-net bd0fea0
Waveform stopped by runtime limit in iSR doesn't deinit the timer, bu…
dok-net 9f5743c
Improved quantum correction code.
dok-net 9d29fc2
Fix broken multi-wave generation.
dok-net 244153e
Aggregate GPIO output across inner loop. True phase sync, and now bet…
dok-net e149284
IRQ latency can be reduced from 2 to 1 us now, no WDT etc.
dok-net ab70633
Improved handling of complete idle cycle miss, progress directly into…
dok-net 4ba59dc
Recalibrated after latest changes and reverts.
dok-net a3bf761
Overshoot compensation for duty cycle results in PWM milestone.
dok-net e2fe477
Adjustments to duty/idle cycle to mitigate effects of floating duty c…
dok-net 3286bf7
Remove implicit condition from loop guard and fix timer restart duration
dok-net 237bdfd
Host all static globals in an anonymous static struct.
dok-net 6e352ea
Busy wait directly for next pending event and go to that pin.
dok-net 5b6be8b
Record nextEventCcy in waveform struct to save a few cycles.
dok-net 25dbff5
Adapt duty cycle modification to only fix full duty and all idle cases.
dok-net 9f79f43
Remember next pin to operate between IRQs.
dok-net 936985e
Don't set pinMode each time on already running PWM or Tone.
dok-net 5fc33d0
Remove quantum, correct irq latency from testing,reuse isr timeout fr…
dok-net a235066
Move updating "now" out of inner loop, prevents float between pins th…
dok-net b0bf144
Merge init loop with action loop again.
dok-net 948601c
Adaptive PWM frequency and floating duty cycle.
dok-net 9445755
Predictive static frequency scaling.
dok-net 0ec53e4
Dynamic frequency down-scaling
dok-net 1d0f914
Frequency scaling is only for PWM-like applications, anything needing…
dok-net f8e07f5
Conserve IRAM cache, resort to best effort.
dok-net ea01c25
Directly scale frequency for all duty/all idle waves to reasonable ma…
dok-net d17a7b9
Getting the math right beats permanently reducing PWM frequency.
dok-net 2ff07a1
Rename identifier to help think about the problem.
dok-net a07f12c
AutoPwm correction moved to correct location - after overshoot recalc…
dok-net d0a79d6
Finish overshoot math fixes.
dok-net 2360dfe
First set pin mode, then digital write.
dok-net 9d6130c
Simplify calculations, fix non-autoPwm for servo use, where exact dut…
dok-net c8f300f
Move wave initialization and modification outside the inner loop.
dok-net 7565dc2
Some optimizing.
dok-net e0fbc99
Updating "now" in the inner loop should lessen interference
dok-net 742199f
Finally get rid of volatile and use atomic thread fence memory barrie…
dok-net ee69ab9
Improved idle cycle overshoot mitigation.
dok-net e8d25b0
Improved duty cycle overshoot mitigation.
dok-net 916db2e
Move startPin etc. into common static struct
dok-net 864a2bf
Persist next event cycle across ISR invocations, like initPin was bef…
dok-net b0682a9
Recalibrated DELTAIRQ and IRQLATENCY. Tested @ 3x 40kHz PWM + 440Hz Tone
dok-net 4af8505
CPU clock to Timer1 ccy correction must be dynamic even when BSP is c…
dok-net b861742
Corrected use of Timer1 registers and add rationale to Timer1 use in …
dok-net 04ab1e0
Let duty cycle overshoot correction depend on relative impact compare…
dok-net 60a09e4
80MHz/160MHz specific code can be compile-time selected in general, o…
dok-net 4e50fbc
Seems that removing the redudant resetting of edge interrupt mode sha…
dok-net 9d86859
Recalibrated delta irq ccys.
dok-net 6fe4732
Off-by-one in 100% duty overshoot correction.
dok-net 6885337
Simple register writes.
dok-net 41f6bb5
Memory fences checked and joining events into same loop iteration tha…
dok-net 89dd855
Shorten progression when going off 100% duty.
dok-net 86afd50
Code simplifications.
dok-net b707020
Dynamically map pins out from in-ISR handling based on next event tim…
dok-net e71d86f
Reverting maximum IRQ period to 10ms. This sets the wave reprogrammin…
dok-net 6855ad1
Revert recent change that is the most likely cause of reported PWM fr…
dok-net ddecf8a
Much simplified overshoot mitigation code.
dok-net 111583b
Fixing overshoot mitigation, 3x 880Hz, 256 states now.
dok-net aa18a70
Increase resolution by keeping reference time moving forward earlier.
dok-net b43d4b0
Mitigation logic for ESP8266 SDK boosting to 160MHz during some WiFi …
dok-net e978ac4
Event timestamps are all recorded for compile-time CPU frequency, the…
dok-net 3b18d51
Expired pins must not be checked for next event.
dok-net b45a2d2
Recalibrate after latest changes.
dok-net 784692b
Save a few bytes code.
dok-net 2d591eb
Guards are in place, so xor rather than and bitwise not.
dok-net dd10064
Reduce memory use.
dok-net 557f356
SDK boost to 160MHz may last across multiple ISR invocations, therefo…
dok-net 2e1ecc7
Overshoot mitigation w/o PWM frequency change.
dok-net b7f1b95
New PWM overshoot mitigation code keeps frequency. Averages duty betw…
dok-net 05307a1
Small refactoring, remove code path that is never taken even at 3x25k…
dok-net 83c6b67
Don't ever skip off duty, no matter if late or infinitely short.
dok-net 5165ba2
Shed speed-up code that didn't speed up things.
dok-net 12e4755
Must always recompute new waveform.nextEventCcy if there is any busy …
dok-net 16956e9
Break out of ISR if timespan to next event allows, instead of busy wa…
dok-net 7646984
Minor code simplification.
dok-net ab1b4c1
Improve code efficiency.
dok-net 3d8865d
Improved performance of loop.
dok-net 60bfa92
Recalibrated.
dok-net b78329b
No positive effect of lead time inclusion was found during testing, r…
dok-net f2dc71b
Fix WDT when at 160MHz CPU clock the Timer1 is set below 1µs.
dok-net 7e247c2
Consolidate 160MHz constexpr check, finish 1µs minimum for Timer1 fix.
dok-net 440c444
Test for non-zero before subtract should improve performance.
dok-net 610fe5a
Reviewers/tested noted they were seeing WDT, and this change appeared…
dok-net 0f1c423
More expressive use of parentheses and alias CPU2X for reduced code s…
dok-net 59d3143
Bug fix: at 160MHz compiled, don't force minimum Timer1 latency to 2µs.
dok-net bc7d279
Alternate CPU frequency scaling mitigation.
dok-net 12a4c65
Handle time-of-flight in the right spot.
dok-net e4892fa
Remove _toneMap from Tone.cpp
dok-net 31ebfa7
Merge branch 'master' into waveform
d-a-v File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Improved handling of complete idle cycle miss, progress directly into…
… duty cycle.
- Loading branch information
commit ab706335f203c3d3b1b221cde0da5ba550fe5c7c
There are no files selected for viewing
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
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.
Uh oh!
There was an error while loading. Please reload this page.