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

Adding support for 100pin version of H32F460 and Tenlog D3 32bit printer #6488

Merged
merged 8 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
312 changes: 312 additions & 0 deletions config/printer-tenlog-d3-32bit.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,312 @@

# This file contains common pin mappings for the Tenlog D3 with a 32bit mainboard

# Original work by audiobrian at https://github.com/audiobrian/tld3pro_klipper
# Additional work by Guillaume Giraudon

# To use this config, the firmware should be compiled for the
# HC32F460 with a 100 pin package.
# You must also select PA3 and PA2 as your serial interface.

# Rename the file to printer.cfg

##################################################################
# Printer
##################################################################

[printer]
max_velocity: 500
max_accel: 2500
max_accel_to_decel: 1250

[gcode_arcs]
resolution: 0.01

[mcu]
baud: 115200
serial: /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0
restart_method: command

[board_pins]
aliases:
LED0=PB7,
GEN_ENABLE=PB2,
BOARD_SDIO_D0=PC8,
BOARD_SDIO_D1=PC9,
BOARD_SDIO_D2=PC10,
BOARD_SDIO_D3=PC11,
BOARD_SDIO_CLK=PC12,
BOARD_SDIO_CMD=PD2,
BOARD_SDIO_DET=PE14,
ONBOARD_SD_CS_PIN=PE4,
BOARD_USART2_TX_PIN=PA2,
BOARD_USART2_RX_PIN=PA3,
BOARD_USART1_TX_PIN=PC4,
BOARD_USART1_RX_PIN=PC5,
X_MAX_PIN=PH2,
Y_STOP_PIN=PC3,
X_STOP_PIN=PC13,
Z_STOP_PIN=PC15,
Z_MAX_PIN=PC14,
FIL_RUNOUT_PIN=PA15,
X_ENABLE_PIN=PB2,
X2_STEP_PIN=PA9,
X2_DIR_PIN=PA8,
X_STEP_PIN=PC7,
X_DIR_PIN=PC6,
Y_STEP_PIN=PB15,
Y_DIR_PIN=PB14,
Z_STEP_PIN=PE13,
Z_DIR_PIN=PE12,
Z2_STEP_PIN=PB13,
Z2_DIR_PIN=PB12,
E0_STEP_PIN=PB4,
E0_DIR_PIN=PB3,
E1_STEP_PIN=PB6,
E1_DIR_PIN=PB5,
FAN2_PIN=PA0,
FAN3_PIN=PE7,
HEATER_BED_PIN=PE10,
HEATER_0_PIN=PA5,
HEATER_1_PIN=PA4,
FAN4_PIN=PE3,
CHAMEBER_PIN=FAN4_PIN,
TEMP_0_PIN=PC1,
TEMP_1_PIN=PC2,
TEMP_BED_PIN=PC0,
POWEROFF_PIN=PB10

# X2_ENABLE_PIN=X_ENABLE_PIN
# Y_ENABLE_PIN X_ENABLE_PIN
# Z_ENABLE_PIN X_ENABLE_PIN
# Z2_ENABLE_PIN X_ENABLE_PIN
# E0_ENABLE_PIN X_ENABLE_PIN
# E1_ENABLE_PIN X_ENABLE_PIN

[pause_resume]

[display_status]

[virtual_sdcard]
path: /home/pi/printer_data/gcodes

[printer]
kinematics: cartesian
max_z_velocity: 20
max_z_accel: 25


[heater_bed]
heater_pin: HEATER_BED_PIN
sensor_type: EPCOS 100K B57560G104F
sensor_pin: TEMP_BED_PIN
min_temp: 0
max_temp: 110
smooth_time: 2.5
#control: pid

[fan]
#Possibly wrong pin
pin: PA1
max_power: 1.0
shutdown_speed: 0
cycle_time: 0.010
hardware_pwm: False
kick_start_time: 0.100
off_below: 0.0

[heater_fan fan]
pin: FAN2_PIN
heater: extruder
heater_temp: 80.0
fan_speed: 1.0

[heater_fan fan1]
pin: FAN3_PIN
heater: extruder1
heater_temp: 80.0
fan_speed: 1.0

