Seeking Help: BLDC Motor Control Board Development (FOC Technique)

I looked at these transistor circuits, and I think something is wrong here regarding the input stage. I assume that most of these circuits have been proven good before. The gate of the power mosfet is pulled down a lot faster than it is pulled up. So the power mosfet will turn off a lot faster than it turns on. I guess this is intentional.

If you assume 3.3 V input to the stage with Q3 you will get close to 3.3 V on the base of Q3. Then about 2.7 V on R44 and it cause a current of 1.2 mA. It cause a voltage on R43 of 0,626 V. It is not safe to say that Q5 will turn on by that due to component variations. I guess the circuit should work with 5 V logic. I suggest that you change R44 to 1.5 kohm or perhaps 1.2 kohm.

The input stage with Q4 seems to be non-inverting, so high input turns power mosfet off. You have about 2.7 V on emitter of Q4. With 3.3 V input you get 0.27 mA in R40 and 1.22 mA in R46. It makes 0.95 mA in Q4 and it do not turn off Q6 safely. At = 0 V input you get about 2.4 mA in Q4 so it turns Q6 on safely. I think you should change R46 to about 3.3 kOhm.

Backflip:
You’re absolutely right—I’ve changed the resistor values, and since the STM32F103 operates at 3.3V, I’ve switched to a 3.3V supply instead of 5V. Thanks a lot for your insightful feedback!

dekutree64:
Thank you for taking the time to look closely at my PCB layout. I’m currently updating it based on your suggestions, and I really appreciate the helpful ideas—they’re making a big difference. I’ll be sharing the updated version shortly!

Here is the current update:



In the latest transistor diagram, I think you missed a 560E resistor i series with the D32 diode.

Hi everyone,

Sorry for the late update—I’ve been under the weather recently and needed some time to recover.

Just a quick update on the project:

I’ve made improvements to the ground and power tracks (Battery+), based on the helpful suggestions from dekutree—thank you for pointing that out! I’ve also added a 560Ω resistor as part of the latest changes. Thanks to Backflip for detailed review of the schematic—much appreciated!

There are still a few ground tracks left unconnected, so a bit of minor work is still pending to fully clean things up.

For DC current sensing, I’ve added another INA181. It’s connected to the Brake ADC via an optional resistor. By configuring this resistor, we can select between monitoring the battery current or the brake ADC input, depending on the application.

Please have a look and let me know if there’s anything else that could be improved. Your feedback is always welcome!

Special thanks again to Backflip and dekutree for their valuable input and support.

Best regards,
BldcLover

There is size issue so I have made this arrangement.





I have tried to look back in this thread, and I am not quite sure of the power requirements. So I just like you to confirm them again, because they do influence some parts of the design:

What is the battery supply voltage you design for?
What is the required average max power to the motor?
What is the required short term peak current to the motor?
Do you consider to have regenerative breaking of the motor?

Are you fixed to use a two-layer PCB instead of four layers?

Hello Backflip,

Thank you for revisiting the power requirements—I’d be happy to clarify them, as they definitely influence key parts of the design:

  • Motor Power Target: I’m currently targeting this design for an e-bike motor rated between 350W and 500W.

  • Battery Supply Voltage: The motor is rated for a 42V battery, but I’m planning to design the DC-DC converter to support up to 85V input for greater flexibility and compatibility.

  • Required Average Max Power to the Motor: At this stage, the motor is rated for 350W, so I’m designing around that power level.

  • Peak Current Requirements: I haven’t measured the exact peak current yet. However, the no-load current is around 0.6A, and under typical conditions (e.g., a single rider), the full-load current ranges from 12A to 15A. Based on the rated power, the theoretical average current would be approximately 8.3A (350W / 42V).

  • Regenerative Braking: I’m planning to include regenerative braking, but I’m still learning how to implement it both on the hardware and software sides. Any guidance or references would be greatly appreciated!

  • PCB Layer Choice: I’m currently working with a 2-layer PCB, as this is a hobby project and I’m operating within a fixed budget. While I understand the benefits of a 4-layer design, the cost is a limiting factor at the moment.

