From 7c964e5fdf99c22c2f2d543a205d97ac6c3366bd Mon Sep 17 00:00:00 2001 From: Lorenzo Date: Tue, 22 Feb 2022 16:28:28 +0100 Subject: [PATCH] dac084S085: SPI DAC DAC084S085 implementation (#5134) Alligator Board Rev2 tested config sample. Add example configuration file for Alligator board rev.3. Signed-off-by: Lorenzo Franco --- config/generic-alligator-r2.cfg | 147 ++++++++++++++++++++++++++++++++ config/generic-alligator-r3.cfg | 135 +++++++++++++++++++++++++++++ klippy/extras/dac084S085.py | 25 ++++++ test/klippy/printers.test | 2 + 4 files changed, 309 insertions(+) create mode 100644 config/generic-alligator-r2.cfg create mode 100644 config/generic-alligator-r3.cfg create mode 100644 klippy/extras/dac084S085.py diff --git a/config/generic-alligator-r2.cfg b/config/generic-alligator-r2.cfg new file mode 100644 index 00000000..427755e9 --- /dev/null +++ b/config/generic-alligator-r2.cfg @@ -0,0 +1,147 @@ +# This file contains common pin mappings for Alligator (Rev.2) board. +# To use this config, the firmware should be compiled for the Arduino +# Due. + +# Remember flash procedure: +# sudo /etc/init.d/alligator-manager --erase +# sudo bossac -e -w -v -b -R -i -p ttyAMA0 klipper.bin +# See alligator github for alligator manager: +# https://github.com/3Dartists/alligator-manager + +# See docs/Config_Reference.md for a description of parameters. + +[static_digital_output DRV8825_microstepping] +pins:PC10 +pins:PC29 +pins:PC19 +pins:PC18 + +[dac084S085 stepper_digipot] +enable_pin: PB14 +spi_bus: spi0 +# Scale the config so that the channel value can be specified in amps. +# (For Alligator v2.0 boards, use 2.50) +scale: 2.50 +# Channel A in this example is X, B is Y, C is Z, D is E0,1,2,3. +channel_A: 1.5 +channel_B: 1.5 +channel_C: 1.5 +channel_D: 1.0 +# channel D will be the current used by all extruders if> 1 + +[stepper_x] +step_pin: PB24 +dir_pin: !PB25 +enable_pin: !PA15 +microsteps: 32 # number of microstep 16, 32 +rotation_distance: 16 +endstop_pin: ^!PC5 +position_endstop: -30 +position_max: 220 +position_min: -30 +homing_speed: 50 + +[stepper_y] +step_pin: PB22 +dir_pin: !PB23 +enable_pin: !PA15 +microsteps: 32 +rotation_distance: 16 +endstop_pin: ^!PC3 +position_endstop: -8 +position_min: -8 +position_max: 220 +homing_speed: 50 + +[stepper_z] +step_pin: PC27 +dir_pin: PC28 +enable_pin: !PA15 +microsteps: 32 +rotation_distance: 4 +endstop_pin: ^!PC2 +position_endstop: 0 +position_max: 240 +position_min: -1 + +[extruder] +step_pin: PC25 +dir_pin: PC26 +enable_pin: !PA15 +microsteps: 32 +rotation_distance: 7 +nozzle_diameter: 0.400 +filament_diameter: 1.750 +heater_pin: PA1 +sensor_pin: PA16 # PA16(near mcu) or PA24(near ethernet) +sensor_type: ATC Semitec 104NT-4-R025H42G +control: pid +pid_kp: 15.572 +pid_ki: 0.446 +pid_kd: 136.064 +min_temp: 0 +max_temp: 270 + +#[extruder1] +#step_pin: PD3 +#dir_pin: !PD2 +#enable_pin: !PA15 +#microsteps: 32 +#heater_pin: PC22 +#sensor_pin: PB25 + +#[extruder2] +#step_pin: PD7 +#dir_pin: !PD6 +#enable_pin: !PA15 +#microsteps: 32 +#heater_pin: PC21 +#sensor_pin: PC28 + +#[extruder3] +#step_pin: PD9 +#dir_pin: !PD8 +#enable_pin: !PA15 +#microsteps: 32 +#heater_pin: PA29 +#sensor_pin: PC5 + +[heater_bed] +heater_pin: PA0 +sensor_type: EPCOS 100K B57560G104F +sensor_pin: PA24 # PA16(near mcu) or PA24(near ethernet) +control: pid +pid_kp: 73.517 +pid_ki: 1.132 +pid_kd: 1193.728 +min_temp: 0 +max_temp: 130 + +[fan] +pin: PA7 + +#[heater_fan fan1] +#pin: PA5 +#heater: extruder + +[output_pin BEEPER_pin] +pin: PB19 +pwm: True +value: 0 +shutdown_value: 0 +cycle_time: 0.1 +scale: 1000 + +[mcu] +serial: /dev/ttyAMA0 + +[printer] +kinematics: cartesian +max_velocity: 300 +max_accel: 1000 +max_z_velocity: 20 +max_z_accel: 100 + +#[bltouch] +#sensor_pin: ^PC6 +#control_pin: PC4 diff --git a/config/generic-alligator-r3.cfg b/config/generic-alligator-r3.cfg new file mode 100644 index 00000000..80543ae2 --- /dev/null +++ b/config/generic-alligator-r3.cfg @@ -0,0 +1,135 @@ +# This file contains common pin mappings for Alligator (Rev.3) board. +# To use this config, the firmware should be compiled for the Arduino +# Due. + +# Remember flash procedure: +# sudo /etc/init.d/alligator-manager --erase +# sudo bossac -e -w -v -b -R -i -p ttyAMA0 klipper.bin +# See alligator github for alligator manager: +# https://github.com/3Dartists/alligator-manager + +# See docs/Config_Reference.md for a description of parameters. + +[static_digital_output DRV8825_microstepping] +pins:PC10 +pins:PC29 +pins:PC19 +pins:PC18 + +[dac084S085 stepper_digipot] +enable_pin: PD2 +spi_bus: spi0 +# Scale the config so that the channel value can be specified in amps. +# (For Alligator v3.0 boards, use 2.50) +scale: 2.50 +# Channel A in this example is X, B is Y, C is Z, D is E0,1,2,3. +channel_A: 1.5 +channel_B: 1.5 +channel_C: 1.5 +channel_D: 1.0 +# channel D will be the current used by all extruders if> 1 + +[stepper_x] +step_pin: PB24 +dir_pin: !PB25 +enable_pin: !PA15 +microsteps: 32 # number of microstep 16, 32 +rotation_distance: 16 +endstop_pin: ^!PC5 +position_endstop: -30 +position_max: 220 +position_min: -30 +homing_speed: 50 + +[stepper_y] +step_pin: PB22 +dir_pin: !PB23 +enable_pin: !PC28 +microsteps: 32 +rotation_distance: 16 +endstop_pin: ^!PC3 +position_endstop: -8 +position_min: -8 +position_max: 220 +homing_speed: 50 + +[stepper_z] +step_pin: PB20 +dir_pin: PB21 +enable_pin: !PA29 +microsteps: 32 +rotation_distance: 4 +endstop_pin: ^!PC2 +position_endstop: 0 +position_max: 240 +position_min: -1 + +[extruder] +step_pin: PB18 +dir_pin: PB19 +enable_pin: !PC27 +microsteps: 32 +rotation_distance: 7 +nozzle_diameter: 0.400 +filament_diameter: 1.750 +heater_pin: PA19 +sensor_pin: PC25 +sensor_type: ATC Semitec 104NT-4-R025H42G +control: pid +pid_kp: 15.572 +pid_ki: 0.446 +pid_kd: 136.064 +min_temp: 0 +max_temp: 270 + +#[extruder1] +#step_pin: PB17 +#dir_pin: !PB14 +#enable_pin: !PD6 +#microsteps: 32 +#heater_pin: PC22 +#sensor_pin: PA29 + +#[extruder2] +#step_pin: PB12 +#dir_pin: !PB13 +#enable_pin: !PD8 +#microsteps: 32 +#heater_pin: PC21 +#sensor_pin: PC28 + +#[extruder3] +#step_pin: PB15 +#dir_pin: !PB16 +#enable_pin: !PD9 +#microsteps: 32 +#heater_pin: PA29 +#sensor_pin: PB25 + +[heater_bed] +heater_pin: PA0 +sensor_type: EPCOS 100K B57560G104F +sensor_pin: PA8 +control: pid +pid_kp: 73.517 +pid_ki: 1.132 +pid_kd: 1193.728 +min_temp: 0 +max_temp: 130 + +[fan] +pin: PA7 + +#[heater_fan fan1] +#pin: PA5 +#heater: extruder + +[mcu] +serial: /dev/ttyAMA0 + +[printer] +kinematics: cartesian +max_velocity: 300 +max_accel: 1000 +max_z_velocity: 20 +max_z_accel: 100 diff --git a/klippy/extras/dac084S085.py b/klippy/extras/dac084S085.py new file mode 100644 index 00000000..bc015dd4 --- /dev/null +++ b/klippy/extras/dac084S085.py @@ -0,0 +1,25 @@ +# SPI DAC DAC084S085 implementation +# +# Copyright (C) 2021 Lorenzo Franco +# +# This file may be distributed under the terms of the GNU GPLv3 license. + +from . import bus + +class dac084S085: + def __init__(self, config): + self.spi = bus.MCU_SPI_from_config( + config, 1, pin_option="enable_pin", default_speed=10000000) + scale = config.getfloat('scale', 1., above=0.) + for chan, name in enumerate("ABCD"): + val = config.getfloat('channel_%s' % (name,), None, + minval=0., maxval=scale) + if val is not None: + self.set_register(chan, int(val * 255. / scale)) + def set_register(self, chan, value): + b1 = (chan << 6) | (1 << 4) | ((value >> 4) & 0x0f) + b2 = (value << 4) & 0xf0 + self.spi.spi_send([b1, b2]) + +def load_config_prefix(config): + return dac084S085(config) diff --git a/test/klippy/printers.test b/test/klippy/printers.test index 03274a51..818bd0b3 100644 --- a/test/klippy/printers.test +++ b/test/klippy/printers.test @@ -95,6 +95,8 @@ CONFIG ../../config/generic-printrboard-g2.cfg # Printers using the sam3x8e DICTIONARY sam3x8e.dict +CONFIG ../../config/generic-alligator-r2.cfg +CONFIG ../../config/generic-alligator-r3.cfg CONFIG ../../config/generic-archim2.cfg CONFIG ../../config/generic-radds.cfg CONFIG ../../config/generic-ruramps-v1.3.cfg