RP2040 and Simple FOC Shield - arsi-apli/BLDC_Klipper_doc GitHub Wiki
Attention! A BLDC motor at the voltage specified by the manufacturer tends to reach high temperatures quickly. Therefore, it is necessary to use a regulated power supply or a regulated DC/DC voltage converter and start testing the motor from a much lower voltage. My motor is rated for 14.4V and I started from 5V. Although the implementation for RP2040 allows power/current reduction, it is preferable to regulate the current with the source voltage, because power reduction via firmware reduces the resolution of PWM regulation.
This implementation allows configuration of the pins used to control the motor electronics. It is primarily designed for the Simple FOC Shield, but any board designed for BLDC motor control can be used. A list of boards can be found here.
How to build the firmware
If the firmware has BLDC support enabled, the MCU can only drive BLDC motors because the code for the stepper motor is replaced by version that generates the BLDC PWM signals. PWM frequency is 19.691kHz.
git clone https://github.com/arsi-apli/klipper.git
git checkout bldc_stepper
make menuconfig
If the command queue for the motor is empty, the motor power is reduced to the holding power..
make
make flash FLASH_DEVICE=/dev/ttyACM0
For the first flash, you need to copy the ./out/klipper.uf2 file to the RPI Pico mass storage device manually.
printer.cfg
[stepper_x] or [stepper_y] or [stepper_z] or [extruder] or [manual_stepper]
enable_pin: gpio3 #Enable pin for the BLDC board
step_pin: gpio0 #The same pin as was entered via menuconfig for PWM A. The pin is used to assign the correct BLDC motor, as up to three can be connected.
dir_pin: gpio4 #The value is ignored
full_steps_per_rotation: 2520 #for 12N14P, (14/2)*360=2520
microsteps: 1
[mcu]
serial: /dev/ttyACM0
baud: 115200
restart_method: command