# Driving DC motors with MOSFETs and a microcontroller?

I'm developing a nano quadcopter using an Atmega328 microcontroller, powered at 3.3V, and very small brushed DC motors. The average current used by these motors is about 800mA @ 3.7V.

Initially, to drive them, I used an L293D motor driver but this component was quite inefficient. The current measured when the motors ran at max power was about 500mA and so the thrust was much lower then it should be.

Now, to solve this problem, I would replace that motor driver with 4 logic level MOSFETs. After a long search, I find this one (2SK4033).

Do you know if it should work? Do I have to use it in conjunction with a diode? If the answer is "yes", what about this one (MBR360RLG)?

I chose these components also because I can buy them from the same online store.

• Andy has answered the MOSFET part of your question, but nobody has mentioned a more fundamental question: how do you plan to replace that L293D with 4 N MOSFETs? Putting an N MOSFET to the high-side could cause efficiency problems. A schematics drawing could help making your idea clear. Mar 14, 2014 at 0:37
• What do you mean with "high-side"? At this moment, the only schematic that I have is the one with the L293D. If it could help, I can post it. My idea is that each motor is driven by a mosfet (4 overall) and if it's needed, a diode too. What could be a more efficient solution? Mar 14, 2014 at 1:10
• Each L293D output includes a "high-side" transistor (between Vcc & the output) and a "low-side" transistor (between GND & the output). If you replace the "high-side" transistor with an N MOSFET, you'll need a power supply that can provide Vgs (at least 2..3..4V) above the output voltage. Or the max. output voltage will be Vcc - Vgs... Mar 14, 2014 at 1:28
• The Vgs must be 3.3V and the output (Vds) must be 3.7V (the same voltage of the battery, that is unique). So, if there is this problem, how can I do? Can you suggest another solution? Mar 14, 2014 at 1:50
• You have the following options: a) use P MOSFETs for the high-side; b) use a separate voltage doubler or DC-DC converter circuit to provide 2*Vcc for driving the high-side MOSFET gates; c) use a bootstrap circuit to provide the proper Vout + Vcc voltage for driving the high-side MOSFET gates. Each of these has its drawbacks and/or limitations. Mar 14, 2014 at 2:36

MOSFETs should work very well for this application. Here are some things to consider:

1:

When using a FET to drive a load, you can either choose a high-side or a low-side configuration. High-side places the FET in between the power rail and the load, and the other side of the load is connected to ground. In a low-side configuration, one lead of the load is connected to the power rail, and the FET is positioned between the load and ground:

The simplest way to drive your motor (or other load) is to use an N-Channel MOSFET in the low-side configuration. An N-FET starts to conduct when its gate voltage is higher than its source. Since the source is connected to ground, the gate can be driven with normal on-off logic. There is a threshold that the gate voltage must surpass ("Vth") before the FET conducts. Some FET's have Vth in the tens of volts. You want a "logic-level" N-FET with a threshold that is considerably less than your Vcc.

There are two drawbacks to the low-side FET configuration:

• The motor winding is connected directly to the power rail. When the FET is off, the entire winding is "hot". You are switching the ground, not the power connection.

• The motor won't have a true ground reference. It's lowest potential will be higher than ground by the FET's forward voltage.

Neither of these should matter in your design. However, they can be problematic if you don't expect them! Especially with higher-power circuits :)

To overcome these problems, you could use a P-FET in the high-side configuration. The driving circuit becomes a bit more complex, though. A P-FET switch usually has its gate pulled up to the power rail. This power rail is higher than the uC's Vcc, so you can't connect the uC's I/O pins directly to the gate. A common solution is to use a smaller low-side N-FET to pull down the gate of the high-side P-FET:

R1 and R3 exist to keep the FETs turned off until Q2 is driven. You will need R3 even in a low-side configuration.

In your case, I think a simple low-side N-FET (with R3) will serve you better.

2:

Notice R2 in the last diagram. A MOSFET gate acts as a capacitor, which has to charge up before the drain-source current starts to flow. There can be significant inrush current when you first provide power, so you need to limit this current to prevent damage to the uC's output driver. The cap will only look like a short for an instant so there is no need for a large margin of error. Your specific Atmel, for example, can source 40mA. 3.3V / 35mA => 94.3 Ohm. A 100-Ohm resistor will work great.

