Trouble with MOSFET

I'm trying to get a MOSFET IRF840 to act as a switch for a small DC water pump. The water pump is rated at 12V and 2.5amps. This is its listing on Ebay: http://cgi.ebay.com/Mini-Water-Fountain-Pump-for-CPU-RV-CO2-Lasers_W0QQitemZ250603147732QQcmdZViewItemQQptZLH_DefaultDomain_0?hash=item3a591c91d4#ht_3700wt_939

The MOSFET IRF840 is supposed to be good to 8A and 500V so it should be good for this purpose I assume?

My problem is that it never seems to be in an off state, as soon as I connect the power, the pump turns on and the MOSFET gets really hot. This happens even if I don't even have the Ardunio hooked up. Am I completely misunderstanding how this MOSFET is to be used? I've attached an actual picture of what I'm working with.

Thanks!

Chris

If you don't have one, you need to connect a high value resistor between the MOSFET gate and common ground. This is needed to keep the MOSFET off until a voltage is applied to the gate. You alo need to check the data sheet to see how well it performs with only 5v on the gate. You might need something to increase the gate voltage for lower internal resistance.

Have you got a potentiometer to hand, maybe 1K? You might want to check the voltage that turns on the MOSFET using it.

I looked at the spec for a the IRF840, and it looks like it needs 10V to switch it on. And Arduino doesn't have high-voltage tolerant output pins.

GB

Two problems:

  1. You need a logic level MOSFET to fully turn on with the +5vdc of a Arduino output pin.

  2. When you get the correct MOSFET you then have to have a ground wire from the external power source ground to the Arduino ground pin.

Lefty

Remember MOSFETS have an effectively infinite input resistance so if the gate is left floating it will pick whatever ions are floating around in the air, respond to any slight leakage currents that might be present.

Tying the gate to the source with a high value resistor is a good plan as people have mentioned, such as 1Mohm, so that its safely off until setup() has run.

The IRF840, looking at the datasheets turns on around +6V so definitely isn't a logic-level FET. You simply need to drive its gate from a NPN transistor with pull-up to 12V - however the pump might be putting spikes onto the 12V rail which might be an issue.

I'd suggest a 1K from 12V to a capacitor to ground. 10K from this R-C junction to an NPN collector and the FET's gate, standard emitter to ground and base to arduino via a 10K?
Another problem you have is that the IRF840 has an enormous Ron of 0.85ohm, so it will drop over 2V even when hard on, and dissipate 5W or so requiring a heat sink. Power dissipation is I-squared-R

In general the current rating of a MOSFET is the least useful rating, use Voltage, Ron and power dissipation ratings to select a part (of course the current rating has to be big enough too)

Here you only need a voltage rating of 30V or so, the 500V of the IRF840 is overkill (high voltage MOSFETs have worse Ron usually)
I'd select a part rated at Ron < 0.05 ohm so that a heat sink isn't needed. Something rated 30--60V and 20-60A and with logic-level drive would be much more useful to you...

Since you already have the MOSFET, you might try using an NPN transistor (get a 15 pack at Radio Shack) to get the MOSFET gate close to the supply voltage. I'd try a 5k resistor between the MOSFET gate and the common source/ground. Then connect the NPN transistor collector to the 12v power source, and emitter to the MOSFET gate. Then try supplying the NPN base from the arduino pin. Note that the grounds need to be common and the electrical flow for the motor +12V > motor > MOSFET > 12v ground.

I thought I'd post an update since everyone was so helpful.

I went to Radio Shack today and picked up a few things that I thought would be helpful and help get me ahead of where I was yesterday:
-) A MOSFET that I thought might work better. (IRF510)
-) Darlington transistor (TIP120)
-) What I thought were NPN transistors, but instead were PNP transistors (Damn you dyslexia!)
-) Assorted 1 Amp diodes (I don't know to tell one diode from another and what varying properties they would have and how that would impact anything yet)
-) 3 spools of 22 AWG Solid Core wire in Red, Black and Green because I was sick of using those messy jumper cables for every connection.
-) Wire strippers

It took me a very long time, but I finally got the whole thing working including getting the motor go slower by turning it off and on really fast.

