Brushed DC motor control IC killing MCU

Thread Starter

Ephex

Joined Jul 4, 2021
83
Hi all

I have a PCB I made for an RC car which somehow kills the MCU. Two separate times on two different boards (v1.2 of the PCB) with different components, it worked fine for 30-40 minutes before one motor gave up, and the MCU shortly after (MCU got hot, 10 Ohm between 3.3V and GND on the board). v1.2 of the PCB features 4 DC motor controllers and an ESP32-S3-WROOM-1-N8. REV_pin and FWD_pin are connected directly to GPIO pins on the ESP32. The motor ICs are connected as such:
Rsense2 is a mere 0.01 Ohm for current measurement
(Rsense2 is a mere 0.01 Ohm for current measurement)

I have learned from a Reddit post that Vm and Vdd are not supposed to both be connected to the battery (2S LiPo, ~8V) despite the data sheet saying "Power Supply Voltage" for both VDD and VM (my mistake). This could very easily have been the thing that caused the MCUs to die after a while, but I'm not sure how it could have happened. Did the logic pins of the motor IC somehow push current the other way into the ESP, destroying it? Did a voltage spike (when a motor got turned off) kill the ESP through BAT+ -> LDO -> ESP32 (there were plenty of capacitors around the LDO though)?

I have designed a new version (v2.0) with most components getting switched out. There are now two dual-channel DC controllers as well as DPDT analog switches to only require one PWM channel for each motor (a total of 8 channels for the ESP32-S3 are available, but I need more).

1702918912482.png
1702919016205.png

FWR_x and REV_x for each motor are connected to GPIO pins on the ESP32, enabling one to be PWM and the other a digital out. The analog switch enables me to change how they are connected to the motor ICs using one bit (Mx_DIR). This is not an attempt at fixing the issue, only to not need more PWM channels. This brings me to my first question:
1. Do I need something between the GPIO pins and the motor IC logic input? A resistor? Opto-coupler?

I have also left capacitors in parallel with each motor (C_M):
2. Are the capacitors C_M needed? What value in that case? Will they affect the system in a good or bad way? It feels a bit off.

The new motor drivers felt more straightforward compared to the old ICs, but they lack a bit in terms of documentation. There are no flyback-diodes in the schematic for the H-bridge and they don't mention it anywhere. They have plenty of "XXXXX protection" but I don't feel certain.
3. Are separate flyback diodes needed for this new IC?

4. How does one handle the voltage transients and back-emf from the motor?

Here is the LDO that converts battery power to 3.3V:
1702920332633.png
Also, my attempt at switching the battery with a tiny switch (SW4):
1702920395319.png

Is anything weird/questionable with my design?

Truly grateful for all the feedback I can get!

// Ephex
 

dl324

Joined Mar 30, 2015
17,004
it worked fine for 30-40 minutes before one motor gave up, and the MCU shortly after (MCU got hot
TLDR
I assume the motors and MCU share the same power supply. If that's the case, do you have snubber diodes on the motors?

Your schematics are "very colorful", but us old timers prefer black on white (monochrome) schematics without distracting grids.
 

Thread Starter

Ephex

Joined Jul 4, 2021
83
@dl324 The motors and MCU do share the same power supply (2S lipo) but of course at different voltages.

I assume "snubber diode" and "flyback diode" are the same thing? In that case:
  • The first mentioned version (v1.2) seems to have built-in flyback diodes for the H-bridge in the motor ICs, so no external ones were implemented.
  • The newer version (v2.0), which is WIP, may have flyback diodes in the H-bridge, but there are none visible in the data sheet and they are not mentioned. The other "protections" might include this, however(?).

My schematics are indeed colorful, I am afraid. Us Zoomers like dark mode with colors;) . The grid might get removed though.
 

k1ng 1337

Joined Sep 11, 2020
986
Sounds like voltage spikes during switching. Try adding a flyback diode and a snubber circuit to each bridge transistor. They absorb transients in a different way but both return energy to the circuit.

Flyback diodes provide a discharge path with a low forward voltage especially with Schottky diodes. This will clamp voltage spikes but this is a diode junction which takes time to forward and reverse bias.

Snubbers charge a capacitor through a resistor according to the RC constant. A larger capacitor will clamp larger transients but is still an RC circuit which takes time to charge and discharge.

Think about the advantages and disadvantages of each.
 

Thread Starter