However, this resistor will slow down the turn-on and turn-off times of the FET, which will put an upper limit on your switching frequency. Also, it prolongs the amount of time where the FET is in the linear region of operation, which wastes power. If you are switching at a high-frequency, this might be a problem. One indicator is if the FET gets too hot!

A solution to this problem is to use a FET Driver. They are effectively buffers that can source more current, and so can charge the gate faster without the need for a limiting resistor. Also, most FET Drivers can use a higher power rail than the typical Vcc. This higher gate voltage reduces the FET's on-resistance, saving addition power. In your case, you could power the FET Driver with 3.7V, and control it with the uC's 3.3V.

3:

Finally, you will want to use a Schottky diode to protect against voltage spikes caused by the motor. Do this any time you're switching an inductive load:

A motor winding is a big inductor, so it will resist any change in current flow. Imagine that current is flowing through the winding, and then you turn off the FET. The inductance will cause current to continue to flow from the motor as the electric fields collapse. But, there's no place for that current to go! So it punches through the FET, or does something else just as destructive.

The Schottky, placed in parallel to the load, gives a safe path for the current to travel. The voltage spike maxes out at the diode's forward voltage, which is only 0.6V at 1A for the one you specified.

The previous picture, a low-side configuration with the flyback diode, is easy, inexpensive, and quite effective.

The only other issue I see with using the MOSFET solution is that it is inherently unidirectional. Your original L293D is a multiple half-bridge driver. This makes it possible to drive a motor in both directions. Imaging connecting a motor between 1Y and 2Y. The L293D can make 1Y=Vdd and 2Y=GND, and the motor spins in one direction. Or, it can make 1Y=GND and 2Y=Vdd, and the motor will spin the other way. Pretty handy.

Good luck, and have fun!

• Nice! Do I need a resistor between the micro lead and the gate? Is 220 Ohm a good value? (3.3V/0.02A=170 Ohm ~ 220 Ohm) Mar 18, 2014 at 13:40
• Good question. In the ideal world, the gate won't sink any current at all. That's one of the benefits of FETs over BJTs. But, in the real world, the gate acts as a small capacitor, which has to charge up before the drain-source current starts to flow. You want it to charge quickly, to turn the FET on quickly. When you first turn on the uC pin, the gate capacitance appears as a short circuit. The ATmega328 can source 40mA per pin. The cap will only look like a short for an instant, so I wouldn't bother with too much margin of error. Say, 3.3V, 35mA: ~100-Ohm. I'll merge this in, later today! Mar 18, 2014 at 15:33
• Oh, and if you are switching the motor at high frequencies, this resistance becomes a problem. It slows down the charging and discharging of the gate, which slows down your switching frequency. Also, it prolongs the amount of time where the FET is in the linear region of operation, which wastes power. If you find that this is an issue, use a "FET Driver" or some other buffer, that's made to source/sink much higher current to/from the gate. Then you can minimize (or eliminate) the resister. Mar 18, 2014 at 16:10
• I think that the switch frequency is the pwm frequency, so it should be about 500Hz. Mar 18, 2014 at 16:30
• Nice :) I'm jealous; I've been wanting to build a quad copter for quite some time now! Let us know... Mar 25, 2014 at 22:52

Here's what I'd look at for any MOSFET. This is from the 2SK4033's data sheet by the way: -

You say 800mA is the average current but, could this increase to over 1A under load? Anyway, at 1A and with a gate drive voltage of 3.3V, the MOSFET drops about 0.15V across its terminals when powering a 1A load. Can you live with this power loss (150mW) and more importantly, when the battery voltage drops below 3V can you live with the performance lost as the gate voltage drops inevitably.

Only you can answer this question. There are better MOSFETs than this but you have to calculate real load currents for the motor that you expect to see.

EDITS

Here is a chip I came across that could be quite useful in place of MOSFETs. It's the DRV8850 from TI. It contains two half bridges and this means it can independently drive two of the 4 motors without needing the flyback diodes (in effect, the top FET is operating as a synchronous rectifier and this of course reduces losses). On-resistance for each FET is 0.045 ohms and it is rated at 5A (power dissipated is about 1.1 watt) but, given that the OP wants about 1A this becomes very trivial. The power voltage range is 2V to 5.5V so again this is very suitable: -

