makerbase-mks / MKS-SKIPR

MKS SKIPR is an all-in-one board launched by Makerbase for running Klipper. It integrates the RK3328 SOC running the Klipper host and the STM32F407VET6 MCU responsible for executing specific machine actions. It meets the use of most 3D printers.
GNU General Public License v3.0
88 stars 14 forks source link

[BUG] stepper Z not stopping after hitting endstop while homing #43

Open prondz opened 1 year ago

prondz commented 1 year ago

When I home an axis the motor moves until the endstop (mechanical endstop) is triggered, bumps back, axis X and Y is ok, but in axis Z the motor doesn't stop moving in the direction of the endstop.

[mcu]
serial: /dev/ttyS0
restart_method: command

[stepper_x]
step_pin:PC14
dir_pin:PC13
enable_pin:!PC15
microsteps: 16
rotation_distance: 40
full_steps_per_rotation:200  #set to 400 for 0.9 degree stepper
endstop_pin:PA14
position_min: 0  
position_endstop: 0
position_max: 220
homing_speed:50
homing_retract_dist:5
homing_positive_dir:false
step_pulse_duration:0.000008

[stepper_y]
step_pin:PE5
dir_pin:PE4
enable_pin:!PD14
microsteps:16
rotation_distance: 40
full_steps_per_rotation:200  #set to 400 for 0.9 degree stepper
endstop_pin:PA15
position_min: 0
position_endstop:0
position_max:220
homing_speed:50
homing_retract_dist:5
homing_positive_dir:false
step_pulse_duration:0.000008

[stepper_z]
step_pin:PE1
dir_pin:PE0
enable_pin: !PE2
microsteps: 16
rotation_distance: 8
full_steps_per_rotation: 200
gear_ratio: 80:16
endstop_pin:probe:z_virtual_endstop ## PB12 for Z-max; endstop have'!' is NO

##  Z-position of nozzle (in mm) to z-endstop trigger point relative to print surface (Z0)
##  (+) value = endstop above Z0, (-) value = endstop below
##  Increasing position_endstop brings nozzle closer to the bed
##  After you run Z_ENDSTOP_CALIBRATE, position_endstop will be stored at the very end of your config
# position_endstop: 0
position_max: 245
position_min: 0
homing_speed: 8
second_homing_speed: 3

[extruder]
step_pin:PB5
dir_pin:!PB4
enable_pin:!PB6
microsteps:16
rotation_distance: 34.406   #Bondtech 5mm Drive Gears
gear_ratio: 50:17
full_steps_per_rotation: 200    #200 for 1.8 degree, 400 for 0.9 degree
nozzle_diameter: 0.400
filament_diameter: 1.750
min_temp: 0
max_temp: 260
heater_pin: PB1
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC1
max_power: 1.0
control : pid  
pid_Kp: 21.527
pid_Ki: 1.063
pid_Kd: 108.982
pressure_advance: 0.00
pressure_advance_smooth_time: 0.150
max_extrude_cross_section:20
instantaneous_corner_velocity: 1.000
max_extrude_only_distance: 50.0
max_extrude_only_velocity:5000
max_extrude_only_accel:2000
step_pulse_duration:0.000004

[heater_bed]
heater_pin: PD12
sensor_type: Generic 3950
sensor_pin: PC3
max_power: 1.0
control = pid
pid_Kp: 79.79
pid_Ki: 10.82
pid_Kd: 392.19
min_temp: 0
max_temp: 530

#fan for printed model FAN0
[fan]
pin: PA2

#fan for hotend FAN1
#[heater_fan my_nozzle_fan]
[heater_fan fan1]
pin: PA1
shutdown_speed: 1

#fan for control board FAN2
#[heater_fan my_control_fan]
[heater_fan fan2]
pin: PA0
shutdown_speed: 1

####################################################################
#   Homing and Gantry Adjustment Routines
#####################################################################
[idle_timeout]
timeout: 3600

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

# [quad_gantry_level]
# gantry_corners:
#   -58,-7
#     308,318
# ##    Probe points
# points:
#     10,10
#     10,200
#     250,200
#     250,10
# speed: 80
# horizontal_move_z: 10
# retries: 1
# retry_tolerance: 0.05
# max_adjust: 30

