aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/clocksync.py
Commit message (Collapse)AuthorAgeFilesLines
* clocksync: The clock estimate should add the rtt time not subtract itKevin O'Connor2017-12-161-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* clocksync: Start with adjusted_freq of 1.0Kevin O'Connor2017-10-131-1/+1
| | | | | | | Avoid setting adjusted_freq to 0.0 as that can cause divide by zero failures at startup. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* clocksync: Initialize clock_est in connect_file()Kevin O'Connor2017-10-121-0/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* clocksync: Implement a floor on the prediction filterKevin O'Connor2017-10-021-3/+4
| | | | | | | | Don't discard samples that are less than 500us from the prediction regardless of the prediction variance. Also, don't use the prediction variance in the external time estimate. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* clocksync: Update clock synchronization code to use a linear regressionKevin O'Connor2017-09-301-40/+67
| | | | | | | | | Implement a "moving" linear regression between the reported mcu clock and the sent_time of the get_status message that generated that report. Use this linear regression to make predictions on the relationship between the system time and the mcu clock. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* clocksync: Don't update prev_est on min rtt updatesKevin O'Connor2017-09-281-1/+2
| | | | | | | Average frequency changes over the longer interval on a sample that causes a minimum rtt update. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* clocksync: Fix serialqueue.set_clock_est() - don't track min_freqKevin O'Connor2017-09-281-5/+3
| | | | | | | | | | | | Revert commit f37fc775. It is not valid to pass a conservative frequency to serialqueue.set_clock_est() as that function may not be called for extended periods - a too low frequency would eventually lead to "Timer too close" mcu errors. Instead, increase the 1ms time offset to 5ms to avoid corner cases that could lead to a message arriving too soon. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* clocksync: Default mcu_freq to 1 instead of 0Kevin O'Connor2017-09-271-1/+1
| | | | | | | This prevents divide by zero errors during stats output if the stats are generated before a connection completes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* clocksync: Add support for dumping internal state for debuggingKevin O'Connor2017-09-271-0/+13
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* clocksync: Be conservative when setting serialqueue.set_clock_est()Kevin O'Connor2017-09-271-1/+5
| | | | | | | | | Accuracy is not as important as ensuring a message is never sent before it can be received in the serialqueue code. So, use the smallest frequency ever seen and add the minimum rtt time when setting set_clock_est(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* clocksync: Rework clock synchronization algorithmKevin O'Connor2017-09-261-97/+94
| | | | | | | | | Instead of tracking the minimum frequency ever observed, attempt to track the actual frequency of the micro-controller (relative to the host clock). This improves the stability of the secondary mcu clocks when multiple mcus are configured. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Initial support for multiple micro-controllersKevin O'Connor2017-09-201-3/+55
| | | | | | | | | Add initial support for controlling multiple independent micro-controllers from a single Klippy host instance. Add basic support for synchronizing the clocks of the additional mcus to the main mcu's clock. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* mcu: Move print_time to clock conversion code to clocksync.pyKevin O'Connor2017-09-191-6/+16
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* clocksync: Don't export get_last_clock()Kevin O'Connor2017-09-191-4/+6
| | | | | | | Everywhere the data in get_last_clock() is used can be done just as easily with estimated_print_time(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* clocksync: Move clock synchronization code into new fileKevin O'Connor2017-09-191-0/+106
Move the low-level clock synchronization code from serialhdl.py to a new file clocksync.py. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>