• Thanks a lot. Yes, the motors could increase the current to a value slightly over 1A, but only for a short time. A pratical rule that I know is to consider a current that is the double of the average (1.6A). I think that 150mW of power loss is not a big problem. Mar 14, 2014 at 0:49
• What about at lower battery voltages when the gate drive is poorer and the loss becomes greater. I'm playing devils advocate of course! Mar 14, 2014 at 1:00
• About the battery voltage drops under 3V, I don't know if I understand what you mean. Anyway, I use a voltage regulator (LE33CZ) to power the ATmega at 3.3V. Doesn't it mean that the voltage is "always" 3.3V? One more question. What about the diode? Mar 14, 2014 at 1:00
• As battery voltage drops to say 3.4 volts, the regulator output will start dropping as well and this means the drive volts to the gate starts dropping and the fets become more inefficient. Deal with this scenario before diodes. The diodes are trivial in comparison. Mar 14, 2014 at 1:06
• Do you need one Fet to control each motor or two. Laszlo assumes you need 2 because you originally used an L293. Mar 15, 2014 at 11:28

Since a brushed DC motor is being used, you don't necessarily need an H-Bridge as a drive. Only two cases really require an H-Bridge; need to externally commutate the motor (think brushless PM motors for example) or need to reverse spin. Neither of these seem to apply here. Using a single direction or Single Quadrant Drive (SQD) would greatly simplify what you are trying to do.

The FET you are thinking of using (2SK4033) is not a great match for the drive voltage that is available (Andy has already pointed out why), and we'll get into more details about choosing FETs later.

Driving brushed DC motors with a Single Quadrant Drive (SQD)

Mostly this will be about choosing a FET as controling element. We assume only one spin direction, which means a Single Quadrant Drive (SQD) will suffice. For a SQD, either P channel or N channel FET can be used. An N channel part would be a low side switch, while a P channel part would be a high side switch. The edge would go to an N channel part since the drive circuit would be a little more simple (one less inversion), lower conduction loss for given die size, and easier to find low $V_{\text{th}}$ units. Here is a schematic of a basic SQD using an N channel FET.

It may not look it, but this is just a Buck power modulator like that used to drive current through an LED. Only here, instead of an LED in series with an inductor, there is motor EMF ($V_{\omega }$) and winding loss ($R_{\text{wind}}$). $R_g$ is the total gate circuit resistance including resistance in the driver, interconnect, and FET package (the 100 Ohm value shown was chosen just for convenience, no real reason). $R_{\text{pd}}$ is a pull down resistor there just to keep the FET turned off while power comes up. $V_b$ is battery voltage. $V{\text{drv}}$ is voltage from the FET driver.

Currents, voltages, and part power dissipation are basically those of a Buck. To simplify things, we make an assumption that motor ripple current is negligible, which would be pretty much true for ripple current less than 10% of the motor current. For motor current ($I_m$) and a given PWM duty cycle (DC), there will be FET currents (peak $I_{d-pk}$, rms $I_{d-rms}$) and Diode currents (average $I_{\text{cr-ave}}$) related as:

• $I_{d-pk}$ = $I_m$
• $I_{\text{d-rms}}^2$ = DC $I_m^2$
• $I_{\text{cr-ave}}$ = (1-DC) $I_m$

Basic criteria for choosing a FET (sort of the ABCs of choosing a FET):

• $V_{\text{DS}}$ > $1.5 V_{\text{B-max}}$

$V_{\text{DS}}$ shouldn't be any less, but there is no need to have it much higher either. In fact, higher voltage parts have bigger die and package size takes a step up above ~ 55V.

• $V_{\text{th-max}}$ < $\frac{V_{\text{Drv-min}}}{3}$

Selecting $V_{\text{th-max}}$ this way will give the full benefit of the $R_{\text{ds}}$ of the part.

• $\text{\Delta T}_{J-A}$ < 50C

Heat rise is really important. It accounts for all losses ... conduction loss, gate loss, and switching loss.

Sample part selection based on 3 criteria:

