1
\$\begingroup\$

I'm trying to use a STM32F100RBT6B microcontroller to turn on a n-channel MOSFET (IRF540) to switch on a voltage of 24V to an electrical magnet.

I understand I would need a gate driver between the microcontroller and the MOSFET. I know the NMOS Qgs is 10nC at max, so I figured I would need at least 10 mA from the driver to switch it on fast enough (1uS at 10 kHz).

I also know the VoH from the microcontroller for a TTL-port is 2.4V. Does anybody know of a gate driver that would work for this application, and how I would go about to find such a gate driver? (I'm a student still learning about this, so correct me if I'm wrong).

\$\endgroup\$

3 Answers 3

4
\$\begingroup\$

Since you're just switching a magnet, you don't need high speed, or high gate current. However, since your MCU operates on 3.3 volts, you do need some sort of driver to guarantee that your MOSFET gets turned on strongly, and 3.3 volts on an output just won't do that.

For a simple case like this, all you need is a transistor and a few resistors, and

schematic

simulate this circuit – Schematic created using CircuitLab

this will do, as long as you don't mind the fact that the signal is inverted. That is, a high output at the MCU will turn the relay off, not on. Note a few things. R2 and R3, when the transistor is off, set the gate drive at 12 volts. Without the combination, using only R2 would apply a maximum of 24 volts to the gate, and this exceeds the maximum specification. Also, D1 is called a flyback diode, and you should always use one when switching anything with a coil. If you don't, when you turn off the relay you'll get a big voltage spike across it, and you may well kill your transistor. Worse, sometimes it will take multiple operations to kill the transistor, so you think you've got a working circuit, but you can't understand why it's unreliable. The diode should be rated for whatever current the relay coil draws, and have a higher voltage rating than the power supply.

\$\endgroup\$
1
\$\begingroup\$

A quick look at the datasheet shows that your irf540 has a gate-source threshold voltage of up to 4V, so you are definitely correct to assume that you cannot reliably operate it directly from your 2.4V TTL signal.

If you're handy with a soldering iron, it could be educational and rewarding to make your own gate driver circuit. Here's a schematic:
Circuit Diagram

  • R0 should be sized according to the characteristics of Q1, to protect Q1's base from overcurrent damage.
  • R1 controls the current flow to the collector of NPN transistor Q1 so that, when a logic HIGH signal reaches the base of Q1, there is a significant voltage drop (usually 20+ volts) across R1
  • This pulls the base of PNP transistor Q2 low, which then causes Q1 to effectively "close"
  • Resistors R2 and R3 form a voltage divider, so that when Q1 "closes," they present ~9V to the gate of Q3 (your MOSFET), fully triggering it to allow power to flow through your electromagnet (Q3 can be on the positive, or ground side of your magnet windings).
  • "Freewheeling" diode D1 protects your MOSFET from inductive voltage spikes from the magnet windings when Q1 switches off.

(Thanks Jim Deardon and WhatRoughBeast for pointing out the mistakes in my first diagram)

\$\endgroup\$
7
  • 1
    \$\begingroup\$ I think you're short of a series resistor into base of Q1 and a (reverse) diode across the (inductive) electromagnet. - BANG! \$\endgroup\$ Feb 3, 2016 at 12:40
  • 1
    \$\begingroup\$ And you've got your Q2 backwards. Emitter at the top, please. \$\endgroup\$ Feb 3, 2016 at 12:46
  • \$\begingroup\$ I would avoid the label "gnd" for the connection to the magnet. \$\endgroup\$
    – Tut
    Feb 3, 2016 at 12:55
  • \$\begingroup\$ schematic fixed \$\endgroup\$ Feb 3, 2016 at 12:59
  • \$\begingroup\$ @Tut I labelled the connectors to the agnet as +24V & GND on the principle of labelling them as an outlet to plug the magnet leads into, in which case I think that's an accurate enough label. However, if you assume them to be leads, directly connected to the magnet, then I think I'd fully agree that a different label was in order. \$\endgroup\$ Feb 3, 2016 at 23:07
0
\$\begingroup\$

WhatRoughBeast and Robherc are right: if you don't need fast switching, you can go without a driver, and they gave you some basic circuits.

Now, for people who need a fast switching (PWM), I think many gate drivers are 3.3V logic compatible. For you kind of circuit, MCP1401, MCP1402, MCP1406... should all be compatible.

As far as I know, IR2110/13... should also operate on 3.3V logic signals (though these are Low/High side drivers, not suited to this particular application).

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.