• Hello ES! We could use some help to get us past the finish line on building the new knowledgebase for the forum.
    Can you donate? Please see our fundraising page. Thank you!

Building controller based on b-g431b-esc1

Catatopatch

New here
Joined
Dec 27, 2025
Messages
22
Location
Canada
Hey guys! This is for me and my group members Bachelors Project for EE, we are all pretty new to the field of Ebikes, but our project is just to showcase it working/record some values/possibly make some components like the controller cheaper etc

Basically my group decided to go with these as our motor/controller/battery & adapter based on what our professors recommended, as well as input from multiple people on our last forum post
Motor: 24V/36V 200W 5 Inch Electric Scooter Motor Wheel with Solid Tire 5" Electric Brushless DC Gearless Hub Motor with Hall Sensor, Replacement Wheels - Amazon Canada
Controller: https://www.digikey.ca/en/products/...670?s=N4IgTCBcDaIEIFoDiAWAzARkQUQMoGEMQBdAXyA
Battery & Adapter: https://www.digikey.ca/en/products/detail/mean-well-usa-inc/GST60A12-P1J/7703712
https://www.digikey.ca/en/products/detail/mean-well-usa-inc/YP12-YC12/7707223

And our goals are to
a) Showcase regen braking and get some energy back which we can store in a supercapacitor and measure
b) Design our own controller based on the B-G431B-ESC --> requirement from prof
c) Design a buck/boost converter to step up/step down the req voltage/current

I just want to ask, how would we design our own controller/is it possible to based on the ESC that we have already? So like I saw online that ppl have built their designs using this esc by connecting the 5 hall effect sensor wires from motor to the esc, the single phase (positive/negative) battery wires to one end of the ESC, and the 3 phase wires from the motor to the other end of the esc like the diagram below

1772397794679.png


So Im wondering if its possible to just copy the components used from the schematics for only those things (like the resistors/mosfets etc), and we should be good? Im also not really sure on how we could add the code that we have to create on SimpleFOC to the controller in this case to handle speed and such, as im assuming on the actual controller we upload the SimpleFOC code through this port here. We do have potentiometers and stuff to change it, but yeah Im not sure how to first upload the code into the controller

1772398128546.png


Im assuming the schematic for the connections and components between the DC (battery) to AC (3phase motor) on the controller is the image below from STMicroelectronics on this specific controller: https://www.st.com/en/evaluation-tools/b-g431b-esc1.html#cad-resources
So if our group builds that the dc to ac wiring should work fine? Or is there anything else that is necessary that we need to include as well? Im also going to try to find the specific schematic for the 5 hall effect sensor connections as well later, but the image below should be for the input DC to output AC?

1772430738342.png


Thanks a lot
 

Attachments

  • 1772430662573.png
    1772430662573.png
    80 KB · Views: 2
Design a buck/boost converter to step up/step down the req voltage/current
?! You don't need additional hardware, the BLDC controller works as a step down in motor mode and as a step up in generator mode itself. It's just question of the controller firmware.
There are several open source projects, that have implemented regen already. Like VESC, MESC, EBiCS....
Schematics and source code are available for free.

Still the same unanswered questions as in January 🤷‍♂️
https://endless-sphere.com/sphere/t...o-test-out-regen-breaking.129518/post-1878066
 
Last edited:
?! You don't need additional hardware, the BLDC controller works as a step down in motor mode and as a step up in generator mode itself. It's just question of the controller firmware.

We are trying to build our own controller based on the existing one, plus wouldnt wiring the entire controller + the step up/step down might be more complicated compared to just creating the controller to handle the inputDC/outputAC and a buck/boost seperately?

"Do you want to show the efficiency? Or do you want to develop your own controller?!"
Yes to both
 
be more complicated
No, the hardware to control the motor has everything you need to control the current and the voltage in both directions.
But I still don't understand how you want to spin the motor for doing regen. You have to have a big mass in movement that you can brake to get regen. So you will have to build a vehicle, that rolls downhill or you have to accelerate a heavy flywheel in motor mode first and then brake it to get the energy back. The motor itself will not help...
 
But I still don't understand how you want to spin the motor for doing regen.
One option is to build a dyno to test it, for example by using a second motor as load and connecting them mechanically. One motor can be set to accelerate and the second one to brake and that is how you can control the load.
 
One option is to build a dyno to test it
We had that discussion already ;)

Huh, but wouldnt it be easier/cheaper if we use the same motor to act as both a generator and a motor?

Of course, you could pull a sack of potatoes up to the hall ceiling with the motor and recover the energy when lowering it again.
I don't know whether a sack of potatoes and a rope would exceed the student team's budget. 🥔
 
Last edited:
No, the hardware to control the motor has everything you need to control the current and the voltage in both directions.
But I still don't understand how you want to spin the motor for doing regen. You have to have a big mass in movement that you can brake to get regen. So you will have to build a vehicle, that rolls downhill or you have to accelerate a heavy flywheel in motor mode first and then brake it to get the energy back. The motor itself will not help...
What do you mean by the hardware to control the motor has everything we need? Are you talking about the controller that we bought?
The main idea is that we are supposed to take existing controllers and adapt them for our own use, so while we cant just copy the schematic directly, we also dont really have to reinvent a totally new controller and way of handling DC to AC.

As for the breaking, one of my group members mentioned that we could brake the motor by using friction and that it should be enough for what we want to show, as we are really not after a super efficient system we are after having a cheap alternative for it. That being said, personally im worried that friction/inertia would not be enough, so I am open for the idea of something with some mass to help it stop

And we will show the regen by putting generated power into capacitor and we can measure the voltage that's in the capacitor and show how it's rising when we do breaking.
 
