# jenswilly.dk

## DC motor drive from 3.3 V MCU

29. November 2012 22:24 by Jens Willy JohannsenFor the ROV project I need to drive six DC motors (waterproof motors from bilge pumps). They are 12 V DC brushed motors running a 6 amps at full speed and I want to control them using PWM (for variable speed) from an LPC1347 MCU.

A popular way of controlling DC motors is by using an H bridge. However, since I only need to drive the motor in one direction I can use a simpler configuration: a single N-channel MOSFET as a low-side switch.

First I need to find a MOSFET that can handle the 6 amps continously and not get too hot. And since I will switching the MOSFET on and off using PWM at a frequency of 20 kHz I also need to consider switching power loss.

Here are a couple of useful links: choosing a MOSFET, MOSFETs and drivers, MOSFET power dissipation.

### Gate current and MOSFET driver

Even though the MOSFET doesn't require a high voltage to fully switch on, the MOSFET gate does have a quite high capacitance (typically, the higher current a MOSFET can handle the higher gate capacitance it has) and in order to switch the MOSFET on and off quickly enough we need a high current (of the order of a few amps).

If the gate current is low it takes longer to switch the MOSFET and the resistance through the MOSFET is much higher when the MOSFET is switching. And higher resistance means higher power loss and higher temperatures.

Since the MCU cannot provide or sink more than 4 mA we'll use a *MOSFET gate driver* to boost the current from the MCU and to handle the higher sink current.

### Flywheel diode and capacitor

I won't go into details since you can read about it in great detail elsewhere (Wikipedia for example) but you do need a diode and a capacitor on the motor circuit. I tried without diode and capacitor with a scope attached. With no flywheel diode there were some really large voltage spikes every time the motor stopped (about 130 V). And without the capacitor (but with diode) there was a nasty "ringing" (starting out a about 20 V) every time the motor stopped.

So the final circuit is:

## Choosing the correct MOSFET

10. September 2010 14:54 by Jens Willy JohannsenI just found out I forgot to post this article about choosing the right MOSFET for the autogun project. Here it is:

When switching on the gun, we're passing a significant amount of current through the MOSFET.

As shown on the power test tables in this posting, we should expect a peak of 50 Amps and a sustained current of about 20 Amps.

So the MOSFET should be able to handle at least 15V and 60A. And since we are turning on the MOSFET from the MCU control circuitry at 5V the gate threshold should be low enough for the MOSFET to turn fully on at 5V. In practice this means a logic-level MOSFET.

The datasheets of MOSFETs will list a whole bucketful of specifications. Some of the important ones are:

V_{DSS} |
maximum drain-source voltage. In my case, it should be at least 15V |

I_{D} |
maximum drain current. In my case, it should be at least 60A to be safe. (Although the *sustained* current will only be 20A.) Be careful with this one. Often it will be specified as one value "silicon-limited" and another - lower one - as "package-limited". This means the chip itself can handle a high current but the casing might melt or burst into flames. Which is bad. So use the lower one. Also, it might be specified as one value "@ 25 °C" and another - again, lower - "@ 110 °C". Again, use the lower one since it is highly unlikely that the MOSFET will be at 25 °C when we are pulling 20A through it. |

P_{D} |
maximum power dissipated in the MOSFET. This is calculated as R_{DS(on)} * I^2. |

V_{GS(th)} |
gate threshold voltage. This is a measure of how much voltage on the gate is required to turn the MOSFET on. As mentioned, since we're dealing with logic-level voltages, it should be no more than 2.5V |

R_{DS(on)} |
drain-source resistance when fully on. This will determine how much power is dissipated in the MOSFET's junction. Since all the power dissipated in the MOSFET junction is converted into heat we need to check how fast we can get rid of that heat. Otherwise, the MOSFET will heat up and eventually break. And possibly (albeit not likely) melt and/or burst spectacularly into flames. Therefore, we will also take a good, long look at the following: |

