Very newbie question

Discussion in 'General Electronics Chat' started by Etbauer, Jan 17, 2010.

  1. Etbauer

    Thread Starter New Member

    Jan 17, 2010
    14
    0
    Hi, I have been trying to control a solonoid from a microcontroller. I have I suppose a very basic question:

    the first is that I have been trying to test a simple MOSFET IRF510. How do I hook this up to a breadboard to make a simple on off switch using a 5V input to the Gate? I have hooked up a circuit with a resistor, led, and 9v battery through the source and drain pins, and have tried to switch it on with the 5v signal from a microcontroller. How should that be hooked to the gate to switch the MOSFET on? Or am I completely confused about how this should work?
     
  2. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Did you include a protection diode in parallel with the solenoid coil so that it is reverse biased when the coil is being driven and forward biased when the coil is turned off?

    hgmjr
     
  3. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    An IRF510 is a standard N-channel enhancement mode power MOSFET.

    We tend to abbreviate a lot of stuff around here, and might just refer to them as N-ch power MOSFETs.

    Standard N-ch power MOSFETs are controlled by voltage on the gate terminal, in respect to the source terminal (ie: using the source terminal as a reference point). This is most commonly referred to as Vgs.

    With N-ch enh MOSFETs, when Vgs=0, the drain to source connection will be fully turned off.
    When Vgs=10, the drain to source connection will be fully turned on.

    Somewhere in between the two voltage levels, there is a "threshold" level, where the MOSFET begins to conduct. The MOSFET is then in the linear region, and acts as a variable resistor.

    Unfortunately, you cannot successfully turn a standard MOSFET completely ON using a microcontroller, unless you use additional circuitry.

    There are plenty of logic-level MOSFETs that are available nowadays; unfortunately you won't find them at Radio Shack.

    An IRxxxxx MOSFET is an International Rectifier or Vishay part number.
    In very general terms, the 3rd character determines whether it is a standard or logic level MOSFET. This is not 100% true, but it is a good start.

    IRF = Standard level.
    IRL = Logic level.

    You can, generally, switch an IRLxx MOSFET directly from a uC's (microcontroller) I/O pins. You should use a resistor between the I/O pin and the MOSFET gate to limit the maximum current; and to protect the uC in case the MOSFET fails. If the uC has a Vcc of 5v, a 250 Ohm resistor will limit maximum current source/sink to 20mA. However, that is not a standard value; 270 Ohms is.

    A nifty logic-level MOSFET available from Mouser.com, Digikey.com and Jameco.com is the IRLD014. It can sink up to 1.7A if it's properly heat-sinked, and it's easy to use with it's 4-pin DIP package; great for breadboarding and mounting on perfboards.

    Note that all MOSFETs are very vulnerable to static electricity. Keep them in ESD-protective packaging until you're ready to install them. One little zap, and they are toast.

    It is good practice to connect the gate to the source terminals using a 10k Ohm resistor. This will turn the MOSFET off in case the drive to the gate fails. It also helps a bit to protect against static electricity.

    If the Vgs limits (usually +/-20v) are exceeded, the MOSFET will be destroyed. Since your power supply is defective, your MOSFET has likely been destroyed - unfortunately, your uC has probably been destroyed as well.
     
  4. Etbauer

    Thread Starter New Member

    Jan 17, 2010
    14
    0
    ok great that helps alot, especially the fact that i need an irl, I will look for that one. Also, I never used that power source on the fet, i have been using a 9v battery with a 5v regulator on the uc, and a 9v or 12v as the power supply for the source and drain pins. However, i might have blown it in another way, i bought a few extras i havent opened yet cause they are cheap. But I think i get how that works, the source voltage ammounts to some combination of the gate and drain voltages? also when I connect the uc, is it standard to run the current straight through the gat pin and back to the ground? Thats the part that I was confused about.
     
  5. Etbauer

    Thread Starter New Member

    Jan 17, 2010
    14
    0

    I havent actually hooked it up to the sol yet, but i did know that the diode was required. :)
     
  6. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Please post a schematic of how you had your circuit connected.
    There are many free schematic capture and simulation tools available. Google is your friend here.

    LTSpice is a good free schematic capture and simulation tool.
    Cadsoft Eagle is somewhat hard to learn, but it is a good tool for schematic capture and PCB layout.

    Yes, they're pretty inexpensive nowadays.

    Ahhh ... no. ;)

    Normally, when using an N-ch enh MOSFET, you will want to connect the source terminal to ground, and provide the control voltage to the gate referenced to the ground. The drain is connected to the "low side" or ground side of the load, and the high side of the load is connected to your +V supply.

    There are ways to use N-ch power MOSFETs as a switch on the high side, but I really don't want to confuse you at this point. It is hard enough to just understand how a low-side MOSFET switch works when you are new to them.

    Actually, the gate of a MOSFET is much like a small capacitor. You charge and discharge the gate. MOSFETs are voltage controlled devices. There is only an extremely small amount of current leakage from the gate; so low that it is of no real consequence.

    You should use a resistor between your uC I/O pin and the gate of the MOSFET. 270 Ohms is a good value to use.
     
  7. Etbauer

    Thread Starter New Member

    Jan 17, 2010
    14
    0
    ok here is a very crude drawing of how i have it set up on the breadboard, not sure if it will help.
     
  8. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Ack! It looks like you have ground and the uC's I/O pin connected together at the MOSFET - this is not a good thing. You will burn out your uC's I/O pin very quickly that way.

    The source terminal of the MOSFET needs to be connected to both power ground and your uC's ground.
    The uC's I/O pin gets connected to the MOSFET gate, using a 270 Ohm resistor.

    There should also be a 10k resistor connected between the MOSFET gate and source terminals.

    The ground side of the load gets connected to the MOSFET drain.

    If the load is inductive (like a motor) there should also be a diode connected across it, cathode towards +V.
     
  9. Etbauer

    Thread Starter New Member

    Jan 17, 2010
    14
    0
    thank you very much, that was exactly what i was looking for, i tried it out and it worked perfectly. I would like to know if there is a good resource online or a book that would have helped me figure that out? In other words how did you calculate out the resistance needed at each point?
     
  10. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    If you look at the Electrical Specifications portion of your uC's datasheet, you will likely find that the maximum source/sink current from any one I/O pin is 20mA.
    Using Ohm's Law, R=E/I, so 5V/20mA = 250 Ohms.

    Consulting a table of standard resistance values:
    http://www.logwell.com/tech/components/resistor_values.html (bookmark that page for future reference)
    ... we find out that 250 Ohms is not a standard value for the E24 range (green columns), but 270 Ohms is a standard value.

    10k Ohms for the gate-to-source pull-down resistor is a "rule of thumb" type of thing; it's a safety to turn the MOSFET off in case the I/O pin fails or is otherwise disconnected. Without that 10k resistor, the gate voltage could vary all over the place, and damage to the MOSFET or the circuit can result. Think of it as similar to the emergency brake in a vehicle. If everything's normal, you don't need it; but it's a darn good thing to have in case something breaks.

    You can learn a lot just by reading through our E-books; there are links to them at the top of every page on the forums.
     
Loading...