[heater_fan chassis]
pin: FAN4_PIN
heater: extruder,extruder1
heater_temp: 80.0
fan_speed: 1.0

[extruder]
gear_ratio: 1:1
step_pin: E0_STEP_PIN
dir_pin: !E0_DIR_PIN
enable_pin: !GEN_ENABLE
microsteps: 16
rotation_distance: 7.9
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: HEATER_0_PIN
sensor_type: EPCOS 100K B57560G104F
sensor_pin: TEMP_0_PIN
smooth_time: 2.5
#control: pid
min_temp: 0
max_temp: 270
max_extrude_only_distance: 250.0

[extruder1]
step_pin: E1_STEP_PIN
dir_pin: E1_DIR_PIN
enable_pin: !GEN_ENABLE
microsteps: 16
rotation_distance: 7.9
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: HEATER_1_PIN
sensor_type: EPCOS 100K B57560G104F
sensor_pin: TEMP_1_PIN
control: pid
smooth_time: 2.5
#control: pid
min_temp: 0
max_temp: 260
max_extrude_only_distance: 250.0

[stepper_x]
step_pin: X_STEP_PIN
dir_pin: !X_DIR_PIN
enable_pin: !GEN_ENABLE
rotation_distance: 40
microsteps: 16
endstop_pin: !X_STOP_PIN
position_endstop: -53
position_max: 300
position_min: -55
homing_speed: 80
homing_positive_dir: false

# Definition for the secondary carriage and extruder1
[dual_carriage]
axis: x
step_pin: X2_STEP_PIN
dir_pin: !X2_DIR_PIN
enable_pin: !GEN_ENABLE
rotation_distance: 40
microsteps: 16
endstop_pin: !X_MAX_PIN
position_endstop: 359.35
position_min: 0
position_max: 360
homing_speed: 80

[stepper_y]
step_pin: Y_STEP_PIN
dir_pin: Y_DIR_PIN
enable_pin: !GEN_ENABLE
rotation_distance: 40
microsteps: 16
endstop_pin: !Y_STOP_PIN
position_endstop: 0
position_max: 300
homing_speed: 60

[stepper_z]
step_pin: Z_STEP_PIN
dir_pin: !Z_DIR_PIN
enable_pin: !GEN_ENABLE
microsteps: 16
rotation_distance: 4
endstop_pin: !Z_STOP_PIN
position_endstop: -0.15
position_max: 350
position_min: -9.0
homing_speed: 10

[stepper_z1]
step_pin: Z2_STEP_PIN
dir_pin: !Z2_DIR_PIN
enable_pin: !GEN_ENABLE
microsteps: 16
rotation_distance: 4
endstop_pin: !Z_MAX_PIN

[safe_z_home]
home_xy_position: 183.8, 176.4
speed: 65
z_hop: 15
z_hop_speed: 5

[bed_screws]
screw1: 35,35
screw2: 35,275
screw3: 275,275
screw4: 275,35

[respond]
default_type: echo

[endstop_phase]

#Turn on PSU automatically
[output_pin psu_shutdown]
pin: !POWEROFF_PIN
value: 0
shutdown_value: 1

#[gcode_macro m80]
#gcode:
#SET_PIN PIN=ps_on VALUE=1

#[gcode_macro m81]
#gcode:
#SET_PIN PIN=ps_on VALUE=0

[filament_switch_sensor my_sensor]
pause_on_runout: True
# When set to True, a PAUSE will execute immediately after a runout
# is detected. Note that if pause_on_runout is False and the
# runout_gcode is omitted then runout detection is disabled. Default
# is True.
runout_gcode:
RESPOND MSG="Filament runout detected. Print paused."
# A list of G-Code commands to execute after a filament runout is
# detected. See docs/Command_Templates.md for G-Code format. If
# pause_on_runout is set to True this G-Code will run after the
# PAUSE is complete. The default is not to run any G-Code commands.
#insert_gcode:
# A list of G-Code commands to execute after a filament insert is
# detected. See docs/Command_Templates.md for G-Code format. The
# default is not to run any G-Code commands, which disables insert
# detection.
#event_delay: 3.0
# The minimum amount of time in seconds to delay between events.
# Events triggered during this time period will be silently
# ignored. The default is 3 seconds.
#pause_delay: 0.5
# The amount of time to delay, in seconds, between the pause command
# dispatch and execution of the runout_gcode. It may be useful to
# increase this delay if OctoPrint exhibits strange pause behavior.
# Default is 0.5 seconds.
switch_pin: FIL_RUNOUT_PIN
# The pin on which the switch is connected. This parameter must be
# provided.

