BLDC driver
Working Environment
Tools:
-
Enveronment:
PlatformIO -
Framework:
Arduino -
Code editor:
Visual Studio Code -
FOC:
Arduino Simple FOC
Hardware:
- Mcu:
STM32G030C8T6
How to build and Flash
Setup Visual studio Code
The VS code setup Instructions are available in Getting Started.
- Setup Visual studio code according to the Host operating system.
- Install PlatformIo extension inside VS code
- Install STM32 Platform in PlatformIo
- Install Board support packages for STM32G0C038T6
- Select the board and Framework as Arduino
Building and Flashing Application:
To build the application, clone the affbotics_software repo and go to the folder BLDC_driver
- Pull the repository locally
- Navigate to the directory
affbotics_software/firmware/avg/BLDC_driver/ - Select the COM port
- Click Upload
Program Flow
Basic Workflow:
Firmware is present in affbotics_software/firmware/avg/BLDC_driver/src/main.cpp
- BLDC driver board communicates using Modbus over RS485
- The Modbus I registers
0x2000can be Writen with a value from -200 to 200 for setting the velocity of the motor. - Where -ve values spin the motor in the opposite direction
- comment the line
#define IAM_LEFTfor Right motor or leave it uncommented for Left motor
Am a Geek:
- Modbus Register address and
SLAVE_IDcan be changed by changing#definevalues - Motor PID values can be tweaked if needed using
motor.PID_velocity.P, motor.PID_velocity.I, motor.PID_velocity.D - change the phase angle
motor.P_angle.Pand directionmotor.initFOC(0, Direction::CW);if required.