B-G431B-ESC Brushless Servo Controller

Ultra low-cost controller for brushless servo based on the B-G431B-ESC1 Discovery kit by ST

Similar projects worth following
The B-G431B-ESC1 Discovery Kit is a programmable ESC 6S Lipo (40A peak) available for only 18USD. See : This compact ESC (20x40mm) has USB, CAN and PWM user interfaces. The STM32G431 may be reprogrammed with a custom firmware, in order to drives a home made brushless servo (MAD 5008 240Kv). A position-velocity-torque regulation, with velocity and acceleration profil, has been tested. With a 1:10 planetary gear box (3d printed), the torque may exceeds (5Nm) at 24V @ 5A, and the velocity is quite good (about 0.1s/60°).
  • 1 × B-G431b-ESC1 evaluation board
  • 1 × MAD5008 240Kv or any 6S brushless motor
  • 1 × AS5048A or any encoder with ABZ or PWM interface
  • 1 × 3D prined gear box for a quasi direct drive actionner ABS printed gears recommended

  • B-G431B-ESC Brushless Servo Controller - March Update

    pat92fr03/03/2022 at 21:08 0 comments

    A new quadruped, using twelve motors, controlled by the B-G431B-ESC and firmware V3.

  • B-G431B-ESC Brushless Servo Controller - January Update

    pat92fr01/20/2022 at 00:34 7 comments

    Testing new release with a mini gimbal motor...

  • B-G431B-ESC Brushless Servo Controller - January Update

    pat92fr01/16/2022 at 18:14 0 comments

    One year ago, I have developped a very fist revision of a custom FOC firmware on the B-G431B-ESC Discovery Kit. The code has been improved and a new firmware revision (V2) will be released soon.

    The firmware is tested with a 8108 and a 5008 bruhsless motors. The AS5048A (PWM input) and the AS5600 (I2C) are also tested.

    List of improvements :

    • 40KHz PWM with CSVPWM
    • 40KHz FOC loop
      • Current limiter
    • 4KHz position and velocity control loop
      • Dynamic change of KP and KD when torque enable 
      • Min/max position limiter
      • Maximum velocity limiter
    • Thermal protection
    • Low voltage protection

    A field-weakeming algorithm has been tested, but it will not be in the next release. The ESC is able to spin the motors at their base speed (Kv*Vdc). I think there is no need to spin faster for a hobby robotic application at the moment.


  • Bandwidth of position and torque PID controller

    pat92fr04/08/2021 at 01:39 0 comments

    The latest firmware update improves the bandwidth of the position and torque PID controller.

    This test was performed with my robot powered by Lipo 4S battery. The robot is under development. It is a 8-dof quadruped using MAD 5008 240kV motors, B-G431B-ESC board, 3D printed planetary gearbox (ratio: 1:4.5) and a M5Stack Fire.


  • Encoders

    pat92fr03/29/2021 at 16:21 0 comments

    Welcome Kai ! He has joined the project as a contributor, and we are working on the third alpha  firmware release, with some improvements :

    • support of encoders I2C et PWM
    • self calibration of motor / encoder
    • faster FOC update (up to 16KHz)
    • faster Position / Velocity / Torque PID loop
    • 1Mbps CAN-FD user interface for control and feedback (position, torque, temperature, voltage, error)
    • Fail-safe (brake when encoder error, over-heating, or under/over-voltage)
    • new operating mode "Position control with torque limit and velocity & acceleration profile".

    We have tested the current firmware with two different hardware configurations :

    • A 40xx brushless motor and an absolute position sensor AS5600 with a I2C interface (1Mbps)
    • A 50xx brushless motor and an absolute position sensor AS5048a with a PWM interface (1Khz)

    Here is the pinout of the ESC, with both I2C and PWM interface for encoders :

    There are so many things to add and to improve. 



  • 5-bar leg (2x B-G431B-ESC)

    pat92fr02/10/2021 at 00:03 0 comments

    This is a very fist test of an home-made 5-bar leg.

    Power supply : 24V @ 2A limitation
    Motors : 2x MAD 5008 240KV
    Encoder : 2x AS5048A (14bit absolute position, PWM output)
    ESC : B-G431B-ESC1 discovery kit by ST

    3d printed planetary gear box (1:4.25). Gear Module 1 (ABS and PLA)
    3d printed legs (PETG)
    28 ball bearings
    Femur 100mm
    Tibia 160mm

    Home-made FOC algorithm with position / velocity / torque control running at 10KHz (36us processing time, using STM32G4 CORDIC)

    Velocity limited to 20000dps
    Motor current limited to 500mA (max Iq).

  • Thermal dissipation

    pat92fr02/09/2021 at 18:08 0 comments

    This compact ESC was designed by ST for drones, with a strong forced convection. 

    At zero-altitude, zero-speed, without propellers, thermal dissipation remains an issue. 

    Problem solved ! (Joke) ^_^

    I have absolutely no experience in implementing FOC algorithm. This is my very first project, about brushless motor controller. I will do my best to release and share something basic but usable soon. 


  • 4-bar leg dual motor servo

    pat92fr02/08/2021 at 22:45 0 comments

    New hardware configuration !

    Each motor are driven by one G431 ESC running sensored FOC with position control mode.

    This is an example of application of such an ESC in robotics.