I didn't have any luck with the transistors that got from Radio Shack, I actually just ended up getting the original IRF840s that I had to work by using 4 in parallel to prevent them from overheating.

Neither the Darlington Transistor TIP120 nor the MOSFET IRF510 responded well to the 5V from the Arduino. Both lowered resistance, but still kept maybe 2k ohms. Also, I have no idea how to properly use a PNP transistor, I attempted to run the 12V through the PNP and use the Arduino's 5V to turn it off an on, however this did not seem to work and I ran into all kinds of crazy issues such as power seeming to run back through the gate from the collector. I maybe could have solved this with proper use of diodes, but after a few hours of messing around, I was still stumped.

It turns out that the IRF840's do respond just fine to the 5V, I just had 3 things wrong:

  1. I was missing a common ground (running a wire from Arduino's ground to the 12V ground that I had)
  2. I needed to run a 1Mohm resistor from from the gate pin to ground.
  3. I was using "digitalWrite( 9, HIGH );" on pin 9. This apparently produces a 1V signal. I found that "analogWrite(9, 254)" worked better. But I ended up just using "digitalWrite( 13, HIGH)" on pin 13.

Once I did these things, the resistance seemed to drop to zero when I applied 5V to the gate. The last problem that I had was that the thing would overheat pretty bad after a just a few moments of the motor being on. I solved this by simply adding 3 more IRF840's in parallel.

Maybe someone can answer this, but I'm not exactly clear on why MOSFETs tend to have very high amperage ratings. When I first heard of MOSFETs and saw some pictures, I said there is no way they can carry the load that they are rated at, it takes thick wire to carry significant amounts of power, not these tiny little pins... turns out I was right.

So my next question is what is the proper method for giving a motor more and less power? Do you do what I did and turn the power on and off really fast? If so, what are proper components to use? If not, what do you do, and again, what are the proper components to use?

This is the source code that I used :

#define MOSFET 13  

void setup()
{

}

void loop()
{
  digitalWrite( MOSFET, HIGH );
  delay( 1 );
  
  digitalWrite( MOSFET, LOW );
  delay( 4 );
}

Here is a picture of the project in its current state:

Maybe someone can answer this, but I'm not exactly clear on why MOSFETs tend to have very high amperage ratings. When I first heard of MOSFETs and saw some pictures, I said there is no way they can carry the load that they are rated at, it takes thick wire to carry significant amounts of power, not these tiny little pins... turns out I was right.

Well, MOSFETs usually need heat sinks attached when used at rated current (see the heat sink in the pix below). They also work best when properly chosen for the application where they are to be used. The MOSFET you chose is for higher voltage applications and has a higher than desired internal on resistance. They usually work better when the gate voltage is better matched to their tested value values. Not sure just how "right" you actually are about MOSFETs and electronics in general according to what you have posted so far.

http://www.electronickits.com/kit/complete/motor/CKMX033.htm

i've melted wires (the copper, not just the plastic) with circuits connected to some high power mosfets and they seemed to take it just fine. as long as you have heatsinking and a good gate drive a decent mosfet can switch a crapload of current. (assuming its rated for it)

Maybe someone can answer this, but I'm not exactly clear on why MOSFETs tend to have very high amperage ratings. When I first heard of MOSFETs and saw some pictures, I said there is no way they can carry the load that they are rated at, it takes thick wire to carry significant amounts of power, not these tiny little pins... turns out I was right.

So my next question is what is the proper method for giving a motor more and less power? Do you do what I did and turn the power on and off really fast? If so, what are proper components to use? If not, what do you do, and again, what are the proper components to use?

Max current rating for a mosfet depends totally on the specific mosfet you are dealing with. The pins will handle the rating for the device, and of course you do require circuit traces and wiring to be rated for the current you wish to draw.

Most of your problem has to do with not using the best mosfet for the job. A logic level mosfet will turn on the mosfet fully at it's rated current with the 4.5-5volt level that an Arduino can supply. You are NOT using logic level mosfets. You are using mosfets that are not fully turning on and by connecting them in parallel you are increasing current by sharing between them, not a good practical solution.

There are a lot of specifications for any specific power mosfet and it determines how much current and if you will need a heat sink or not. By using a very overrated high current mosfet but drawing well less then it's max rated current you can get by with no heatsink. It's all in understanding the mosfet's datasheet.

As far as how to control a motor with an Arduino, it depends on what you want the motor to do. If just on and off in one direction then controlling it with a simple digitalWrite() command will work. If you wish to control it's speed then using analogWrite() using a PWM output pin will allow from 0-100% speed control. If you want the motor to be able to turn in both directions, then a simple mosfet will not be sufficient, but rather a full H-drive motor controller circuit is required.

Lefty

Most of your problem has to do with not using the best mosfet for the job. A logic level mosfet will turn on the mosfet fully at it's rated current with the 4.5-5volt level that an Arduino can supply. You are NOT using logic level mosfets. You are using mosfets that are not fully turning on and by connecting them in parallel you are increasing current by sharing between them, not a good practical solution.

Whoops, sorry for the misinformation. I did test the resistance and it seemed to be very low, though I couldn't be sure if it was near zero because my 20 year old multi-meter didn't seem to want to calibrate to zero.

Its been hard for me to find a "logic-level mosfet" as this search term doesn't seem to come up with much, is this a logic level mosfet?:
http://www.dipmicro.com/store/SI2301

What terms do you suggest I search for when looking for a logic level mosfet?

It appears that the MOSFET I linked to above will work for my 12V / 2.5A motor, but what if I want to drive a 120V motor that takes A/C power? Is there a limit to how much current a logic level mosfet will tend to drive? Can I use pulse width modulation (PWM) on the AC motor? If not, how do you control power to an AC motor?

[edit]Sorry crossed over posting[/edit]

I was using "digitalWrite( 9, HIGH );" on pin 9. This apparently . produces a 1V signal.

No, unless the circuit is sucking too much current an Arduino pin powered with 5V will give 4.3V or higher. How did you measure this? Was there a current limiting resistor between the pin and the base of the transistor?

[Once I did these things, the resistance seemed to drop to zero when I applied 5V to the gate.

What are you measuring this with? Being a bit less than 1 ohm isn't necessarily good enough.
The datasheet says the fully on resistance will be 0.85 ohms. If the motor takes a couple of amps, the heat will be IIR, or about 4*0.85= 3.4W, which is going to get a package without a heatsink warm->v hot.

As people have written, what you need depends on what type of control is needed. Given it is a pump, I assume one direction.
Is the pump capable of being speed controlled? There are some mechanical pump mechanisms which become much less effective as the speed varies away from their optimal value. I also think the current consumption goes up.

Have you got the spec of the pump and motor?

To run the MOSFET at low heat, look for one with a low RDS(on).
Look at the current rating of the motor.
A very rough estimate for a reasonable RDS(on) would be divide 0.5W by the current squared (current*current) (this not very scientific, but likely okay).
[edit]The logic is, most devices are rated at temperature rise with 1W in ambient, no heatsink, so if the device can survive that temperature rise due to 1W, it should be safe at 0.5W[/edit]

HTH
GB

I believe running MOSFETS in parallel is fine. That is one of the important features of MOSFETS.

Ideally look for
Low RDS(on) which, when multiplied by I2 defines the amount of power turned into heat
Low VGS(th) which needs to be low (e.g. under 2V) if you want to switch it on by an Arduino pin.

Here are some examples, to illustrate what is available
http://www.rapidonline.com/Electronic-Components/Discrete-Semiconductors/MOSFETs/TO-220-Logic-level-power-MOSFETs-N-Channel/77687

HTH
GB

Its been hard for me to find a "logic-level mosfet" as this search term doesn't seem to come up with much, is this a logic level mosfet?:
MOSFET Transistor P-Channel 20V/3.1A SI2301 - dipmicro electronics

What terms do you suggest I search for when looking for a logic level mosfet?

It appears that the MOSFET I linked to above will work for my 12V / 2.5A motor, but what if I want to drive a 120V motor that takes A/C power? Is there a limit to how much current a logic level mosfet will tend to drive? Can I use pulse width modulation (PWM) on the AC motor? If not, how do you control power to an AC motor?

Many MOSFET manufactures will have the letter L in their part number to show that it's a logic level mosfet. The best method is to learn to read the datasheet for the device. That advice applies to all semiconductors, it's how you learn to select and utilize transistors and diodes.

As far as how much current can a mosfet handle, again that is specific to each and every mosfet part number, they come in all current values from too small to way to large.

Mosfets can only be used with DC loads (motors). AC motors are a whole different animal and have to be controlled with SCR or Triac devices, sometimes intergated inside what's called a solid-state AC relay. Controlling speed for a AC motor is even more complex and expensive to implement.

Lefty

Perhaps I should post this in a separate topic, but it is a continuation of the project addressed above and may relate to the way that I am using power.

I'm having some very weird issues with using PWM analogWrite() and the delay function.

The issue is that if I use analogWrite(9, 100), the delay() functions do not work until I set the PWM back to 0 "analogWrite( 9, 0 )." Additionally, after this goes on for a while, the delay function seems to catch up and make up for all the delay time it missed before, so if I called delay(5000) 15 times and it ignored it those 15 times, eventually it seems to delay for 75000 milliseconds. Also of note is that the delay() function seems to work just fine if I remove the PWM pin so that it is not connected to anything. ..its really really odd.

I combed over the code because oftentimes problems like this are due to coding errors, but I have not been able to find any problems in the code.

Here is the part of the code where the delay is not working, I set it up to eliminate any outside factors:

  // SET PUMP
  if( moisture < 15 ){
    analogWrite(PUMP, 100 );
    Serial.print("Begin 5 second delay...");
    delay(5000); 
    Serial.print("...End 5 second delay\n");
  }
  else{
     analogWrite(PUMP, 0 ); 
  }

The serial out looks like this:
Begin 5 second delay......End 5 second delay
11.10
Begin 5 second delay......End 5 second delay
9.60
Begin 5 second delay......End 5 second delay
14.70
Begin 5 second delay......End 5 second delay
14.90
Begin 5 second delay......End 5 second delay
14.30
Begin 5 second delay......End 5 second delay
13.70
Begin 5 second delay......End 5 second delay
12.80
Begin 5 second delay......End 5 second delay
10.70
Begin 5 second delay......End 5 second delay
11.60
27.80
Begin 5 second

The serial out prints really fast, there should be a 5 second delay between "Begin 5 second delay.." and "...End 5 second delay", but there is not, that whole bit prints out instantly. Then at the very end, it delays for a really long time, if you notice, the serial out has paused mid-print, there should be a " delay..." after the last "Begin 5 second"

[edit]Update: The pump runs on 12V or 6V. My power supply also had a 5V out so I tried that. The problem still exists when powering the pump using 5V, but its a lot less. For example, it will only skip one call to "delay()" instead of 10 calls in a row.[/edit]

Can you put something like an LED on another pin, and put it on when before the delay() and off after it? 5 Seconds should be okay to time with a watch.

What happens with analogWrite(PUMP, 0) or analogWrite(PUMP, 255)?

Where do the numbers, e.g. 11.10, 9.60, come from?

Have you a voltmeter/multimeter to see what is happening to the Arduino's power?

Is there a current limiting resistor between the Arduino pin and the gate/transistor driving the pump?

GB

Ok, so I fixed it.

It looks like there were some shennanigans going on between the arduino pin that I was using to trigger the MOSFET gate that turned the pump on and the arduino itself. I added a diode between this pin and the gate and it works fine even on the 12V now... I assume some power must have been surging back through the gate?

Incidentally, I think this problem was also sending weird electrical surges back into my computer through the USB and causing it to restart on me (the same thing happens if I pull my USB mouse out too fast)... not good...

Picture:

Ok, so I fixed it.

Excellent!

So the pump is under control?

Excellent!

So the pump is under control?

Yeah, the pump is under control, the wiring to the right in the last picture I posted is to a wooden stick that the pump sprays with water, when the stick gets wet, the resistance of the stick goes down and that shuts off the pump until it dries out again.

It was sort of working before, the only thing was that the calls to "delay()" in the code wouldn't work while the pump was on. I'm guessing it was due to some sort of power surge going back into the Ardunio through the pin to the MOSFET gate and then wreaking havoc on the Arduino, I'm probably lucky I didn't fry the Arduino or worse, my computer.