In this case with $V_{\text{B-max}}$ = 3.7V and $V_{\text{Drv-min}}$ = 3.3V, look for an N channel part with $V_{\text{DS}}$ > 5.6V and $V_{\text{th-max}}$ < 1.1V and a guess at $R_{\text{DS}}$ of ~40mOhms just get in the ballpark. I put this into the digikey screen, but any similar vendor would work. Several parts came up. Since the part you mention is Toshiba, selected one of those to look at further.

• SSM3K123TU: $V_{\text{DS}}$ = 20V, $V_{\text{th-max}}$ = 1V

Next step is to figure out the Heat rise. What kind of power can this part take and still have less than a 50C rise? This is a small part, 2mm X 2.1mm. Looking at the thermal resistance graph in the datasheet (sheet 5, curve c), we see that for the most minimally mounted part $R_{\text{th}}$ converges to 500C/W. So, for 50C rise power in the FET must be limited to 0.1W total for the part to be acceptable. Power in the FET is the sum of conduction loss, and switching loss:

$P_T$ = $P_{\text{cond}}$ + $P_{\text{sw}}$

where

$P_{\text{cond}}$ = $R_{\text{ds}}$ DC $I_m^2$

$P_{\text{sw}}$ ~ $\frac{1}{2} I_m V_b F_{\text{PWM}} \left(\tau _f + \tau _r\right)$

When the FET switches, it all happens in the Miller Plateau. To turn a FET on, as $V_{\text{gs}}$ increases, at some point $V_{\text{ds}}$ will start to fall. That's the start of the Miller Plateau. $V_{\text{gs}}$ will be stuck at that voltage (the Miller Plateau voltage $V_{\text{mp}}$) until the FET is turned on and $V_{\text{ds}}$ reaches 0V. The time it takes for that to happen is the fall time of the switching waveform.

That's the Miller Plateau for the SSM3K123. See it circled there in red? Looks like it's about 4nC wide. So, the time it takes for the FET to switch is the same time it takes for the gate drive circuit to process (by displacement current) that 4nC of Miller Plateau charge ($Q_{\text{mp}}$). Current in the driver will be determined by ($V_{\text{mp}}$ - $V_{\text{drv}}$)/$R_g$. Also approximate that $V_{\text{mp}}$ is 1/2 $V_{\text{drv}}$, so that:

$Q_{\text{mp}}$ = $\frac{\tau V_{\text{drv}}}{2 R_g}$ or $\tau$ = $\frac{2 R_g Q_{\text{mp}}}{V_{\text{drv}}}$ = $\frac{2(100 Ohms) \text{(4nC)}}{\text{3.3V}}$ = 242nSec

Time for some operating assumptions. Ambient temperature is 50C (so max FET die temp is 100C), PWM frequency is 20kHz (because lower frequencies are audible, and really 5kHz to 10kHz is just obnoxious), duty cycle (DC) is 90%, and motor current ($I_m$) is 1.2A. From the $R_{\text{ds}}$ versus temp curve on page 3 of the datasheet we see that at 100C, $R_{\text{ds}}$ is 33mOhms. Now we are ready to calculate power loss in the FET.

$P_T$ = $0.9 \text{(33mOhm)} \text{(1.2A)}^2$ + $\text{(3.3V)} \text{(1.2A)} \text{(242nSec)} \text{(20kHz)}$ = 36mW + 19mW = 55mW

So, for these conditions FET heat rise comes in at about 1/2 the limit of 100mW. In fact, $I_m$ could be 1.65A and the FET would still be in the heat rise budget.

Loose Ends

• Put the drive circuit and switches close to the motor.

• While it may be possible for the micro to drive the FET directly, a driver for the protection of the micro is a good idea (something like a NC7WZ16 could work here).

• Gate circuit resistance becomes an exercise in impedance matching. The lowest gate circuit resistance should be is the characteristic impedance of gate circuit parasitic L and FET $C_{\text{iss}}$. Here is an earlier question that goes in to more detail and may be helpful.

• Choose a diode with the same voltage rating as the FET, and current rating higher than the maximum $I_m$. A Schottky will have lower loss, but if FET duty cycle is > ~70% it won't really matter if a switching diode is used instead.