Commit Graph

2540 Commits

Author SHA1 Message Date
Kevin O'Connor 3d3b87f97f toolhead: Ensure full kin_flush_delay after flush_step_generation()
Commit b7b13588 made it possible that the kinematic code could be
restarted after a flush_step_generation() call without a sufficient
delay.

Rename last_sg_flush_time to min_restart_time and use that to ensure
_calc_print_time() always pauses kin_flush_delay time since the last
flush_step_generation() call.

Also, update force_move to invoke flush_step_generation() after any
movements.  This is needed to ensure there is a sufficient delay
should force_move be called on a stepper motor that is part of the
toolhead kinematics and is using a step generation "scan time".

This fixes possible "internal error in stepcompress" reports when
using FORCE_MOVE.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-16 20:40:55 -05:00
Kevin O'Connor 1ea9f3aa35 mcu: Increase trsync_state reporting during multi-mcu homing
The current code has the mcu report a trsync_state message every 10ms
and expects a time extension within 25ms.  However, this means that if
a single mcu->host report is lost then 20ms would elapse until the
next report, which would allow for only a 5ms round-trip time before a
timeout error is reported.

Increase the trsync_state timing so that a message is sent every
7.5ms.  This increases the total number of messages per second sent
from mcu to host to 133 (from 100).  With this change, a single lost
message would still allow for up to a 10ms round-trip time.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-16 14:19:11 -05:00
Kevin O'Connor dab39c02cd mcu: Stagger trsync reporting time during multi-mcu homing
When multiple MCUs are involved in homing, stagger the scheduling of
the trsync_state report messages from each mcu.  Staggering helps
spread the bandwidth, helps reduce locking contention in the host, and
reduces the chance that intermittent latency could result in a
communication timeout.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-16 14:19:11 -05:00
Kevin O'Connor 1a1568c38b mpu9250: Fix incorrect use of time.sleep()
It is not valid to call time.sleep() in the host python code (it could
causes glitches in other processing, and it does not ensure there is a
pause between operations on the mcu).

