This is a beginner guide for how to setup the B-G431B-ESC1 with SimpleFOC.
The B-G431B-ESC1 is a small but powefull esc at a great price point. More information on the specs can be found on the site of ST.
The board consists of main board (the ESC) and a daughterboard which is actually a programmer. This can be seen at the figure below:
Step 1: Install PlatformIO
This board is the most easily configured in PlatformIO. You can follow the install instructions of PlatformIO here and a great video of the installation made by @Owen_Williams can be watched here.
Step 2: Add board
Once PlatformIO is configured, the board needs to be added. This board is not a standard board so it needs to be added manually. Therefore the following files made by @Owen_Williams need to be added to the following folders:
- Go to
- Copy the folder called
board_templateand name it
- Add/replace the following files: PeripheralPins.c, PinNamesVar.h, ldscript.ld, variant.cpp, variant.h
- Go to
C:\Users\wittecactus\.platformio\packages\framework-arduinoststm32and update the boards.txt file
- Go to
C:\Users\wittecactus\.platformio\platforms\ststm32\boardsand add this json file.
Now the board is configured.
Step 3: Run your code!
Open a new project in PlatformIO. Select your newly configured board. PlatformIO works a bit differenty from the standard Arduino IDE. You put your arduino code in src/main.cpp and configure the libraries in platformio.ini . It is important that you put the following code in your platformio.ini file to make the board working and have serial communication:
; Library options: dependencies, extra library storages ; Advanced options: extra scripting ; ; Please visit documentation for the other options and examples ; https://docs.platformio.org/page/projectconf.html [env:disco_b_g431b_esc1] platform = ststm32 board = disco_b_g431b_esc1 framework = arduino monitor_speed = 115200 build_flags = -D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC -D PIO_FRAMEWORK_ARDUINO_NANOLIB_FLOAT_PRINTF -D PIO_FRAMEWORK_ARDUINO_USB_HIGHSPEED_FULLMODE lib_deps= askuric/Simple FOC @ ^2.0.2 SPI Wire
For your main code do not fotget:
- To add
#include<Arduino.h>to your sketch (for platformIO)
- Use the following 6PWM driver setup:
BLDCDriver6PWM driver = BLDCDriver6PWM(PHASE_UH, PHASE_UL, PHASE_VH, PHASE_VL, PHASE_WH, PHASE_WL);
The rest is regular SimpleFOC code! Watch the following guide from @Owen_Williams for more information to make your first SimpleFOC code. For extra information check the datasheet and the following topic.
I hope that I can help some people with this guide! If the real pro’s want to add something or correct me somewhere just say it! Good luck everyone!
Sidenote: I hope to update this guide soon with I2C support.