#####################################################################
#   Probe
#####################################################################
[probe]
pin:PB15
x_offset: 0
y_offset: 25.0
z_offset: 0.55
speed: 10.0
samples: 2
samples_result: median
sample_retract_dist: 3.0
samples_tolerance: 0.05
samples_tolerance_retries: 1

[printer]
kinematics: cartesian
max_velocity: 500
max_accel: 3000
max_z_velocity: 25
max_z_accel: 30
# max_accel_to_decel: 4000
# square_corner_velocity: 2.0

########################################
# TMC UART configuration
########################################

[tmc2209 stepper_x]
uart_pin: PE6
run_current: 0.8
hold_current: 0.5
interpolate: True
stealthchop_threshold: 400

[tmc2209 stepper_y]
uart_pin: PE3
run_current: 0.8
hold_current: 0.5
interpolate: True
stealthchop_threshold: 400

[tmc2209 stepper_z]
uart_pin: PB7
run_current: 0.8
hold_current: 0.5
interpolate: True
stealthchop_threshold: 120

[tmc2209 extruder]
uart_pin: PB3
run_current: 0.8
hold_current: 0.5
interpolate: True
stealthchop_threshold: 400

########################################
# EXP1 / EXP2 (display) pins
########################################

[board_pins]
aliases:
    # EXP1 header
    EXP1_1=PB2,  EXP1_3=PE11, EXP1_5=PD9, EXP1_7=PE15, EXP1_9=<GND>,
    EXP1_2=PE10, EXP1_4=PD10, EXP1_6=PD8, EXP1_8=PE7,  EXP1_10=<5V>,
    # EXP2 header
    EXP2_1=PA6, EXP2_3=PE9, EXP2_5=PE8, EXP2_7=PD13,  EXP2_9=<GND>,
    EXP2_2=PA5, EXP2_4=PA4, EXP2_6=PA7, EXP2_8=<RST>, EXP2_10=<3.3v>
    # Pins EXP2_1, EXP2_6, EXP2_2 are also MISO, MOSI, SCK of bus "ssp1"

######################################################################
# MKS Mini 12864v3.0 (with neopixel backlight leds)
######################################################################

[display]
lcd_type: uc1701
cs_pin: EXP1_3
a0_pin: EXP1_4
rst_pin: EXP1_5
contrast: 63
encoder_pins: ^EXP2_5, ^EXP2_3
click_pin: ^!EXP1_2
## Some micro-controller boards may require an spi bus to be specified:
#spi_bus: spi
## Alternatively, some micro-controller boards may work with software spi:
spi_software_miso_pin: EXP2_1
spi_software_mosi_pin: EXP2_6
spi_software_sclk_pin: EXP2_2

[output_pin beeper]
pin: EXP1_1

[neopixel fysetc_mini12864]
pin: EXP1_6
chain_count: 3
color_order: RGB
initial_RED: 1.0
initial_GREEN: 1.0
initial_BLUE: 0.0

# See the MKS Lcd Config path file for definitions of common LCD displays.

[mcu rpi]
serial: /tmp/klipper_host_mcu

[adxl345]
cs_pin: rpi:None
spi_bus: spidev0.2

[resonance_tester]
accel_chip: adxl345
probe_points:
    100, 100, 20  # an example

[input_shaper]
shaper_freq_x: 68.4
shaper_type_x: mzv
shaper_freq_y: 45.6
shaper_type_y: mzv

[virtual_sdcard]
#path:/home/mks/uploads
path: ~/gcode_files

[pause_resume]

[gcode_macro CANCEL_PRINT]
description: Cancel the actual running print
rename_existing: CANCEL_PRINT_BASE
gcode:
  TURN_OFF_HEATERS
  CANCEL_PRINT_BASE

[display_status]

[gcode_macro G32]
gcode:
    BED_MESH_CLEAR
    G28
    QUAD_GANTRY_LEVEL
    G28
prondz commented 1 year ago

Its working now

# boards. To use this config, the firmware should be compiled for the
# stm32f407. When running "make menuconfig", select the 48KiB
# bootloader, and enable "Serial for communication" and select the "on USART1 PA10/PA9"

# The "make flash" command does not work on the MKS SKIPR. Instead,
# after running "make", copy the generated "out/klipper.bin" file to a
# file named "mks_skipr.bin" on an SD card and then restart the
# MKS SKIPR with that SD card.