Please feel free to share any suggestions, feedback, or concerns based on this information. I truly appreciate the support and guidance from the community!

Best regards,

BldcLover

Hi everyone,

Just a quick update:

I’ve completed the initial design for the motor controller. If you notice any areas that could be improved, please feel free to share your suggestions—I’d really appreciate your feedback!

I’m now in the process of selecting a low-cost MOSFET suitable for a 42V, 350W e-bike motor. If anyone has recommendations for reliable and budget-friendly options, I’d love to hear them!

Thanks again for all the support!

Best regards,
BldcLover



I shall try with a few comments :slightly_smiling_face:

Be aware, that this high DC voltage can be a challenge. If a fault cause a short circuit anything, the battery may be able to support very high currents, and it causes arching and fire risks. So you need good sand fuses in series with the battery to prevent some nasty events.

I would avoid the extra common shunt resistor, because it introduces increased self inductance of the ground current path. You are able to measure the currents in the three other shunts and add the results to provide the same signal. I do not like the self inductance in ground from the big electrolytic capacitor to the far away half bridge. In previous design, you also had a ground path on the other side of the PCB, and it helps. It would be better also to have two electrolytic capacitors and one on each end of the PCB to reduce this self inductance. It may cause a longer physical PCB, but the height of the board may become less overall.

I think you will like to be able to measure +/- 15 Amps with the shunts. This is 0,15 V on the 10 mOhm shunt. You cannot choose less amplification of the INA181 than 20, so it causes +/- 3 V. But you only got a range of +/- 1.65 V with the 3.3 V power supply. Therefore I suggest shunts of 5 mOhm.

I think you like to have a fair common mode rejection, CMRR with this INA181. It is guaranteed to be above 84 dB or 1:14.000 with zero Thevenin impedance on the reference input. But R19 and R62 makes a Thevenin resistance of 15 kOhm. The internal resistor is 500 kOhm according to page 22 in data sheet. Therefore the CMRR is reduced to about 33 or about 30 dB. I suggest you reduce the resistors to perhaps 1 kOhm. Another possibility is to make a common center voltage reference supply with close to zero impedance.

I am not that experienced in PCB design to ESCs, so I cannot say that a two layer PCB is sufficient or not. I know, that the signal integrity is very much improved by a main ground plane in the PCB. With four layers you will also be able to reduce the problems related to the self inductance of the shunts, that cause high voltage transients on the measured voltage on the shunts. I explained a bit about that in my other recent post tagged current_sensing.
https://community.simplefoc.com/t/shunt-current-measurement-considerations/7103
It also explain the need for some RC filtering here. If you got layer 2 as ground and layer 3 as power, two electrolytic capacitors are not an issue anymore.

I tried to look into choice of power mosfet. The IRF540 is an old design, but it is also widely available. But I like to have a bit lower power loss to avoid a heatsink. So I suggest a mosfet with about half RdsOn. It could be IPP180N, with about same price or IRF8010.

High Voltage and Battery Safety

Suggestion:

Be aware, that this high DC voltage can be a challenge. If a fault causes a short circuit, the battery may be able to support very high currents, which could lead to arcing and fire risks. So you need good sand fuses in series with the battery to prevent some nasty events.

Response:

Thank you for the important reminder. Yes, I’ve placed a fuse in series with the battery wire. During earlier testing, I was using the same setup. Still, I appreciate the suggestion — safety is crucial in high-voltage systems, and it’s good to be reminded of the risks involved.


Common Shunt and Self-Inductance

Suggestion:

I would avoid the extra common shunt resistor, because it introduces increased self-inductance of the ground current path. You can measure the current in the three phase shunts and sum them instead. I also dislike the self-inductance from the large electrolytic capacitor to the distant half-bridge. In the previous design, a ground path on the other side of the PCB helped. It would be better to have two electrolytic capacitors, one at each end of the PCB, to reduce this inductance. While it might make the board longer, the overall height could be reduced.

Response:

