Commit Graph

2491 Commits

Author SHA1 Message Date
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
Viesturs Zariņš 6749985302
toolhead: Use dict for step generation flush times. (#6303)
Makes the API to extruder and input shaper more robust, avoiding the need to track the old delay.

Signed-off-by: Viesturs Zariņš <viesturz@gmail.com>
2023-10-19 13:28:16 -04:00
Kevin O'Connor 447125faae serialqueue: Eventually time out if unable to write CANbus messages
Klipper logs an error on a failed CANbus write.  Unfortunately, if the
bus becomes permanently disabled (eg, due to a user removing power to
devices on the CANbus) then it can result in the logs filling with
error messages.

Permanently disable the low-level processing of messages if CANbus
writes continually fail for at least 10 seconds.  This avoids filling
the log with redundant messages.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-10-04 22:42:14 -04:00
Dmitry Butyugin a4cd0336bd
idex_modes: Fixed the case when carriages home in the same direction (#6310)
Previous version of the code assumed that dual carriages home away
from each other, which is not true on some machines, which have the
second dual carriage homing on the first carriage. The new code
correctly identifies the relative order of the carriages now.

This fixes discrepancies between the documentation and the actual
implementation of the carriages kinematic ranges calculation.

Notes about dual_carriage homing and proximity checks changes

Fixed clearing of homing state after homing in certain modes

In case of multi-MCU homing it is possible that the carriage position
will end up outside of the allowed motion range due to latencies in data
transmission between MCUs. Selecting certain modes after homing could
result in home state clearing instead of blocking the motion of the
active carriage. This commit fixes this undesired behavior.

Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2023-09-29 13:46:42 -04:00
Kevin O'Connor e9bf2d4c5c mcu: Enhance RetryAsyncCommand to handle low-level retransmits
The RetryAsyncCommand code needs to ensure that any response messages
are not from a previous (unrelated) query.  To do that it compares the
'#sent_time' from potential responses to ensure they are not from a
previous session.  However, if there are any low-level serial
retransmits then the low-level code sets the '#sent_time' to zero (to
indicate that the query send time is not strictly known).  That could
result in a valid response not being accepted by RetryAsyncCommand.

If a low-level connection is experiencing a small amount of periodic
retransmits it could result in multiple high-level retry attempts
failing to the point that there is a user-facing error.  This could
result in "Timeout on wait for 'tmcuart_response' response" errors.

Fix by accepting responses even if there is a low-level retransmit
once the code can confirm that there can be no previous query still in
progress.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-09-21 14:52:55 -04:00
DavidvtWout 8ef0f7d7e3
spi_temperature: Limit maximum temperature in MAX31865.calc_adc() to melting point of platinum (#6320)
Limit the maximum temperature in MAX31865.calc_adc() to the melting
point of platinum. Above this temperature the Callendar-Van Dusem
formula does not make sense. The default value for max_temp is
99999999.9 and at this temperature the result of this formula is
negative. This sets max_sample_value to 0 which causes the mcu
to shutdown.

Set max adc value to (1<<15)-1 .  This is needed because the max value of the adc register
of the MAX31865 is 0b1111 1111 1111 1110 which represents
32767 and not 32768.

Signed-off-by: David van 't Wout <github@yoctobyte.nl>
2023-09-10 18:51:14 -04:00
FrY Sennberg 2acfa28294
tmc2240: Adding UART interface support to tmc2240 (#6305)
Signed-off-by:  Christoph Frei <fryakatkop@gmail.com>
2023-09-10 14:41:59 -04:00
bigtreetech ec1dcf3bd2 lis2dw12: Add support for lis2dw12 accelerometer
lis2dw12 is an accelerometer from STMicroelectronics(https://www.st.com/resource/en/datasheet/lis2dw12.pdf)
With better performance than the ADXL345 according to the datasheet.

Signed-off-by: XM.Zhou from BigTreeTech zhouxm@biqu3d.com
Signed-off-by: Alan.Ma from BigTreeTech tech@biqu3d.com
2023-08-21 14:26:46 -04:00
D4SK aa8ba30f8a
cartesian: fix x-axis being hardcoded for dual_carriage (#6313)
Signed-off-by: Konstantin Vogel <konstantin.vogel@gmx.net>
2023-08-11 21:21:46 -04:00
Pedro Lamas ed66982b8e heaters: adds temperature monitors
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
2023-08-01 20:32:03 -04:00
Dmitry Butyugin 55d09771b1 idex_modes: A small fix for MOVE_SPEED param
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2023-08-01 20:26:19 -04:00
Michael Jäger 6f7c743615
temperature_combined: A class that can combine several other temperature sensors (#6230)
Signed-off-by: Michael Jäger <michael@mjaeger.eu>
2023-08-01 13:18:03 -04:00
Philippe Daouadi 039daecb4f
axis_twist_compensation: Add X twist compensation module (#6149)
Implements AxisTwistCompensation, and Calibrater

Supports calibration of z-offsets caused by x gantry twist

Modify PrinterProbe._probe function to check if the probed z value should be adjusted
based on axis_twist_compensation's configuration

Add documentation for [axis_twist_compensation] module

Signed-off-by: Jeremy Tan <jeremytkw98@gmail.com>
2023-08-01 13:08:53 -04:00
Dmitry Butyugin 36be1cfc51
idex_modes: COPY and MIRROR mode implementation (#6297)
COPY and MIRROR mode implementation

Correctly apply input shaper params to new dual_carriage

Added SAVE_/RESTORE_IDEX_STATE commands

Documentation updates for the new IDEX modes

Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2023-08-01 12:23:52 -04:00
Stefan Dej ea330717cd screws_tilt_adjust: add max_deviation to report status
Signed-off-by: Stefan Dej <meteyou@gmail.com>
2023-08-01 12:14:15 -04:00
SkyKnight e9534d6f92
webhooks: Add process id, user id and group id to the info endpoint. (#6284)
Signed-off-by: Gregoire Mbutilovich <skyknight_x@hotmail.com>
2023-07-28 12:48:14 -04:00
Zarrsito d725dfd309
screws_tilt_adjust: Added Support for M6 Screws (#6287)
Added support for M6 Screws

Signed-off-by: Sascha Petersen <Zarrsito@gmail.com>
2023-07-16 22:30:37 -04:00
Eric Callahan b9247810b9 virtual_sdcard: reset file position and size to integer zero
This resolves an issue with API server clients that always
expect these values be be integers.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2023-06-23 20:33:42 -04:00
Eric Callahan d32a833455 bed_mesh: fix fade regression
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-06-21 21:17:17 -04:00
Eric Callahan 1ad4c0fd6e bed_mesh: improve zero reference offset
The relative_reference_index will now refer to a coordinate that is
static and cannot be changed at runtime.  If new mesh parameters
are specifed and the reference lies outside of the mesh then the
reference location will be probed.

Additionally this introduces a 'zero_reference_position' option which
accepts a specific X/Y coordinate.  This may be used in place of the
relative_reference_index.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2023-06-20 11:48:17 -04:00
Eric Callahan 775092fc01 bed_mesh: generate new points before each calibration
When mesh parameters change the substituted indices need to be
updated, even when using the default point set.   Always generate
new points to perform this update rather than cache
the "orig_points".

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-06-20 11:48:17 -04:00
Kevin O'Connor 0245073c55 serialhdl: Catch os.error on can.interface.Bus() call
It seems opening the canbus socket can sometimes throw an os.error (in
addition to can.CanError).  Catch that error to avoid Klipper
reporting an internal error.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-06-17 19:32:06 -04:00
Alex Voinea 5ee72d320c tmc: Configurable `multistep_filt`
Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
2023-06-16 16:38:42 -04:00
BIGTREETECH 645a1b8364
i2c_software: Implementation of software i2c (#6141)
Signed-off-by: Alan.Ma from BigTreeTech <tech@biqu3d.com>
2023-06-07 20:55:46 -04:00
Dmitry Butyugin a3c00d0bed input_shaper: Correctly initialize input shaper stepper_kinematics
If the stepper already executed some steps with the basic
stepper_kinematics, subsequent creation of a new one for input_shaper
would result in stepcompress errors unless position and time tracking
flags are also copied over.

Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2023-06-06 20:17:49 -04:00
Dmitry Butyugin e15bad4844 input_shaper: Fixed tracking of step_generation_scan_time
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2023-06-06 20:17:49 -04:00
Dmitry Butyugin 345934bd68 idex_modes: Native input shaping support with dual carriages
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2023-06-06 20:17:49 -04:00
Eric Callahan 0539e9f266 bme280: use consistent report time for BME680
Sample the BME680 every .8 seconds, matching that of the
BME280.  This resolves an issue where `get_report_time_delta()`
returns a value that doesn't match the actual delta.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-05-31 13:43:07 -04:00
Dmitry Butyugin 624d360a34 resonance_tester: Apply input shaper params on SHAPER_CALIBRATE
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2023-05-25 12:52:29 -04:00
Dmitry Butyugin 16c53992d6 resonance_tester: Support CHIPS= parameter in SHAPER_CALIBRATE command
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
2023-05-25 12:48:17 -04:00
Frans-Willem Hardijzer ec61f10f0f
hybrid_corexy: Fix changing dual-carriage carriage will inadvertently set axis to homed, even if it wasn't. (#6183)
In hybrid_corexy and hybrid_corexz, the update_limits function is (only) called by the DualCarriage implementation, whenever the carriage changes.
Unfortunately, these limits also keep track of homing status, when they're unhomed they are set to 1 to -1 (invalid range).
As a fix, if the limit was set to "unhomed", we keep it that way, and only update it with the new rail limits if it was already properly homed before.

Signed-off-by: Frans-willem Hardijzer <fw@hardijzer.nl>
2023-05-25 11:55:07 -04:00
Eric Callahan a3eebab4f2 util: report git version info as a dict
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-05-04 14:07:14 -04:00
Eric Callahan b89a049fdb klippy: report repo branch, remote, and tracking url
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-05-04 14:07:14 -04:00
Kevin O'Connor 1a24e7c5b6 klippy: Report repo version as "dirty" if there are untracked python files
Check for untracked files in the klippy/extras/ and klippy/kinematics/
directories and report those files in the log.  This helps identify
code modifications when inspecting a log.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-05-02 11:40:18 -04:00
Scott Mudge 10e816979e aht10: update comments and docs for AHT20/AHT21 support
The control bytes for the AHT20 and AHT21 are identical to the AHT10, but I had not been able to test just yet to ensure the sensor code supported the other sensors. I've wrapped up testing and updated the comments/docs to reflect this additional support.

Signed-off-by: Scott Mudge <mail@scottmudge.com>
2023-04-24 11:10:00 -04:00
Dr. Matthew Swabey 80a7744b42
sensor_mpu9250: Fix or improve reliability (#6170)
Fixes common MPU-9250 accelerometer issues for RPi Linux MCU and
improves reliability on all other architectures by adjusting the MPU-*
reading algorithm to only read whole Klipper messages' worth of
data from MPU-* and eliminating many unnecessary checks of the MPU FIFO
fill-level that consumed bus bandwidth needed for data transfer. Fixes
intermittent "Lost communication with MCU 'rpi'" due to "Timer too
close" and transposed / corrupted data due to FIFO overrun/data loss
when using MPU-* accelerometers. In addition FIFO overrun checks are
performed by testing the MPU interrupt flag vs. inferring from the FIFO
fill level.

Stress tested for 13hrs with two MPU-6500 attached to one I2C bus on RPi
    and one on a PR2040
Stress tested for 23hrs with two MPU-6500 attached to one I2C bus on RPi
    and one on a ATmega328P (Seeduino Nano)

Signed-off-by: Matthew Swabey <matthew@swabey.org>
2023-04-19 12:34:22 -04:00
Justin Schuh c2fe372925 gcode_macro: Catch variable encoding errors
Catch parsing and json encoding errors at variable assignment.

Signed-off-by: Justin Schuh <code@justinschuh.com>
2023-04-19 12:22:20 -04:00
Justin Schuh d68a6c28ba webhooks: Log json encoding errors
Signed-off-by: Justin Schuh <code@justinschuh.com>
2023-04-19 12:22:20 -04:00
vcore85 c2b2278a49
tmc5160: add DRV_CONF Register for TMC5160 (#6154)
In some condition ,“drvstrength 2” does not work. According to page 17, some mosfets need “drvstrength” set to 0 .

From datasheet rev1.15, the DRVSTRENGTH reset default is 0 .  (instead of 2)

Signed-off-by: Albert Lin <vcore85@gmail.com>
2023-04-11 11:43:19 -04:00
Kevin O'Connor 83308a1051 tmc: Support reporting tmc2240 temperature in driver get_status()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-04-07 15:20:40 -04:00
Kevin O'Connor 22ee889f41 serialqueue: Rename stalled_bytes stat to upcoming_bytes
The stalled_bytes counter refers to the number of bytes that are not
yet eligible for transmission.  However, the naming leads to confusion
as it could be interpretted as an inability to transmit data.  Rename
to upcoming_bytes to try to avoid that confusion.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-04-07 15:17:43 -04:00
Scott Mudge acca55b074
aht10: Added support for AHT10 ambient temperature sensor (#6138)
This commit adds support for the I2C-based AHT10 ambient temperature sensor. The sensor comes pre-calibrated and has a fairly simple command interface, so the interface class is in-turn relatively simple. So far this has been tested on a BTT GTR 1.0 MCU board (STM32F4), and seems to work fine.

Signed-off-by: Scott Mudge <mail@scottmudge.com>
2023-04-07 13:41:06 -04:00
Alex Voinea c9731a6fe2 tmc: DUMP_TMC optional REGISTER parameter
Add an optional REGISTER parameter to DUMP_TMC so that the output is more filtered/cleaner for manual TMC calibration.

Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
2023-03-30 11:41:51 -04:00
BIGTREETECH 346e3901f6
tmc: Enable sg_angle_offset for smooth switching from Stealthchop to Spreadcycle (#6123)
Signed-off-by: Alan.Ma from BigTreeTech <tech@biqu3d.com>
2023-03-27 21:18:06 -04:00
Alex Voinea 73f4c6cd00 tmc: SET_TMC_FIELD VELOCITY
Ability to specify `VELOCITY` as a parameter for SET_TMC_FIELD. Useful for configuring at runtime the TSTEP based fields of the driver.

Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
2023-03-20 10:58:25 -04:00
Alex Voinea 0469710a69 tmc: Implement TMCtstepHelper
Implement a helper for calculating velocity based thresholds for tmc drivers. This code was written in such a way that it can be used with more fields than just tpwmthrs.

Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
2023-03-20 10:58:25 -04:00
Kevin O'Connor c54d83c9f1 tmc: Initialize self.coolthrs in TMCVirtualPinHelper constructor
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2023-03-15 16:46:35 -04:00
Alex Voinea a9feeaa9eb tmc: Do not override tcoolthrs if it is configured
If tcoolthrs is configured (not the default 0), then do not force
the value of tcoolthrs=0xfffff during homing. This way, tcoolthrs
can be set to a custom value during homing.

`tpwmthrs` and `en_pwm_mode`/`en_spreadcycle` are now also
correctly restored if they were changed after startup.

Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
2023-03-15 16:45:36 -04:00
Alex Voinea dd39091388 tmc: Enable `multistep_filt` for drivers that support it
`multistep_filt` was not configured at all on tmc2240 and tmc5160. As such, it would default to the value of 0 when the GCONF field was sent to the driver. However, that field has a default value of 1 in the driver, so klipper was overriding the defaults by accident.
This field improves the stability of velocity based thresholds (it's effectively TSTEP filtering) and it also improves the current regulation stability in stealthchop2 (according to the datasheet).
This field was already set to 1 correctly in the tmc2208/tmc2209 driver code.

Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
2023-03-15 11:09:10 -04:00
Alex Voinea 117c1d42ac tmc2209: Remove duplicate `pdn_disable` initialization
Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
2023-03-15 11:06:24 -04:00