It's possible for the original homing move of an axis to alter the
position of other axes. Make sure those other axes are not requested
to move on a subsequent second home retract move, as that could cause
an error if those other axes have not been homed.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Commit 3814a132 added code to homing.py to call calc_position() - add
that function to manual_stepper.py .
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
If the choice mapping uses integer keys then lookup the config option
using self.getint(). This simplifies the callers and improves the
encoding of the printer.configfile.settings export.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Convert stepper.get_past_commanded_position() to the more general
stepper.mcu_to_commanded_position().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Calculate the "homing position" using the endstop trigger time instead
of the position of the steppers.
This is in preparation for multi-mcu homing.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Added optional PROFILE parameter to allow bed_mesh_calibrate to
save the mesh directly into the provided profile name instead of
default. If omitted, it will be stored in default.
Signed-off-by: Randell L Hodges <rhodges@taxfodder.com>
Changed the bed_screws_adjust command so that it finishes after 4
consecutive accepts. Before if you had 4 screws and adjusted the
first one you had to accept 7 times to finish the bed_screws_adjust.
Signed-off-by: Christian Enderle <mail@chrenderle.de>
The atmega328pb has officially named these pins as PE2 and PE3, so use
that naming scheme instead of the previous Klipper invented names.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Track the offset between driver phase and mcu position. This offset
should be constant as long as neither the driver nor the mcu is reset.
If the offset ever changes, log a warning.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Try to keep the host mcu_position synchronized with the
micro-controller by querying during startup and after every homing
event.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The Trinamic specs aren't consistent with upper vs lower case, which
can be confusing. Improve clarity by using lower case names
consistently in the code. Register names will continue to use all
upper case naming in the code.
Update the SET_TMC_FIELD command to automatically convert field names
to lower case.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
If a shutdown occurs during homing, make sure any follow up errors are
clear that the cause of the error is the shutdown. This suppresses
the confusing "Unable to obtain 'trsync_state' response" messages.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
It is possible for a homing move to not fully complete. Fixup the
trapq history to make processing of the history easier for callers.
Similarly, do not add artificial "null" moves to the trapq history.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Using sc->last_step_clock for the last position marker does not work
properly, because the stepper.py code calls stepcompress_reset() prior
to calling stepcompress_set_last_position(). Fix by passing an
explicit clock to stepcompress_set_last_position().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This fixes the bug introduced by f1091a484b.
The problem is that condition was returning string which
could not be converted to boolean. We solve that by showing
`Start Printing` when `is_active`.
```
ERROR:root:Unhandled exception during run
Traceback (most recent call last):
...
File "/opt/klipper/klippy/extras/display/menu.py", line 117, in eval_enable
return bool(ast.literal_eval(self._enable_tpl.render(context)))
File "/usr/lib/python2.7/ast.py", line 49, in literal_eval
node_or_string = parse(node_or_string, mode='eval')
File "/usr/lib/python2.7/ast.py", line 37, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "<unknown>", line 1
/opt/octoprint/uploads/wait_print.gcode
```
Signed-off-by: Kamil Trzcinski <ayufan@ayufan.eu>
Created two new extended gcodes: Z_OFFSET_APPLY_ENDSTOP, and Z_OFFSET_APPLY_PROBE.
These use the z gcode offset to revise the probe offset, or z endstop position
allowing users to make a frequently used babystepping value permanent without
manual config editing.
Signed-off-by: Ben Eastep <shifting@shifting.ca>
A higher UART baud rate will allow for faster transfers and may result
in more stable operation in general. Increase the baud to 40000 on
32bit MCUs and leave the baud at 9000 baud for 8bit AVR MCUs.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
It looks like the tmc2209 chips have increased uart errors with the
default SENDDELAY of zero. Increasing the SENDDELAY to two seems to
work around this issue.
Reported by @ReXT3D.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Validation passes if either of the following succeeds (in order):
1. Active firmware's raw dictionary changed after update
2. Checksum of firmware.cur matches expected
Additionally, deletes firmware.bin if found after update succeeds.
Signed-off-by: Justin Schuh <code@justinschuh.com>
Document change in behavior of the controller_fan module.
Lookup heater objects in connect() event handler.
Return list of stepper names from stepper_enable.get_steppers().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Allows contoller_fan sections to monitor only certain steppers instead of
all of them, similar to how heaters are currently handled.
Signed-off-by: Sophie Hirn <sophie.hirn@wyvernscale.com>
Set the reqclock on trsync commands to ensure those commands do not
cause 32-bit timer rollover errors. Otherwise, it may result in
"Timer too close" errors.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Do not infer the sercom from the config section name, as that
prevents one from using SPI buses on multiple samd mcus.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Add menuconfig option for stm32f072
* Add support for internal temp of stm32f072
* Share the temperature calculation logic between stm32f0x2 MCUs
Signed-off-by: Erik Henriksson <erikhenrikssn@gmail.com>
- Add dual_carriage abilities for hybrid-corexy and hybrid-corexz
- Introduce the module idex_mode
- Fix add_stepper to the correct rail in hybrid-corexy
Signed-off-by: Fabrice GALLET <tircown@gmail.com>
Before this change, a `CANCEL_PRINT` set a `print_stats` to `paused`
that would later be workaround-ed with `fluidd`/`mainsail` to re-define
`CANCEL_PRINT`.
This sets a proper canceled state, but additionally closes a file
from a `virtual_sdcard` context for `canceled`/`error`, as this is no longer
resumable from this point.
Signed-off-by: Kamil Trzcinski <ayufan@ayufan.eu>
Sometimes an automated filament load is implemented,
but extruder might not always extrude filament.
This adds a flag to check if this operation is possible.
Signed-off-by: Kamil Trzcinski <ayufan@ayufan.eu>
Separate out trsync handling from endstop handling in mcu.py code.
Enable the low-level trdispatch C code.
This is in preparation for multi-mcu homing.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add ability to run C code directly from the low-level socket reading
thread. This enables host based low-latency handlers.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The BED_MESH_OFFSET gcode can be used to apply X and/or Y offsets the the mesh lookup. This allows printers with independent extruders to correct the Z adjustment when changing a tool.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This is a temporary offset applied to the mesh used to fade toward a "target". For clarity, apply the fade offset when the final z calculation is made.
SIgned-off-by: Eric Callahan <arksine.code@gmail.com>
This is useful for macros that'd like to skip QGL if already leveled,
e.g.:
```
{% if not printer.quad_gantry_level.applied %}
QUAD_GANTRY_LEVEL
{% endif %}
```
Signed-off-by: Michael Rose <elementation@gmail.com>
neopixel: add sync param to prevent waking toolhead
dotstar: refactor to match neopixel methods and add sync parameter
Signed-off-by: Paul McGowan <mental405@gmail.com>
Add help description to HELP
Add help description to RESPOND
Add help description to MEASURE_AXES_NOISE, TEST_RESONANCES and SHAPER_CALIBRATE
Add help description to PAUSE, RESUME, CLEAR_PAUSE and CANCEL_PRINT
Add help description to GET_POSITION
Add help description to SET_RETRACTION and GET_RETRACTION
Signed-off-by: Stefan Dej <meteyou@gmail.com>
Pass a print_time instead of a clock to get_past_commanded_position().
Fix calculation on steppers that home and use an inverted direction
pin.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
To support continuous belt printing, add nestable repeat
loop support via an `[sdcard_loop]` module.
Supported G-Code:
- SDCARD_LOOP_BEGIN COUNT=n ; Loop for N times, or infinitely if N is 0
- SDCARD_LOOP_END ; End of loop
- SDCARD_LOOP_DESIST ; Complete all loops without iterating
Marlin M808 compatibility example in `config/sample-macros.cfg`:
- M808 Ln ; Loop for N times, or infinitely if N is 0
- M808 ; End of loop
- M808 K ; Complete all loops without iterating
Added unit tests in test/klippy/sdcard_loop.test
See https://reprap.org/wiki/G-code#M808:_Set_or_Goto_Repeat_Marker
Signed-off-by: Jason S. McMullan <jason.mcmullan@gmail.com>
Allow a larger velocity, accel, and square_corner_velocity than what
is specified in the config file.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The min_stop_interval safety check is fragile and leads to a notable
amount of complexity. Avoid these issues by not programming this
safety check.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
On some kinematics it's possible for the XY position to change
slightly during a probing move. Return back to the original XY
position on a probe lift so each probe attempt starts at the same
nominal position.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This is useful when a saved bed mesh is used to ensure that the bed level
has not drifted too far from where it was when the mesh was created.
Signed-off-by: Johannes Stuettgen <johannes.stuettgen@gmail.com>
Users may define "faulty regions", locations within the mesh where a probed value is unreliable. When bed mesh generates points it will substitute points in faulty regions with up to 4 points nearest to the region. After calibration is complete the Z values at these points will be averaged and assigned to the original value inside the faulty region.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
If a negative number is specified for the RELATIVE_REFERENCE_INDEX parameter clear the internal relative_reference_index.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Start the raise sequence once the endstop notification arrives. This
can reduce the response time as it does not require waiting for the
homing sequence to fully finalize.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
If reset_last_position() is invoked prior to the printer being
"ready", then the transform may not be properly accounted for. Handle
this by calling reset_last_position() when the printer becomes
"ready".
This should fix some "must home first" errors on extrude-only moves.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add a dwell() to the start of drip_move() to ensure that input_shaper
movements scheduled in advance of the nominal move time aren't
scheduled prior to the homing start. (Otherwise the stepper may move
prior to endstop checking, which can corrupt the "no movement"
checks.)
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Only set resend_interval if a mcu_duration is specified. This fixes a
bug introduced in commit 861144d8.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Times longer than 5 seconds may result in a 32bit ticks overflow in
the micro-controller (for fast micro-controllers).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Module which bring support for P2 devices running in connected mode. This enables using a Palette2 directly with Klippy without Octoprint, or without Palette2 plugins for Octoprint which are not functional out of the box with Klipper.
Signed-off-by: Clifford Roche <clifford.roche@gmail.com>
The input shaper can only reduce vibrations by 20x. Therefore,
the best-case achievable vibrations level is max(psd) / 20.
Any vibrations below that level can be ignored for the prupose
of input shaper scoring. This allows tuning script to ignore
wide tails of resonances, because it is not helpful to try to
reduce them with input shaping.
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
In practice, these errors are usually due to problems on the host
computer instead of problems with communication.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
HTU21D sensor class lacked the method `get_report_time_delta` invoked
during watermark control loops. This short fix simply adds that method
in, calling the `self.report_time` attribute created during class
construction.
Signed-off-by: Jon Sanders <jonsan@gmail.com>
This adds support for BMP280 and BME680 sensor ICs,
along with fixing calibration data readout for BME280.
Gas sensor readout for the BME680 is just the raw compensated value.
To get actual meaningful values, more research is needed.
Signed-off-by: Michael Kurz <michi.kurz@gmail.com>
The tmc2660 spec has an ambiguous "SG" field that sometimes refers to
the "stallGuard" flag and sometimes refers to the "SG_RESULT" field.
The tmc2130 and tmc5160 have similar fields that are not ambiguous, so
adopt that naming strategy.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add functionality to support a Filament Motion Sensor for detecting extruder jams as well as runouts. Works by an encoder toggling the switch_pin 0/1 as the filament is pulled through the sensor.
Signed-off-by: Joshua Wherrett <thejoshw.code@gmail.com>
Temporarily postpone loading the CAN module so that moonraker (and
similar) can improve upgrade scripts.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The tmcuart_send command increases cpu usage on the micro-controller.
Should multiple tmcuart_send commands be issued at the same time to a
single AVR micro-controller, it could increase the load to the point
that it introduces a failure. It could also lead to tmcuart_send
transmission errors, which would cause retransmission requests, which
further increase the load.
Track and share mutexes so that only one tmcuart_send command can be
active on a single mcu at a time.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The tmc2130 (and tmc5160) will respond back with the value written
during the next SPI command. Use this feature to verify that the
value written matches the value sent.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
None of the other TMC driver enable SFILT by default and it seems
enabling SFILT may not be ideal for sensorless homing.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Machines that have no heaters produce an error when the idle timeout occurs. This commit fixes this by checking if there are any heaters to turn off.
Signed-off-by: Florian Heinze <florian@heinze.at>
Introduce a heaters.set_temperature() command and call that from
commands that set a heater temperature. This new function calls
toolhead.register_lookahead_callback() so that the idle_timeout gets
notification that activity has occurred.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Make the baud rate an optional parameter to the console.py tool. When
not present, it will default to 250000.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Don't try to detect a "real serial port" in serialhdl.py. Instead,
have the callers invoke either connect_uart(), connect_file(), or
connect_pipe().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add new fields to Command_Templates.md.
Remove unused self.rpm variable.
Use an explicit get_frequency() method in keeping with Klipper's
convention of not "peeking into member variables".
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This adds new config options for fans: 'tachometer_pin' to specify the
GPIO pin, and 'tachometer_ppr' (default 2) to specify the number of
signal pulses per revolution. The rpm is also exposed by get_status for
command templates and the API server. For fast fans (at least 10000
RPM), the polling interval can be shortened using the
'tachometer_poll_interval' option.
There is a new mcu object for a generic edge counter, which repeatedly
polls a GPIO pin and periodically reports the count to the host.
Signed-off-by: Adrian Keet <arkeet@gmail.com>
If `klippy` loses connection to a device, the next `read()` from the
device file descriptor will result in a zero-byte result, i.e. an `EOF`.
Right now this gives a confusing error message, so this simply handles
the special case of `EOF` and outputs a better log message.
Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
When `serialhdl` opens a terminal device it must prevent the device from
becoming the controlling terminal of `klippy`, as such a terminal will
send additional messages to the session leader, e.g. a SIGHUP, which
would kill `klippy`. See e.g. #3981.
pySerial already does this, but for e.g. `klipper_mcu` we were not doing
this ourselves.
On Linux a process must set `O_NOCTTY` when opening any file that could
potentially be a terminal device, to avoid this.
Earlier process daemonization tools prevent this from being an issue by
double forking, but under `systemd` a process must take steps to avoid
opening a controlling terminal.
Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
With commit 53b10d3a the setup of sensorless homing could occur before
the driver was enabled which would cause the reinitialization of the
driver settings to undo the sensorless homing setup.
Use set_field() when setting the sensorless homing registers so that
it wont conflict with a driver init.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Check the status of all Trinamic stepper motor drivers once a second.
If the driver reports an error then invoke a shutdown. Also log any
serious warnings.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Send the full TMC stepper motor driver initialization sequence every
time the driver is enabled.
Don't raise an error on startup if unable to contact a tmc2208/tmc2209
driver. If the driver is still unavailable when it is enabled then a
shutdown will be issued. This allows users to troubleshoot (and
possibly bring up communication to the driver) prior to enabling the
driver.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The tmc2660 appears to send responses as soon as the clk starts
toggling. That means the 20 bit response is at the top of the 24bit
sent message. Also, this implies that RDSEL must already have the
correct value in the prior message.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Where the tmc2660 flags match other drivers, use lowercase so that the
same monitoring code can be used for all the tmc drivers. Also, use
the same field formatters where applicable.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The tmc5160 field formatters were mostly duplicates of the tmc2130 -
add the "reset" field to tmc2130.py so both drivers have similar
reporting.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Refactor the tmc driver implementations so that there is a single
implementation of the SET_TMC_CURRENT command.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Raise a printer.command_error() instead of an mcu.error() if a query
command does not succeed. That error is less likely to result in an
unhandled exception error.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
currently, if there are 2 files on the virtual sd card whose names differ only in
case (eg. MyFile.gcode vs myfile.gcode) the actual file that gets loaded is at
best unpredictable. this patch checks for an exact match before attempting a
case-insensitive one.
Signed-off-by: Andre LeBlanc <andrepleblanc@gmail.com>
The stepper positions will only be in sync after the step generation
code has been flushed. This fixes an "internal error in stepcompress"
error during a SYNC_STEPPER_TO_EXTRUDER command.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This patch adds the ability to daisy-chain multiple tmc2130 and
tmc5160 drivers.
Signed-off-by: Marco D'Alessio <marco@wrecklab.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
If neither rotation_distance nor step_distance is present, then
generate an error saying rotation_distance is needed (instead of an
error about step_distance).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This reverts commit ac61f8b726.
Many temperature sensors are capitalized, so don't make this chaneg to
the bme280.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Some internal code treats the message ids as encoded "variable length
quantities", while other internal code assumes the message id is
always one byte long. Continue using this scheme, but convert the VLQ
users to use the name "msgtag" while the 1-byte users use "msgid".
Increase the number of available msgids from 96 to 127 - the higher
values get encoded as negative "msgtags".
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>