#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*# [extruder]
#*# pid_kp = 13.675
#*# pid_ki = 0.390
#*# pid_kd = 120.000
#*# control = pid
#*#
#*# [heater_bed]
#*# pid_kp = 54.627
#*# pid_ki = 0.625
#*# pid_kd = 1194.280
#*# control = pid
#*#
#*# [extruder1]
#*# pid_kp = 25.829
#*# pid_ki = 2.236
#*# pid_kd = 74.582
#*#
#*# [stepper_z]
#*# position_endstop = 0.065
8 changes: 8 additions & 0 deletions src/hc32f460/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ config BOARD_DIRECTORY
string
default "hc32f460"

choice "MCU Package"
prompt "Number of pins"
config HC32F460_PINS_64
bool "64"
config HC32F460_PINS_100
bool "100"
endchoice


######################################################################
# Communication interface
Expand Down
7 changes: 7 additions & 0 deletions src/hc32f460/gpio.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// GPIO functions on HC32F460
//
// Copyright (C) 2022 Steven Gotthardt <[email protected]>
// Modified by @audiobrian (https://github.com/audiobrian/tld3pro_klipper)
// and Guillaume Giraudon to add 100 pin package.
ggiraudon marked this conversation as resolved.
Show resolved Hide resolved
//
// This file may be distributed under the terms of the GNU GPLv3 license.

Expand All @@ -18,7 +20,12 @@
DECL_ENUMERATION_RANGE("pin", "PA0", GPIO('A', 0), 16);
DECL_ENUMERATION_RANGE("pin", "PB0", GPIO('B', 0), 16);
DECL_ENUMERATION_RANGE("pin", "PC0", GPIO('C', 0), 16);
#if CONFIG_HC32F460_PINS_100
DECL_ENUMERATION_RANGE("pin", "PD0", GPIO('D', 0), 16);
DECL_ENUMERATION_RANGE("pin", "PE0", GPIO('E', 0), 16);
#else
DECL_ENUMERATION_RANGE("pin", "PD2", GPIO('D', 2), 1);
#endif
DECL_ENUMERATION_RANGE("pin", "PH2", PortH * 16 + 2, 1); // H: special case


Expand Down
20 changes: 20 additions & 0 deletions src/hc32f460/hard_pwm.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Hardware PWM support on HC32F460
//
// Copyright (C) 2022 Steven Gotthardt <[email protected]>
// Modified by @audiobrian (https://github.com/audiobrian/tld3pro_klipper)
// and Guillaume Giraudon to add 100 pin package.
//
// This file may be distributed under the terms of the GNU GPLv3 license.

Expand Down Expand Up @@ -75,6 +77,24 @@ static const struct gpio_pwm_info pwm_mapping[] = {
{GPIO('C',14), 4, TimeraCh5},
{GPIO('C',15), 4, TimeraCh6},
{GPIO('D', 2), 2, TimeraCh4},
#if CONFIG_HC32F460_PINS_100
{GPIO('D',12), 4, TimeraCh1},
{GPIO('D',13), 4, TimeraCh2},
{GPIO('D',14), 4, TimeraCh3},
{GPIO('D',15), 4, TimeraCh4},
{GPIO('E', 2), 3, TimeraCh5},
{GPIO('E', 3), 3, TimeraCh6},
{GPIO('E', 4), 3, TimeraCh7},
{GPIO('E', 5), 3, TimeraCh8},
{GPIO('E', 8), 1, TimeraCh5},
{GPIO('E', 9), 1, TimeraCh1},
{GPIO('E',10), 1, TimeraCh6},
{GPIO('E',11), 1, TimeraCh2},
{GPIO('E',12), 1, TimeraCh7},
{GPIO('E',13), 1, TimeraCh3},
{GPIO('E',14), 1, TimeraCh4},
{GPIO('E',15), 1, TimeraCh8},
#endif
};


Expand Down
Loading