Support for HDSC chips (HC32F460)

Ok so on the Ender 2 Pro, there’s 2 fans on the extruder assembly. The one visible on the outside was actually for the heat break. The extruder fan is on the side and isn’t so visible and I can turn it on and off just fine. I’m currently trying to get CRTouch working but it looks like Klipper is unable to deploy and retract the pin. I’ve verified that the control pin I have on the config (PB2) is correct and that at least the wiring harness is fine. I’m currently working on verifying that the CRTouch itself isn’t broken but the self test at least successfully completes.

I set up an ESP32 to test my CR Touch’s probe extension, retraction, and sensing and it work just fine. I went ahead and took a multimeter to check the PB2 pin and it would power up to ~3.3v only when I have it configured as the bltouch control pin. It would stay at 0 volts when not configured, so it looks like I am using the correct physical pin as well. It looks like PWM is not currently working on PB2, or at least it isn’t working the way it should for a CR Touch.

1 Like

Just as an update to this, I think I messed up my power measurements and read the 2 as a 5. I haven’t seen any huge draw since.

I also managed to get the stock LCD working on the E2Pro. This is my config along with the beeper config:

[display]
lcd_type: st7920
cs_pin: PB15
sclk_pin: PB14
sid_pin: PB12
encoder_pins: ^PA2,^PB13
click_pin: ^!PC7

[output_pin BEEPER_pin]
pin: PC6
pwm: True

Okay after a few days of using and abusing Klipper, here’s my config for the Kobra:

# Anycubic Kobra configuration
# Requires HC32F460 defconfig

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

