A PID demo program using the STM32F446RE to control RobotMaster C620/C610 BLDC controller with mbed OS 6.8 + past the test with full bandwidth 8 motors and 8 drivers with 1kHz PID frequency
Paper: https://www.ni.com/en-us/innovations/white-papers/09/can-physical-layer-and-termination-guide.html
m3508/m2006 is a type of BLDC motor and c620/c610 is the motor driver for them. the way u can control is provide a current command via can bus to the driver to make the motor move. The motor driver with drive the motor wiith your current command, and feedback the position, velocity and teh current draw of the motor(rotor). PID is a control algrithm that drive the system to your destinated output from a/ the particular input by using the feedback of the driver. In this repo is the example program use the STMF446RET6 to calculate the PID and send the command to c620/c610 via CAN BUS to driver the motor to a destinated output.
The PID Algro use 3 Layer control loop design, with position loop, velocity loop and current (torque) loop like the follow pictures. This control loop is base of the physics u learn in secondary school:
With the driver feedback the real-time position, velocity, current. we can drive the motor with the feedback in a 3 layer control loop.
the Accelaration filter is used o prevent the error of the pid controller too large and cause the variable overflow.
!! if the command variable overflow will cause the driver enter error mode, and motor will rotate like crazy!
Connect the Circuit like the follow: STM32F446re -> Can transceiver (TJA1050) -> c620/c610 speed controller -> m3508/m2006 motor
if you using the c620 driver for the position control pls notice the following few things to prevent damage
THIS WILL RESULT THE MOTOR LOSS CONTROL AND OVER-REVING, PLEASE TEST THE PID LOOP BEFORE INSTALL TO THE ACTUAL HARDWARE!!!
The position loop is may have roundcounterror over 1000rpm (at the output shaft) this may also may cause OVERREVING please test the velocity carefully
The connection of the CAN-BUS plug (GH 1.25) is not reliable at all pls check the hardware wire connection first if the motor have no response!
PLEASE SAFELY SECURE THE MOTOR BEFORE YOU POWER ON ANY DRIVERS, THE POWER OF THIS PACKAGE IS MORE THAN YOU EXPECTED
good luck if you hand hold the motor while testing:smirk:
This program will perform velocity control for the c620. The motor will hold its startup position and rotate 360 deg CW then 360 deg CCW in 60 deg increament (on the output shaft) after pressing the User Button(PC13).
The given code provide the base setup of this driver, but you are recommanded to change it depend on application the velocity control command is also given in this demo.
The details operation and usage u can refer to the c620.cpp to check the operation
Located at c620.cpp
Welcome to debug this program, pls open your own branch / post an issue for any bug you found. updated at 2022 - 8 - 31