Hi, I am using a MOSFET for the first time and I have ran into a problem when using it. So, I'm using the MOSFET to switch on/off a DC motor. And when I upload some simple code to do this the motor just spins and doesn't follow the instructions in the sketch. I am wondering if it is something with the circuit, the code, or the components themselves...
I believe this MOSFET would work with a small hobby motor, but I may be wrong...
Here's the code:
int motor1 = 9;
void setup() {
// put your setup code here, to run once:
pinMode(motor1, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(motor1, HIGH);
delay(5000);
digitalWrite(motor1, LOW);
delay(5000);
}
The mosfet is not a logic level mosfet, and is therefore not really suitable to use with an Arduino.
It might indeed work with a small load.
The diode is backwards.
It's wise to use two resistors with a power mosfet.
One 220ohm as drawn and a 10k from the output pin to ground.
The gate resistor limits pin current during PWM switching.
The resistor to ground prevents problems during bootup.
Leo..
That MOSFET is a 200V rated MOSFET - hence has a huge on resistance, not at all sensible for
high currents at low voltages.
Get yourself a decent logic-level MOSFET with a voltage rating that's more sensible, 30 or 50V,
with an on-resistance of 20 milliohms or less. These days you can get down to 2 milliohms
relatively easily, two orders of magnitude better than the one you have.
And make sure the diode is the right way round, or you'll blow up something.
If your fritzing diagram is correct you are using a 9V battery to power a motor? That's not
adequate for the load.
[ Oh yes, a 150 ohm gate resistor is a good choice, protect the Arduino pin from over current ]
Thank you everyone for helping me out, I really appreciate it.
I still have a few questions. First of all, do you have any recommendations for a logic-level MOSFET that would be appropriate for this circuit? And from all that responded to this topic they have said my diode is backwards, what does that mean? Also I am not using a 9V battery to power the motor but rather 4 AA batteries. Is that appropriate for this? Finally, I got the circuit from here: \http://fritzing.org/projects/mosfet-motor-example\
I'm not sure if this circuit is wrong, or if it's just mine.
The band of the diode goes towards the positive side of the load, so it normally won't conduct. Inductive loads like motors produce a voltage spike in the opposite polarity as the applied voltage when you turn them off, and if you don't include the diode to dissipate this, the spike can damage the rest of the circuit.
Your diagram shows it the other way around, so it would be conducting when you tried to power the motor - if you turned it on, a very high current would flow until the MOSFET, diode or power supply failed.
For the fet, you need a MOSFET that advertises a "logic level gate" or has a spec for Rds(on) at Vgs = 4.5v (or less), Vds less than the voltage you are switching, continuous current and peak current specs higher than the current your load will draw (with some safety margin). Also, calculate power dissipated based on Rds(on) and the current you're expecting to draw, and compare to maximum power dissipation spec on datasheet. And you need it in a package you can solder to - something like TO-220 if you're not comfortable using SMD parts.