Use minclock instead of time.sleep() to ensure there is a sufficient
pause during chip startup.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2024-01-07 11:59:55 -05:00
Kevin O'Connor 92fe8f15b8 buttons: Fix possible ordering issue if a callback blocks
Invoke button callbacks directly from the background thread.  This
ensures that button notifications are delivered and delivered in the
correct order.  Previously, if a callback blocked, it was possible a
new update could start before the previous update was completed, which
could lead to lost events or out of order events.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-30 12:55:59 -05:00
Kevin O'Connor 25bc649cd2 toolhead: Make sure to flush history when in debug output mode
When in debugging "batch mode", use the existing method of keeping the
last 30 seconds of history from the furthest planned move time.  This
avoids keeping all moves in memory during a batch test.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-30 12:35:42 -05:00
Kevin O'Connor 9847b44901 toolhead: Avoid calling reactor.monotonic() on each _advance_flush_time()
Move calculation of clear_history_time to the callers of
_advance_flush_time() as a minor processing optimization.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-30 11:43:32 -05:00
Francois Chagnon d7f6348ae6
toolhead: Keep stepcompress move history relative to current time (#6439)
Expire history relative to current time rather than last move in history queue

Signed-off-by: Francois Chagnon <fc@francoischagnon.net>
2023-12-30 11:34:21 -05:00
Kevin O'Connor b502558052 bulk_sensor: Fix missing logging import
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-28 13:13:57 -05:00
Kevin O'Connor 6f686ddee3 bulk_sensor: Add some module level documentation
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-26 11:47:21 -05:00
Kevin O'Connor c716edafe2 bulk_sensor: Simplify the registration of internal clients in BatchBulkHelper
Previously, the BatchBulkHelper class was designed primarily to
register webhook clients, and internal clients used a wrapper class
that emulated a webhooks client.

Change BatchBulkHelper to support regular internal callbacks, and
introduce a new BatchWebhooksClient class that can translate these
internal callback to webhooks client messages.

This makes it easier to register internal clients that can process the
bulk messages every batch interval.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-26 11:47:21 -05:00
Kevin O'Connor 3370134593 bulk_sensor: Rework APIDumpHelper() to BatchBulkHelper()
The APIDumpHelper class is mainly intended to help process messages in
batches.  Rework the class methods to make that more clear.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-26 11:47:21 -05:00
Kevin O'Connor 95c753292d bulk_sensor: Minor code reorg to _stop() in APIDumpHelper()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-26 11:47:21 -05:00
Kevin O'Connor acde3720a4 bulk_sensor: New add_mux_endpoint() helper function in APIDumpHelper
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-26 11:47:21 -05:00
Kevin O'Connor ffd44c0219 bulk_sensor: Move APIDumpHelper() from motion_report.py to bulk_sensor.py
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-26 11:47:21 -05:00
Kevin O'Connor f4c8f0bf88 angle: Define BYTES_PER_SAMPLE and SAMPLES_PER_BLOCK
This makes the code a little more readable.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-26 11:47:21 -05:00
Kevin O'Connor 3f84501955 adxl345: Add a read_axes_map() helper function
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-26 11:47:21 -05:00
Kevin O'Connor 43ce7c0b9a adxl345: No need to implement is_measuring()
The APIDumpHelper class already ensures that the start/stop callbacks
will only be called when needed.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-26 11:47:21 -05:00
Kevin O'Connor d6a4669ce0 bulk_sensor: Add new ChipClockUpdater helper class
All the accelerometers use a standard response for their query_status
messages.  Create a common helper class to process those responses.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-26 11:47:21 -05:00
Kevin O'Connor e67cbbe5c1 bulk_sensor: Add new BulkDataQueue class
Move the bulk sample queue collection to a new helper class in
bulk_sensor.py.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-26 11:47:21 -05:00
Kevin O'Connor 978c294741 bulk_sensor: New file with helper code for reading bulk sensors
Move the ClockSyncRegression class from adxl345.py to a new
bulk_sensors.py file.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-26 11:47:21 -05:00
Kevin O'Connor 644f7e0872 toolhead: Simplify _advance_flush_time() sg_flush_time calculation
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-26 11:35:27 -05:00
Kevin O'Connor fe56bf36c9 toolhead: Fix _calc_print_time() after G4 and SET_PRESSURE_ADVANCE
Commit b7b13588 changed the internal flush time tracking, but
introduced the possibility of motion restart occurring too close to
the last motion end in some rare cases.  This could result in
internal stepcompress errors.

Track the last step generation flush time (last_sg_flush_time) and use
when recalculating the next print_time.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-26 11:18:40 -05:00
Kevin O'Connor 547bfbf818 pwm_tool: Fix error reporting
References to pins.error are not valid as the pins module is not
imported.  Reported by @Piezoid.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-19 14:57:39 -05:00
Sami Haahtinen 3417940fd8 hall_filament_width_sensor: max filament diameter
Add support for maximum filament diameter to hall filament width sensor.
If the diameter of the filament diameter is larger than the limit, the
virtual runout sensor will trigger. The default value is set to maximum
flow adjustment threshold to prevent oversized filament from clogging.

Signed-off-by: Sami Haahtinen <ressu@ressukka.net>
2023-12-17 11:13:33 -05:00
Kevin O'Connor 2defd7374a pwm_tool: Add support for maximum_mcu_duration
Implement the maximum_mcu_duration config parameter along with its
associated queue flushing.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-16 15:44:17 -05:00
Kevin O'Connor 1e5f688b53 mcu: Add support for registering callbacks during move queue flush
Support notification callbacks each time the mcu move queue is
flushed.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-16 15:42:39 -05:00
Kevin O'Connor 19862bc3b7 toolhead: Track separate time for flush_step_generation() and need_flush_time
Introduce a new step_gen_time variable for flush_step_generation().
This allows need_flush_time to be set to future times without
interfering with flush_step_generation().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-16 15:42:39 -05:00
Pedro Lamas 6676c1df86 gcode: expose status with available commands
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
2023-12-11 11:51:51 -05:00
Kevin O'Connor 2c2bb720fa adxl345: Simplify sequence and limit_count upconversion
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-10 14:59:18 -05:00
Kevin O'Connor 1a83845c9f angle: Simplify sequence upconversion
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-10 14:59:18 -05:00
Kevin O'Connor fe7082e4a8 buttons: Simplify ack upconversion code
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-10 14:59:18 -05:00
Kevin O'Connor c5bd813d8b clocksync: Simplify 32bit clock upconversion code
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-10 14:59:13 -05:00
Kevin O'Connor 62bf52bfcf serialqueue: Simplify sequence number upconversion
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-07 17:52:06 -05:00
Kevin O'Connor 99d7af87fd pwm_tool: Notify the toolhead that the move_queue needs to be flushed
Call toolhead.note_kinematic_activity() on each pin update to ensure
that those updates will be flushed properly.

This fixes "Timer too close" errors on SET_PIN commands that are
issued when the toolhead is idle.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-07 17:09:26 -05:00
Kevin O'Connor c491ea669f toolhead: Support flushing even while lookahead queue is idle
Track a "NeedPrime" queue state instead of the "Flushed" state, and
continue running the background flushing timer as long as there may be
data in any of the move queues.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-07 17:09:26 -05:00
Kevin O'Connor b7b13588c7 toolhead: Rework flushing to be based on mcu flush time
Rename last_kin_move_time to need_flush_time and rename
force_flush_time to last_flush_time to improve variable name clarity.

Move low-level flushing to new _advance_flush_time() so that it is
possible to flush the queues without needing to advance print_time.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-07 17:09:26 -05:00
Kevin O'Connor 9e574c3497 toolhead: Separate out priming flush notification to its own timer
Simplify the code by introducing a separate lookahead priming flush
timer.  After this change, the flush_timer is not active in any of the
special queuing states.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-07 17:09:26 -05:00
Kevin O'Connor 93cd8834f3 toolhead: Clarify internal toolhead "stall" and "pause" naming
Clarify the internal naming to make a more clear distinction between
"stalling" (input not coming fast enough) and "pausing" (the need to
hold up reading of input to avoid buffering too far into the future).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-07 17:09:26 -05:00
Kevin O'Connor bafb126abd toolhead: Remove undocumented buffer management config parameters
These internal low-level config parameters were never documented.
Going forward, developers may modify them by altering the internal
settings in toolhead.py.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-12-07 17:09:26 -05:00
Kevin O'Connor 03f69cd81a tmc: Query latest value during _init_registers()
The set_register() code may block, and it therefore may be possible
that the loop in _init_registers() could occur in parallel with other
updates.  That could result in a "OrderedDict mutated during
iteration" error.

Avoid the error by querying the latest value during each iteration of
the loop.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-11-28 21:24:41 -05:00
Andrei Ignat ea2f6bc0f5
exclude_object: Don't use gcmd.respond_error() (#6407)
gcmd.respond_error() has been deprecated: 61524542d2

Signed-off-by: Andrei Ignat <andrei@ignat.se>
2023-11-22 11:53:38 -05:00
Kevin O'Connor bb4711c5d3 tmc5160: Increase maximum current error check
It's possible to build and configure tmc5160 drivers with external
mosfets that support more than 3 amps.  The actual maximum for tmc5160
drivers is dependent on how the board is wired and the mosfets used.
Increase the error check to 10 amps.  This error checking is primarily
intended to catch "obvious misconfigurations" (eg, specifying
milli-amps instead of amps), and the new value of 10 amps should
suffice for this task.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-11-20 18:15:46 -05:00
Kevin O'Connor 187cc2f1b8 configfile: Improve support for python3.12
It seems python3.12 has removed support for readfp() - use read_file()
instead.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-11-16 22:28:40 -05:00
vaxxi 3c8f202dfa
bmp280: Add support for BMP180 sensor (#6370)
Extends the BMxx80 category with support for the older BMP180 sensor, providing temperature and humidity output.

Signed-off-by: VAXXi Popescu <github@vaxxi.net>
2023-11-16 22:27:44 -05:00
Kevin O'Connor 29b7550ce5 pwm_tool: Add support for high-speed PWM pin updates
The output_pin module is only capable of updating an output pin at
most once every 100ms.  Add a new pwm_tool module that is capable of
queuing updates in the micro-controller and thus allowing for much
higher update rates.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-11-16 22:07:15 -05:00
Kevin O'Connor 48a05eaa54 stepcompress: Add support for queuing messages that consume move queue space
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-11-16 22:07:15 -05:00
Thijs Triemstra 4688c21c54
klippy: Replace deprecated logger.warn with logger.warning (#6385)
Replace deprecated logger.warn with logger.warning

logger.warn will be removed in Python 3.13

Signed-off-by: Thijs Triemstra <info@collab.nl>
2023-11-16 22:06:13 -05:00
Pedro Lamas 9e765daeed bed_screws: Reset on move error
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
2023-11-02 13:08:53 -04:00
Kevin O'Connor f7567a0db9 Revert "toolhead: Use dict for step generation flush times. (#6303)"
This reverts commit 6749985302.

A defect was found in the above commit (the input shaper code calls
note_step_generateion_scan_time() for many steppers, so the
input_shaper class can't be used as the index).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-10-21 15:46:08 -04:00