Ephex

Joined Jul 4, 2021
83
Try adding a flyback diode and a snubber circuit to each bridge transistor.
The thing is that the car has 4 motors => 4 H-bridges => 16 bridge transistors, which means that 3 additional components per bridge transistor require 48 more components in total, which sadly is too much. What would be a good compromise?

Also, the old motor driver IC had built-in flyback diodes, so adding external ones (if the newer IC does not have them) might not solve the problem(?)

EDIT: For the voltage spikes, do those spike the battery voltage or do they somehow affect the logic inputs? What about placing a Schottky diode over each motor driver between Vm and GND with a reverse voltage of e.g. 1-2V above the nominal battery voltage? Will that not lead to such voltage spikes causing the diode to conduct, limiting the voltage? Additionally, maybe add one to protect the MCU from voltages above 3.3V? Maybe clamp the LDOs as well? I'm new to this so I might be way off.

You will find that printing your circuits on paper is expensive.
I'd rather save my eyes when drawing circuits, and revert to default colors if I ever were to print them out on paper :)
 
Last edited:

dl324

Joined Mar 30, 2015
17,004
Additionally, maybe add one to protect the MCU from voltages above 3.3V? Maybe clamp the LDOs as well? I'm new to this so I might be way off.
If spikes of sufficient magnitude are put on the power supply, it can cause the MCU to latch-up. Latch-up is usually destructive if you don't remove power soon enough.
and revert to default colors if I ever were to print them out on paper
Please use default colors when posting on AAC so they'll be easier for us to read.

The layout of your components is good, but all of the colors make your schematics look childish.
 

Thread Starter

Ephex

Joined Jul 4, 2021
83
If spikes of sufficient magnitude are put on the power supply, it can cause the MCU to latch-up. Latch-up is usually destructive if you don't remove power soon enough.
The voltage spikes are applied to the battery voltage, which is stepped down to 3.3V through an LDO which is then finally fed to the MCU. At which point is the voltage protection supposed to be placed, and what should it look like?


Please use default colors when posting on AAC so they'll be easier for us to read.

The layout of your components is good, but all of the colors make your schematics look childish.
That's fair, for posting here on AAC, I will use default colors from now on. If they look childish or not, I would say is subjective ;)
 

dl324

Joined Mar 30, 2015
17,004
The voltage spikes are applied to the battery voltage, which is stepped down to 3.3V through an LDO which is then finally fed to the MCU. At which point is the voltage protection supposed to be placed, and what should it look like?
Have you observed voltage spikes getting through the LDO?
If they look childish or not, I would say is subjective ;)
It seems that "childish" is becoming the norm. I've seen schematics drawn by college professors that would be a source of embarrassment for me.
 

k1ng 1337

Joined Sep 11, 2020
986
The thing is that the car has 4 motors => 4 H-bridges => 16 bridge transistors, which means that 3 additional components per bridge transistor require 48 more components in total, which sadly is too much. What would be a good compromise?

Also, the old motor driver IC had built-in flyback diodes, so adding external ones (if the newer IC does not have them) might not solve the problem(?)

EDIT: For the voltage spikes, do those spike the battery voltage or do they somehow affect the logic inputs? What about placing a Schottky diode over each motor driver between Vm and GND with a reverse voltage of e.g. 1-2V above the nominal battery voltage? Will that not lead to such voltage spikes causing the diode to conduct, limiting the voltage? Additionally, maybe add one to protect the MCU from voltages above 3.3V? Maybe clamp the LDOs as well? I'm new to this so I might be way off.


I'd rather save my eyes when drawing circuits, and revert to default colors if I ever were to print them out on paper :)
I reread your posts and it seems like you skipped some troubleshooting steps. Are you sure everything is wired correctly? If so, are you sure your chosen components can handle the power you are demanding of them? Is the PWM frequency compatible? Are you providing adequate dead time in your code?

If the above is ok then I think the voltage spikes are from the motor(s) when they are in a fault condition. Turning off a transistor while current still flows will cause the voltage at those nodes to rise until a discharge path is found. If the MCU and the motor(s) are on the same Vin, the MCU has no choice but to accept the increase in line voltage unless regulator can handle a transient which is apparently cannot.