View all 8 project logs

View all 3 instructions

Enjoy this project?



Ghent The Slicer wrote 11/01/2022 at 05:32 point

Hi Pat,

Are you still working on this? The code last update was 7 months ago. I just got this board and would like to make it work with AS5047P SPI encoder.

  Are you sure? yes | no

rraetz wrote 01/20/2022 at 21:52 point

Hi Pat, Amazing to see the progress of this project! What's the maximum current that the B-G431B can continuously supply without getting too hot (with the heat sink, but no fan)? Do you think 3-4 Amps are ok? I am considering this for one of my projects. 

  Are you sure? yes | no

pat92fr wrote 01/20/2022 at 22:13 point

Hello ! Thank you rraetz. 

This is quite a difficult question to answeer! This ESC becomes hot very fast. The firmware monitors the temperature, and I have set a maximum at about 70°C. I think this ESC can handle a higher temperature (at least 90°C for a short time).

I have a 6kg quadruped with 12 ESC and MAD 5008 motors. No thermal problem  when standing or walking, with just a small heat sink. The current limit is set to 26A on each ESC. The robot is powered with a 12-15V battery. When standing, the robot overall curent is less than 10A. The peak over-all current is about 20 to 30A.

3 to 4A may be OK. I think it depends on your application. What kind of motor will you use (power/speed ratings and pole pairs) ? How much continuous/peak torque do you need (Nm) ? I have many motors. Maybe I can do a test with a similar setup.


  Are you sure? yes | no

rraetz wrote 01/20/2022 at 22:39 point

Hello Patrick

Thanks a lot for your detailed answer. This is very much appreciated! I would be using it  with a Faulhaber 3274 BP4 motor (48V version, 152W,  3,44A continuous, 2 poles). However, it would be for a haptic application with very low speed (300-400rpm) and therefore I use the 48V version to keep the required current low (even though I am using a 12V supply). The RMS current/torque requirement is hard to estimate at this point but I know that it might require 3-4A continuously during a few seconds sometimes. I think it seems feasible when I compare it to your application.  


  Are you sure? yes | no

petersesztak wrote 09/06/2021 at 21:46 point

Hi Pat,

First of all: congrat for your smart work !

Is the any news concerning next new release (all what I have: 02-ALPHA) ?

I plan to try it (AS5601 encoder with a small 7 pole-pair BLDC motor).

I am particularly interested in "Position control with torque limiter and velocity/acceleration profil" mode.

Thanks in advance !,


  Are you sure? yes | no

pat92fr wrote 01/20/2022 at 22:18 point

Hello Petersesztak,

Sorry for late reply. New firmware is coming.

I have deleted the mode with velocity/acceleration profil. But it is quite simple to restore it.

Firmware works fine with an I2C encoders, like AS5600. The position control loop is running at 4KHz at the moment.


  Are you sure? yes | no

iforce2d wrote 07/18/2021 at 15:04 point

Hi Pat, I'm trying this with a 4250 580kv motor (6 pole pairs) and AS5048A. At the moment I'm hard-coding the mode to REG_CONTROL_MODE_VELOCITY_TORQUE and trying some fixed values for goal_velocity_dps. With some values the motor will turn with a rough sound, but usually it will just screech and shudder occasionally, and in both cases the ESC gets very hot. Hopefully this just means the PID settings need to be tuned. Looks like I need to buy a CANbus to USB adapter to use the GUI configurator?

  Are you sure? yes | no

pat92fr wrote 01/20/2022 at 22:23 point

Hello iforce2d,

Sorry for late reply. There was issues with my FOC implementation, when using a AS5048A (angle estimation latency, erronous near-zero angle...). I have tried to fix them in the new release. The GUI script uses the USB interface (VCP). For faster control, you have to use CAN interface.


  Are you sure? yes | no

dan_perrett wrote 05/17/2021 at 22:18 point

Hi Patrick - I see from your GitHub that you have a pinout for wiring in an AS5600 encoder via I2C - is this being implemented in the code or can I help with this? I'm hoping to use your firmware for position control of hoverboard motors...

  Are you sure? yes | no