R_{ΘJ-A} |
thermal resistance between junction and ambient. This is a measure of how much power can be dissipated as heat from the junction to the surrounding air without any help. |

R_{ΘJ-C} |
thermal resistance between junction and case. We might need this if we need a heatsink. In that case we need to add this with the thermal resistance of the heatsink (R_{ΘHS}) and check if we are below the max allowable thermal resistance. |

T_{J} |
maximum operating temperature for the junction. We need this to check if enough heat is dissipated. |

Browsing through dozens of MOSFETs, this one looked promising: IRL1404PbF. It is listed as a "N-LogL 40V 160A 200W 0,004R TO220AB" MOSFET.

(Which means "N-channel, logic-level, V_{DSS}=40V, I_{D}=160A, P_{D}=200W, R_{DS(on)}=0,004Ω in a TO-220 package".)

It looks good because:

- it is logic-level activated
- it can handle 15V
- it can handle 60A
- it has a low R
_{DS(on)}which means that the P_{D}will be low (P_{D}= R_{DS(on)}* I^2 = 0,004Ω * 20A^2 = 1,6W) which means that we just might be able to get by without a heatsink

To check if we can dissipate the heat fast enough, we need to calculate how hot the junction becomes under load by using the following formula (T_{amb} is the max operating ambient temperature. in Denmark the temperature is never above 35 so that should be a safe value):

Tj = P_{D}* R_{ΘJ-A}+ T_{amb}= R_{DS(on)}* I^2 * R_{ΘJ-A}+ T_{amb}= 0,004Ω * 20A^2 * R_{ΘJ-A}+ T_{amb}= 1.6W * 62 °C/W + 35 °C = 99,2 °C + 35 °C = 134,2 °C

Perform this calculation with your own values with this Instacalc calculator.

The result is below the specified 175 °C.

(If, however, we were to run 25A continous current through, we would end up with a junction temp of 190 °C (do the math yourself) which is too high.)

As you can see the current rating for a MOSFET should be taken with a grain of sand. The IRL1404 MOSFET is rated to 160A. But without a heatsink it can't even handle 25A continously.

### Bonus reading: choosing a heatsink

If we ended up with a too high temperature, we would need to mount a heatsink to the MOSFET in order to lower the thermal resistance.

In that case, instead of using R_{ΘJ-A} for thermal resistance, which is junction-to-ambient air resistance, we would use the combined thermal resistance by adding the following:

RΘ_{J-C} |
junction-to-casing (0,75 °C/W for the IRL1404) |

RΘ_{C-S} |
casing-to-heatsink (0,5 °C/W for a "flat, greased surface" and typically between 0,5 and 1,5 depending on whether you use thermal grease, mica or bolt it directly on) |

RΘ_{HS} |
heatsink-to-ambient (depending on the heatsink) |

We can calculate the maximum thermal resistance that will dissipate the heat from the junction fast enough by using the above formula (transposed a bit):

maxR_{ΘJ-A}= (Tj-T_{amb})/P_{D}= (175-35)/P_{D}= 140°C / R_{DS(on)}*I_{D}^2 = 140°C / 0,004Ω * 20 A ^2 = 140°C / 0,004Ω * 400 A^2 = 140°C / 1.6W = 87.5 °C/W

In this case the max thermal resistance of the junction-ambient without heatsink is lower than that (per the datasheet it is 62 °C/W) so we don't need a heatsink, but if we calculated it for a 25A sustained current we would end up with a max thermal resistance of 56 °C/W and since the j-c plus c-s is about 2 °C/W (if we don't use thermal grease) we would need a heatsink with a maximum RΘ of 54 °C/W. Like this little one here which has a thermal resistance at normal airflow (as opposed to "forced", i.e. fan ventilated) of 16,2 °C/W.

*whew*

Links:

A lot about thermal resistance and heatsinks: http://www.jaycar.com.au/images_uploaded/heatsink.pdf

About choosing a MOSFET and explanation of the MOSFET's parameters: http://robots.freehostia.com/SpeedControl/MosfetBody.html