I'm struggling a little bit with MOSFETs. I'm trying to build a project I found online, a coffee roaster. I've successfully built the prototype in which the display works properly and two LEDs take the place of the actual high power requirement items, the fan and the heat. The LEDs work as expected and I thought I was ready to move to the next step.
I wired a couple of MOSFETs as shown here (note, the diagram doesn't show it, but the Arduino's also connected to the same ground):
The heater element was wired through the other end of the solid state relay, and the fan directly through the MOSFET. I started off with a 21V power supply I found as part of an old DirecTV installation, but it seemed the project was behaving strangely -- the fan wasn't going fast enough (I measured voltage at the fan at only 8V, and the MOSFET was receiving only 2.5 or so from the Arduino), and it was erratic. For example, when I pressed reset, the fan would go full speed for a half second before stopping.
I then tested the motor against the power supply and learned that it had not been working very well, probably because it didn't have enough output (only 1A or so and the motor is rated more than 1A). I got ready to swap it out for a 19V laptop supply I had. I disconnected the USB power from the Arduino and noticed that its display was still active with the script, and the fan was running full power, so I got worried power was going from the MOSFET backwards into the Arduino -- was it really getting 19V? I didn't know, so I pulled the wires off the MOSFET quickly, noticing it was very hot.
Clearly I'm doing something wrong, because the circuit didn't work, and now my Arduino won't start (the green power light comes on but that's it...and it passed a loopback test but won't accept any uploads or run the current sketch).
I was using an IRLB8721PbF and also tried an IRF540N.
Thanks a lot...I would love to learn how to use these properly. I'm always worried that these don't provide any isolation from the Arduino to the power supply...
You can connect a solid state relay directly to the Arduino outputs. The input draws only a few mA so no resistor is required. Connect the + input terminal to a digital port pin, the - to ground so that a HIGH on the pin will turn on the relay.
The transistor controlling the fan should have worked, but DC motors, relays, etc. require a reverse diode across the winding to protect the rest of the circuit from high voltage switching transients. Since your circuit does not show one, you may have damaged some of the components.
Thanks...I did try to power the SSR directly from the Arduino in the past but it wasn't enough power, so I used a MOSFET and that worked. But, I was powering the Arduino only from my computer's USB port, and I've read that less than 6v may not be enough to get full power from the pins...am I right about this?
The heater is 1200 watts so I don't know if it would be too much for the MOSFET. The fan is the problem for me -- today it was spinning too slowly, and I was only getting 2.3v to the MOSFET and 8v to the fan (using a 21v power supply). Perhaps this is also a result of using USB power to the Arduino?
it sounds like your power supply might be overloaded, and
you don't seem to have sufficient gate drive to the MOSFETs
What FETs are they? What is their Vgs threshold? What is their specified Ids at Vgs=4.5V? If the FET isn't driven hard enough, it will not turn on completely, and it will dissipate possibly significant power, causing overheating.
2.8V on the gate indicates that something is very wrong, e.g. the Arduino's supply has sagged or something else is pulling the pin down. Also, an IRF540 needs about 10V gate drive to saturate fully, so it's not appropriate to drive it from 5V logic unless you know your load current is below 10A under all conditions.
sshanky:
today it was spinning too slowly, and I was only getting 2.3v to the MOSFET and 8v to the fan (using a 21v power supply).
Then you have either miswired the MOSFET or its damaged, or you are using
analogWrite() and the multimeter is averaging the PWM waveform.
A MOSFET gates take only a tiny current at DC and will be right at 5V if driven HIGH.
Note that when driving a MOSFET with PWM or other AC source it may take a large
current (the gate behaves as a capacitor), so you are advised to add a 150 ohm
resistor in series with the gate to limit transient currents. You should also add a 10k
or 100k resistor between gate and source - this protects against the device switching
on before the Arduino pin is switched to be an output - it discharges the gate capacitance
when the power is removed.
For use direct from an Arduino you must use a logic level MOSFET, if you have
a non logic level MOSFET you need a level shifting circuit or gate-driver chip and
a 12V supply.