Allow the callers of process_batch() to directly inspect the gcode
mutex. Those callers can then directly invoke run_script().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Factor out _calc_mean() and _calc_median() functions and call from
both run_probe() and cmd_PROBE_ACCURACY().
This also fixes a subtle error in the run_probe() median function - on
some kinematics the x and y position can change on a z move so the x
and y should be taken from the z probe values actually used.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This changes the config file so that the configuration of
multi-samples is now done in the [probe] (and [bltouch]) section
instead of the various delta, bed_mesh, z_tilt, etc. config sections.
With this change, PROBE and PROBE_CALIBRATE commands now also utilize
multi-sampling.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Now that the extruder, display, heater_fan, output_pin, and servo
classes have get_status() methods, it is no longer necessary to
override them in the menu code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
These action commands prevent Octoprint from sending extra gcodes that can interfere with Klipper's pause/resume control.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Prior to the BLTouch v3, the recommended command times were 700us
(pin_down), 1200us (touch_mode), 1500us (pin_up), 1800us (self_test),
and 2200us (reset). However, the recommended Marlin timing (via servo
"angles") was 647.111, 1162.667, 1472, 1781.333, and 2193.778us.
As of the BLTouch v3, the recommended times are now 650, 1165, 1475,
1780, and 2190us. The v3 continues to recommended Marlin timings of
647.111, 1162.667, 1472, 1781.333, and 2193.778us.
Update Klipper to use the new BL-Touch v3 recommended timing. The new
timings are required for the BL-Touch v3 and they are closer to what
the Marlin firmware has historically used.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
"The z_tilt_adjust was coded to require 3 points because the original
intent was for railcore-xl and voron. Since then, a number of users
have started using z_tilt_adjust for prusa i3 style printers with dual z
steppers. That's fine, but we just haven't gotten around to removing
the superfluous check in the code." -- Kevin O'Connor
remove that check.
Signed-off-by: John "Fess" Fessenden <fess@fess.org>
Factor out minimum required points check for ProbePointsHelper
in prep for setting different values for quad_gantry_level
and z_tilt_adjust
Signed-off-by: John "Fess" Fessenden <fess@fess.org>
"Feed Filament" menu item value was off-screen that made this item useless. So I changed its name to just "Feed". Users shall easily guess that this item is for filament feeding because this item is located in "Filament" menu.
Signed-off-by: Alexander Fadeev <alfsoft@gmail.com>
safety feature that prevents quad_gantry_level from trying to do a
correction that might break things - if your probe fires early for
whatever reason and tries to do an 8mm correction in one corner instead
we abort if a correction is over a configurable limit by default 4mm
configurable via `max_adjust` parameter in the config
Signed-off-by: John "Fess" Fessenden <fess@fess.org>
In particular trying to keep the output from a single quad_gantry_level
so that it fits in the octoprint terminal window without the need to
scroll
Signed-off-by: John "Fess" Fessenden <fess@fess.org>
Adding gcode command for setting the target temperature of temperature_fan.
Example gcode: SET_TEMPERATURE_FAN_TARGET temperature_fan=chamber target=35.0
Signed-off-by: Martin Nowroth <madnoth@gmail.com>
The parameter to the M221 command should be the ratio of the nominal to
measured filament area, rather than the ratio of the diameters. Since we
are taking the ratio, most of the area calculation cancels out.
Fixes#1535.
Signed-off-by: Len Trigg <lenbok@gmail.com>
The servo pins (P9_14/P9_16) are muxed to the SOCs hardware PWM unit
driven by a 13MHz GP timer. They have to be driven by the linux host
mcu. This commits adds hardware PWM support using the linux sysfs
user space interface.
The servo pins can be specified as "replicape:servo0" and
"replicape:servo1". Removes the "servo0_enable", "servo1_enable"
configuration parameters.
Fixes#1105.
Signed-off-by: Janne Grunau <janne-3d@jannau.net>
Adjust the HEND default, which was faulty after the the fields update, remove disallowance of setting CS
Signed-off-by: Florian Heilmann <Florian.Heilmann@gmx.net>
Adds parameter for bed meshes to be adjusted relative to a probed point
during calibration. This allows the probe z offset to be ignored for
probes that are not stable over time (for example, the thermal drift of
inductive probes). An endstop other than the probe is then necessary to
determine the bed-nozzle offset.
Signed-off-by: Matt Baker <baker.matt.j@gmail.com>
menu: Show current positions based on gcode positions
Added "move_[xyze]pos" properties to the "gcode" object for use in menus.
The new properties track the toolhead's position in gcode coordinates,
taking gcode and bed leveling offsets into account.
This position is equal to the value returned by M114 gcode.
Changes the move menus to show current position based on gcode
position. This allows gcode offsets and bed leveling offsets
to be taken into account, and prevents unexpected toolhead
movements when moving it using the menu.
Signed-off-by: Robert Konklewski <nythil@gmail.com>
The z_adjust offset provided to adjust_steppers is calculated given the
steppers adjust exactly according to the given x_adjust/y_adjust. As the
algorithm eliminates an offset that is common to all steppers, this offset
must be taken into account in the final correction.
Signed-off-by: Arne Jansen <arne@die-jansens.de>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The z_offset calculation should have been calculated from the probe
height to the measured bed position.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Use the field names from the trinamic specification. This makes the
field similar to all the other driver_XXX config options.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
sense_resistor is now a mandatory parameter for tmc2660 blocks. Duet2 users should use a value of 0.051
Signed-off-by: Florian Heilmann <Florian.Heilmann@gmx.net>
Don't immediately raise an error if the heating_gain check fails.
Instead, just transition to the normal max_error check. This should
make the code less likely to raise an error should the heater have a
slow approach to the target temperature.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Allow the first check_gain_time interval to only require a
heating_gain relative to the lowest observed temperature during that
interval. This makes the code less likely to raise a spurious error
when the heater is enabled while the heater temperature is dropping.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Don't reset the error counter if the reported temperature is
significantly above the target temperature. This may help catch cases
where the temperature sensor reports random values.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This implementation includes a BaseSensor class that all underlying sensor implementations should subclass.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Support reading a "gcode_id" parameter from heater/sensor config
sections.
Signed-off-by: Douglas Hammond <wizhippo@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Instead of directly turning off motors, heaters, and fans from
gcode.py, raise a new event and allow the heater, fan, and toolhead to
handle the event as needed.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The 'bed_shape' option has been removed. The user will enter a 'bed_radius' if they have a round be, otherwise they should enter 'min_point' and 'max_point'. When the bed is round the user should supply a 'round_probe_count' option, otherwise just 'probe_count'.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Use the field helper to simplify the bit manipulation in the driver.
This also enables the extended DUMP_TMC output.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Raise a printer.config_error() on an invalid register_command() call.
This error is easier to handle for the vast majority of callers.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Implementation of "PROBE_ACCURACY" to measure the maximum, minimum,
average and standard deviation of a probe.
Signed-off-by: Rui Caridade <rui.mcbc@gmail.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Support added for filament diameter sensor. Sample configuration parameters added to example-extras.cfg.
Signed-off-by: Mustafa YILDIZ <mydiz@hotmail.com>
Adds the ability to register a custom/generic heater through a new extra called heater_generic.
This takes a gcode_id that is reported by M105. Adds a new command to set the temperature for any heater using the syntax:
SET_HEATER_TEMPERATURE HEATER=<heater_name> TARGET=<target_temp>
Signed-off-by: John Jardine <john@gprime.net>
- When using absolute extrusion the gcode position e-axis position is now captured on PAUSE and restored in RESUME with a call to the G92 handler.
- Add a get_status() function that returns a dictionary with an 'is_paused' key.
- Do not allow consective calls to PAUSE or RESUME to exectue. Also do not allow a RESUME to executed without a previous PAUSE.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
In the normal case, a regular pin_up command should be sufficient to
raise the probe. (Should the regular pin_up fail, the code can issue
a "reset" command during the retry.)
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Commit c3efcd9c moved the config_spi setup to a build_config callback.
It's also necessary to move the config_thermocouple to a build_config
callback as well.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add helper function for reading current, microsteps, and stealthchop
settings from the config file. Use these helpers in both the tmc2130
and tmc2208 modules.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Move these helper functions to the FieldHelper class so that they can
be used by other Trinamic drivers.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Report values of TMC2208 register fields in DUMP_TMC command to help in
tuning and diagnostics.
This also adds functions to refer to register fields by name for TMC drivers
and register mappings for TMC2208.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Signed-off-by: Dmitry Frolov <dmitry.frolov@gmail.com>
Stopping the connect sequence can make it difficult to get the bltouch
out of an error state. Allow the connect to proceed, ideally if the
bltouch stays in an error state it will be detected during the first
probe attempt.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
I noticed Octoprint was disconnecting after a while, and after reading the logs, I came across this error:
```
Unhandled exception during run
Traceback (most recent call last):
File "/home/pi/klipper/klippy/klippy.py", line 171, in run
self.reactor.run()
File "/home/pi/klipper/klippy/reactor.py", line 176, in run
g_next.switch()
File "/home/pi/klipper/klippy/reactor.py", line 203, in _dispatch_loop
timeout = self._check_timers(eventtime)
File "/home/pi/klipper/klippy/reactor.py", line 82, in _check_timers
t.waketime = t.callback(eventtime)
File "/home/pi/klipper/klippy/extras/idle_timeout.py", line 62, in timeout_handler
return self.check_idle_timeout(eventtime)
File "/home/pi/klipper/klippy/extras/idle_timeout.py", line 59, in check_idle_timeout
return self.transition_idle_state(eventtime)
File "/home/pi/klipper/klippy/extras/idle_timeout.py", line 35, in transition_idle_state
logging.exception("idle timeout gcode execution")
NameError: global name 'logging' is not defined
```
I therefore added the missing import.
Signed-off-by: Samori Gorse <samori.gorse+github@gmail.com>
This module adds PAUSE and RESUME gcodes that can programatically determine if the gcode is printing from virtual sd or over the serial connection. It also captures the current toolhead position and gcode feedrate on pause, and recovers that position and feedrate on resume.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
- Add is_active() member function to return the active printing status of the virtual sdcard
- M27 now reports current file position when file has been opened. See http://marlinfw.org/docs/gcode/M027.html
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Add support for performing linear interpolation between a set of
measured temperature/resistance pairs.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Move the low-level PrinterADCtoTemperature() class from thermistor.py
to adc_temperature.py and use it from the Linear() class.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
We want the duration of each command to be an exact multiple of
SIGNAL_PERIOD. The durations might not be exact if the bltouch is on
a secondary mcu. Account for this in send_cmd().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Rework the undocumented test_sensor_pin config option into a
pin_up_touch_mode_reports_triggered option and document it.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Query the bltouch state during the pin_up command to try and verify
that the probe does actually retract. This may be useful to detect if
the bltouch enters into an "error" state.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The BLTouch is more accurate when probing in "pin_down" mode than
"touch_mode" (at least on some hardware). Rework the code to use that
mode.
When probing in pin_down mode, the BLTouch can go into an error state
if a pin_up is not sent immediately after a touch signal. Rework the
pin_up code to reduce the time it takes to transmit the command.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Introduce a sync_print_time() method and update send_cmd() to track
the duration of bltouch commands.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Verify that there is always some movement during a probing operation.
This is normally done by the homing.py code (via its verify_movement
check), but that check may not be enabled when z_virtual_endstop is
used. So, always enable the check in the bltouch.py code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Separate the thermistor math from the heater temperature callback
system. This may make it easier for debugging.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Whenever a stepper driver or a heater becomes active, it is desirable to turn on a fan cooling the associated parts on the controller board. This module implements such a fan that turns on whenever a stepper or specified heater turns on, decelerates to a configurable speed when all of the watched parts turn off, and returns to an off-speed, when a user-defined timeout is met.
Signed-off-by: Nils Friedchen <Nils.Friedchen@googlemail.com>
Convert all users of the printer_state("connect") handler to register
a "klippy:connect" event handler instead.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Convert all users of the printer_state("ready") handler to register a
"klippy:ready" event handler instead.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Convert all users of the printer_state("shutdown") handler to register
a "klippy:shutdown" event handler instead.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
- changes that make easier to use menu as module UI
- new helper method for delayed callbacks
- method for getting the menu instance from display
- new action for sending menu:action events
- allow_without_selection option for cards
Signed-off-by: Janar Sööt <janar.soot@gmail.com>
- long press with timer (button release is not needed anymore)
- initial support for edit mode long press gcode
Signed-off-by: Janar Sööt <janar.soot@gmail.com>
The sam3 i2c code and the linux code use a 7-bit i2c address, while
the avr, lpc176x, and samd21 i2c code uses an 8-bit address with the
least significant bit always zero. A similar issue occurred in the
host code (sx1509.py and replicape.py use 7-bit addresses while
uc1701.py and mcp4451.py use 8-bit addresses).
Consistently use 7-bit addresses in all the code. This breaks
compatibility between host and mcu software, so make a change to the
config_i2c command to force users to synchronize software updates.
This also breaks common Smoothieboard configs, so update the mcp4451
code to validate the i2c_address.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
As discussed in #1057, the default loading- and unloading procedure does
not behave as expected. Setting the extruder to relative mode fixes this.
Signed-off-by: Nils Friedchen <Nils.Friedchen@googlemail.com>
If an SPI device is shared among many devices, then all the device's
CS pins should be set high prior to setting up the clk pin.
(Otherwise, there's a chance a device could interpret the clk pin
setup as part of a transmission.)
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
I have made one change to `gcode.py` to support quoted parameter
values.
I have added support for the basic `M118` command (see
https://reprap.org/wiki/G-code#M118:_Echo_message_on_host). I have
also added a `RESPOND` command that takes extended parameters.
`ECHO` might be a better name than `RESPOND` but is already defined
in `gcode.py`.
Signed-off-by: Alec B. Plumb <alec@etherwalker.com>
Allow an arbitrary gcode_id to be supplied during heater setup. This allows future extras to register additional IDs beyond B, and T#.
Signed-off-by: John Jardine <john@gprime.net>
It appears some bltouch "clones" do not report the probe as triggered
when put in "touch mode" while the pin is raised. Add a config option
to allow users to disable the test.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Some of the bltouch implementations may only respond to a probe event
with a 5ms pulse. Make sure to check the signal pin at least every
millisecond to ensure no signal is lost.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
To deal potential z scaling when fade is enabled, a fade_target option has been introduced. This option may either be set to 0.0 or any z position within the range of the mesh. A value of 0.0 will result in previous behavior, where z adjustment phases out until no further adjustment is added. A non-zero value will phase out adjustment until the target has been reached, after which the rest of the print will be offset along the z axis by the fade_target. By default the fade_target will be calculated as an average of the mesh.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Due to various potential issues with fading out z-adjustment, it is better to disable by default and allow users to opt-in.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>