[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 2000
max_z_velocity: 5
max_z_accel: 100

[stepper_x]
step_pin: PA5
dir_pin: PA4
enable_pin: !PC3
rotation_distance: 40
microsteps: 16
endstop_pin: tmc2209_stepper_x:virtual_endstop
position_min: -42 # Marlin says -37.2
position_endstop: -42 # Marlin says -37.2
position_max: 224
homing_speed: 100
homing_retract_dist: 0

[tmc2209 stepper_x]
uart_pin: PA15
run_current: 0.6
stealthchop_threshold: 999999
uart_address: 3
# calibrated at homing_speed 100, max is 148, min is 71
driver_SGTHRS: 97
diag_pin: ^PA6

[stepper_y]
step_pin: PC4
dir_pin: PA7
enable_pin: !PC3
rotation_distance: 40
microsteps: 16
endstop_pin: tmc2209_stepper_y:virtual_endstop
position_min: -3 # Marlin says -0.2
position_endstop: -3 # Marlin says -0.2
position_max: 222
homing_speed: 80
homing_retract_dist: 0

[tmc2209 stepper_y]
uart_pin: PA15
run_current: 0.6
stealthchop_threshold: 999999
uart_address: 1
# calibrated at homing_speed 80, max is 158, min is 79
driver_SGTHRS: 105
diag_pin: ^PC5

[stepper_z]
step_pin: PC7
dir_pin: !PC6
enable_pin: !PC3
rotation_distance: 4
microsteps: 16
endstop_pin: probe:z_virtual_endstop
position_min: -5 # Marlin says -0.3
position_max: 250
homing_speed: 10

[tmc2209 stepper_z]
uart_pin: PA15
run_current: 0.6
stealthchop_threshold: 999999
uart_address: 2
driver_SGTHRS: 50
diag_pin: ^PA8

[extruder]
step_pin: PC14
dir_pin: PC15
enable_pin: !PC3
microsteps: 16
rotation_distance: 7.794750 # Marlin says 8.205
nozzle_diameter: 0.400
filament_diameter: 1.750
max_extrude_only_distance: 105
pressure_advance: 0.045
heater_pin: PA1
sensor_type: ATC Semitec 104GT-2
sensor_pin: PC1
control: pid
# default in Marlin:
#pid_Kp: 22.20
#pid_Ki: 1.08
#pid_Kd: 119.00
# calibrated to 200c with parts fan on and heat bed at 60c:
pid_Kp: 17.111
pid_Ki: 0.659
pid_Kd: 111.06
min_temp: 5
max_temp: 240 # Marlin says 275, I cap to 230 to prevent PFTE fumes
min_extrude_temp: 130 # For starting G-Code

[tmc2208 extruder]
uart_pin: PA15
run_current: 0.7
stealthchop_threshold: 999999

[heater_bed]
heater_pin: PA0
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC0
control: pid
# default in Marlin:
#pid_Kp: 54.027
#pid_Ki: 0.770
#pid_Kd: 948.182
# factory calibration:
#pid_Kp: 97.10
#pid_Ki: 1.41
#pid_Kd: 1675.16
# calibrated to 200c with parts fan on and heat bed at 60c:
pid_Kp: 61.847
pid_Ki: 0.902
pid_Kd: 1059.902
min_temp: 0
max_temp: 130

[bed_mesh]
speed: 100
mesh_min: 10, 10
mesh_max: 210, 210
probe_count: 6, 6

[safe_z_home]
home_xy_position: 110, 110

[virtual_sdcard]
path: /home/jookia/kobra/klipper/sdcard

[probe]
pin: PB8
x_offset: 42 # Marlin says 43.50
y_offset: 3 # Marlin says 4.70
z_offset: 1.240 # originally 1.040, 1.200 tested good
samples: 5
samples_tolerance_retries: 2

[fan]
pin: PB9

[heater_fan extruder_fan]
pin: PA13

[controller_fan controller_fan]
pin: PA14
fan_speed: 0.4 # LOUD fan!

[filament_switch_sensor my_sensor]
switch_pin: ^!PC13

[output_pin beeper]
pin: PB5
pwm: True
value: 0
shutdown_value: 0
cycle_time: 0.01
scale: 1

[gcode_macro M300]
gcode:
    # Use a default 1kHz tone if S is omitted.
    {% set S = params.S|default(1000)|int %}
    # Use a 10ms duration is P is omitted.
    {% set P = params.P|default(100)|int %}
    SET_PIN PIN=beeper VALUE=0.5 CYCLE_TIME={ 1.0/S if S > 0 else 1 }
    G4 P{P}
    SET_PIN PIN=beeper VALUE=0

I haven’t used any frontends for Klipper, just G-Code sent using this:

cat /dev/stdin >/tmp/printer | cat /tmp/printer

Quick update on the CR-Touch/BLTouch issue. I got an oscilloscope to check the bltouch control_pin and PWM does not appear to work at all on PB2 when configured as the control_pin. Once klippy connects to the klipper firmware, PB2 is set to high 100% of the time and bltouch debug commands do not affect it.

Another thing to note about PWM is that the beeper tones seem off. I replaced the HC32 board on my Ender 2 Pro with an SKR Mini E3 V3 and the beeper frequency seems very different. At the moment though I can’t verify whether something is wrong with the beeper or if it’s just the expected inaccuracy as I’m going off memory only. I’m currently waiting on an LCD so I can have a beeper on both the SKR Mini and the HC32 board to do a side-by-side comparison. Either that or I find a pin to use for testing PWM that I can connect a 5v piezo buzzer to.

EDIT: Just to make sure I wasn’t encountering an issue with the oscilloscope, I tried hooking up a 5v piezo buzzer to PB2 after verifying on an ESP32 that I would actually hear something with the ~3.3v PWM signal for deploying a bltouch probe, and I did not get any tone from PB2 after issuing a pin_down command via klippy.

1 Like

Morning. Scrolling through the comments I couldn’t quite determine. I just purchased an anycubic Kobra this month and would like to get killer running on it. Not really comfortable modding the board. Has anyone got a profile working that doesn’t require modding ? Thanks I’m advance.

Hello again Klipper friends. I’ve managed to get a kind of proof of concept working of Klipper on the stock Anycubic Kobra. This should work for the Max if it has the same issue. It’s going to take a little more to develop, but I would like anyone interested to reply or post here with offers to test and iron out any bugs.

Edit: I’ve put the code + instructions online at GitHub - Jookia/klipper at tmc2209f

Hello, i am posting a link to my github repository about the ender 2 pro with the HC32 mcu board. Hope it helps

Cool! Can you provide source code or is it just a build from Steve?

For anyone still interested at this point, HC32F460 support has been merged in to mainline. You just need to provide a config now.

I’ve opened a PR at WIP: Support broken TMC boards on the Anycubic Kobra by Jookia · Pull Request #6091 · Klipper3d/klipper · GitHub in hope of getting my fix in mainline.

1 Like

Sorry for the topic spam, but I’ve closed the PR and opened this thread: How to support the Anycubic Kobra boards?

Hi, by my tests PB1 is the control pin almoust sure . For the sensor pin if I define PB2 debug query_probe returns message “probe: open” (even if its closed) , If I define PB11 returns “probe: trigguered” . the only debug command that works is pin_up and trigguers pin to go up and down. pin_down and remaining commands do nothing.

What board are you using? The actual control pin depends on the board. On mine, assuming the diagram I was looking at was correct, it is PB2. I confirmed it with a multimeter and I think I ran an additional test to confirm that it is PB2 in my board’s case. Either way it looks like a PWM issue both in your case and mine, although the cause may be different. I have no clue whether it’s a problem with the HC32 chips themselves or with the firmware though.

I´m using the original creality board on the Ender 2 Pro also with the HC32 mcu as you. On mine if I put PB2 as the control pin and PB1 as sensor pin absolutely nothing happens…

It’s possible that in your case, with PB2 configured as the sensor pin, sending the pin_up command also causes Klipper to check the pin status via the sensor by pulling it up momentarily (if PB2 is configured to require enabling a pull-up resistor on the pin) which could cause the CRTouch to interpret it as a command which results in the pin going up and down.

I don’t remember what additional test I did to confirm that it is PB2 instead of PB1 but I was positive that PB2 is the control pin. If I can find the time tomorrow, I can check PB1 on the oscilloscope to see what happens if PB1 is configured as the control pin. Or if you want to check it yourself, you can either change the sensor pin to something other than PB2 and see if pin_up still causes the pin to go up and down. You can also keep PB2 as the sensor pin and change the control pin to something other than PB1 and see what pin_up does.

I´ve just also tested PB0 (z endstop) as sensor pin and this yes it works. endstop down returns triggered end stop up returns open. Yet, touch mode and pin down no positivbe results yet. Or its me doing something wrong or my CRTouch isn´t working well.

So I guess for those that have a BL Touch with PB1 as control pin and PB0 as sensor pint (hooked on z endstop connector) this may work fine. CRtouch works differently so on our case up now isn´
t working at all.

Bumping this topic: Is anyone else experience significant amounts of packet loss on their board?

it looks like the resistorson my board are soldered completely different

Ancubic kobra bought 3 weeks ago