Thank you for the detailed feedback. I am planning to implement both sine commutation and FOC.

  • For sine commutation, I intend to remove the three phase shunts and use a single DC shunt.

  • For FOC, I will revert to three phase shunts and remove the DC shunt.

I also agree with your observation on self-inductance and layout concerns. Based on your suggestions and input from Dekutree, I’ve decided to go with a 4-layer PCB, which should help significantly with signal integrity and grounding. In some parts of the layout, I was indeed struggling to provide proper ground paths, so the extra layers should help resolve that.


Shunt Resistor Value and INA181 Output Swing

Suggestion:

I think you will want to measure ±15 A with the shunts. This is 0.15 V across a 10 mΩ shunt. The INA181 has a minimum gain of 20, so this causes ±3 V output. But the INA181’s output range with a 3.3 V supply is only ±1.65 V, so I suggest 5 mΩ shunts instead.

Response:

Here are the output swing calculations for different shunt values:


:small_blue_diamond: Case 1: 5 mΩ Shunt

  • Vshunt = ±15 A × 5 mΩ = ±0.075 V

  • Output = 1.65 V ± (0.075 V × 20) = 1.65 V ± 1.5 V

  • ➜ Output range = 0.15 V to 3.15 V :white_check_mark:

Perfect fit — fully utilizes the INA181’s swing range without clipping.

Yes, you are absolutely right. This is the ideal choice.


:small_blue_diamond: Case 2: 3 mΩ Shunt

  • Vshunt = ±15 A × 3 mΩ = ±0.045 V

  • Output = 1.65 V ± (0.045 V × 20) = 1.65 V ± 0.9 V

  • ➜ Output range = 0.75 V to 2.55 V :white_check_mark:

Still valid, but reduces ADC resolution.


This comparison confirms that 5 mΩ is a well-balanced choice for maximizing resolution without risking output clipping.


CMRR and Reference Input Impedance

Suggestion:

You want good common-mode rejection (CMRR) with the INA181. It’s rated at ≥84 dB with zero Thevenin impedance on the reference pin. But R19 and R62 form a 15 kΩ resistance, and with the INA181’s internal 500 kΩ resistor, this drops CMRR to ~30 dB. I suggest reducing those resistors to ~1 kΩ or using a low-impedance reference source.

Response:

Thank you for pointing this out — it’s an excellent observation. I’ve replaced R19 and R62 with 2 kΩ resistors, so the total Thevenin resistance is now 1 kΩ, significantly improving CMRR. I had overlooked this detail initially.


Layer Stackup and Signal Integrity

Suggestion:

I’m not experienced in ESC PCB design, but I know signal integrity improves significantly with a dedicated ground plane. With 4 layers, you can also reduce self-inductance in shunts, which helps minimize high-voltage transients. You may also benefit from RC filtering. If you place GND on layer 2 and power on layer 3, using two electrolytic capacitors becomes easier.

Response:

Yes, I’m moving forward with a 4-layer PCB, thanks to your suggestions and insights from Dekutree. I was facing issues with proper grounding on some components in my 2-layer design. The 4-layer approach will also help minimize parasitic inductance and improve layout flexibility.


MOSFET Selection

Suggestion:

The IRF540 is widely available but quite old. I prefer something with lower Rds(on) to reduce power loss and possibly avoid a heatsink. Consider alternatives like IPP180N or IRF8010.

Thank you for the MOSFET suggestions. I’ve already shortlisted a few options and will share them shortly for feedback. Reducing conduction losses is a high priority, and I agree — using a more modern, low-Rds(on) device will improve efficiency and thermal performance.

INA181 with groud plane ,



3.3vdc supply top and bottom view,


3.3VDC Supply to INA181 bottom layer

3.3VDC Supply to INA181 , top layer

+12vdc top view

+12VDC to bottom view,

Layer 2 as ground plane:

Now I am confused — should I use large polygons for 3.3 VDC and +12 VDC in layer 3 as power planes, and keep the +Battery trace routed externally, or should I replicate the same strategy on the power layer?

Here is the my github repo: