1. Arduino Fet Switch
  2. Arduino Fetch Url
  3. Arduino Fet Driver Circuit

Ardunio-Compatible M0/Zero/SAMD21 with FET Driver, MOSFETs, Absolute Magnetic Encoder, USB and RS485 comms.

High-Power Control: Arduino + N-Channel MOSFET

Eventually you are going to find yourself holding a 12v [[solenoid]], [[motor]], or light and wondering “How the heck am I supposed to control this from my Arduino?” And we have covered this in the past. Today we are going to talk about another way of doing just that, this time with an N-Channel MOSFET metal–oxide–semiconductor field-effect transistor, specifically the RFP30N06LE MOSFET (You can pick these up from sparkfun). but you can use any N-Channel MOSFET exactly the same way.

How this works

STARTER KIT, ARDUINO, WITH UNO BOARD; Silicon Manufacturer:Atmel; Core Architecture:AVR; Silicon Core Number:ATmega328; Silicon Family Name:ATmega. Questions about guitar & voice analog interfaces for Arduino microcontroller systems. Superior tone from simple, homemade circuits with JFETs, transistors & MOSFETs. This guide is about wiring the MOSFET (Metal Oxide Semiconductor Field-Effect) to Arduino and driving a high current bigger power loads.

WARNING: I am about to simplify the crud out of this, so beware… it is here in an attempt to explain, in simple terms, what is going on.

First off, a MOSFET is a transistor, just a special kind.

If you don’t know transistors at all, they are 3 lead components that have 2 simple functions, to switch or amplify (in this example it is setup as a switch). You basically have an In called the Source, an Out called the Drain, and a Control called the Gate. When you send a HIGH signal to the gate (control pin), the transistor switches and allows current to flow from the source (in) to the drain (out).

So we connect it so that our motor, solenoid or light is connected to V+ but not ground (V-). Ground is connected to the transistor’s drain. When our arduino sends a HIGH signal to the transistor’s gate, it switches the transistor (connecting the drain and source) and completes the circuit for the motor, solenoid, or light.

More Information

If you want to know more, or actually know what is actually going on in there. Pete over at Sparkfun put out amazing video explaining MOSFETs for a solid 20min. Highly recommended.

Hooking it up / What’s the diode used for?

This circuit is pretty simple. The only part that looks funny is the resistor. This is a [[pull-down resistor]]. The resistor holds the gate low when the arduino does not send a high signal. This is here incase the arduino comes loose, or the wiring is bad it will default to off. You don’t want this pin to ever be floating as it will trigger on and off.

You can see that in 2 of the 3 illustrations, there is a [[diode]] parallel to the device we are powering. Any time you are powering a device with a [[coil]], such as a [[relay]], [[solenoid]], or [[motor]], you need this guy, and don’t leave home without it. What happens is when you stop powering the coil, a reverse [[voltage]], up to several hundred volts, spikes back. This only lasts a few microseconds, but it is enough to kill our MOSFET. So this [[diode]] (only allows current to pass one way) is normally facing the wrong direction and does nothing. But when that voltage spikes comes flowing the opposite direction, the diode allows it to flow back to the coil and not the [[transistor]]. We will need a diode fast enough to react to the kickback, and strong enough to take the load. A rectifier diode like the [[Diode Rectifier – 1A 50V |1N4001]] or SB560 should do the job. If you are looking for extra protection you could use an optoisolator between the Arduino and the transistor. An optoisolator optically isolates both sides (high and low power) of the circuit so the high-voltage can not possibly come back to the microcontroller.

Just make sure that protection [[diode]] is facing the correct way (stripe facing the V+ of device). If it is facing the wrong direction, the device you are trying to power will not work as the [[diode]] will just allow the current to bypass it.

Limitations

[[Transistors]] like the RFP30N06LE are really great for controlling high-power devices from your arduino, but they do have some limitations. This current configuration is only useful for switching [[DC]] current, so don’t try this with an [[AC]] source, also MOSFETS have both a [[voltage]] and an [[amperage]]/current limitation. The RFP30N06LE can handle switching up to 60V, and the amperage is limited to 30A (with heat sink and proper wiring). Anything over a few amps, especially when the current is constant (like in a motor) and not short pulses, I would recommend using a heat-sink. I usually just solder a bent pice of metal to the back, just something to help dissipate the heat. Just note, if you are using more than one of the RFP30N06LEs, you can not solder them to the same heat-sink as the back is connected to the drain of the MOSFET, not the source. If you need to switch AC, I would look at using a [[relay]] instead.

Fade it!

You know the [[PWM]] outputs on your Arduino? Yeah, the thing that allows you to analogWrite(pin, value). Well, [[PWM]] is not actually an [[analog]] output. The Arduino is actually pulsing (very quickly) between 0 and 5v so that the average [[voltage]] is somewhere in between 0 and 5. Because of this, the [[PWM]] can be extended through the [[transistor]] (the transistor can only turn on or off, but can do so very quickly) allowing us to fade lights or control the speed of a motor just like if they were connected directly to the Arduino. All you need to do in order to take advantage of this is make sure the MOSFET’s gate is connected to a [[PWM]] pin.

Code

You don’t really need code for this, you just send a HIGH signal to the gate pin, and BAM… it works. But I threw this together for you so you can test it fading with the PWM- This code fades in a sin wave like the video below. (only useful for a motor or light obviously).

[code lang=”arduino”]
//////////////////////////////////////////////////////////////////
//©2011 bildr
//Released under the MIT License – Please reuse change and share
//Simple code to output a PWM sine wave signal on pin 9
//////////////////////////////////////////////////////////////////

#define fadePin 3

void setup(){
pinMode(fadePin, OUTPUT);
}

void loop(){

for(int i = 0; i<360; i++){ //convert 0-360 angle to radian (needed for sin function) float rad = DEG_TO_RAD * i; //calculate sin of angle as number between 0 and 255 int sinOut = constrain((sin(rad) * 128) + 128, 0, 255); analogWrite(fadePin, sinOut); delay(15); } }[/code]

Video

This video is showing the capabilities of PWM with the RFP30N06LE. The light, though it looks like a standard house light, is actually a 15W 12V DC light.

No Comments

Questions About Arduino Microcontroller Interfaces

QUESTION. I need to connect your preamp to an Arduino microcontroller. The Arduino input can't exceed five volts. I also want to isolate the Arduino from the outside world. How would I do this? (Question from Peter Laucks, 2010)

ANSWER. Consider an opto-isolator. You could buy a dedicated isolator. (Example: Vishay CNY75A or 83536 from Mouser.) But the easy way is to buy the infrared emitter and detector kit from Radio Shack.

The kit includes both an emitter and detector. The emitter is actually an LED that puts out invisible infrared light. The detector is an infrared phototransistor. (Kit contents actually vary. Some kits might substitute a photodiode for the phototransistor. The diode has faster response, but isn't as sensitive. For our purposes, either the diode or transistor should work.) The cost for the Radio Shack kit is only about $3.49.


This DIY optocoupler can safely couple a guitar to the Arduino

The circuit that I suggest has three stages. The first stage Q1 is our JFET preamp. I've dropped off the output coupling capacitor and load resistor, because we don't need them this time. This stage provides a high impedance to the guitar and amplifies the signal just slightly. The second stage Q2 has its own coupling capacitor. This stage drives D1, the infrared LED with our guitar signal. A battery or small power supply operates these first two stages. The Arduino powers the third stage. Notice that the Arduino circuit has no electrical connection to the LED circuit or preamp. This lack of connection is what we mean by isolation. Our third stage Q3 is a phototransistor. For the sake of linearity and response speed, this stage is slightly degenerative. Q3 has a gain approaching 0.99. The LED stimulates the phototransistor to send the guitar audio to the Arduino microcontroller.

Your first test should be to confirm that the detector works. The book Getting Started with Arduino has the code and pictorial diagram. See pages 62 to 67. Never mind that the book uses a CdS sensor. (That would work, too, but CdS is laggy and wouldn’t reproduce music well.) You can test just the detector by aiming a TV remote control at it. Just click any button and look for a response. Make sure that you point the remote at the end or 'head' of the detector.

Arduino Fet

Notice Different Power Voltages. In my circuit, I’m running the LED amp on nine volts, but the detector on five volts. That doesn’t matter, because the two amps don’t connect electrically.

Head-to-head only. The LED and phototransistor must face head-to-head. Bring the LED within an inch of the detector and the Arduino should indicate an AC input. To make the circuit more reliable, you could seal the detector and emitter in a short piece of heat shrink tubing. Again, the emitter D1 and detector Q3 must face one another in end-to-end fashion. The drawing at left shows what I mean.

QUESTION. Please provide me with a circuit for a five-volt buffer. I need the buffer after a resistive ladder DAC. (Question from Peter Laucks, 2010)

ANSWER. The buffer could be a tube, op amp, transistor, FET, or Darlington. Tubes are too big, too hot and too energy inefficient. Op amps add too much complexity for this project. That leaves transistors, JFETs and Darlingtons. You can power these solid-state devices from the Arduino. See the sample circuits nearby.

The JFET design seems to be slightly better than the transistor design. (See the schematic at top-right.) The JFET's input impedance is very high and the output impedance is medium-low.

A Darlington would perform even better, but the circuit would be slightly more complicated. (See the schematic at bottom-right.) Fortunately, the added complexity is inside the part! The reason for the Darlington’s superiority is that it can provide the lowest output impedance. I don’t know how low you need the output impedance to be.

For the Darlington, I strongly recommend the 2N6426 from Mouser. Similar devices are the 2N6427 and MPSA13. Each Darlington “transistor” is actually an IC with two super beta transistors inside. Either one of these internal devices is a “superman.” Together, they rule the universe.

If you don't want to try the 2N6426, you could build your own Darlington with two 2N3904 transistors from Radio Shack. Yet two 2N3904s only have a combined gain of 40K. The 2N6426 has a gain of 300K. Either version of the circuit should work, but the 2N6426 has the edge. (All that gain provides extra elbow room in the form of sensitivity. Actually, nobody uses the whole 300K. Think about it: In theory, 1 milliamp on the base gets you 300 amps on the collector. In real life, that much current would crater your PC board!)


QUESTION. Do you have an opto circuit to isolate an ULN2004 stepper drive chip from the Arduino? (Question from Peter Laucks, 2010)

ANSWER. Yes! I assume that you want the Arduino to power an opto that drives the motors through Darlington array ULN2004. See the schematic below.

Here’s the circuit description: The Arduino digital output pulses an infrared LED that's in series with a 220-ohm, half-watt resistor. (One LED for each motor coil.) The resistor reduces the Arduino current to a safe value for the LED. Be sure to use a half-watt resistor here. The LED could be active-high or active-low. (The drawing below shows both versions of the circuit.)

The 12-volt stepper supply powers the phototransistor. The phototransistor’s emitter is in series with a 5.6K, quarter-watt resistor. Another resistor, 56K, quarter watt, couples the emitter signal to the Darlington array input. Whenever the LED lights, the phototransistor sends a high pulse to the motor drive chip. A 0.01 µF capacitor shunts digital noise to ground. A parallel 10 µF capacitor filters low-frequency ripple from the phototransistor supply.

The 56K resistor is optional. The purpose of this resistor is to limit current and isolate the phototransistor from the Darlington array. Tweak the value of this resistor as necessary. If your driver requires a little extra voltage, you can remove the 56K resistor.

Caution! Don't connect the Arduino ground to the 12-volt ground!

You might prefer to use an opto array instead of discrete optos. Then I suggest the Vishay 782-ILQ615-3 from Mouser. This part comes in a DIP-16 package and includes four opto-couplers. The LEDs in this package will operate adequately with only 10 mA.



Arduino Fet Switch

Go to Page: 1234567Next

Arduino Fetch Url

WARNING. This is your project. Your achievement is entirely yours. I assume no responsibility for your success in using methods on these pages. If you fail, the same is true. I neither make nor imply any warranty. I don't guarantee the accuracy or effectiveness of these methods. Parts, skill and assembly methods vary. So will your results. Proceed at your own risk.

WARNING. Electronic projects can pose hazards. Soldering irons can burn you. Chassis paint and solder are poisons. Even with battery projects, wiring mistakes can start fires. If the schematic and description on this page baffle you, this project is too advanced. Try something else. Again, damages, injuries and errors are your responsibility.
— The Webmaster

Arduino Fet Driver Circuit

Copyright © 2010 by James T. Hawes. All rights reserved.

•URL: http://www.hawestv.com/mtv_FAQ/FAQ_fetpreamp6.htm •Webmaster: James T. Hawes
•Revision—March, 2014 •Page design tools: HTML, Notepad & Explorer