The main idea is that we are supposed to take existing controllers and adapt them for our own use, so while we cant just copy the schematic directly, we also dont really have to reinvent a totally new controller and way of handling DC to AC.
There is nothing to adapt. If a controller can drive the motor in motor mode, it can drive it in regen mode also. It's just a matter of the duty cycles you are applying on the three half bridges with the PWM. 🤷‍♂️
 
There is nothing to adapt. If a controller can drive the motor in motor mode, it can drive it in regen mode also. It's just a matter of the duty cycles you are applying on the three half bridges with the PWM. 🤷‍♂️
But Im worried about just copying the designs from preexisting diagrams no? Like this is for our final year design project, so we are expected to design. If we simply copy something that we found on the Internet I dont think thats enough.

Like currently our design looks like this 1772695644227.png
So the microcontroller sends pwm signals to the inverter mosfets, so the mosfets switch on and off at some freq to spin the motor

When you stop the pwm switching by the microcontroller the motor keeps spinning due to inertia and is essentially a generator

Since the motor generates 3phase ac, it goes back to the buck converter since the inverters diodes act as a rectifier, and it doesnt go through back to the dc battery due to the diode blocking the voltage

and then the buck converter regulates the voltage to a level the supercapacitor connected to it can handle, and we can measure the energy going into the supercapacitor
 
Hm, I think you have to read a lot about BLDC control...
The motor you have linked in the parallel thread #35 has hallsensors, so you don't have to use sensorless control. That makes things much easier. Measuring the voltage on the phases would be only necessary, if you want to do sensorless 6 step commutation, but this will make it difficult to start the motor from standstill. So I recommend to do the commutation with FOC and the rotor position detection with the hallsensors, that's state to the art. And with FOC it is very easy to get regen, just apply a negative iq. There are tons of literature and generic schematics about that... e.g. here
1772701789446.png

the motor keeps spinning due to inertia and is essentially a generator
the amount of stored energy will be very low, as it's a very small and light motor (the main mass is the stator, not the rotor). If you apply regen, it will just do "plopp" and the motor will stand still.
 
Last edited:
Hm, I think you have to read a lot about BLDC control...
The motor you have linked in the parallel thread #35 has hallsensors, so you don't have to use sensorless control. That makes things much easier. Measuring the voltage on the phases would be only necessary, if you want to do sensorless 6 step commutation, but this will make it difficult to start the motor from standstill. So I recommend to do the commutation with FOC, that's state to the art. And with FOC it is very easy to get regen, just apply a negative iq. There are tons of literature and generic schematics about that... e.g. here
View attachment 385295


the amount of stored energy will be very low, as it's a very small and light motor. If you apply regen, it will just do "plopp" and the motor will stand still.
Can't we read the hall sensors from the motor by directly connecting them to the microcontroller like in my diagram above? Tho then again I'm not really sure what you mean by right now it's sensorless 6 step commutation

Also regarding the code/commutation method, yeah I'm fine with doing it using simpleFOC, though im not sure if the microcontroller will allow it as my group wants to go with the esp32 microcontroller



Also regarding the load/inertia thing, if we do decide to go with another motor/weight like you showed in the parallel thread, wouldnt we still need to basically build the exact same thing as the schematic above since

Taken from my slides:

Alternative 1
-By using two motors instead of one and connecting them mechanically, we can set one as the load
-The AC Motor 1 would be powered by the DC battery, where the DC battery would connect to a 3-phase inverter to convert DC to AC exactly how our main idea is setup
-The 2nd motor would be mechanically linked to the 1st motor using a shaft, or gears and a chain like a regular bike, thus the 2nd motor would act as the load or generator
-The output of the 2nd motor would be 3 phase AC voltage, so to connect it to a supercapacitor to store the energy (E = 1/2CV^2) we would need to have it go through a 3-phase rectifier


But like it would still need to go through battery --> 3phase inverter --> motor1 --> Mechanically connected to motor 2 to spin --> motor 2 output --> 3phase rectifier --> buck converter --> supercapacitor

As well as adding the pwm switching stuff (so everything on the left side of the schematic) + microcontroller + possible DC bus b4 the buck converter from what my group members saw




Finally, main question I really want to be answered I guess, is will the circuit for the PWM & DC to 3phase AC work if we build it like that directly first of all? Like Im personally not really sure and if doesnt work, what other schematics do we need added from the stm site for our controller (for just the pwm and dc/ac conversion)
 
Can't we read the hall sensors from the motor by directly connecting them to the microcontroller like in my diagram above?
I can't see any hallsenor in your schematics. The hall sensors are in the motor. You can find a quite simple working schematic in the EBiCS repo:
 
I can't see any hallsenor in your schematics. The hall sensors are in the motor. You can find a quite simple working schematic in the EBiCS repo:
Our group was assuming that we can just directly connect the 5 hall sensor wires directly to the microcontroller (represented by the single wire coming out of the motor to the microcontroller)

Being honest here from my understanding of the schematic you sent, Im assuming CN1 is the 5 hall sensor wires from the motor, and then the respective outputs (5v, gnd, hall1/2/3) would be connected to the microcontroller? So that schematic is the wiring for the hall effect sensor?

1772712602938.png


Im assuming the schematic for the connections and components between the DC (battery) to AC (3phase motor) on the controller is the image below from STMicroelectronics on this specific controller: https://www.st.com/en/evaluation-tools/b-g431b-esc1.html#cad-resources
And then this schematic for the AC/DC conversion and pwm stuff, would we be able to use this?


Edit: Sorry if I sound dumb, but its 7am and I havent slept at all yet
 
Last edited:
Back
Top