pat92fr wrote 05/17/2021 at 22:36 point

Hello ! AS5600 with I2 port is supported. A new release of the firmware is coming (a matter of days). I would appreciate if you could test it with your hover board motor and give me feedbacks. PM me if you want access to the private Git with the last updates on progress.

  Are you sure? yes | no

hannibal80 wrote 05/01/2021 at 13:34 point

Great stuff here! Please, bear with me if I'm asking a silly question, I'm very new to this world, but per my understanding, the esc is supposed to be able to read motor angle and speed without any sensor. Why are you using an encoder? Thank you! 

  Are you sure? yes | no

Adrian Prinz wrote 05/01/2021 at 17:30 point

By driving the motor sensorless (this way - there are multiple other ways e.g. frequency induction..) you are using the Back EMF (induced voltage by the coils). The BEMF is proportional to the rotation speed, thus it can be measured to estimate it - in addition to some other tricks :) With a small rotation speed the measurement of this BEMF gets less precise and thus the speed approximation. By using an encoder with a reasonable high resolution to determine the rotation speed, you do not run into this problem at low rpm => you can control the motor speed more precise...

  Are you sure? yes | no

pat92fr wrote 05/02/2021 at 08:13 point

At the moment, sensored. 

I am using this ESC in robot joint actuator. The velocity may be zero at the same time, torque must be maximum. 

So, there is an absolute sensor on the motor rear shaft, and the position and velocity is estimated by the ESC using this absolute position sensor. I have no plan about implementing sensorless for my application, but any contribution is welcome !


  Are you sure? yes | no

luethich80 wrote 04/23/2021 at 06:10 point

Hi all, so happy to see this board is even existing, looks so perfect for my custom modelling project. I have a question tough, hope you can help: Your custom firmware runs directly on the STM32G4, not on the daughterboard, correct? How can you program the G4, through the daughterboard? What IDE and base library did you use for your code? Are you open to share the code so I could add my custom application based on your speed and torque control? Thank you so much for your support!

  Are you sure? yes | no

pat92fr wrote 05/02/2021 at 08:08 point

Hello Luethich, 

The firmware runs on the G4. I am using the daughter board for programming the G4 through USB port. The USB port is also used to send setpoints and recevive feedback (virtual serial comm port). There is Python GUI to control the motor from computer. The CAN port is also used for setpoint and feedback communication.

I have used CubeIDE and HAL. There is no library.  This my own FOC software implementation (not perfect). Of coure, the source code is open. The public repository is not up to date, at the moment. If you want to access the last code, I can invite you as contributor, and you will gain access to private Git. Let me know. 

I am currently redesigning the position/velocity/torque PID control. In fact this ESC is a side project. The main project is my 8-DOF quadruped using 8 ESC.


  Are you sure? yes | no

hassan-asif wrote 04/09/2021 at 06:33 point

Hi Pat92fr: The user manual for B-G431B-ESC1 on ST website is revision 4. DO you have revision 1 or revision 2 available with you? I want to look into schematics of B-G431B-ESC1. In revision 4, ST has deleted the schematics of B-G431B-ESC1.

Looking forward to hear from you. Thank you.

  Are you sure? yes | no

pat92fr wrote 05/02/2021 at 08:01 point

Hello Hassan, I have uploaded the schematic of the ESC in the Repository in Hardware / BoardSchematic. Sorry for the delay. YHere is the link : :


  Are you sure? yes | no

rraetz wrote 02/08/2021 at 16:30 point

I was not aware of this kit. Seems like a dream come true! Do you plan to use it with closed-loop FOC (with angular position sensor)? 

  Are you sure? yes | no

pat92fr wrote 02/08/2021 at 17:45 point

Hello QuestforMotion. Yes, of course, and that works quite well. I have just implemented a FOC algorithm using an absolute encoder (14bit) for angular position. My firmware offers several operating modes : position control, velocity control, and torque control. I will make it open source hardware (printed parts) and software. The main drawback of this evaluation kit is the thermal dissipation. Board is getting very hot at maximum torque. I think a forced convection is mandatory. Bye !

  Are you sure? yes | no

rraetz wrote 02/09/2021 at 00:46 point

Thanks for your quick answer, I appreciate it. That's great! I have some experience programming FOC firmware using the TI Launchpad and motor control evaluation boards, but they are way more expensive (30USD board + 80USD motor driver). So it's amazing to see that there seems to be a viable alternative. Thermal dissipation should be solvable, I guess... Anyway, I am looking forward to checking your implementation of the motor control!  

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates