# Protect N-MOSFET against short circuit and overload

I want to connect a PWM pin from an ATTiny to a N-Channel MOSFET in order to fade some LEDs, or switch the speed of a motor.
Three wires are connected to my board: VIN, a GND and the OUTPUT GND.

Questions:
1) What should I do to make sure that my MOSFET, Micro Controller and the LEDs are protected against short circuit AND voltage overload?
I want to minimize the damage if any of the wires (VIN, GNDs, OUTPUT) are connected accidentally to each other, or if a high voltage/current is flown into the circuit.

2) Also, should I put a pull-down resistor on the PWM pin?

First of all, to protect your MCU it's a good idea to use a 33 ohm resistor between your PWM pin and the Gate of the MOSFET or transistor.

While the PWM pin should be either HIGH or LOW, there could be situations where your Gate pin can have nothing as input, for example when the MCU is powered off. Therefore it's also a good idea to use a pull-down resistor between GND and the Gate pin. This ensures that your MOSFET stays off if the MCU is not connect or is powered off. I would say a 10k ohm or even a 1k ohm would suffice, it depends on the amount of noise and power consuption. Use the 1k ohm on higher-noise environments.

For the sake of your MOSFET protection, unless your current load is higher than the MOSFET's current take or the transistor's Icc, you don't need to worry about it if you are only using it to control LEDs or even lamps. Most MOSFETs can flow up to 3 Amps of current, while normal transistors' aren't that much. Use a current meter to check how much current your device consumes at the highest level (e. g. when all parts of it are turned on at the hgighest level and speed.)

However, you should also consider an extra protection if your device has any kind of a Electromagnetic Coil inside it, like the Solenoids, Motors and Relays.
This is because the coils generate a reverse voltage spike when the power is switched off, which could damage your MOSFET or transistor. This is a side effect called Inductance.
To prevent this, a diode is usually used know as the flyback diode or the kickback diode. It is generally a normal diode which is conncected reverse-biased in the circuit near the consumer device, which allows the reversed current to be looped inside the diode and the device, thus allowing the current to be drained. Wikipedia has a nice article around it.

As for your case, you are planning to use a motor, which has a coil inside it, so try to put a diode near the motor and away from the MOSFET (if possible) to drain the unwanted reverse current.
If you can't put it on the consumer device, at least use it on your PCB along with the MOSFET, it's better than nothing.
I would say a 1N4007 could suffice here, just remember to put it backwards in the circuit (Anode goes to the Drain pin of the MOSFET and Cathode goes to the VIN of your device. Unlike resistors, diodes must be used in the correct direction.)

Please be sure that you are supplying enough current to your circuit. It's also a good idea to use a 220 μF cap to regulate the 5V input of your ATTiny.

As for the protection against short circuits, you could either:
a) limit the current with a resistor
b) use a resettable fuse.

Obviously, limiting the current here would be a stupid idea, so you could use a resettable fuse to prevent flowing too much current into the circuit. A Resettable fuse (or PTC) is a device which blocks too much current from flowing until you remove the load and break the circuit; In this case shorting the circuit will flow all of its current through it!
The PTC's discussion goes beyond to the answer of your questions, so try looking it up on Google.

Have a great fun playing with the electronics.
Hope I've helped you!

• I am wondering whether a freewheeling diode is needed when switching with a N-MOSFET in the ground leg of a motor. Should not the body diode of the MOSFET be sufficient? – ARF Feb 25 '17 at 14:45
• I personally don't know if it's sufficient for all N channel varieties, but the extra protection here doesn't hurt, specially for low-current MOSFETs ;) – David Refoua Feb 25 '17 at 16:44