I see from your schematic the one motor has a large 10uF (polarized) capacitor directly across each motor. First of all, using a polarized capacitor like this is dangerous because the terminal voltage is constantly swapped. Second, this large capacitor can dump many Amps of current back into the line turning turn off because there is no current limiting resistor (is this what you want?). Either reduce these caps to 100nF or get rid of them altogether and build a RC or RCD snubber.

Here is a simple RCD snubber circuit. Notice how the low side is shorted the source terminal of the FET. You only have Csnub in your circuits which means the inrush and outrush currents can be very large especially for a 10uF capacitor!

3423423.png
 

BobTPH

Joined Jun 5, 2013
9,149
The thing is that the car has 4 motors => 4 H-bridges => 16 bridge transistors, which means that 3 additional components per bridge transistor require 48 more components in total, which sadly is too much.
Just one snubber across each motor, preferably right at the motor terminals.
 

Thread Starter

Ephex

Joined Jul 4, 2021
83
Have you observed voltage spikes getting through the LDO?
I have not. Nothing was connected to an oscilloscope when it happened. I guess it doesn't hurt to have protection in several steps.

If something like this would be added, wouldn't this limit the VCC-net to 9V and the +3V3-net to 3.5V?

1703004106593.png

Also, adding optocouplers for the logical inputs to all motor driver ICs (total of 8 components) would galvanically isolate(?) the MCU from each motor driver? Finally, adding a 100nF ceramic capacitor to Vm on each motor driver would hopefully further filter out noise from the motors during switching.

It seems that "childish" is becoming the norm. I've seen schematics drawn by college professors that would be a source of embarrassment for me.
I'd say that dark mode and colors provide functional benefits. There's no need to let the background pixels blast our eyes at [255,255,255] all the time. Different colors also help distinguish different parts of the schematic from each other.
 

dl324

Joined Mar 30, 2015
17,004
If something like this would be added, wouldn't this limit the VCC-net to 9V and the +3V3-net to 3.5V?
Schottky diodes with such low breakdown voltages would be pretty useless. Do you mean zener diodes or MOV's?
Also, adding optocouplers for the logical inputs to all motor driver ICs (total of 8 components) would galvanically isolate(?) the MCU from each motor driver?
They'll still share power and spikes on power seem to be the leading suspect.
Finally, adding a 100nF ceramic capacitor to Vm on each motor driver would hopefully further filter out noise from the motors during switching.
Capacitors alone won't do much to suppress back EMF from switching motors off. Diodes are a simple solution.

I still don't have a good picture of how you're switching the motors because I can't force myself to read your schematics.
 

Thread Starter

Ephex

Joined Jul 4, 2021
83
I reread your posts and it seems like you skipped some troubleshooting steps. Are you sure everything is wired correctly? If so, are you sure your chosen components can handle the power you are demanding of them? Is the PWM frequency compatible? Are you providing adequate dead time in your code?
For the old design (1.2); it was working fine for 30-40 minutes, but I ran in RWD only (with high duty-cycles) when the "accident" happened. The old driver ICs had an internal shut down at 1.5A, but the motors never pull such current, the stall current is ~1A @8.4V if I remember correctly. The PWM frequency is 25kHz, which was recommended "to reduce noise". I also never ran at sub 20% duty cycle which was also not encouraged.

If the above is ok then I think the voltage spikes are from the motor(s) when they are in a fault condition. Turning off a transistor while current still flows will cause the voltage at those nodes to rise until a discharge path is found. If the MCU and the motor(s) are on the same Vin, the MCU has no choice but to accept the increase in line voltage unless regulator can handle a transient which is apparently cannot.
This sounds very plausible. The new motor driver ICs don't require both Vm and Vdd, only VBB (motor supply voltage) while assuming that the logic pins get ~3.3V.

I see from your schematic the one motor has a large 10uF (polarized) capacitor directly across each motor. First of all, using a polarized capacitor like this is dangerous because the terminal voltage is constantly swapped. Second, this large capacitor can dump many Amps of current back into the line turning turn off because there is no current limiting resistor (is this what you want?). Either reduce these caps to 100nF or get rid of them altogether and build a RC or RCD snubber.
I'm not sure which capacitors you are talking about. There are no polarized capacitors used in v1.2, only a few between VCC and GND for v2.0. Regardless, there were never going to be polarized capacitors over each motor, precisely for the reasons you mentioned. The value of 10uF however is absolutely something that should be changed if it is too big. I will change them to 100nF! (For clarification, I am talking about C11 in the first picture, and the value "C_M" for v2.0.