# See docs/Config_Reference.md for a description of parameters.
[mcu]
# The hardware use USART1 PA10/PA9 connect to RK3328
# serial: /dev/serial/by-id/usb-Klipper_stm32f407xx_4D0045001850314335393520-if00
serial: /dev/ttyS0
restart_method: command

[heater_bed]
heater_pin: PD12
sensor_type: Generic 3950
sensor_pin: PC3
max_power: 1.0
control = pid
pid_Kp: 79.79
pid_Ki: 10.82
pid_Kd: 392.19
# pid_Kp: 54.027
# pid_Ki: 0.770
# pid_Kd: 948.182
min_temp: 0
max_temp: 530

#fan for printed model FAN0
[fan]
pin: PA2

#fan for hotend FAN1
#[heater_fan my_nozzle_fan]
[heater_fan fan1]
pin: PA1
shutdown_speed: 1

#fan for control board FAN2
#[heater_fan my_control_fan]
[heater_fan fan2]
pin: PA0
shutdown_speed: 1

####################################################################
#   Homing and Gantry Adjustment Routines
#####################################################################
[idle_timeout]
timeout: 3600

[safe_z_home]
home_xy_position: 10,20
speed: 50
z_hop: 10
z_hop_speed: 5

[printer]
kinematics: cartesian
max_velocity: 500
max_accel: 3000
max_z_velocity: 25
max_z_accel: 30
# max_accel_to_decel: 4000
# square_corner_velocity: 2.0
#####################################################################
# LED Control
#####################################################################

#[output_pin caselight ](Use PA9)
##  Chamber Lighting - In 5V-RGB Position
#pin: PC5
#pwm: true
#shutdown_value: 0
#value:100
#cycle_time: 0.01

########################################
# TMC UART configuration
########################################

[stepper_x]
step_pin: STEP_1
dir_pin: DIR_1
enable_pin: !EN_1
endstop_pin: tmc2209_stepper_x:virtual_endstop
rotation_distance: 40
microsteps: 64
full_steps_per_rotation: 200
#gear_ratio:
step_pulse_duration: 0.000000100
position_min: 0
position_endstop: 0
position_max: 220
homing_speed: 50
homing_retract_dist: 0
#homing_retract_speed:
#second_homing_speed:
#homing_positive_dir:

[tmc2209  stepper_x]
uart_pin: UART_1
diag_pin : ^EndStop_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: 70

[stepper_y]
step_pin: STEP_2
dir_pin: DIR_2
enable_pin: !EN_2
endstop_pin: tmc2209_stepper_y:virtual_endstop
rotation_distance: 40
microsteps: 16
full_steps_per_rotation: 200
#gear_ratio:
step_pulse_duration: 0.000000100
position_min: 0
position_endstop: 0
position_max: 220
homing_speed: 25
homing_retract_dist: 0
#homing_retract_speed:
#second_homing_speed:
#homing_positive_dir:

[tmc2209  stepper_y]
uart_pin: UART_2
diag_pin: ^EndStop_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: 45

[stepper_z]
step_pin: STEP_3
dir_pin: !DIR_3
enable_pin: !EN_3
endstop_pin: tmc2209_stepper_z:virtual_endstop
# endstop_pin:!EXP1_7
rotation_distance: 8
microsteps: 64
full_steps_per_rotation: 200
#gear_ratio:
step_pulse_duration: 0.000000100
position_min: 0
position_endstop: 0
position_max: 245
homing_speed: 5
homing_retract_dist: 0
#homing_retract_speed:
#second_homing_speed:
#homing_positive_dir:

[tmc2209  stepper_z]
uart_pin: UART_3
diag_pin: EndStop_3
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: 35

[extruder]
step_pin: STEP_4
dir_pin:DIR_4
enable_pin:!EN_4
microsteps:16
rotation_distance: 32
# gear_ratio: 50:17
full_steps_per_rotation: 200
nozzle_diameter: 0.400
filament_diameter: 1.750
min_temp: 0
max_temp: 260
heater_pin: PB1
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC1
max_power: 1.0
control : pid  
pid_Kp: 21.527
pid_Ki: 1.063
pid_Kd: 108.982
pressure_advance: 0.00
pressure_advance_smooth_time: 0.150
max_extrude_cross_section:20
instantaneous_corner_velocity: 1.000
max_extrude_only_distance: 50.0
max_extrude_only_velocity:5000
max_extrude_only_accel:2000
step_pulse_duration:0.000004

[tmc2209 extruder]
uart_pin: UART_4
run_current: 0.8
hold_current: 0.5
interpolate: True
stealthchop_threshold: 400

########################################
# EXP1 / EXP2 (display) pins
########################################

[board_pins]
aliases:
    # EXP1 header
    EXP1_1=PB2,  EXP1_3=PE11, EXP1_5=PD9, EXP1_7=PE15, EXP1_9=<GND>,
    EXP1_2=PE10, EXP1_4=PD10, EXP1_6=PD8, EXP1_8=PE7,  EXP1_10=<5V>,
    # EXP2 header
    EXP2_1=PA6, EXP2_3=PE9, EXP2_5=PE8, EXP2_7=PD13,  EXP2_9=<GND>,
    EXP2_2=PA5, EXP2_4=PA4, EXP2_6=PA7, EXP2_8=<RST>, EXP2_10=<3.3v>,
    # Pins EXP2_1, EXP2_6, EXP2_2 are also MISO, MOSI, SCK of bus "ssp1"
    # See the sample-lcd.cfg file for definitions of common LCD displays.
    STEP_1=PC14, DIR_1=PC13, EN_1=PC15, EndStop_1=PA14, UART_1=PE6,
    STEP_2=PE5, DIR_2=PE4, EN_2=PD14, EndStop_2=PA15, UART_2=PE3,
    STEP_3=PE1, DIR_3=PE0, EN_3=PE2, EndStop_3=PB15, UART_3=PB7,
    STEP_4=PB5, DIR_4=PB4, EN_4=PB6, EndStop_4=PA13, UART_4=PB3,
    STEP_5=PD6, DIR_5=PD5, EN_5=PD7, EndStop_5=PC5, UART_5=PD4,
    STEP_6=PD2, DIR_6=PD1, EN_6=PD3, EndStop_6=PB14, UART_6=PD0,
    STEP_7=PC7, DIR_7=PC6, EN_7=PC8, UART_7=PD15

# Some alternate glyphs for use with 128x64 LCDs. These are used by
# adding them to your printer.cfg.

# See docs/Config_Reference.md for a description of parameters.

######################################################################
# MKS Mini 12864v3.0 (with neopixel backlight leds)
######################################################################

[display]
lcd_type: uc1701
cs_pin: EXP1_3
a0_pin: EXP1_4
rst_pin: EXP1_5
contrast: 63
encoder_pins: ^EXP2_5, ^EXP2_3
click_pin: ^!EXP1_2
## Some micro-controller boards may require an spi bus to be specified:
#spi_bus: spi
## Alternatively, some micro-controller boards may work with software spi:
spi_software_miso_pin: EXP2_1
spi_software_mosi_pin: EXP2_6
spi_software_sclk_pin: EXP2_2

[output_pin beeper]
pin: EXP1_1

[neopixel fysetc_mini12864]
pin: EXP1_6
chain_count: 3
color_order: RGB
initial_RED: 1.0
initial_GREEN: 1.0
initial_BLUE: 0.0

# See the MKS Lcd Config path file for definitions of common LCD displays.

[mcu rpi]
serial: /tmp/klipper_host_mcu

[adxl345]
cs_pin: rpi:None
spi_bus: spidev0.2

[resonance_tester]
accel_chip: adxl345
probe_points:
    100, 100, 20  # an example

[input_shaper]
shaper_freq_x: 68.4
shaper_type_x: mzv
shaper_freq_y: 45.6
shaper_type_y: mzv

[virtual_sdcard]
#path:/home/mks/uploads
path: ~/gcode_files

[pause_resume]

[gcode_macro CANCEL_PRINT]
description: Cancel the actual running print
rename_existing: CANCEL_PRINT_BASE
gcode:
  TURN_OFF_HEATERS
  CANCEL_PRINT_BASE

[display_status]

[gcode_macro G32]
gcode:
    BED_MESH_CLEAR
    G28
    QUAD_GANTRY_LEVEL
    G28