I am designing a BLDC motor control board using the Field-Oriented Control (FOC) technique. I have completed some parts of the design and tested certain sections successfully.
Here is the my Github repo:
I am planning to use the STM32F103C8T6 for control, but I haven’t placed it in the design yet. I will be adding it later. Right now, I need help with:
Inverter section – Verification and improvements Shunt selection & configuration – Ensuring accurate current sensing
I have follow current sense section from VESC
If you have experience with BLDC motor control, power electronics, or FOC implementation, I’d really appreciate your insights. Looking forward to your feedback and suggestions!
Hi, new member here. I just looked around your schematics here some thoughts:
If you can, please use STM32G4 instead of F4, it is better fit with motor control. For example, with the builtin opamps, you can have a good current measure method without utilizing INA240 chips.
About current filter circuitry, do you really need to control it on fly. I mean, how about having a simple solder jumper to attach / detach the cap instead of using MC74 switch?
Instead of having separated gate driver for each phase, how about having one 3 half bridge driver. Here is just my thought, not every chip are identical, so having different gate drivers may lead to inconsistent pwm signals (please correct me if I’m wrong about this).
Speaking of the gate driver, I couldn’t find any mention about dead time PWM in the datasheet. So please be cautious when implementing the firmware, like setting the BDTR register for timer.
The mosfet only have 1R resistor for current limiting right? How do you think about fast on / slow off circuitry. Like (didode - resistor ) // resistor circuity, so at the turning on phase, the equivalent resistance will be lower than turning off phase. It will help you on tuning the driver efficiency and noise reduction. Maybe you don’t need to populate the components yet, but at least you can leave the footprint there, so you can optimize it in the future.
You are using wrong value for CAN termination resistor, it should be 120R, not 220R. And not every board need that resistor, only the first and last device in the bus need it. Usually, I use 2 60R resistors and one solder jumper in between them. So if this board is the last device, then I will bridge the jumper, otherwise I will leave it opened.
To have daisy chaining topology, why don’t we have one more CAN connector, then you can connect the next device easier. Additionally, the above termination resistors and jumper can be placed near the new connector. Trust me, routing is satisfying
Just minor things, it is better to have net label on every net. For CAN bus, I prefer to use CAN+, CAN- than CANH, CANL since we can route it as differential pair in Kicad. The same for Kelvin connection on current sense circuitry, I usually use Isns+, Isns-
Thank you for your feedback! I really appreciate your insights. Here are my thoughts on the points you raised:
1)Use of XL7500A buck converter
I chose the XL7500A to keep the design low-cost. However, I understand your concern about its limitations.
Could you suggest an alternative low-cost IC that would be more suitable for this application?
I have selected this IC as per the Power consumption of the whole system:
→ MOSFET gate current calculation,
Below is the just an example, I will use 12 mosfet so it will consume around 35 to 40mA max [ please let me know my calculation and understaning is right or not?]
example: I calculated the required gate drive current for “18 MOSFETs” (6 per phase, 3 upper and 3 lower). The details are as follows:
Iavg = N × Qg × fPWM
Iavg = 18 × 153nC × 15.6kHz
Iavg = 55mA
where,
- Gate charge (Qg) = 153nC (for the TI MOSFET: It will change as per mosfet selection)
- Number of MOSFETs (N) = 18
- PWM frequency (fPWM) = 15.6 kHz [I will run FOC at this frquency]
The remaining circuit consumes around 200–250mA max, so I chose XL7500A (400mA output) to accommodate the total current requirement.
2)EN pin connection to GND
According to the datasheet, the EN pin should be driven LOW to enable the device (floating defaults to LOW). Based on this, I have set it to LOW in my design.
4)SW pin usage : Here I will use switch to turn on and off the device
5)R47 in series with the buck input : I planned to use a 500mA fuse at this location to protect the MCU and other critical sections for safety reasons.
6)Current sense IC power: Thanks for pointing this out! It was a mistake, and I have now updated the design to use 3.3V for the current sense IC.
I appreciate your feedback and would love to hear your thoughts on my updated approach!
Guys, my plan is to use Sequoia’s design, for my big quiet fan, honestly I really wish we could stop trying to rehash things and focus on one flagship board. The replacement for the lepton (whose name I don’t mention) was pretty close, it just had a severe noise problem, probably from mosfet ringing (just like the lepton, although not quite as bad it was crippling, preventing reliable reading of the hall sensors).
It’s not done yet, though. I would strongly encourage you to just work on that one, not try to roll your own. People always think the work is worth it but they have not once really made a good board as far as I can see. One that they would have been happy to find if they had found it before starting work. The price goes up and up and the work it takes to get all the bugs out goes on apparently forever. If you are lucky you will spend a ton of time and get something that only just works for you and only just well enough and that’s it. Nobody else is likely to be able to use it. They will do the same thing next time as you did this time. Look far and wide, find nothing that is good enough, and have to go and make their own or do without.
I see your point, and I appreciate the suggestion! However, I’m designing a low-cost board as part of my learning process. I want to gain hands-on experience with the design, debugging, and optimization. That said, I’ll definitely take inspiration from existing designs and apply best practices to minimize noise issues. If you have any insights on improving performance while keeping costs down, I’d love to hear them! Also, could you share the MOSFET ringing images you observed? That would be really helpful in understanding the issue better. Additionally, what other issues have you encountered? It would be great to learn from your experience. Thanks!
@Anthony_Douglas I don’t think making a new board is a bad idea, even just for learning. I’m pretty sure that nowadays, it is not so expensive to start a new hardware design.
@BldcLover Sorry its my mistake, I did not check the schematics in details, so I misunderstand that you are using 15VDC to power the mosfets. But you are using battery directly, so there is no concerns about that.
But stills, you should:
Replace the AMS1117 LDO, you are trying to use an LDO to convert 15V → 5V. It is really bad for the IC and will get hot. Please use buck converter to do that.
Double check your current sense circuit. It seems wrong to me, the shunt resistor should be from the Source pin of the Q8 and Q10 to ground.
Be careful about PWM deadtime, since I don’t see any gate driver.
Let’s imagine, in you design:
At first the PA_HIGH is logic high, and PA_LOW is logic low. So: Q7, Q9 on; Q8, Q10 off
We do switch, PA_HIGH from high → low, PA_LOW from low-> high at the same time. Then: Q7, Q9 STARTING to turn off; Q8, Q10 STARTING to turn on.
Based on the datasheet of IRF540N. It needs 100ns to on and 145ns to off. That’s mean, at ~100ns after the switch event, Q7 and Q9 still on, while Q8 and Q10 has already turned on. Then we’ll have current spike from battery straight through the mosfets to ground . It’s called shoot-through problem . To prevent it, we will not turn on the mosfet immediately, but give it some delay (or say deadtime), so other mosfets can fully turn off.
Most mosfet gate driver/motor control IC nowadays already have dead time feature, so you can easily use PWM at 100% dutycyle. But in your design, I don’t see it yet. So please keep in mind this when implement it in firmware, or the best, using some dedicated IC to drive the mosfet like DRV8305, or if you don’t need high current (< 5A), using integrated driver IC, like DRV8313 or the legendary: DRV8316
Controlling the on / off time of the mosfet also directly affect the motor performance and efficiency. So that’s why in my previous comment, I mentioned about fast on / slow off stuff. Please leave some testpoints, DNP footprints, filter capacitor at gate-source to have a better optimization in the future, ringing problem might be fixed by optimizing the gate circuitry too.
The LDO does sound like a problem, although I haven’t seen the circuit where it’s used. But the other two points are ok, I think.
I was surprised at first by the current sense being inline rather than lowside, but the INA240 datasheet says it can do it. The VESC schematic is also using it inline.
STM32F103C8T6 has an advanced motor control timer that allows adjusting deadtime in software.
There is one potential problem I see in that PhaseA schematic image, though I’m not necessarily experienced enough to judge. There doesn’t appear to be a bootstrap circuit. The high side mosfets look like they will only receive 15V at the gate, but I think it needs to be boosted to 15V above the battery voltage for it to switch on.
Regarding the AMS1117 LDO Replacement:
Thank you for your suggestion. I understand that using an LDO for a 15V to 5V conversion is inefficient and could lead to excessive heat dissipation. Instead of AMS1117, I am considering using LM1117, as it can handle up to 20V input, offering better voltage tolerance.
Additionally, instead of XL7500A, I am looking into using SD4938[it has max 150V input], as it is commonly used in some Chinese controllers. If you have any insights or alternative recommendations, I would appreciate your feedback.
Current Sense Circuit Verification:
I appreciate your concern. Actually, I am planning to implement inline current sensing directly from the phase instead of using low-side sensing. If you have any suggestions or concerns regarding this approach, please let me know—I would be happy to consider them.
PWM Deadtime and Shoot-through Prevention:
You’re absolutely right, and I will carefully manage deadtime both in hardware and software to prevent shoot-through. While designing the schematic, I used IRF540 as a placeholder, but for the final implementation, I will be selecting a different MOSFET.
I am currently evaluating several options, and some of them are listed in the Excel sheet I shared. Your feedback is valuable, and I will ensure these considerations are addressed in my design.
excel file is not supported here so I have put the photo
I have updated the schematic and selected the STM32G431C6T6 MCU (48-pin).
I have shared a schematic image detailing the pin connections, along with an Excel file for reference. Please review it and provide any feedback on the pin selection.
Note: Peripheral connections have not been designed yet; this update only covers MCU pin assignments.
C30 is kind of useless, you can remove it, and adding 100nF decoupling cap for each power pin. I mean VBAT, 3xVDD.
VDDA if you are using 3.3V LDO and it is not noisy you can use an 100nF cap like the above. But if you just want to have nice ADC, use PI filter with ferrite bead there.
VREF should have decoupling cap too, 1uF is fine. Ferrite bead here may not necessary.
VREF can be used either as an internal voltage buffer (output) or external voltage reference (input). In the case of internal voltage buffer, you may feed it to INA240 ref pin. In the case of external ref, you can use the same net as VDDA
Crystal should also have load capacitors too.
Debug Led is perfectly fine, but as an OCD nerd, I prefer to control it via a mosfet instead. So we can power the led from some other power source, like 5V, not 3.3V.
NRST should have pull up resistor
The PB8 pin is also the Boot0 pin, so it need to have a pull down resistor. it should be weak enough (like 10k+), so your can signal will not be effected.
You may need pull up on HALL_A,B,C
You can use PB3 as SWO too, it may helpful on debugging.
You can place test points on unused GPIOs, who knows
It seems you are using TIM1 for PWM signals, just note it some where in the schematic
I am a bit confused about the INA240. I came across some discussions on the TI forums where people mentioned issues with reading phase currents. Do you have any insights or suggestions on this?
I am planning to measure currents in the range of 50 to 70A, depending on MOSFET selection and using a 0.5mΩ shunt. Any advice on optimizing this setup would be greatly appreciated.
You can use a mosfet instead of transitor for controlling LED, like my fav: IRLML6244. Mosfets require gate-source voltage to control not current, so it is more efficient. Since the purpose is not putting stress on our little 3.3V LDO, you can use 5V or even more raw power to supply the LED.
The PF0 may need a series resistor, 22Ohm is good enough.
About the IN240, you can power it with STM32 VDDA, and tie one of the REF pin to STM32 VREF.
I am planning to measure currents in the range of 50 to 70A, depending on MOSFET selection and using a 0.5mΩ shunt. Any advice on optimizing this setup would be greatly appreciated.
0.5m Ohm shunt is quite small, you will need very high gain setting, like 200V/V, which will introduce noise. 1m Ohm may be better fit. But keep in mind you will need shunt with more than 5W heat dissipation.
I have made the connections as per the suggestions. Could you please verify them?
Also, I noticed that in the STM32G431 [B-G431B-ESC1] Motor Control Kit schematic, the series resistor is placed on PF1 instead of PF0. I originally planned to use a 220Ω resistor on PF0 based on recommendations. What are your thoughts on this?
Additionally, for the power supply, I am considering using MP9486A instead of XL7500A. What do you think about this choice?
For your BAT_SENSE circuit you may want to add some diodes to protect the MCU against BEMF, at least if you are not using batteries only to power that thing.
@BldcLover Hi, sorry for late reply. I have been busy recent days
About the MCU, I don’t see any further problem. @Grizzly got a point, this knowledge has been consumed by me too. Thanks!
Also, I noticed that in the STM32G431 [B-G431B-ESC1] Motor Control Kit schematic, the series resistor is placed on PF1 instead of PF0. I originally planned to use a 220Ω resistor on PF0 based on recommendations. What are your thoughts on this?
Yeah, it’s my typo. You should place on PF1 (or the OSC_OUT) based on ST suggestion.
About the gate driver circuitry:
You may use wrong net label, there are both +15VDC and +14VDC.
You can use correct label input / output type. At least it will help on DRC.
To provide better thermal sense, you can use the filtered voltage instead of 3.3V, though it is not strictly required.
Maybe I’m dumb, but I don’t know what R45 is for?
About the power supply, MP9486A seems much better than XL7500A. Just keep in mind the switching frequency quite high (up to 1MHz) it can be noisy, you should keep the loop area as small as possible.
Oh, and don’t try to copy the design for each phase. You can reuse the same schematic for 3 phases.
I have updated the schematic based on your suggestions and inputs.
1)For your BAT_SENSE circuit you may want to add some diodes to protect the MCU against BEMF, at least if you are not using batteries only to power that thing.
Ans: I have updated it. Also, could you please recommend a fast switching diode suitable for protecting the MCU from reverse voltage?
You may use wrong net label, there are both +15VDC and +14VDC.
Ans: Updated, I have corrected the labels accordingly.
You can use correct label input / output type. At least it will help on DRC.
Ans: Do you mean I should use consistent labeling on every out side of the sheet?
To provide better thermal sense, you can use the filtered voltage instead of 3.3V, though it is not strictly required.
Ans: Updated, I have applied this change.
Maybe I’m dumb, but I don’t know what R45 is for?
Ans:
-: Role of R45 (Drain-to-Source Resistor)
Provides a Discharge Path for Residual Drain Voltage:
When the MOSFET (Q20, Q18) turns off, some residual charge may remain on the drain due to parasitic capacitance.
R45 helps discharge this residual voltage, preventing floating or unexpected behavior.
Aids in Fast Body Diode Recovery:
If the MOSFET’s body diode conducts, it can stay slightly forward-biased after switching off.
R45 helps drain this stored charge, improving diode recovery and reducing conduction losses.
Damps High-Frequency Oscillations:
MOSFET switching can introduce ringing due to PCB inductance and capacitance.
R45 helps suppress these oscillations, improving overall circuit stability.
Smooths Turn-Off Behavior:
Without R45, the drain-source voltage transition might be abrupt, causing voltage spikes and EMI issues.
This resistor helps soften the transition, reducing stress on components.
Also, please let me know if you have found any issues or if you have any doubts.
About the power supply, MP9486A seems much better than XL7500A. Just keep in mind the switching frequency quite high (up to 1MHz) it can be noisy, you should keep the loop area as small as possible.
Ans: Noted, I will optimize the power supply layout to minimize noise and loop area.
Oh, and don’t try to copy the design for each phase. You can reuse the same schematic for 3 phases.
Ans: Do you mean I should copy and paste the section in the layout and manually adjust the labels?
Now, you can connect them together, to have a nice beautiful block level-ish design with consistence phase schematic without repeating your self too much. It will also helps on replicate the pcb layout later on with just one click.