Here is a simple RCD snubber circuit. Notice how the low side is shorted the source terminal of the FET. You only have Csnub in your circuits which means the inrush and outrush currents can be very large especially for a 10uF capacitor!
Thanks! To limit the amount of components on the board (it is currently packed) I will resort to only reducing the value of C_M to 100nF.
 

Thread Starter

Ephex

Joined Jul 4, 2021
83
Schottky diodes with such low breakdown voltages would be pretty useless. Do you mean zener diodes or MOV's?
They'll still share power and spikes on power seem to be the leading suspect.
Capacitors alone won't do much to suppress back EMF from switching motors off. Diodes are a simple solution.
Alright, switched them out to zener diodes. Would it be enough with one reverse biased zener diode between VCC and GND or should I have one near each motor driver? Also, what about the one for +3V3 and GND? Close to the LDO or near the MCU? Does it even matter?

I still don't have a good picture of how you're switching the motors because I can't force myself to read your schematics.
The PWM signals are applied directly from the MCU on the logic pins of the driver ICs. Here's the complete schematic of v1.2 in default KiCad color scheme:
(there's a current measurement circuit in both designs that can be ignored for now)

1703006593035.png

Motor driver schematic:
1703006634880.png



The current state of the newer design v2.0:

1703006739655.png

I hope it's possible to make out each component, I "exported the schematic to clipboard".
 

k1ng 1337

Joined Sep 11, 2020
986
Alright, switched them out to zener diodes. Would it be enough with one reverse biased zener diode between VCC and GND or should I have one near each motor driver? Also, what about the one for +3V3 and GND? Close to the LDO or near the MCU? Does it even matter?


The PWM signals are applied directly from the MCU on the logic pins of the driver ICs. Here's the complete schematic of v1.2 in default KiCad color scheme:
(there's a current measurement circuit in both designs that can be ignored for now)

View attachment 310346

Motor driver schematic:
View attachment 310347



The current state of the newer design v2.0:

View attachment 310349

I hope it's possible to make out each component, I "exported the schematic to clipboard".
In the second image, you have a 10uF capacitor shown as non-polarized. Caps this large are usually polarized so I wasn't sure you knew that.

According to the functional diagram of your A3909 half bridge drivers, there is no snubber circuit present. The FETs each have a body diode but the datasheet doesn't provide information about them so they shouldn't be relied upon. The chip does have overcurrent protection so I'm starting to think your problem is elsewhere.

Untitled.png


I am suspicious about how you are controlling the motors with XS3A2467. How did you deal with dead time? I'm not an expert but I'll take a look at your code.
 

Thread Starter

Ephex

Joined Jul 4, 2021
83
In the second image, you have a 10uF capacitor shown as non-polarized. Caps this large are usually polarized so I wasn't sure you knew that.
The ones used were 10uF ceramic capacitors (1206).

According to the functional diagram of your A3909 half bridge drivers, there is no snubber circuit present. The FETs each have a body diode but the datasheet doesn't provide information about them so they shouldn't be relied upon. The chip does have overcurrent protection so I'm starting to think your problem is elsewhere.
The A3909 driver is the one for the new PCB (v2.0) and can be changed. I have not ordered v2.0 yet, it is only v1.2 that has been tested IRL. Given that reverse-biased zener diodes are placed to protect against voltage spikes, and optocouplers between the MCU and logic input ports, would it still be necessary for external snubber circuits you think?

I am suspicious about how you are controlling the motors with XS3A2467. How did you deal with dead time? I'm not an expert but I'll take a look at your code.
Those DPDT analog switches are for v2.0 and do not exist on v1.2. The plan is, however, to have 3 GPIO pins for each motor:
  • One GPIO assigned to PWM, connected to the DPDT
  • One GPIO assigned as digital output, also connected to the DPDT (the other pole)
  • One GPIO that switches the analog DPDT such that the PWM/digitalout "change place" from the motor driver's perspective
This way, only one GPIO per motor has to use a PWM channel on the MCU. If you want to change direction, the DPDT can be switched with the last mentioned GPIO. I have not seen this before but felt like it solves the problem I had with limited number of PWM channels.
 

BobTPH

Joined Jun 5, 2013
9,149
If you are using an H- bridge, why are you using an analog switch to change direction? The whole purpose of an H-bridge is to change direction.
 
Top