If switching a pin from output low to input with pullup, there is an
intermediate state of either driven high or high impedance without a
pullup. Similarly, when switching from output high to input without a
pullup, there is an intermediate state of either driven low or high
impedence with a pullup. In both cases it is preferable for the
latter transition.
Also, calculate the final setting prior to making any changes to
reduce the time in that intermediate state.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Don't leave the wires in a high output state during setup - leave them
in a high-impedance with pullup state.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The get_temp() code will stop reporting the last temperature of the
heater if there hasn't been any recent temperature updates. However,
on a full mcu communication loss this can cause the verify_heater code
to report a heating error prior to the mcu code reporting the
communication failure. Increase the heater timeout from 5 to 7
seconds to make it more likely the mcu failure is reported first.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
SHT3x would return a read NACK on host retries.
When the MCU receives the I2C CMD, it reads out data.
SHT3x clears the data buffer.
The MCU fails to deliver a response to the host.
The host retries, the device returns NACK,
then the MCU goes into the shutdown state.
Make sure there is at least 0.5s between retries.
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
Some devices can return a read NACK on host retries.
When the MCU receives the I2C CMD, reads out data,
but fails to deliver a response to the host.
The host retries, the device returns NACK,
and the MCU goes into the shutdown state.
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
Avoid using the name "config" as a local register storage variable as
it can be confused with the common "config" configfile reference.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Commit d120a313b incorrectly removed an assignment to self.config - in
this instance the reference was to a local variable not related to the
global configfile storage.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The more.musl.cc site is blocking downloads from all github actions,
which makes it difficult to use that site for the ar100 cross build
toolchain. Convert to the openrisc or1k-elf toolchain as a
replacement.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Update Code_Overview.md to note that the config object should not be
stored after the "config loading phase".
Remove a few inadvertent cases where a 'config' object was stored
in module member variables.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The rp2040 uses a pll vco divider of 6. Prefer setting postdiv1=6 and
postdiv2=1 (instead of the previous postdiv1=3 and postdiv2=2).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add a benchmark for the rp2350 device when running via CAN bus.
Remove the old stm32f042 CAN bus benchmark as that test predates a
number of importnat CAN bus code changes and is likely no longer
accurate.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Completely filling the spi transmit fifo could lead to a situation
where the rx fifo overflows. Make sure not to write past the rx fifo
size.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Completely filling the spi transmit fifo could lead to a situation
where the rx fifo overflows. Make sure not to write past the rx fifo
size.
Also, be sure to wait for the transmission to fully complete before
exiting spi_transfer().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Avoid unnecessary (HAVE_STM32_CANBUS && MACH_STM32xx) checks in
Kconfig. The HAVE_STM32_CANBUS is a helper symbol for all the chips
that support canbus, there's no need to mix it with a check for a chip
that is already known to have canbus.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Validate host provided index prior to accessing memory using that
index.
Also, consistently use a uint8_t for max_sections (to account for
integer overflow issues).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add a filter workbench Jupiter notebook to help printer developers tune filters based on probing data
Signed-off-by: Gareth Farrington <gareth@waves.ky>
Initial setup of Load Cell Probing. This implementation supports triggering from the Load Cell Probe on the MCU. It also supports, optiopnal, filtering of the force signal by sos filter to eliminate drift caused by bowden tubes or other mechanical causes.
Signed-off-by: Gareth Farrington <gareth@waves.ky>
As probes stop supporting `probe:z_virtual_endstop` this class will give users a polite and specific configuration error.
Signed-off-by: Gareth Farrington <gareth@waves.ky>
This is an implementation of the SOS fliltering algorithm that runs on the MCU.
The filter opperates on data in fixed point format to avoid use of the FPU as klipper does not support FPU usage.
This host object handles duties of initalizing and resetting the filter so client dont have to declare their own commands for these opperations. Clients can select how many integer bits they want to use for both the filter coefficients and the filters output value. An arbitrary number of filter sections can be configured. Filters can be designed on the fly with the SciPy library or loaded from another source.
Signed-off-by: Gareth Farrington <gareth@waves.ky>
There have been several optimization to the usb to canbus bridge code
since that statement and it is likely many setups can run a
SHAPER_CALIBRATE with all activity on a single 1mbit canbus.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Added a paragraph about flash loop protection on some motherboards. It has been noted that not all people know about the need to change the bin filename on some stock boards or other methods that may hinder progress.
Signed-off-by: James Hartley <james@hartleyns.com>
The docs aren't particularly clear that if you generate a mesh in our start g-code, you can just use it without additional commands. This is causing issues with support on r/klippers
Signed-off-by: Rowland Straylight <rowlandstraylight@gmail.com>
Add a new G-Code command that can register a manual_stepper as an
additional axis on standard G-Code G1 commands.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add a new add_extra_axes() to support adding additional axes. Once
called, toolhead.get_position() will return a list object with more
than 4 items, and toolhead.move() requires the same size list.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
It's not valid to alter the extruder position from a call to
set_position(), so don't allow callers to attempt that.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Make it more clear that stepper_load_next() has three separate code
paths - one for each of the optimized stepper_event_X() functions.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
In practice the host will not schedule any steps immediately after a
direction change (due to acceleration limits and the host
"step+dir+step filter"). However, there is also no harm in enforcing
a minimum duration in the mcu.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Commit 8faed8d9 made it possible to utilize stepper_event_full() while
utilizing tmc "step on both edges" optimation. That commit would
ensure a minimum step pulse duration, but it did not ensure a minimum
duration between step pin and dir pin changes. Commits 0d27195f and
554ae78d optimized the gpio handling on stm32h7 chips, which could
potentially cause a very small amount of time between step pin and dir
pin changes.
Enforce a minimum time after a step pin update before updating the dir
pin.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Move up the freeing of the stepper_move struct and setting of
s->position in stepper_load_next(). This simplifies the code and
will make it easier to add more logic to this function.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
As per #6923 this PR adds the fact that this config works for the late revision CR-ERA_V1.1.0.3 board as well.
Signed-off-by: James Hartley <james@hartleyns.com>
It has been noted that there are 3 possible boards with 2 possible configs, which we have both of, but this one does not state that it is for the 4.5.2 early kickstarter version. Which was causing some confusion.
Signed-off-by: James Hartley <james@hartleyns.com>
* tests: Added a regression test for generic_cartesian kinematics
* kinematics: An intial implementation of generic_cartesian kinematics
* generic_cartesian: Refactored kinematics configuration API
* generic_cartesian: Use stepper instead of kinematic_stepper in configs
* generic_cartesian: Added SET_STEPPER_KINEMATICS command
* generic_cartesian: Fixed parsing of section names
* docs: Generic Caretsian kinematics documentation and config samples
* generic_cartesian: Implemented multi-mcu homing validation
* generic_cartesian: Fixed typos in docs, minor fixes
* generic_cartesian: Renamed `kinematics` option to `carriages`
* generic_cartesian: Moved kinematic_stepper.py file
* idex_modes: Internal refactoring of handling dual carriages
* stepper: Refactored the code to not store a reference to config object
* config: Updated example-generic-cartesian config
* generic_cartesian: Restricted SET_STEPPER_CARRIAGES and exported status
* idex_modes: Fixed handling stepper kinematics with input shaper enabled
* config: Updated configs and tests for SET_DUAL_CARRIAGE new params
* generic_cartesian: Avoid inheritance in the added classes
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
Increase the internal nominal clock from 8Mhz to 12Mhz - this improves
support for higher chip frequencies.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The rp2040 operates at a fast internal clock with a relatively slow
external timer and dividing down could result in a too small delay.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
There is no reason to use a higher internal PLL frequency. This
change also makes it possible to enable higher clock frequencies on
the stm32h723.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Use the helper functions to enable the peripheral clock instead of
directly manipulating the clock enable bits.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Increase the confirmation rate of heater enable settings. This allows
the mcu to utilize faster internal speeds.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add a function that returns the minimum amount of time the host needs
to reserve for messages to be sent from host to micro-controller.
Add a function that returns the maximum amount of time (in seconds)
that all micro-controllers should be able to schedule future timers
at.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add optimized gpio functions for stm32h7 - caching the ODR register
can notably improve the performance of the gpio_out_toggle() code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Separate homing operations (as called from probe:z_virtual_endstop)
from the normal probe command handling.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Use the normal probe_session_start(), run_probe(),
pull_probed_results(), and end_probe_session() API from
ProbeSessionHelper. This removes the custom probing_move() callback.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Move the HomingViaProbeHelper() instance from ProbeSessionHelper to a
new ProbeEndstopSessionHelper class.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Currently, `MANUAL_STEPPER STOP_ON_ENDSTOP=1` type commands will move
until hitting the endstop, but it will still always consume the total
amount of move time. That is, following moves can't be started until
the total possible time of the homing move is completed.
Implement "drip moves" so that the code only schedules the movement in
small segments. This allows following movements to be scheduled
without a significant delay.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Implement move checking and trapq loading directly from drip_move().
This simplifies the interactions between these components.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Avoid lookahead.flush() calling back into toolhead._process_moves().
Instead, rename toolhead._process_moves() to
toolhead._process_lookahead(), have it call lookahead.flush(), and
consistently use it when flushing the lookahead queue.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
`hall_filament_width_sensor` contains a runout sensor object internally.
This exposes those values in the API status result.
```
SEND: {"id":123,"method":"objects/query","params":{"objects":{"hall_filament_width_sensor":["enabled","filament_detected","is_active","Diameter","Raw"]}}}
GOT: b'{"id":123,"result":{"eventtime":199567.823596603,"status":{"hall_filament_width_sensor":{"enabled":true,"filament_detected":true,"is_active":true,"Diameter":1.9499999999999986,"Raw":6113}}}}'
```
The duplication of `is_active` and `enabled` seems confusing, but both
of these can be independently manipulated by GCode:
```
SEND: {"id":123,"method":"gcode/script","params":{"script":"DISABLE_FILAMENT_WIDTH_SENSOR"}}
GOT: b'{"id":123,"result":{}}'
SEND: {"id":123,"method":"objects/query","params":{"objects":{"hall_filament_width_sensor":["enabled","is_active"]}}}
GOT: b'{"id":123,"result":{"eventtime":199770.446013297,"status":{"hall_filament_width_sensor":{"enabled":true,"is_active":false}}}}'
SEND: {"id":123,"method":"gcode/script","params":{"script":"SET_FILAMENT_SENSOR SENSOR=hall_filament_width_sensor ENABLE=0"}}
GOT: b'{"id":123,"result":{}}'
SEND: {"id":123,"method":"objects/query","params":{"objects":{"hall_filament_width_sensor":["enabled","is_active"]}}}
GOT: b'{"id":123,"result":{"eventtime":199847.927726196,"status":{"hall_filament_width_sensor":{"enabled":false,"is_active":false}}}}'
```
Signed-off-by: Russell Cloran <rcloran@gmail.com>
gpio reset calls are heavy.
gpio state are persistent between calls.
Drop useless calls.
Avoid calls if SDA does not changed.
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
On fast MCU software spi may violate maximally supported by TMC driver rate.
Add dynamic limits to overcome that.
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
Support setting individual options instead of one global option (
WANT_BUTTONS, WANT_TMCUART, WANT_NEOPIXEL, WANT_PULSE_COUNTER,
WANT_HX71X).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This option seems to be confusing ld's region usage checks (builds
that could fit in small chips are being reported as not fitting). The
option was disabled back in commit 4e8674d5 because it showed worse
results. However, recent versions of gcc seem to produce the same
results even if this option is enabled, so change the build to avoid
disabling that option on newer versions of gcc (those that have the
-ffat-lto-objects option - which is needed to ensure
compile_time_requests sections can be extracted with objcopy).
The PRU build is dependent on -fuse-linker-plugin, so enable that
option explicitly in its build.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Don't build the pru binaries directly in the build test cases, instead
use the upstream binaries provided.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Commit 70838797 added support for clearing the homing state in
SET_KINEMATIC_POSITION commands. However, it can be difficult to use
that support as the default for SET_KINEMATIC_POSITION is to set all
axes as homed.
Add a new SET_HOMED parameter to allow one to explicitly request which
axes to consider in a homed state.
Also introduce a CLEAR_HOMED parameter and prefer that to the existing
CLEAR parameter.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The i2c_delay() function did not properly handle counter rollovers.
It also performed an expensive run-time divide.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
A security vulnerability was found in Jinja 3.1.5 . The software is
not impacted by this vulnerability, but there is no harm in updating
to the fixed version.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The output_pin template code has a cache to speed up duplicate
rendering of templates. However, this cache doesn't work if one of
the parameters is a Python list or dictionary. Just disable the cache
in this case.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
It seems both ERRIE and LECIE must be enabled to get hardware error
interrupts. Without this, the rx_error and tx_error reports are
likely to always be zero.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
You can use the 40Mhz crystal oscillator recommended by TI official manual to get the best performance.
refer to: [ldc1612.pdf](https://www.ti.com/cn/lit/ds/symlink/ldc1612.pdf) 7.3.4
Signed-off-by: Xiaokui Zhao <xiaok@zxkxzk.cn>
Add a new "low level option" to allow users to configure if they want
to optimize for Trinamic drivers or traditional stepper motor drivers.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add support for "step on both edges" to the main stepper_event_full()
code. This makes that mode of operation available even when the
micro-controller is not compiled for "optimized step on both edges".
It also enables the custom pulse duration support (step_pulse_ticks)
when in "step on both edges" mode.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Add gram scale features to load_cell
* Convert sensor counts to grams and make this available via unix socket and object status
* Basic GCodes for tearing and reading the load cell
* Guided Calibration
* Diagnostic gcode to check the health of the load cell
* Update load_cell Documentation
* Add API server load_cell/dump_force endpoint
* Update [load_cell] config with calibration fields
* Add G-Code commands for working with load cells
* Add status reference for load_cell objects
Signed-off-by: Gareth Farrington <gareth@waves.ky>
Restores the behavior before #6739 since people seemed to rely on it,
even if the math is not exact.
Signed-off-by: Philippe Daouadi <philippe@ud2.org>
STM32F401 has USART6 on PA12/PA11 and PC7/PC6 with alternate
function mapping AF08. This can be used, for example, to connect
to the Elegoo Neptune 3, where PA12/PA11 are wired to an RJ10 plug
going to the stock screen.
Signed-off-by: Marius Petcu <marius@petcu.me>
The Linux kernel reports a canbus message as transmitted when it gets
the echo frame back. Processing the message prior to sending the echo
frame can lead to odd looking debugging logs (as the response messages
may appear to predate the request messages). This doesn't impact the
Klipper code, but it does make analyzing logs harder. Fix by sending
the echo frame prior to processing the frame.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Don't limit the canbus_notify_tx() wakeup to cases where notify_local
is set - perform the wakeup whenever the host_status field indicates
the main task has work pending.
This fixes a small race condition where the main task could block
sending a usb echo frame, and the canbus_send() code gets called as
the usb bandwidth becomes available but before a usb wakeup
notification is sent. In that situation, the usb code may not issue a
wake event and the echo frames may be delayed.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
With the introduction of "scanning" probes it has
become common for configurations to generate a large
number of points. This can overwhelm both the log and
the pty when new points are generated.
This patch limits the initial points logged to 50. In
addition points are no longer logged or pushed over
the pty when the mesh configuration changes.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
It seems the Linux kernel will consider a maximum size usb packet to
be a transaction that will continue into the next usb packet. It will
thus hold on to the traffic from the first packet until it gets the
next packet. However, if the mcu has no further data to send after
the first packet then the data could get delayed for an extended
period of time.
To avoid this, check for transmissions that could end on a maximum
sized packet and send that data in two packets instead. This avoids
this unusual corner case.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Move the definition of the usb endpoint sizes from usb_cdc.h to
usb_cdc_ep.h . This allows individual boards to override the default
endpoint sizes.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Addition to the board_defs file for the BTT Octopus Max EZ, written and confirmed by discord user Nikki @winningfaith81
Signed-off-by: James Hartley <james@hartleyns.com>
The python-can v3.3.4 package requires setuptools to be an explicit
dependency when run on python v3.12, but there is no single version of
setuptools that runs on all supported versions of python. So, tie
setuptools to python versions 3.12 or later.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
It appears there was a security vulnerability in Jinja v3.1.4 . The
Klipper docs are not impacted by this vulnerability, but it's simple
enough to increment the version to avoid warnings.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
If the low-level canbus stops working then it could become impossible
to send messages to and from the canbus bridge node itself. This can
make it difficult to diagnose canbus problems.
Change the canbus bridge code to detect if message transmits become
stalled for 50+ milliseconds and go into a "discarding" state. In
this discarding state, messages destined for the canbus will be
discarded until the canbus becomes active again. In this discarding
state it will therefore be possible to transmit messages to and from
the canbus bridge node.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add support for a new get_canbus_status command to canserial.c .
Add new canbus_stats.py module that will periodically query canbus
mcus for connection status information.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This significantly reduces the amount of data in the generation 2 garbage collection bucket from the initial startup of klipper.
Signed-off-by: Branden Cash <203336+ammmze@users.noreply.github.com>
Added a temperature sensor configuration for ADS1103, ADS1104, ADS1105, ADS1113, ADS1114 and ADS1115 chips that can be used to add Analog to Digital Conversion capability to machines that don't have that on their own. Like Raspberry Pi's or if more analog input pins are needed than the chip provides like for RP2040. Generally they can be used for any analog input, but the typical use case is for temperature measurement. This code also has been written with temperature measurement in mind and not as a general ADC.
Signed-off-by: Konstantin Koch <korsarnek@gmail.com>
Signed-off-by: Jack Wakefield <jackwakefield@protonmail.com>
Pass a string such as "xyz" to kin.clear_homing_state(). This makes
the parameter a little less cryptic.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Use strings such as "xyz" to specify which axes are to be considered
homing during a set_position() call. This makes the parameter a
little less cryptic.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Call clear_homing_state() on each motor off event. This simplifies
the kinematic classes as they no longer need to register and handle
the motor_off event.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Update the heating code to periodically check that the main thread is
operating properly. This is a mitigation for some rare cases where
the main thread may lockup while the background heater updating code
continues to run. The goal is to detect these rare failures and
disable future heater updates.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
`CLEAR` clears the homing status (resets the axis limits) without turning off
the motors. This is particularly useful when implementing safe Z homing in
`[homing_override]` on printers with multiple independent Z steppers (where
`FORCE_MOVE` can't be used).
Signed-off-by: Dennis Marttinen <twelho@welho.tech>
Use WANT_ADXL345 and WANT_MPU9250 instead of WANT_SENSOR_ADXL345 and
WANT_SENSOR_MPU9250. This makes these definitions similar to the
other accelerometer defintions.
Order menu so accelerometers are close to each other in the menu.
Simplify Makefile as Kconfig already assures a symbol will only be
defined if its dependencies are met.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This adds a new resonance test method that can help if a user has some mechanical problems with the printer.
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
The M23 command has similar requirements for extracting the full
parameter string that M117/M118 have. Use the same code for those
fixups.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Alter gcmd._command in cmd_default if the special M117/M118 handling
is detected. This avoids having to recheck for this condition in
get_raw_command_parameters().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The g-code command parser did not allow three characters to be passed
as parameters to commands (asterisk, semicolon, pound sign). Rework
the parsing code to better leverage the python shlex package so that
these characters can be supported.
In particular, this should allow better support for printing g-code
files that have unusual characters in the filename.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Don't silently drop leading numbers and unusual characters at the
start of a command - for example, don't interpret '99M88' as 'M88'.
Don't silently drop spaces in a command - for example, don't interpret
"M 101" as the command "M101". Doing so will cause other parts of the
code (such as get_raw_command_parameters() ) to not work properly.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Extended g-code command names may only contain A-Z, 0-9, and
underscore, and the first two characters may not be digits.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
When calculating the junction speed between two moves the code checked
for angles greater than 0.999999 or less than -0.999999 to avoid math
issues (sqrt of a negative number and/or divide by zero). However,
these arbitrary constants could unnecessarily pessimize junction
speeds when angles are close to 180 or 0 degrees.
Change the code to explicitly check for negative numbers during sqrt
and to explicilty check for zero values prior to division. This
simplifies the code and avoids unnecessarily reducing some junction
speeds.
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
As a minor math optimization, it's possible to calculate:
.5 * self.move_d * self.accel * tan_theta_d2
using:
self.delta_v2 * .25 * tan_theta_d2
because self.delta_v2 is "2. * self.move_d * self.accel".
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The Fysetc PITB V2 board uses a spi bus config that is supported by the
RP2040 chip, but not klipper, so this adds the relevant config to the file
to allow you to run the tmc5160's on the board via hardware SPI. This
resolves the issue of software spi not working on this board, which I
was unable to fully understand.
I have also seen other users encounter similar bus config issues with
the rp2040 setting up things like accelerometers and such with this
pin layout.
As requested, this also uses the new convention for spi bus naming, while
maintaining the old bus names for compatibility.
Signed-off-by: Jessica Hunt <hunt.jessica@proton.me>
Rewrite chipid.c so that it contains just the USB and canbus id
manipulation code. Move the low-level chipid reading to bootrom.c.
Also, introduce a new bootrom_reboot_usb_bootloader() function in
bootrom.c so that the main.c code does not need to know the specifics
of rebooting into the bootrom.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The rp2350 chip requires a higher internal frequency, so choose a
value that works for both rp2040 and rp2350.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Some versions of the system memcpy() may make unaligned memory
accesses, which can result in a bus fault when accessing the usb dpram
device memory.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Recent versions of the rp2040 sdk no longer contain the elf2uf2 tool.
So, move that code to a new dedicated directory. This is in
preparation for updating the rp2040 sdk version.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Return an empty list instead of an emptry string if no command found.
This improves compatibility within console.py on python3.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit adds automatic calculation support for compensating X and Y axis twist in the axis_twist_compensation module.
Signed-off-by: Jorge Apaza Merma <yochiwarez@gmail.com>
This commit implements support for the Y-axis in the axis_twist_compensation
module. This update enables the module to handle corrections for printers
with a twisted Y rail.
Signed-off-by: Jorge Apaza Merma <yochiwarez@gmail.com>
Commit 9d4ab862 broke support for '#' style comments on the same line
as [include] config directives. Fix by adding back in the check for
comments in _parse_config().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Corrected issue where accelerometer names were incorrectly prefixed
with "adxl345", preventing the selection of other chip types when running TEST_RESONANCES.
Implemented support for selecting the `accel_per_hz` parameter when running TEST_RESONANCES.
docs: Update TEST_RESONANCES + SHAPER_CALIBRATE with missing parameters and bracket corrections
Signed-off-by: Maksim Bolgov <maksim8024@gmail.com>
Don't look for includes in autosave data nor from the internal menu,
display, and temperature configs.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Separate out the low-level parsing code to a new ConfigFileReader()
class.
Separate out the auto-save handling code to a new ConfigAutoSave()
class.
This simplifies the main PrinterConfig() class.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Avoid referring to particular board manufacturers in "make
menuconfig". This information becomes rapidly outdated and is
sometimes viewed by competing manufacturers as being unfair.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
It has been noted over the last six to eight months that some versions of Numpy have issues with the klipper python environment on some machines. This PR introduces a fixed version that is known to work and a small test for people to do to make sure there are no output issues from the get go. These have been pulled from the pinned posts in the discord, from a time when 1.26 was causing issue, and now it seems v2 is also having some issues, hence the change.
Signed-off-by: James Hartley <james@hartleyns.com>
After a probe attempt the toolhead position needs to be recalculated
to the position that the toolhead ultimately halted at. Check that
the position setting wouldn't actually change the internal view of the
stepper motor and log a warning if any skew is detected.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Disable irqs within trsync_do_trigger().
This fixes a bug in ldc1612 - as that code was calling
trsync_do_trigger() without first disabling irqs.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Rename sched_tasks_busy() to sched_check_set_tasks_busy() and change
it to only return true if tasks are active (running or requested) for
two consecutive calls. This makes it less likely that timers will
yield to tasks except when tasks really are notably backlogged.
This also makes it less likely that multiple steppers controlling the
same rail will be interrupted by tasks mid-step. This should slightly
improve the timing, and make it less likely that a halt during
homing/probing will occur with these steppers taking a different
number of total steps.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Added wrapper around sw/hw bus API,
pins.py code will ensure that pins will not mix
between HW/SW buses.
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
* fix type comparison bug that stopped the sensor from initializing
* correct mismatch between docs and code for `sample_rate` (fixed to work same as hx71x)
* add input_mux, pga_bypass and vref options
* update configuration reference & fix typo
Signed-off-by: Gareth Farrington <gareth@waves.ky>
The change in parameter order introduced in commit f4143af4 failed to
update the call _handle_request_restart() code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This solves an issue where the USB directory could exist, but the busnum
file itself may not exist immediately. This was encountered when
flashing a Pico connected to a Raspberry Pi 5.
Signed-off-by: Jack Wakefield <jackwakefield@protonmail.com>
This is similar to 7940a6a7, but using gcrq.send_async_request() for
requests that could be asynchronous.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
If there is a duplicate request it is not necessary to add a 100ms
delay to the next update. Rework the callback signaling to better
report these duplicate updates.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This reverts commit 7940a6a728.
Queing of fan updates via GCodeRequestQueue is only valid if updates
originate from gcode commands. The heater_fan, controller_fan, and
temperature_fan modules could send updates asynchronously. Revert the
fan queuing changes until this issue can be resolved.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add flashsd configuration for Tronxy x5sa and other printers based on
Chitu v6 board.
These boards should support sdio (this is what the schematic details),
however I couldn't get this working from a quick try.
Signed-off-by: Bevan Weiss <bevan.weiss@gmail.com>
Check for overflows in the timer handler instead of checking the
elapsed query time. This should be a better check as it also accounts
for task delays that occur before the query starts.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
As the input values are uint8_t types, any shift may result in value loss.
Explicit promotion to the output type (uint32_t) keeps things safe.
Have also changed the int32_t in ads1220_read_adc to uint32_t, type
promotion and bit manipulation are a bit 'weird' on signed integers, so
keep it as an unsigned to align with following function call parameter type.
Have retained the prior explicit sign extension logic however.
Signed-off-by: Bevan Weiss <bevan.weiss@gmail.com>
Chopping lines from arc can take significant time.
Merge cycles to make the event loop progress and optimize performance.
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
* Fix getting wrong ADC value on PA0
* Fix invalid/unused pin being used as adc channel on STM32H7/G431/L4
Signed-off-by: Nicholas Huskie <huskie@idealfuture.org.cn>
Added links for Fluidd/Mainsail/Octoprint
Added references to overview.md and mkdocs.yml and spelling errors.
Signed-off-by: James Hartley <james@hartleyns.com>
This change follows the same approach as implemented for fan control.
The change removes the move queue flushing when changing servo position,
which does not appear to be necessary. This can be beneficial, for
example, for WS7040-based cooling on IDEX setups where the servo can
be used to control the air flow between the toolheads, with this change
eliminating micro-stutters of the toolhead on servo position adjustment.
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
Previous implementation could crash the idex carriages into each other.
The new code moves the idex carriages together, eliminating this risk
and decreasing the time needed to restore the carriages positions.
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
* Create the load_cell host module skeleton to create the sensors and start taking samples.
* Add support for the HX717 and HX711 ADC sensors.
Signed-off-by: Gareth Farrington <gareth@waves.ky>
- Removed stealth from Extruder to stop under extrusion issues
- Changed Bed sensor to correct one for Ender 3
* Update generic-bigtreetech-skr-mini-e3-v3.0.cfg
Signed-off-by: Miles Pawar <slab.paged-0p@icloud.com>
Add temperature sensor with thermal drift calibration.
Currently only Eddy Current based probes support
calibration.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Rename this method so that it is more distinct from the the common
temperature setup_minmax() method.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Create a new module to help format verbose mcu error messages. Move
the shutdown message formatting to this module. This moves the error
formatting out of the background thread and out of the critical
shutdown code path.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The scan modes provide kinematic XYZ coordinates in the
probe results. These positions may deviate from the requested
positions, which can introduce errors in mesh generation when
transposing the result into the Z matrix.
Rely on the coordinates generated by bed mesh to transpose
the matrix, presuming that points at the same index in the
list match.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Returns current mesh configuration and state. Includes probed and
mesh matrices, saved profiles, current points, and travel paths.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This adds supplemental path generation that implements
"overshoot" when a change of direction is performed
during a rapid scan. This overshoot reduces measurement
error at the extremes of the mesh along the X axis.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
It seems recent arm gcc versions no longer build correctly using the
"--specs=nano.specs --specs=nosys.specs" linker flags. Replace those
linker flags with "-nostdlib -lgcc -lc_nano".
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
When probing in "scan" mode, the toolhead will pause at each position,
but does not descend. This can notably reduce the total probing time.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Support calculating the low-level kinematic toolhead position while
calculating the probed frequency.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Calculate the average frequency from a set of samples, and then
calculate the estimated Z height from that frequency. This may
improve accuracy, as the frequency to Z height is not linear and
averaging after the non-linear transform could bias the results.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Split the sample gathering code out of EddyEndstopWrapper class and
into a new EddyGatherSamples class.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Change run_probe() to gather the results locally, and introduce a new
pull_probed_results() method that returns the previously probed
results. This is in preparation for future probing code that benefits
from batching probe results.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Store the results of each probe attempt in a local "results" variable
(instead of a class variable) when performing "automatic" probes.
This is in preparation for gathering the results in the probing
implementation.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Allow command ids, response ids, and output ids to be either 1 or 2
bytes long. This increases the total number of message types from 128
to 16384.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Reduce the maximum data size from 52 bytes to 51 bytes. This will
enable support for 2-byte response ids.
This change would alter the behavior of the ldc1612 sensor support.
Force an ldc1612 command name change so that users are alerted that
they must rebuild the micro-controller code upon update of the host
code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Update the msgproto.py code so that it can support message ids that
are larger than a single byte. (The host C code in
klippy/chelper/msgblock.c already supports multi-byte ids.)
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Instead of directly calling axis_twist_compensation, send an event
that can perform the necessary updates.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Rework ProbeSessionHelper's multi_probe_start() and multi_probe_end()
to start_probe_session() and end_probe_session(). Ensure all external
callers always invoke these methods prior to running run_probe().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add a get_print_params() method that can extract all the common
probing parameters. Replace get_lift_speed() with this more general
function.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Move the PROBE and QUERY_PROBE commands from ProbeSessionHelper class
to new ProbeCommandHelper class.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Correct the name of "cs_actual" and correct the size on tmc5160.
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Raise a printer.command_error exception if a home_wait() call fails.
This makes it easier to support future types of homing errors.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
It is not clear if DRDY is cleared during a STATUS read (which could
occur from command_query_ldc1612_status() ). So, just check the
"unread conversion" bit when reading data.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
A 40um distance is more likely to be a full step distance on common Z
leadscrews (which often use a rotation distance of 8mm).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Setting of microsteps in the stepper config section has been required
since commit eea0137b. Remove the no longer needed compatibility
code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Make sure thigh is set to zero during sensorless homing, as it would
not make sense for it to be enabled.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
idex_mode would swap the X and dual-carriage rail in some cases
(homing), but not in others. As such, the position calculation was
correct while homing, but incorrect for the second carriage during
normal moves. This commit fixes homing to work without swapped rails,
removes the swapping of rails while homing, and removes the ability to
swap rails (as it is now no longer used). Fix has been tested in a
Hybrid_CoreXY IDEX printer (Voron Double Dragon). Hybrid_CoreXZ has
identical changes and is similar enough that I am confident it will work
as intended. Changes to cartesion seem simple enough, but would benefit
from someone running a couple of tests.
Signed-off-by: Frans-Willem Hardijzer <fw@hardijzer.nl>
Round beds require an odd number of probe points in
order to prevent erroneously truncating the mesh.
The adaptive mesh algorithm did not consider that and
as a result, it was possible to generate adaptive
meshes with even number of probe points.
This change fixes this by increasing the probe point
count by 1 in cases where the adaptive probe points
are even.
Signed-off-by: Mitko Haralanov <voidtrance@gmail.com>
Update the jinja2 version to suppress security warnings. Klipper is
not impacted by the vulnerability, but it is harmless to update the
version.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Some of the alternate pins defined are routed to FDCAN2 instead of
FDCAN1, this commit uses the correct IRQ register and peripheral
clock enable bit to enable FDCAN on those pins.
Signed-off-by: Amr Elsayed from Dropeffect GmbH <code@dropeffect.com>
The Creality CR-6 SE has a strain gauge on its hotend used for z-probing and homing. Currently, running G28 to home all axes puts the hotend just outside of the print bed and thus assumes a wrong homing point for the Z axis.
This change aims to address this issue by setting a safe Z-homing point (in the middle of the print bed) into the Creality CR-6 SE 2020 and 2021-revision config files.
Signed-off-by: Stéphane Lepin <stephane.lepin@gmail.com>
Current command, using the *, results in bad chart output when more than one .csv file exists in the tmp folder. This isn't obvious for people who may not know that the * is a wildcard character.
Signed-off-by: Jonathan Williams <jcw122@gmail.com>
Commit 3f845019 unified the reading of the axes_map configuration
variable, but broke the per-sensor scaling capabilities. Pass the
scale parameters to read_axes_map() so that it can be implemented
per-sensor.
Reported by @Neko-vecter.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Extends the BMxx80 category with support for the BMP388 sensor,
providing temperature and pressure output similar to the existing BMxx80 class of sensors.
Signed-off-by: 林玮 (Jade Lin) <linw1995@icloud.com>
Rename pull_samples() to pull_queue() and rename clear_sample() to
clear_queue(). This avoids confusion between the queue of response
messages and the larger list of samples stored within those messages.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Move the sensor_bulk_data message queuing into the class, and then
rename that class. This simplifies the users of the code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add a new extract_samples() method to the ChipClockUpdater class that
calculates the sample timestamp for each sample in a list of bulk
sensor reports.
Update the adxl345 code to use that extract_samples() code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Provide some background information on the Linux can interface
txqueuelen parameter, errors that it can cause, and considerations
when configuring it.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Some Linux systems do not install ifconfig, while ip should always be
available. So, update the canbus documentation to recommend that.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This reverts commit b029d04668.
The MCU_Stepper class does not have a is_motor_enabled() method, so
the change above results in an internal exception.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Calculate the sensor Z position after the probe halts and return that
as the "probed position". This sensor position provides a more
accurate measurement.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Adding position and enabled in manual_stepper status. Enabled is already available through stepper_enable object. But this makes it more straightforward to access it.
Signed-off-by: Viesturs Zarins <viesturz@gmail.com>
Not all systems (i.e. Nix) repect the standard Linux filesystem hierarchy,
instead relative paths should be used and allowing GCC to rely on it's
builtin search paths.
Signed-off-by: Michael 'ASAP' Weinrich <michael@a5ap.net>
The -iquote tells GCC to only search that path when resolving a quoted
"include" (vs <angle brackets>) which by convention imples a include from
the projects own soruce tree. This prevents a conflict between Klippers
"sched.h" and "gpio.h" and <linux/gpio.h> and glibc <sched.h>.
Signed-off-by: Michael 'ASAP' Weinrich <michael@a5ap.net>
Commit 600e89ae fixed unicode handling on Python3, but broke Python2
support. Use an alternate implementation that should work for both
Python3 and Python2.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The default minimum_cruise_ratio setting does not get populated to the
printer.configfile.settings information due to the way the
max_accel_to_decel backwards compatibility support was implemented.
Slightly rework the config reading so that the default for
minimum_cruise_ratio is populated there.
Reported by @ReXT3D.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
When querying the stepper motion queue, the resulting "interval",
"count", and "add" are already normalized to the correct direction.
That is, the "count" field will be positive if moving in a positive
axis direction and negative if moving in the reverse direction. So,
negating the step_distance field just complicates the readers.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Similar to commit df79893, this allows klipper to use up to
/dev/i2c-14. Similar to before, this limit is arbitrary.
This is required for some other SoCs, which have even
more i2c buses available, e.g. the rk3399:
$ ls -1 /dev/i2c-*
/dev/i2c-0
/dev/i2c-3
/dev/i2c-7
Signed-off-by: Carl Richard Theodor Schneider <dev.github@crtified.me>
Add a new runtime_warning() method that will add a 'runtime_warning'
type message to the printer.configfile.warnings object.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The pid logic can continue after a shutdown, even though the pin
commands sent to the mcu are ignored. However, this behavior can
result in confusing "stats" messages in the log. Explicitly disable
updates after a shutdown event so that the log statistics are more
clear.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The user facing max_accel_to_decel setting is complicated and
confusing. Replace it with a new minimum_cruise_ratio parameter.
Internally this user-facing parameter will calculate the existing
low-level "accel_to_decel" mechanism.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Fixed crashes due to wrong parameter passed to the shaper selection function
and when the custom FREQ_END is specified.
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
The added parameters include square_corner_velocity, shaper frequencies
to optimize, input shapers to test, input shaper damping ratio and
damping ratios to test. All these options can be useful for fine-tuning
the input shapers when the default suggestions generated by the tuning
script are not optimal.
Also the `SHAPER_CALIBRATE` command was modified to pass some of these
parameters to the shaper tuning routine. Specifically, square corner
velocity and the maximum tested frequency are used to adjust shaper
tuning and maximum acceleration recommendations.
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
Remove the deprecated SET_EXTRUDER_STEP_DISTANCE and
SYNC_STEPPER_TO_EXTRUDER commands. Remove the deprecated
shared_heater config option.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
When a ZFADE value is passed to BED_MESH_OFFSET it is used
to adjust how fade is applied. This resolves issues with
fade when SET_GCODE_OFFSET is used during a tool change.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Adaptive meshing avoids saving the mesh after calibration to prevent
users from inadvertently overwriting an existing profile with an
adaptive mesh. This introduced a change in behavior of how
get_status() reports the profile_name, as it can now be an empty
string when a mesh is active.
This patch assigns adaptive meshes a name with a unique postfix.
In addition, it moves profile name tracking from the profile manager
to the ZMesh class.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Do not generate points for the zero_reference_position or faulty_regions
when manual probing is requested.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Adaptive bed mesh allows the bed mesh algorithm
to probe only the area of the bed that is being
used by the current print.
It uses [exclude_objects] to get a list of the
printed objects and their area on the bed. It,
then, modifies the bed mesh parameters so only
the area used by the objects is measured.
Adaptive bed mesh works on both cartesian and
delta kinematics printers. On Delta printers,
the algorithm, adjusts the origin point and
radius in order to translate the area of the
bed being probe.
Signed-off-by: Mitko Haralanov <voidtrance@gmail.com>
Signed-off-by: Kyle Hansen <kyleisah@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Make sure to disable/enable the peripheral to ensure the clock
polarity is properly set prior to a change in CS.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Load the interrupt vector table into ram at startup. This reduces the
chance of a flash cache access causing timing instability.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Place all normal code into ram. This reduces the chance that rp2040
instruction cache misses could cause subtle timing issues.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Avoid calling memset() and memcpy() prior to copying the ram and
clearing the bss. Also, place both ResetHandler() and
reset_handler_stage_two() in an explicit ".text.armcm_boot" linker
section. These changes make it easier to support targets that want to
run all code in ram.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Remove support for changing the cycle time of pwm pins from the
output_pin module. Use a new pwm_cycle_time module that supports
setting dynamic cycle times. This simplifies the output_pin code and
low-level pin update code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Advise users to configure a pwm_tool config section if checking for
maximum mcu duration is required.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Update static_digital_output.py to directly configure static digital
pins. There are no other users of "static" pins, so remove that
support from mcu.py, replicape.py, and sx1509.py. This simplifies the
low-level pin handling code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Remove support for configuring "static" pins in output_pin module. A
"static" pin only saves a few bytes of memory in the micro-controller.
The savings does not justify the increased code complexity.
Deprecate the static_value parameter to warn users. In the interim, a
static_value parameter will set both value and shutdown_value
parameters.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Refactor the low-level "bulk sensor" management code in the mcu. This
updates the sensor_adxl345.c, sensor_mpu9250.c, sensor_lis2dw.c, and
sensor_angle.c code to use the same "bulk sensor" messages. All of
these sensors will now send "sensor_bulk_data" and
"sensor_bulk_status" messages.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
There is a jinja2 security advisory on the current Jinja2 version.
Klipper is not impacted by this advisory (as it does not run jinja2 on
any untrusted data), but there is no harm in updating.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Commit 3d3b87f9 incorrectly removed the call to
note_kinematic_activity(). A call to toolhead.dwell() is not
sufficient to wake up the mcu move queue flushing. The call to
note_kinematic_activity() is needed for that.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Creality released the Ender 5 S1 model in November of 2022. It
has enough hardware differences from the previous models that
that the existing Ender 5 configs are not compatible. This
configuration is based on one provided by Creality that was then
tweaked and modified. I have been using these values (plus some
additional entries) for about 6 months with no issues.
Signed-off-by: Brian Greenberg <grnbrg@grnbrg.org>
There is no harm in enabling flushing for a little longer than
necessary. In contrast, a slight rounding issue causing a message to
not get flushed properly could result in an error. So, extend the
flushing time slightly to avoid potential issues.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
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>
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>
Move overflow detection from mp9250_stop() to
command_query_mpu9250_status(). Currently the host ignores any
contents returned from a stop request, so overflow reporting at that
point has limited utility.
In practice, this change will result in one additional i2c transaction
to the mpu9250 device every 100ms.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The mpu9250 code always reads from the sensor in 48 byte chunks and
always sends an mpu9250_data message immediately after that. Make
that more clear in the querying code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Commit 80a7744b optimized the fifo tracking code. However, it
introduced an error in the time tracking in
command_query_mpu9250_status(). The purpose of that function is to
provide a precise timestamp of the total number of messages produced
at the time of that call. Thus, the returned fifo value needs to be
the fifo level in the chip at the time of the call (not the value read
during previous checks).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
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>
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>
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>
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>
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>
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>
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>
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>
At least STM32G4 requires four ADC clock cycles between hardware
clearing ADCCAL and setting ADEN or the write disappears. Make a
tenacious write attempt.
Signed-off-by: Alex Maclean <monkeh@monkeh.net>
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>
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>
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>
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>
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>
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>
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>
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>
Note that the max_accel parameter is the actual acceleration used in
most movements.
Note that the accel/velocity limits can be changed using the
SET_VELOCITY_LIMIT command.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
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>
Extends the BMxx80 category with support for the older BMP180 sensor, providing temperature and humidity output.
Signed-off-by: VAXXi Popescu <github@vaxxi.net>
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>
In testing with a user on Discord we discovered the sensorless homing thresholds were out of line with what Sovol ships with Marlin. This aligns with their settings.
Signed-off-by: Herb McNew <herb.mcnew@gmail.com>
New configuration for the Sovol SV06 Plus
Initial pass at adding a printer configuration for the Sovol SV06
Plus based on the existing Sovol SV06 config. Updated for the larger
build volume, added filament runout sensor, and removed any references
to the LCD screen since the stock screen doesn't work with Klipper.
Signed-off-by: Herb McNew <herb.mcnew@gmail.com>
Try to make it more clear that Discord is not Discourse, as the two
similarly sounding services are often confused by users unfamiliar
with them.
The Klipper Discourse and Klipper Discord are available for many
topics related to Klipper - reword some sections to make their use
more open.
Avoid referring to the Klipper github repo in this Contact document as
we no longer use Klipper github issues at all.
Remove the table of contents as it is largely redundant for the
document.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Use two different files for the Octopus Pro and Octopus (non-Pro).
The configs are the same in practice, but the difference in version
and naming can lead to confusion.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
In the "Verify endstops" section there is an example of adding an
exclamation point to the pin definition to invert its logic. I
believe the intention in the example is to keep the hardware pull-up
^ and follow it with ! to invert the pin logic, but the ! is missing.
Signed-off-by: Tom Dunn <thomas.dunn@gmail.com>
The atsam USB hardware only requires that the ACM endpoint be endpoint
3. As of commit 11828387 the atsam chips can therefore use the
default USB endpoints.
This will allow CAN bridge support for the SAME70 to function
(upstream host driver has hardcoded endpoints).
Signed-off-by: Alex Maclean <monkeh@monkeh.net>
Recently tested on my ender 5 pro that came from creality with a v1.1.5 board. Works. Tested all endstops, motors, and heaters.
Signed-off-by: Jake Aronleigh <jakestar98@outlook.com>
Wait for two tx packets before startup, and make sure one of those
packets is acked before sending a third tx packet.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
Commit cd8d57c2 added USB double buffering mode on transmits.
However, when enabling double buffering mode, the hardware seems to
always send at least two packets. Spurious transmissions could cause
the Linux gs_usb driver to get confused, which could lead to the can0
device becoming unavailable on restarts. Fix by waiting for two USB
packets to be available before enabling the endpoint.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The bulk out endpoint should not be enabled in tx mode, and the bulk
in endpoint should not be enabled in rx mode.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Prioritize sending responses back to the host over transmitting new
messages from the host. Otherwise, the gs_usb host usb
acknowledgments could saturate the usb bandwidth for extended periods.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Read USB messages arriving from the host into a queue. This makes it
less likely that USB "bulk out" packets will be NAK'ed on the USB bus,
which improves USB bus utilization.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Copy the code for these two functions to their respective callers.
This is in preparation for double buffer support.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add helper functions for manipulating the buffer memory and packet
control registers. This is in preparation for double buffer support.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Implement the usbfs fast buffer switching mechanism on the "bulk in"
endpoint. This can improve the overall USB throughput and bus
utilization.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Implement the usbfs fast buffer switching mechanism on the "bulk out"
endpoint. This can improve the overall USB throughput and bus
utilization.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The usbfs device supports two buffers for each endpoint - typically
one for rx and one for tx. Add support for explicit handling of both
buffers. This is in preparation for improved "double buffering"
support.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Replace the set_stat_x_bits() functions with a single calc_epr_bits()
function. This new function supports setting bits other than the stat
field in the epr register.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add support for can2040_stop()
Add data_state_go_error() helper
Add new can2040_get_statistics() API function
Call report_note_discarding() after setting MS_DISCARD state
Convert report_is_rx_eof_pending() to report_is_not_in_tx()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
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>
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>
PR to add the newer version of the Ender 2 Pro with the CR-FDM-v2.5.54.170 motherboard with the HC3232F460 chip.
Confirmed as working with discord member NyftHeart and using configs from Steve Gotthardt, with his permission to use and submit.
Signed-off-by: James Hartley <james@hartleyns.com>
Commit 594c0243 updated the workflows from actions/stale@v3 to
actions/stale@v8, but did not make the corresponding updates to the
config parameters. This resulted in the closing of some PRs. Update
the config parameters to avoid this regression.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Created a base config for the Creality CR10s Pro v2 as described here: https://www.creality.com/products/cr-10s-pro-v2-3d-printer
This will allow users with this printer to more easily setup Klipper firmware.
Signed-off-by: Peter Kydas <peter@kydas.me>
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>
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>
I am endeavoring to rewrite some of the docs to be more front end agnostic to reflect the different front ends available since these docs were written. I am starting with this one, as it quite often used.
Signed-off-by: James Hartley <james@hartleyns.com>
image->num_blocks is of type unsigned size_t thus unsigned int
or unsigned long int.
%lu specifies a type of long unsigned int. Thus resulting in compiler warning about type mismatch on some systems.
Fix this by printing the value with length modified z.
Signed-off-by: Martin Botka <martin.botka@somainline.org>
- Open log files in text mode,
- Normalize the encoding of tmcuart messages,
- Fix a bug where StatsStream.get_lines() would return None timestamps for lines
before the first Stats line. Timestamps are now back-propagated.
Signed-off-by: Maël Kerbiriou <m431kerbiriou@gmail.com>
It has been discovered on the discord by the user Pizn that the blouch pins are swapped in this config and don't include the ^ pull on the sensor pin.
This has been tested and confirmed by the user.
Signed-off-by: James Hartley <james@hartleyns.com>
Existing `mesh_min` values start probing too far away from the edge.
Additionally `mesh_max` Y value of 197 is out of bed movement range (197 + `bltouch.y_offset` = 237.5) and causes Y stepper to overhit, which can potentially damage the printer in the long run.
Signed-off-by: Aleksandr Ivanov <aux@hexmode.org>
Adds the new BTT SKRat V1.0 controller board to the board_defs for the flash-sdcard.sh tool.
The new board definition was tested by me without any errors.
Signed-off-by: Dennis Kuehn <denniskuehn@online.de>
The reference to `my_nozzle_fan` in these configs could be confusing and misleading, leading users to think it is the parts/print cooling fan, changed to heatbreak_cooling_fan as used in other configs.
Signed-off-by: James Hartley <james@hartleyns.com>
The reference to my_nozzle_fan is misleading and could cause people to skip over the [fan] definition and assume this is the parts/print cooling fan. Alias changed to reflect heatbreak_cooling_fan as used in most configs that have a controllable hotend fan.
Signed-off-by: James Hartley <james@hartleyns.com>
Clarifying the ADXL345 on pi instructions. Previously, the instructions on installing the linux klipper instance were in a confusing place.
Signed-off-by: Adam Kramer <akramer@gmail.com>
This change is required to sucessfully use PA13/PA14 for UART. Otherwise
they function as SWDIO/SWCLK.
Relevant excerpt from the reference manual (translated):
The initial state of PA13, PA14, PA15, PB3, and PB4 ports is that the
JTAG/SWD function is valid after reset. When configuring FSEL[5:0] to
select the function, you need to write 0 to the corresponding bit of the
register PSPCR to invalidate the JTAG/SWD function.
Signed-off-by: Boris-Chengbiao Zhou <bobo1239@web.de>
This fixes serial communication when selecting the PH2/PB10 pins.
The chip datasheet (not reference manual) assigns pins to one of two
communication function groups (`Func_Grp1/2`). Pins in group 1 have
access to USART1/2 while group 2 has access to USART3/4. PH2/PB10 belong
to group 2 so we now correctly use USART3 for them.
Signed-off-by: Boris-Chengbiao Zhou <bobo1239@web.de>
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>
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>
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>
This PR is to remove `move_to_previous: true` from the ender 3 S1 and S1 plus configs. This is a confusing option, it is not really useful on these type of printers and can cause issue to the end user
Signed_off_by; James Hartley <james@hartleyns.com>
Add a new HAVE_LIMITED_CODE_SIZE symbol that enables a menu to select
optional features. This symbol is enabled on chips with small build
sizes.
Replace the HAVE_GPIO_BITBANGING with four new symbols:
WANT_GPIO_BITBANGING, WANT_DISPLAYS, WANT_SENSORS, WANT_SOFTWARE_SPI,
and WANT_SOFTWARE_I2C. This allows users a little more flexibility
when selecting features they need.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add clock speed selection
Add Flash App Address selection
Add alternate serial connection and remove company specific names
Signed-off-by: Steven Gotthardt <gotthardt@gmail.com>
The header documentation currently shows the year the Creality Ender 3 V2 Neo as being the 2020 model. This is likely a copy/paste error from the header of the original Creality Ender 3 V2 config. The year the Creality Ender 3 V2 Neo came out was in 2022 as indicated by the name of this config file. This patch fixes the copy/paste typo by updating the year in the header documentation from 2020 to 2022.
Signed-off-by: Jason W. Thompson <jason@jasonthompson.dev>
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>
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>
Change the default CANbus frequency from 500000 to 1000000. A higher
frequency allows for greater data transfer rates, lower latency of
messages, and should overall be more robust.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Recommend USB to CAN adapter and no longer recommend using the
waveshare rpi hat.
Recommend using allow-hotplug for all USB adapters.
Note bandwidth limitations when using USB to CAN bridge mode.
Note that a USB to CAN mcu is not a USB serial device.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
Disable tx state machine before resetting it
Check for rx message with same id as tx but different payload
Do not use canrx line to alter bit timing of cantx line
Improve bit time synchronization with slow transmitters
Implement tx synchronization to faster transmitters
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
New printer : Longer LK4X configuration
This configuration is based on the one provided by Longer with some tweaks.
Signed-off-by: Thomas Lété <bistory@gmail.com>
On a USB bus reset the controller address needs to be reset to zero.
Otherwise, the device becomes unresponsive after a USB reset and will
remain unresponsive until a power cycle. This often shows up in the
Linux system logs as "device descriptor read/64, error -32" messages.
Make sure USB_INTE_BUS_RESET_BITS is enabled and clear the USB address
on a bus reset.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
There is no need to heavily prioritize the sending of canbus packets
over USB. A single check to flush the incoming canbus packets is
sufficient.
Also, be sure to wake up canserial_notify_tx() even if canhw_send()
blocks.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The canserial code already advertizes a receive window, so the host
should never flood the canserial code. Remove the extra scheduling
checks to simplify the usb_canbus code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
A buffer of only 8 canbus packets is only 64 bytes of data, which
could be exceeded if the usb-to-canbus mcu gets busy doing other work.
Increase the buffer to 32 packets.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The DAINTMSK prevents irqs but does not prevent the status reporting
in the GINTSTS and DAINT fields. Thus, the mask bits should be
checked prior to sending a wakeup notification.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
Correction for table "Recommended connection scheme for I2C (i2c0a) on the RP2040", line 160, to match the correct writing in the Fritzing image shown above, RP2040 pin 36 in place of 39;
Correction of typo in line 346, "pins" in place of "pin"
Signed-off-by: Adrian Rose <adrian@crazyroses.net>
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>
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>
Avoid some gcc warnings by using uint32_t for iterators
Better document the fallthough case statement in crc_bytes()
Fix txpending race from report_line_ackdone()
Make can2040_transmit() multi-cpu atomic
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>
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>
As found on the discord by user Qtin, this board now ships with one of STM32H743 or STM32H723
Example config updated to reflect this. This has been tested on the users board. To note, the H743
bin will flash to the H723 chip, but will not work.
Signed-off-by: James Hartley <james@hartleyns.com>
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>
This adds support for the stock configuration of the V-Minion printer from Ratrig, based on the Octopus v1.1 (STM32F446)
Signed-off-by: Benjamin Lesher <bbro44@protonmail.com>
Realtime programming best practice is to lock realtime code
memory to prevent paging which will lead to unbounded latencies. The
Linux MCU process has well bounded memory and small RAM footprint
so locking the entire process' RAM has no downsides and will improve
behavior when the system comes under memory pressure.
(See bootlin training and Linux Foundation documentation linked below.)
RT process priority ranges from 0-99 (although POSIX only requires 32),
boost MCU process priority to half the max/2 to improve robustness when
the system comes under pressure from other RT Kernel or user processes.
Reference links:
bootlin: https://bootlin.com/doc/training/preempt-rt/preempt-rt-slides.pdf
Linux Foundation: https://wiki.linuxfoundation.org/realtime/documentation/howto/applications/application_base#howto_build_a_simple_rt_application
Signed-off-by: Matthew Swabey <matthew@swabey.org>
Having the controller fan PA14 in the config is important for the stepper drivers not to overheat and skip steps.
Signed-off-by: Robert Lilienthal <13837429+RobLil@users.noreply.github.com>
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>
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>
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>
`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>
Add the default base config for the Ender 3 v2 Neo (as released 2022).
This config also works with the newer D32F303 based 4.2.2 boards.
Signed-off-by: Sam McLeod <sammcj@users.noreply.github.com>
Reading an I2C device from the Linux MCU used a separate write(2)
to select the target register & read(2) to get the value(s). This
implementation uses ioctl(file, I2C_RDWR, ...) to skip a large bus idle
period and extra process sleep by combining them like the stm32.
I2C_RDRW requires I2C_FUNC_I2C flag in the I2C driver. I2C_FUNC_I2C
is defined in:
BCM2835: Pi 1 Models A, A+, B, B+, the Raspberry Pi Zero, the
Raspberry Pi Zero W, and the Raspberry Pi Compute Module 1
BCM2836: Pi 2 Model B
Identical to BCM2835 except Cortex
BCM2837: Pi 3 Model B, later models of the Raspberry Pi 2 Model B,
and the Raspberry Pi Compute Module 3
BCM2837B0: Pi 3 Models A+, B+, and the Raspberry Pi Compute Module 3+
BCM2711: Pi 4 Model B, the Raspberry Pi 400, and the Raspberry Pi
Compute Module 4
RK3xxx: Rockchips SoCs NanoPi, RockPi, Tinker, etc.
SUNXI: H2, H3, etc. Orange Pi
AMLOGIC: S905x, Banana Pi, Odroid, etc.
TEGRA: NVidia Jetson etc.
MediaTek: Several SBCs in other ranges
Signed-off-by: Matthew Swabey <matthew@swabey.org>
Purely esthetic. Make all tmc driver init code similar to one another. The various fields were grouped based on the register which they affect or the function they perform.
Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
Previously, the globalscaler was calculated during the config parsing and set to a fixed value. If the current was changed for any reason after the initialization, only IRUN and IHOLD would be changed. This however caused issues:
- If the new current was lower, then the resolution of the possible current values would be low since there are only 32 IRUN/IHOLD steps.
- If the new current was higher, it wouldn't actually work since IRUN and IHOLD are capped at 31, so it wouldn't be possible to increase the current without increasing globalscaler.
With this commit, the globalscaler is recalculated whenever necessary in order to ensure the correct range of IRUN/IHOLD is used.
Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
Fix filament sensor and remove unneeded config changes in extruder
The filament sensor on the printer used for initial testing had been removed prior to flashing klipper to it. Only a basic test to see it if triggered or not was preformed. It was discovered by someone else doing some testing on another printer that it would frequently pause. This was a simple oversight, assuming it was a runout switch.
Removed section of config related to filament runout switch and replaced with basic config for filament motion so they printer will simply pause when no more motion is detected. Also notated to add CLEAR_PAUSE to start gcode if using this sensor as it will trigger a paused state when loading or unloading filament. If printer is in a paused state at the start of the print, the attempt to pause will cause the printer to rapidly pause and unpause itself.
Removed min_extruder_temp and max_extrude_only_distance from the extruder section, as they were there only for macros on a test system that is not put into this sample config
Signed-off-by: Zachary Welvaert <zwelvaert@gmail.com>
The actual board name is EZBoard V2 without the lite. Renaming the file and correcting the intro text to reflect the actual board name.
Signed-off-by: Anthony Dellett <anthony.dellett@gmail.com>
This is an update to the script that looks for the new systemd service and restarts it if appropriate.
Signed-off-by: James Hartley <james@hartleyns.com>
Use mcu.lookup_command().get_command_tag() instead of
mcu.lookup_command_tag(). This improves error reporting on a protocol
mismatch. It also enables support for a msgtag that is negative.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Adds sdio support for the stm32f4 to allow for SD card flash updates
without power cycling some boards, e.g. BTT Octopus Pro.
Signed-off-by: H. Gregor Molter <gregor.molter@secretlab.de>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The recent PR to change this to say `#!/usr/bin/env python` instead of `#!/usr/bin/env python2` can cause issues on non rpi based OS's where `python` is not mapped to `python3`.
`#!/usr/bin/env python3` should work in both situations.
Signed-off-by: James Hartley <james@hartleyns.com>
Some users may not desire this behavior and others
may wish to initialize to a profile not named default.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Config file contains pin mappings to suit Lulzbot Mini 2 using Lulzbot SingleExtruder(0.5mm) and Lulzbot flexible magnetic bed.
Mini 2 uses Einsy Retro mainboard.
Signed-off-by: Trent Sheather <trent.sheather@gmail.com>
The pca9685_pwm set_pwm() code can be called from a background thread
(when the pin controls a heater). Propagate updates to the main
thread for enable tracking.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Using the CAN2 interface still requires that CAN1 be enabled, and the
filtering hardware is always on the CAN1 hardware block.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The existing sample times are not long enough to reliably sample the
internal temperature sensor. Longer sample times should also improve
results with temperature sensors that have a higher inductance.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Prefer explicitly setting the CR hardware register to defined values
during initialization.
Also, prefer "#if CONFIG_MACH_STM32H7" over bit definitions to make it
clear that the code applies only on stm32h7.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The stm32l412 doesn't have a PLLSAI1 clock and therefore the CKMODE
should not be set to zero.
The stm32h7 chips run the adc at 25mhz, so BOOST should be set to
0b10.
Improve timing comments.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Use the common lookup_clock_line() code to lookup the adc clock lines.
This also enables resets on the adc1/adc2 hardware block.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Not all chips implement hardware oversampling. The software already
implements oversampling, and additional hardware oversampling is
unlikely to improve results. Remove the hardware oversampling to
simplify the code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
On all chips, the JQDIS bit is set and the CONT, RES, ALIGN bits are
clear after a reset. There is no need to program the OVRMOD bit. Use
the same logic across chips to help unify the adc implementation.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Not all chips have the LDORDY flag, while all chips will stabilize in
10us. There is no need for two different implementations as it is
safe to wait 20us on all chips.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Sort using comparison on only first item in list to avoid greater/less
than comparison of stepper objects (which causes an error on Python3).
Reported by discourse user salbang.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
If note_kinematic_activity() has a time far in the future it could
result in a single flush attempt of that time range. Be sure to break
up that range into small chunks using the normal _update_move_time()
mechanism.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
It was possible a note_kinematic_activity() call could increase
last_kin_move_time, but _process_moves() could reset it. Fix by
making sure _process_moves() only ever increases last_kin_move_time.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Later addition of a F429 variant SKR2 was released. Changed btt-skr2 to btt-skr-2-f407 and added a new alias for btt-skr-2-f429
Signed-off-by: James Hartley <james@hartleyns.com>
Issue specific to Python 3, NoneType is being used to compare heartbeat time (actually caused by invalid condition operator), and by returning NoneType in timer functions.
Signed-off-by: Clifford Roche <clifford.roche@gmail.com>
As discussed with user HiitsameAsh on discord, he has confirmed this addition will flash a Fysetc Cheetah V2
Signed-off-by: James Hartley <james@hartleyns.com>
Existing code uses very restrictive build volume constraint checking
with just narrow cone on top of fully cylinder for delta printers.
Code here implements more permissive and still safe build volume
constraint checks.
Signed-off-by: Jan Herich <jan.herich@gmail.com>
Check for the build symbol prior to calling bootloader_request().
Enable the build symbol on rp2040, atsam, and atsamd chips.
This also enables serial bootloader requsts on rp2040, atsam, and
atsamd.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Rename the build symbol. This is in preparation for enabling
HAVE_BOOTLOADER_REQUEST on usb and canbus.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Make all the microstep lookup table registers configurable via the
config file. It also loads the default values.
TMC220x and TMC2660 do not support this feature.
Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
Current Z_OFFSET_APPLY_ENDSTOP command only works for printers
with cartesian architecture which have separate Z axis defined.
But this functionality (persisting Z babystep value to endstops)
is exactly as convinient for delta printers, therefore this
PR implements it.
Signed-off-by: Jan Herich <jan.herich@gmail.com>
Add a check to the start of initial_pins_setup() to make it easier for
gcc to optimize the code if it is not in use.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Rename canserial_send() to canbus_send() and canserial_set_filter() to
canbus_set_filter(). This makes it more clear where the code should
reside.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Rename canbus_send() to canhw_send() and rename canbus_set_filter() to
canhw_set_filter(). This makes it more clear where the code should
reside.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Improve handling of race conditions with hardware updates. This is
the same changes applied to stm32f0_adc.c in commit 88325b6c.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
add G17, G18 and G19 commands to select arc planes
enhance G2/G3 to support arc moves in XY, XZ and YZ planes
Signed-off-by: Andrew Mirsky <andrew@mirsky.net>
Minor fix. The screw labels "back left" and "back right"
where swapped in [screws_tilt_adjust] section.
Signed-off-by: Frank Roth <developer@freakydu.de>
# sensor_pin: PC7 # there is an external pull up so no need in ^
# control_pin: PB5
# speed: 3.0
# samples: 2
# x_offset: -42.0
# y_offset: -1.0
# z_offset: 1.0 # during calibration this line is commented out and new record added at the end of file
[safe_z_home]
home_xy_position: 100, 100 # Change coordinates to the center of your print bed
speed: 50
z_hop: 10 # Move up 10mm
z_hop_speed: 5
[stepper_x]
enable_pin: !PC2
dir_pin: !PG2
step_pin: PC0
microsteps: 16
rotation_distance: 40
endstop_pin: !PA2 # there are external pull ups
position_endstop: 0
position_max: 220 # for A10/M/T / change to 250 for A20/M/T
homing_speed: 40
[stepper_y]
enable_pin: !PA7
dir_pin: !PC4
step_pin: PC6
microsteps: 16
rotation_distance: 40
endstop_pin: !PA6 # there are external pull ups
position_endstop: 0
position_max: 220 # for A10/M/T / change to 250 for A20/M/T
homing_speed: 40
[stepper_z]
enable_pin: !PA5
dir_pin: PA1
step_pin: PA3
microsteps: 16
rotation_distance: 8
#endstop_pin: probe:z_virtual_endstop # uncomment for BLTouch/3DTouch
endstop_pin: !PC7 # comment for BLTouch/3DTouch
position_endstop: 0 # comment for BLTouch/3DTouch
position_max: 230 # for A10/M/T / change to 250 for A20/M/T
position_min: -5
homing_speed: 20
[extruder]
enable_pin: !PB6
dir_pin: PL5
step_pin: PL3
microsteps: 16
rotation_distance: 8 # Needs to be optimized: https://www.klipper3d.org/Rotation_Distance.html#calibrating-rotation_distance-on-extruders
nozzle_diameter: 0.4
filament_diameter: 1.750
heater_pin: PB4
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PK3
min_temp: 0
max_temp: 250
max_extrude_only_distance: 200.0
# Parameters for stock hotend on A10M
# Please recalibrate according to https://www.klipper3d.org/Config_checks.html#calibrate-pid-settings
control: pid
pid_kp: 54.722
pid_ki: 4.800
pid_kd: 155.958
[extruder_stepper extruder_1]
extruder:
enable_pin: !PL1
dir_pin: PL2
step_pin: PL0
microsteps: 16
rotation_distance: 8 # Needs to be optimized: https://www.klipper3d.org/Rotation_Distance.html#calibrating-rotation_distance-on-extruders
[extruder_stepper extruder_2]
extruder:
enable_pin: !PG0
dir_pin: PL4
step_pin: PL6
microsteps: 16
rotation_distance: 8 # Needs to be optimized: https://www.klipper3d.org/Rotation_Distance.html#calibrating-rotation_distance-on-extruders
[heater_bed]
heater_pin: PG5
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PK2
min_temp: 0
max_temp: 120
# Parameters for `SuperPlate` on A10M
# Please recalibrate according to https://www.klipper3d.org/Config_checks.html#calibrate-pid-settings
control: pid
pid_kp: 70.936
pid_ki: 1.785
pid_kd: 704.924
[fan]
pin: PH6
cycle_time: 0.150
kick_start_time: 0.300
# # for GT2560V4.0 with 20pin flat cable toward the display
# [display]
# lcd_type: hd44780
# hd44780_protocol_init: True
# rs_pin: PD1
# e_pin: PH0
# d4_pin: PH1
# d5_pin: PD0
# d6_pin: PE3
# d7_pin: PC1
# encoder_pins: ^PG1, ^PL7
# click_pin: ^!PD2
# for GT2560V4.1B with 12pin flat cable toward the display YHCB2004-06 ver3.0
# the aip31068_spi driver was added to Klipper on 2024-12-02, commit aecb29d2
[display]
lcd_type: aip31068_spi
latch_pin: PE3
spi_software_sclk_pin: PD0
spi_software_mosi_pin: PC1
spi_software_miso_pin: PH7 # any unused pin
encoder_pins: ^PH0, ^PH1
click_pin: ^!PD2
[filament_switch_sensor sensor_e0]
switch_pin: !PK4
[filament_switch_sensor sensor_e1]
switch_pin: !PK5
[filament_switch_sensor sensor_e2]
# switch_pin: !PE2 # for GT2560V4.0
switch_pin: !PF0 # for GT2560V4.1B
# to enable M118 echo command
[respond]
# Specific macros for mixing colors.
# Add in slicer new filament color and in filament start G-Code add desired mixing factor:
# M163 S0 P50 ; set extruder 0 to 50%
# M163 S1 P40 ; set extruder 1 to 40%
# M163 S2 P10 ; set extruder 2 to 10%
# M164 ; commit the mix factors
[gcode_macro M163]
description: M163 [P<factor>] [S<index>] Set a single mix factor (in proportion to the sum total of all mix factors). The mix must be committed to a virtual tool by M164 before it takes effect.