Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds TMC2240 support #1133

Merged

Conversation

pedrolamas
Copy link
Member

Adds support for TMC2240 temperature monitoring.

Stepper disabled

image

Stepper enabled

image

Resolves #1089

Signed-off-by: Pedro Lamas <[email protected]>
@pedrolamas pedrolamas added the FR - Enhancement New feature or request label Aug 3, 2023
@pedrolamas pedrolamas requested a review from matmen August 3, 2023 18:23
@pedrolamas pedrolamas added this to the 1.25 milestone Aug 3, 2023
@pedrolamas pedrolamas force-pushed the pedrolamas/tmc2240-support branch from 217379e to 1b50f6e Compare August 4, 2023 15:58
@pedrolamas pedrolamas merged commit 68b6183 into fluidd-core:develop Aug 4, 2023
@pedrolamas pedrolamas deleted the pedrolamas/tmc2240-support branch August 4, 2023 16:00
@brotherdust
Copy link

@pedrolamas , may I ask why the temperature reporting is so infrequent?

@pedrolamas
Copy link
Member Author

pedrolamas commented Aug 7, 2023

@brotherdust Temperature report from TMC2240 is only available when the driver is enabled, the other times Klipper returns null when we read the temperature - hence why you see in the above screenshots those spaces, as I was just testing with SET_STEPPER_ENABLE STEPPER=stepper_x ENABLE=1 and SET_STEPPER_ENABLE STEPPER=stepper_x ENABLE=0

@brotherdust
Copy link

@pedrolamas , you, sir, are a paragon of kickassery! Thanks for the clarification!

@brotherdust
Copy link

Also,
I updated to latest Klipper and FluidD. Didn't even have to define anything!
image

@brotherdust
Copy link

@pedrolamas , If I can manage to get stepper temperature estimation implemented, it might call for a differentiated label. Perhaps the driver temp should be something like "Stepper [axis] Driver" and the stepper motor could be something like "Stepper [x] Motor (estimated)"? What say you?

@pedrolamas
Copy link
Member Author

Sounds reasonable to me! I guess it will also depend on how the data will be reported by Klipper...

@brotherdust
Copy link

Yeah I was reading over the datasheet a couple of days ago in preparation of this and... the implementation details of this function are pretty vague. I'm not sure if it's actually a hardware or software thing yet. Datasheet would seem to indicate that the nerd knobs are available, but it's something that has to be calculated. I'll have to ask TMC, I guess.

@eldeeb91
Copy link

eldeeb91 commented Aug 8, 2023

I am now on Fluidd 1.25, But I only see the extruder temperature followed by Stepper X:
image
But I have tmc2240 for all the drivers, here is my cfg file:

[include fluidd.cfg]
[include SET_IDLER.cfg]
[virtual_sdcard]
path: /home/pi/printer_data/gcodes
on_error_gcode: CANCEL_PRINT

[idle_timeout]
gcode:
    TURN_OFF_HEATERS
    M84
    SET_LED LED=ExtruderLED GREEN=0.357 RED=0.388 BLUE=0.063
    G4 P500
    SET_LED LED=ExtruderLED GREEN=0 RED=0 BLUE=0 INDEX=8
    G4 P500
    SET_LED LED=ExtruderLED GREEN=0 RED=0 BLUE=0 INDEX=7
    G4 P500
    SET_LED LED=ExtruderLED GREEN=0 RED=0 BLUE=0 INDEX=6
    G4 P500
    SET_LED LED=ExtruderLED GREEN=0 RED=0 BLUE=0 INDEX=5
    G4 P500
    SET_LED LED=ExtruderLED GREEN=0 RED=0 BLUE=0 INDEX=4
    G4 P500
    SET_LED LED=ExtruderLED GREEN=0 RED=0 BLUE=0 INDEX=3
    G4 P500
    SET_LED LED=ExtruderLED GREEN=0 RED=0 BLUE=0 INDEX=2
    G4 P500
    SET_LED LED=ExtruderLED GREEN=0 RED=0 BLUE=0 INDEX=1                        
timeout: 600

