mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-08-08 22:35:17 -06:00
mcp4018: Add SET_DIGIPOT command to mcp4018 implementation (#5737)
Added a SET_DIGIPOT command to the mcp4018 implementation. Previously the mcp4018 was read only, and set at the time of configuration. This allows you to change the value during a print, which is needed for some older printers that need to lower the stepper current during preheating. Signed-off-by: Jake Bordens <jake@allaboutjake.com>
This commit is contained in:
parent
354915d2ad
commit
ae6c16422f
3 changed files with 75 additions and 1 deletions
|
@ -261,3 +261,50 @@ gcode:
|
|||
{% if 'U' in params %}
|
||||
EXCLUDE_OBJECT RESET=1 NAME={params.U}
|
||||
{% endif %}
|
||||
|
||||
######################################################################
|
||||
# G130: Set digital potentiometer value
|
||||
######################################################################
|
||||
|
||||
# The macro below uses the MCP4018 SET_DIGIPOT command to implement
|
||||
# a `G130` as used on classic Mightyboard-based printers such as
|
||||
# The Makerbot Replicator 2/2X.
|
||||
#
|
||||
# The `G130` command can be used to lower the stepper current
|
||||
# during preheating and raise the current again prior to starting
|
||||
# the print. This is necessary for printers with smaller power
|
||||
# supplies that needed all the power to heat the bed.
|
||||
#
|
||||
# This macro requires one or more [mcp4018] configuration sections:
|
||||
# (x_axis_pot, y_axis_pot, z_axis_pot, a_axis_pot, b_axis_pot)
|
||||
#
|
||||
# Example: G130 X20 Y20 Z20 A20 B20 ; Lower stepper Vrefs while heating
|
||||
|
||||
[gcode_macro G130]
|
||||
gcode:
|
||||
M400
|
||||
{% if ('X' in params) and ('mcp4018 x_axis_pot' in printer.configfile.config) %}
|
||||
{% set x_value = params['X']|float %}
|
||||
{% set x_axis_pot_scale = printer.configfile.config["mcp4018 x_axis_pot"].scale|float %}
|
||||
SET_DIGIPOT DIGIPOT=x_axis_pot WIPER={ x_axis_pot_scale * (x_value / 127.0)}
|
||||
{% endif %}
|
||||
{% if ('Y' in params) and ('mcp4018 y_axis_pot' in printer.configfile.config) %}
|
||||
{% set y_value = params['Y']|float %}
|
||||
{% set y_axis_pot_scale = printer.configfile.config["mcp4018 y_axis_pot"].scale|float %}
|
||||
SET_DIGIPOT DIGIPOT=y_axis_pot WIPER={ y_axis_pot_scale * (y_value / 127.0)}
|
||||
{% endif %}
|
||||
{% if ('Z' in params) and ('mcp4018 z_axis_pot' in printer.configfile.config) %}
|
||||
{% set z_value = params['Z']|float %}
|
||||
{% set z_axis_pot_scale = printer.configfile.config["mcp4018 z_axis_pot"].scale|float %}
|
||||
SET_DIGIPOT DIGIPOT=z_axis_pot WIPER={ z_axis_pot_scale * (z_value / 127.0)}
|
||||
{% endif %}
|
||||
{% if ('A' in params) and ('mcp4018 a_axis_pot' in printer.configfile.config) %}
|
||||
{% set a_value = params['A']|float %}
|
||||
{% set a_axis_pot_scale = printer.configfile.config["mcp4018 a_axis_pot"].scale|float %}
|
||||
SET_DIGIPOT DIGIPOT=a_axis_pot WIPER={ a_axis_pot_scale * (a_value / 127.0)}
|
||||
{% endif %}
|
||||
{% if ('B' in params) and ('mcp4018 b_axis_pot' in printer.configfile.config) %}
|
||||
{% set b_value = params['B']|float %}
|
||||
{% set b_axis_pot_scale = printer.configfile.config["mcp4018 b_axis_pot"].scale|float %}
|
||||
SET_DIGIPOT DIGIPOT=b_axis_pot WIPER={ b_axis_pot_scale * (b_value / 127.0)}
|
||||
{% endif %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue