Correct use of a MOSFET with arduino

I've been designing a generic Nch MOSFET setup to use with my Arduino and have finally come up with the following schematic. I've used a DC motor as a load as they are the most problematic. My theory is, if it works for that, it should be fine for most things.
I've seen similar threads on here from the past but they are either locked threads are never reached a conclusion.

  • I toyed with the idea of using a "normal" MOSFET and a Transistor to switch it, but in the end decided just to get a logic level one instead as it's less parts, fuss and power rails. I realise at 5v it's not quite at it's perfect resistance, but it's close enough.
  • I've used a 10K Ohm resistor between the D3 pin and GND to hold the line low when it's not in use, so it's not flapping around at some unknown voltage
  • I used a 330 Ohm resistor to limit the current drawn from the Arduino by the MOSFET
  • A diode across the motor is to stop and reverse currents created by the magnetic / inductive influence of the motor itself.
  • I also use a small cap across the motor to absorb any RF level frequencies that can be common.

Regarding the capacitor:
This was originally going to be a much bigger cap (~1mF) to take the edge off the PWM square wave and help with motor "squealing" in the audio range, but I decided against it. It was also going to be used to absorb any relatively large currents produced at startup and/or when the motor's momentum keeps going after the circuit it turned off. I decided against this as the cap when charged up and discharging into the circuit may cause the very issue I'm trying to avoid.

Does this seem to be ok?

Hi,
Have you built and run this?

What is Vcc?
How much current does the motor run at startup, at normal run?
What PWM frequency?

You may need a FET driver to move the gate fast enough in some cases like higher current.

I believe from what I've read that the pulldown should be on the arduino pin side of the gate resistor, not the gate side.

manor_royal:
I believe from what I've read that the pulldown should be on the arduino pin side of the gate resistor, not the gate side.

Correct - the pull-down is there for when the Arduino powers up etc. and the pin has not been configured as an output yet. It is intended to keep the gate from "floating" in the linear region. The way it is drawn, it is part of a voltage divider made from the two resistors. With 330 and 10K, the drop will not be too bad, but it is better on the Arduino side for the reason I indicated (and then you are not dealing with a voltage divider).

This page explains everything.

https://www.gammon.com.au/motors

Leo..

terryking228:
Hi,
Have you built and run this?

What is Vcc?
How much current does the motor run at startup, at normal run?
What PWM frequency?

You may need a FET driver to move the gate fast enough in some cases like higher current.

No not yet, waiting for the MOSFETS to arrive.
It's going to be a general purpose driver.
It's quite small on the diagram but Vcc can be up to 60v @ 32 Amps.
PWM is 980Hz for an Arduino Uno using the standard PWM pins. Potential to go up a lot higher with user defined PWM

manor_royal:
I believe from what I've read that the pulldown should be on the arduino pin side of the gate resistor, not the gate side.

Ok, thanks for spotting that. Here's the updated version.

Wawa:
This page explains everything.

Gammon Forum : Electronics : Microprocessors : Driving motors, lights, etc. from an Arduino output pin

Leo..

Thanks. His circuit has no RF protection from motors if that's what his load was. Apart from that it seems the same for sink current circuit.

Ziplock9000:
Thanks. His circuit has no RF protection from motors if that's what his load was.

The cap across the motor is not for "protection".
The diode across the motor has that function (protecting the mosfet).
A cap across the motor, and sometimes ferrite beads over the wires, are for RF suppression.
Leo..

Wawa:
The cap across the motor is not for "protection".
The diode across the motor has that function (protecting the mosfet).
A cap across the motor, and sometimes ferrite beads over the wires, are for RF suppression.
Leo..

Yeah wrong word.
In my mind it was protecting the rest of the circuit that will be connected to this (as it's modular) from RF. I may add a bypass cap too to further enhance this. What do you think?

Would you also recommend a second larger cap in parallel to this, say 1mF to stop inrush current at switch on and outrush current from the coils when turned off.. also to suppress coil whine from the PWM?

A cap across the motor is hard on the mosfet.
When the mosfet turns on, and the cap is not charged yet, inrush current is very high.
Only limited by the internal resistance of the supply and the 'on' resistance of the fet.
There will be a longer/larger inrush current if you increase cap value. Leave it at 100n.
If coil whine is a problem, then change the PWM frequency.
Try PWM pin 5 or 6 first, and see if that changes things.
Leo..

Thanks mate.