mirror of https://github.com/Desuuuu/klipper.git
chipmisc: Add support for configuring ad5206 digipots
Support an "ad5206" config section so that one can configure the digipots found on Reprap "RAMBo" boards. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
9d75c3b0ca
commit
931811ab59
|
@ -81,3 +81,33 @@
|
|||
# enabled, and then the 'value' parameter can be specified using the
|
||||
# desired amperage for the stepper. The default is to not scale the
|
||||
# 'value' parameter.
|
||||
|
||||
|
||||
# Statically configured AD5206 digipots connected via SPI bus (one may
|
||||
# define any number of sections with an "ad5206" prefix).
|
||||
#[ad5206 my_digipot]
|
||||
#enable_pin:
|
||||
# The pin corresponding to the AD5206 chip select line. This pin
|
||||
# will be set to low at the start of SPI messages and raised to high
|
||||
# after the message completes. This parameter must be provided.
|
||||
#channel_1:
|
||||
#channel_2:
|
||||
#channel_3:
|
||||
#channel_4:
|
||||
#channel_5:
|
||||
#channel_6:
|
||||
# The value to statically set the given AD5206 channel to. This is
|
||||
# typically set to a number between 0.0 and 1.0 with 1.0 being the
|
||||
# highest resistance and 0.0 being the lowest resistance. However,
|
||||
# the range may be changed with the 'scale' parameter (see
|
||||
# below). If a channel is not specified then it is left
|
||||
# unconfigured.
|
||||
#scale:
|
||||
# This parameter can be used to alter how the 'channel_x' parameters
|
||||
# are interpreted. If provided, then the 'channel_x' parameters
|
||||
# should be between 0.0 and 'scale'. This may be useful when the
|
||||
# AD5206 is used to set stepper voltage references. The 'scale' can
|
||||
# be set to the equivalent stepper amperage if the AD5206 were at
|
||||
# its highest resistance, and then the 'channel_x' parameters can be
|
||||
# specified using the desired amperage value for the stepper. The
|
||||
# default is to not scale the 'channel_x' parameters.
|
||||
|
|
|
@ -76,13 +76,6 @@ pin: PH5
|
|||
|
||||
[mcu]
|
||||
serial: /dev/ttyACM0
|
||||
custom:
|
||||
# Initialize digipot
|
||||
send_spi_message pin=PD7 msg=0487 # X = ~0.75A
|
||||
send_spi_message pin=PD7 msg=0587 # Y = ~0.75A
|
||||
send_spi_message pin=PD7 msg=0387 # Z = ~0.75A
|
||||
send_spi_message pin=PD7 msg=00A5 # E0
|
||||
send_spi_message pin=PD7 msg=017D # E1
|
||||
|
||||
[printer]
|
||||
kinematics: cartesian
|
||||
|
@ -91,6 +84,18 @@ max_accel: 3000
|
|||
max_z_velocity: 5
|
||||
max_z_accel: 100
|
||||
|
||||
[ad5206 stepper_digipot]
|
||||
enable_pin: PD7
|
||||
# Scale the config so that the channel value can be specified in amps.
|
||||
# (For Rambo v1.0d boards, use 1.56 instead.)
|
||||
scale: 2.08
|
||||
# Channel 1 is E0, 2 is E1, 3 is unused, 4 is Z, 5 is X, 6 is Y
|
||||
channel_1: 1.34
|
||||
channel_2: 1.0
|
||||
channel_4: 1.1
|
||||
channel_5: 1.1
|
||||
channel_6: 1.1
|
||||
|
||||
# Enable 16 micro-steps on steppers X, Y, Z, E0, E1
|
||||
[static_digital_output stepper_config]
|
||||
pins:
|
||||
|
|
|
@ -76,13 +76,6 @@ hard_pwm: 1
|
|||
|
||||
[mcu]
|
||||
serial: /dev/ttyACM0
|
||||
custom:
|
||||
# Initialize digipot
|
||||
send_spi_message pin=PD7 msg=0487 # X = ~0.75A
|
||||
send_spi_message pin=PD7 msg=0587 # Y = ~0.75A
|
||||
send_spi_message pin=PD7 msg=0387 # Z = ~0.75A
|
||||
send_spi_message pin=PD7 msg=00A5 # E0
|
||||
send_spi_message pin=PD7 msg=017D # E1
|
||||
|
||||
[printer]
|
||||
kinematics: cartesian
|
||||
|
@ -91,6 +84,17 @@ max_accel: 3000
|
|||
max_z_velocity: 25
|
||||
max_z_accel: 30
|
||||
|
||||
[ad5206 stepper_digipot]
|
||||
enable_pin: PD7
|
||||
# Scale the config so that the channel value can be specified in amps
|
||||
scale: 1.56
|
||||
# Channel 1 is E0, 2 is E1, 3 is unused, 4 is Z, 5 is X, 6 is Y
|
||||
channel_1: 1.0
|
||||
channel_2: 0.75
|
||||
channel_4: 0.82
|
||||
channel_5: 0.82
|
||||
channel_6: 0.82
|
||||
|
||||
# Enable 8 micro-steps on steppers X, Y, Z, E0
|
||||
[static_digital_output stepper_config]
|
||||
pins:
|
||||
|
|
|
@ -32,6 +32,31 @@ class PrinterStaticPWM:
|
|||
mcu_pwm.setup_static_pwm(value / scale)
|
||||
|
||||
|
||||
######################################################################
|
||||
# AD5206 digipot
|
||||
######################################################################
|
||||
|
||||
class ad5206:
|
||||
def __init__(self, printer, config):
|
||||
enable_pin_params = pins.get_printer_pins(printer).parse_pin_desc(
|
||||
config.get('enable_pin'))
|
||||
self.mcu = enable_pin_params['chip']
|
||||
self.pin = enable_pin_params['pin']
|
||||
self.mcu.add_config_object(self)
|
||||
scale = config.getfloat('scale', 1., above=0.)
|
||||
self.channels = [None] * 6
|
||||
for i in range(len(self.channels)):
|
||||
val = config.getfloat('channel_%d' % (i+1,), None,
|
||||
minval=0., maxval=scale)
|
||||
if val is not None:
|
||||
self.channels[i] = int(val * 256. / scale + .5)
|
||||
def build_config(self):
|
||||
for i, val in enumerate(self.channels):
|
||||
if val is not None:
|
||||
self.mcu.add_config_cmd(
|
||||
"send_spi_message pin=%s msg=%02x%02x" % (self.pin, i, val))
|
||||
|
||||
|
||||
######################################################################
|
||||
# Setup
|
||||
######################################################################
|
||||
|
@ -41,3 +66,5 @@ def add_printer_objects(printer, config):
|
|||
printer.add_object(s.section, PrinterStaticDigitalOut(printer, s))
|
||||
for s in config.get_prefix_sections('static_pwm_output '):
|
||||
printer.add_object(s.section, PrinterStaticPWM(printer, s))
|
||||
for s in config.get_prefix_sections('ad5206 '):
|
||||
printer.add_object(s.section, ad5206(printer, s))
|
||||
|
|
Loading…
Reference in New Issue