[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 3000
max_z_velocity: 10
max_z_accel: 100


[mcu]
serial: /dev/serial/by-id/usb-Klipper_stm32f407xx_3D0034000850475832383220-if00
# serial: /dev/serial0
baud: 115200
restart_method: command

[force_move]
enable_force_move: True

[exclude_object]

[firmware_retraction]
retract_length: 1           #   The length of filament (in mm) to retract when G10 is activated, and to unretract when G11 is activated (but see unretract_extra_length below). The default is 0 mm.
retract_speed: 6           #   The speed of retraction, in mm/s. The default is 20 mm/s.
unretract_extra_length: 0   #   The length (in mm) of *additional* filament to add when unretracting.
unretract_speed: 6         #   The speed of unretraction, in mm/s. The default is 10 mm/s.


[temperature_sensor RPI]
sensor_type: temperature_host
min_temp: 10
max_temp: 100

[temperature_sensor MCU]
sensor_type: temperature_mcu
min_temp: 0
max_temp: 100


[stepper_x]
step_pin: STEP_1
dir_pin: !DIR_1
enable_pin: !EN_1
endstop_pin: !EndStop_1
microsteps: 64
rotation_distance: 40
# position_endstop: -12
position_endstop: -7
position_max: 300
# position_min: -12
position_min: -7
homing_speed: 50

# [tmc2209  stepper_x]
# uart_pin: UART_1
# interpolate = True
# run_current: 0.8
# sense_resistor: 0.110
# stealthchop_threshold: 500
# driver_IHOLDDELAY: 8
# driver_TPOWERDOWN: 20
# driver_TBL: 2
# driver_TOFF: 3
# driver_HEND: 0
# driver_HSTRT: 5
# driver_PWM_AUTOGRAD: True
# driver_PWM_AUTOSCALE: True
# driver_PWM_LIM: 12
# driver_PWM_REG: 8
# driver_PWM_FREQ: 1
# driver_PWM_GRAD: 14
# driver_PWM_OFS: 36
# driver_SGTHRS: 0

[tmc2240 stepper_x]
cs_pin: UART_1
spi_software_sclk_pin: SCLK
spi_software_mosi_pin: MOSI
spi_software_miso_pin: MISO
interpolate = True
run_current: 0.8
# sense_resistor: 0.110
stealthchop_threshold: 500
# driver_IHOLDDELAY: 8
# driver_TPOWERDOWN: 20
# driver_TBL: 2
# driver_TOFF: 3
# driver_HEND: 0
# driver_HSTRT: 5
# driver_PWM_AUTOGRAD: True
# driver_PWM_AUTOSCALE: True
# driver_PWM_LIM: 12
# driver_PWM_REG: 8
# driver_PWM_FREQ: 1
# driver_PWM_GRAD: 14
# driver_PWM_OFS: 36
# driver_SGTHRS: 0

# [temperature_sensor tmc2240_stepper_x]
# sensor_type: temperature_driver
# sensor_driver: tmc2240 stepper_x
# min_temp: 10
# max_temp: 100

# [temperature_sensor stepper_x]
# sensor_type: temperature_driver
# sensor_driver: tmc2240 stepper_x

[stepper_y]
step_pin: STEP_2
dir_pin: DIR_2
enable_pin: !EN_2
endstop_pin: !EndStop_2
microsteps: 64
rotation_distance: 40
position_endstop: -20
position_max: 305
position_min: -20
homing_speed: 50

# [tmc2209  stepper_y]
# uart_pin: UART_2
# interpolate = True
# run_current: 0.8
# sense_resistor: 0.110
# stealthchop_threshold: 500
# driver_IHOLDDELAY: 8
# driver_TPOWERDOWN: 20
# driver_TBL: 2
# driver_TOFF: 3
# driver_HEND: 0
# driver_HSTRT: 5
# driver_PWM_AUTOGRAD: True
# driver_PWM_AUTOSCALE: True
# driver_PWM_LIM: 12
# driver_PWM_REG: 8
# driver_PWM_FREQ: 1
# driver_PWM_GRAD: 14
# driver_PWM_OFS: 36
# driver_SGTHRS: 0

[tmc2240  stepper_y]
cs_pin: UART_2
spi_software_sclk_pin: SCLK
spi_software_mosi_pin: MOSI
spi_software_miso_pin: MISO
interpolate = True
run_current: 0.8
# sense_resistor: 0.110
stealthchop_threshold: 500
# driver_IHOLDDELAY: 8
# driver_TPOWERDOWN: 20
# driver_TBL: 2
# driver_TOFF: 3
# driver_HEND: 0
# driver_HSTRT: 5
# driver_PWM_AUTOGRAD: True
# driver_PWM_AUTOSCALE: True
# driver_PWM_LIM: 12
# driver_PWM_REG: 8
# driver_PWM_FREQ: 1
# driver_PWM_GRAD: 14
# driver_PWM_OFS: 36
# driver_SGTHRS: 0

[stepper_z]
step_pin: STEP_3
dir_pin: !DIR_3
enable_pin: !EN_3
microsteps: 64
rotation_distance: 8
position_max: 390
endstop_pin: probe:z_virtual_endstop

# [tmc2209  stepper_z]
# uart_pin: UART_3
# interpolate = True
# run_current: 0.4
# sense_resistor: 0.110
# stealthchop_threshold: 500
# driver_IHOLDDELAY: 8
# driver_TPOWERDOWN: 20
# driver_TBL: 2
# driver_TOFF: 3
# driver_HEND: 0
# driver_HSTRT: 5
# driver_PWM_AUTOGRAD: True
# driver_PWM_AUTOSCALE: True
# driver_PWM_LIM: 12
# driver_PWM_REG: 8
# driver_PWM_FREQ: 1
# driver_PWM_GRAD: 14
# driver_PWM_OFS: 36
# driver_SGTHRS: 0

[tmc2240  stepper_z]
cs_pin: UART_3
spi_software_sclk_pin: SCLK
spi_software_mosi_pin: MOSI
spi_software_miso_pin: MISO
interpolate = True
run_current: 0.4
# sense_resistor: 0.110
stealthchop_threshold: 500
# driver_IHOLDDELAY: 8
# driver_TPOWERDOWN: 20
# driver_TBL: 2
# driver_TOFF: 3
# driver_HEND: 0
# driver_HSTRT: 5
# driver_PWM_AUTOGRAD: True
# driver_PWM_AUTOSCALE: True
# driver_PWM_LIM: 12
# driver_PWM_REG: 8
# driver_PWM_FREQ: 1
# driver_PWM_GRAD: 14
# driver_PWM_OFS: 36
# driver_SGTHRS: 0

[stepper_z1]
step_pin: STEP_4
dir_pin: !DIR_4
enable_pin: !EN_4
microsteps: 64
rotation_distance: 8
endstop_pin: probe:z_virtual_endstop

# [tmc2209  stepper_z1]
# uart_pin: UART_4
# interpolate = True
# run_current: 0.4
# sense_resistor: 0.110
# stealthchop_threshold: 500
# driver_IHOLDDELAY: 8
# driver_TPOWERDOWN: 20
# driver_TBL: 2
# driver_TOFF: 3
# driver_HEND: 0
# driver_HSTRT: 5
# driver_PWM_AUTOGRAD: True
# driver_PWM_AUTOSCALE: True
# driver_PWM_LIM: 12
# driver_PWM_REG: 8
# driver_PWM_FREQ: 1
# driver_PWM_GRAD: 14
# driver_PWM_OFS: 36
# driver_SGTHRS: 0

[tmc2240  stepper_z1]
cs_pin: UART_4
spi_software_sclk_pin: SCLK
spi_software_mosi_pin: MOSI
spi_software_miso_pin: MISO
interpolate = True
run_current: 0.4
# sense_resistor: 0.110
stealthchop_threshold: 500
# driver_IHOLDDELAY: 8
# driver_TPOWERDOWN: 20
# driver_TBL: 2
# driver_TOFF: 3
# driver_HEND: 0
# driver_HSTRT: 5
# driver_PWM_AUTOGRAD: True
# driver_PWM_AUTOSCALE: True
# driver_PWM_LIM: 12
# driver_PWM_REG: 8
# driver_PWM_FREQ: 1
# driver_PWM_GRAD: 14
# driver_PWM_OFS: 36
# driver_SGTHRS: 0

[extruder]
step_pin: STEP_5
dir_pin: !DIR_5
enable_pin: !EN_5
microsteps: 64
rotation_distance: 3.433476394849785 #200*16/932
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PE5
sensor_type: ATC Semitec 104GT-2
sensor_pin: PC1
#control: pid
#pid_Kp: 14.669
#pid_Ki: 0.572
#pid_Kd: 94.068
min_temp: 0
max_temp: 250
max_extrude_only_distance: 150.0

# [tmc2209 extruder]
# uart_pin: UART_5
# run_current:0.8
# sense_resistor: 0.110
# stealthchop_threshold: 2000
# driver_IHOLDDELAY: 8
# driver_TPOWERDOWN: 20
# driver_TBL: 2
# driver_TOFF: 3
# driver_HEND: 0
# driver_HSTRT: 5
# driver_PWM_AUTOGRAD: True
# driver_PWM_AUTOSCALE: True
# driver_PWM_LIM: 12
# driver_PWM_REG: 8
# driver_PWM_FREQ: 1
# driver_PWM_GRAD: 14
# driver_PWM_OFS: 36
# driver_SGTHRS: 0

[tmc2240  extruder]
cs_pin: UART_5
spi_software_sclk_pin: SCLK
spi_software_mosi_pin: MOSI
spi_software_miso_pin: MISO
interpolate = True
run_current: 0.8
# sense_resistor: 0.110
stealthchop_threshold: 500
# driver_IHOLDDELAY: 8
# driver_TPOWERDOWN: 20
# driver_TBL: 2
# driver_TOFF: 3
# driver_HEND: 0
# driver_HSTRT: 5
# driver_PWM_AUTOGRAD: True
# driver_PWM_AUTOSCALE: True
# driver_PWM_LIM: 12
# driver_PWM_REG: 8
# driver_PWM_FREQ: 1
# driver_PWM_GRAD: 14
# driver_PWM_OFS: 36
# driver_SGTHRS: 0

[heater_bed]
heater_pin: PA0
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC0
#control: pid
#pid_Kp: 325.10
#pid_Ki: 63.35
#pid_Kd: 417.10
min_temp: 0
max_temp: 130

[bed_mesh] 
mesh_min: 35, 55 
mesh_max: 250,265
probe_count: 4, 4 
speed: 80
horizontal_move_z=10

[bltouch]
sensor_pin: ^PC8
control_pin: PA8
x_offset:35
y_offset:-35
#z_offset: 1.430

[safe_z_home]
home_xy_position: 150, 150 # Change coordinates to the center of your print bed
speed: 50
z_hop: 10                 # Move up 10mm
z_hop_speed: 5

[bed_screws]
screw1:30,50
screw1_name: Front_Left

screw2:280,50
screw1_name: Front_Right

screw3:280,280
screw1_name: Back_Right

screw4:30,280
screw1_name: Back_Left

[screws_tilt_adjust]
screw1:10,90
screw1_name: Front_Left

screw2:250,90
screw1_name: Front_Right

screw3:250,290
screw1_name: Back_Right

screw4:10,290
screw1_name: Back_Left

[z_tilt]
z_positions:
    10,170
    250,170
#   A list of X, Y coordinates (one per line; subsequent lines
#   indented) describing the location of each bed "pivot point". The
#   "pivot point" is the point where the bed attaches to the given Z
#   stepper. It is described using nozzle coordinates (the X, Y position
#   of the nozzle if it could move directly above the point). The
#   first entry corresponds to stepper_z, the second to stepper_z1,
#   the third to stepper_z2, etc. This parameter must be provided.
points:
    10,200
    250,200
#   A list of X, Y coordinates (one per line; subsequent lines
#   indented) that should be probed during a Z_TILT_ADJUST command.
#   Specify coordinates of the nozzle and be sure the probe is above
#   the bed at the given nozzle coordinates. This parameter must be
#   provided.
#speed: 50
#   The speed (in mm/s) of non-probing moves during the calibration.
#   The default is 50.
#horizontal_move_z: 5
#   The height (in mm) that the head should be commanded to move to
#   just prior to starting a probe operation. The default is 5.
#retries: 0
#   Number of times to retry if the probed points aren't within
#   tolerance.
#retry_tolerance: 0
#   If retries are enabled then retry if largest and smallest probed
#   points differ more than retry_tolerance. Note the smallest unit of
#   change here would be a single step. However if you are probing
#   more points than steppers then you will likely have a fixed
#   minimum value for the range of probed points which you can learn
#   by observing command output.


[multi_pin dual_fan]
pins: PC14, PB1

[fan]
pin: multi_pin: dual_fan

[filament_switch_sensor runout]
pause_on_runout: True
switch_pin: ^PA4

[heater_fan Heater Fan]
pin: PB0
heater: extruder
heater_temp: 50.0

[controller_fan Electronics]
pin: PD11
#max_power:
#shutdown_speed:
cycle_time:0.05
#hardware_pwm:
#kick_start_time:
#off_below:
#tachometer_pin:
#tachometer_ppr:
#tachometer_poll_interval:
#enable_pin:
#   See the "fan" section for a description of the above parameters.
fan_speed: 0.6
#   The fan speed (expressed as a value from 0.0 to 1.0) that the fan
#   will be set to when a heater or stepper driver is active.
#   The default is 1.0
#idle_timeout:
#   The amount of time (in seconds) after a stepper driver or heater
#   was active and the fan should be kept running. The default
#   is 30 seconds.
#idle_speed:
#   The fan speed (expressed as a value from 0.0 to 1.0) that the fan
#   will be set to when a heater or stepper driver was active and
#   before the idle_timeout is reached. The default is fan_speed.
heater:heater_bed,extruder
stepper: stepper_x, stepper_y, stepper_z, stepper_z1, extruder
#   Name of the config section defining the heater/stepper that this fan
#   is associated with. If a comma separated list of heater/stepper names
#   is provided here, then the fan will be enabled when any of the given
#   heaters/steppers are enabled. The default heater is "extruder", the
# #   default stepper is all of them.



[neopixel ExtruderLED]
pin: PC6
chain_count:8
initial_RED: 0.129
initial_GREEN: 0.259
initial_BLUE: 0.388

[board_pins]
aliases:

    STEP_1=PE3, DIR_1=PE2, EN_1=PE4, EndStop_1=PA15, UART_1=PD5,
    STEP_2=PE0, DIR_2=PB9, EN_2=PE1, EndStop_2=PD2, UART_2=PD7,
    STEP_3=PB5, DIR_3=PB4, EN_3=PB8, EndStop_3=PC8, UART_3=PD4,
    STEP_4=PD6, DIR_4=PD3, EN_4=PB3, UART_4=PD9,
    STEP_5=PD15, DIR_5=PA1, EN_5=PA3, EndStop_5=PE7, UART_5=PD8,
    SCLK= PD0, MOSI= PD14, MISO= PD1,


#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*# [extruder]
#*# control = pid
#*# pid_kp = 18.610
#*# pid_ki = 0.596
#*# pid_kd = 145.162
#*#
#*# [bed_mesh default]
#*# version = 1
#*# points =
#*# 	-0.017500, 0.123125, 0.151875, 0.131875
#*# 	-0.207500, -0.081875, -0.071250, -0.075625
#*# 	-0.238125, -0.075625, -0.030625, -0.080625
#*# 	-0.208125, -0.008125, 0.035000, 0.059375
#*# x_count = 4
#*# y_count = 4
#*# mesh_x_pps = 2
#*# mesh_y_pps = 2
#*# algo = lagrange
#*# tension = 0.2
#*# min_x = 35.0
#*# max_x = 249.98
#*# min_y = 55.0
#*# max_y = 265.0
#*#
#*# [heater_bed]
#*# control = pid
#*# pid_kp = 73.870
#*# pid_ki = 0.886
#*# pid_kd = 1540.190
#*#
#*# [bltouch]
#*# z_offset = 1.770

@pedrolamas
Copy link
Member Author

@eldeeb91 I assume you also upgraded Klipper and Moonraker to the latest versions?

If so, can you upload what you get from these 2 urls:

  • http://<host:port>/printer/objects/query?heaters
  • http://<host:port>/server/temperature_store?include_monitors=true

Note: replace <host:port> above with your moonraker host and port.

@pedrolamas
Copy link
Member Author

pedrolamas commented Aug 8, 2023

@eldeeb91 there's 2 spaces on your config between tmc2240 and the driver name!!

Instead of [tmc2240 extruder] (with two spaces), you should have [tmc2240 extruder], and the same goes for all the other drivers!

@Mosher23
Copy link

Hello,

I have updated fluidd to latest version and was surprised to see StepStick temps in the chart. Great job Pedro!

What are your temps? I have over 100C after homing only.

Screenshot 2023-08-11 at 11 50 01

@pedrolamas
Copy link
Member Author

@Mosher23 I don't have my TMC2240 in production use (I currently only use them for testing purposes with Fluidd) so I don't have a benchmark here... my advice is that you jump onto Klipper Discord and ask around on #general-talk or #stepper-drivers channels.

@eldeeb91
Copy link

Here is a screenshot and it’s printing for 10 hrs:
E24C1ED5-29A9-45B9-9583-904C2B8F38FB

I have also a blower fan to cool down my electronics box.

@Mosher23
Copy link

@eldeeb91 What StepSticks do you use?
I use BTT.

@eldeeb91
Copy link

@Mosher23 I also have BTT, check my configuration on my comment up #1133 (comment).

@brotherdust
Copy link

I have BTT and mine run about 100-110C if the fans aren't on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FR - Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TMC2240: show temperature in graph
4 participants