I have a project I'm going to work on that will need to drive more LED's than I want to hang off a sing port and also driving some 12 volt LED strips. I am experimenting with both transistors and Mosfets.
I am using an Uno. As soon as I power the board the mosfet is switched on, but functions correctly once the program starts running. Is the initial power-up position for a pin High? I am using a very simple circuit, I have the arduino pin connected directly to gate, on the drain pin I have power to resistor to led connected to drain, I have source connected to ground.
I have a similar circuit set up with an npn transistor, with a resistor on the base and it works perfect.
I would prefer to use the mosfet since it's basically a simple switch based on voltage instead of needing to calculate the resistor for the transistor.
Anytime you are using a mosfet that is switching a voltage source independent from the arduino voltage source you can experience problems when powering on and off and during reset/restart. It's recommended to wire a 10K ohm resistor from the gate to source terminals on the mosfet to prevent that problem.
retrolefty:
Anytime you are using a mosfet that is switching a voltage source independent from the arduino voltage source you can experience problems when powering on and off and during reset/restart. It's recommended to wire a 10K ohm resistor from the gate to source terminals on the mosfet to prevent that problem.
You've stated the what, "problems at power up" - which OP has already said he is experiencing.
retrolefty:
Anytime you are using a mosfet that is switching a voltage source independent from the arduino voltage source you can experience problems when powering on and off and during reset/restart. It's recommended to wire a 10K ohm resistor from the gate to source terminals on the mosfet to prevent that problem.
You've stated the what, "problems at power up" - which OP has already said he is experiencing.
Can you clarify the why?
If the arduino is powered off while the mosfet still has an independent voltage source powered up then the 'floating gate' does not ensure the mosfet will be off. A pull-down resistor will prevent this situation.
Floating gate MOSFETs obey the standard physics, so the gate voltage can be estimated. There is a capacitance from drain to gate Cgd which might be a quarter of the gate capacitance. When the drain voltage increases from 0 volts to 12 volts, it can capacitively couple 1/4 of that voltage onto the gate : 3 volts on the gate. The MOSFET spec sheet spells out the magnitude of those twp capacitances.
The 2n7000 has 50pf gate Ciss, 25 pf drain to gate Coss in the spec
So a 12v drain change puts 6 on the gate using max cap values
Ciss
Coss
The gate has such a small resistance that it will charge itself off static and random rfi floating around (like mains). I just did a thermostat for my camping fridge and used an IRL540N as the power switch, pulling the gte off the arduino bard resulted in full power to the load
retrolefty:
Anytime you are using a mosfet that is switching a voltage source independent from the arduino voltage source you can experience problems when powering on and off and during reset/restart. It's recommended to wire a 10K ohm resistor from the gate to source terminals on the mosfet to prevent that problem.
Lefty
That fixed it. In effect it became a pull down resistor. I do remember reading about pins floating last year when I got into arduinos, but I just did not realize thats what was going on. Thanks for the answer.
The MOSFET you are using is not logic-level, it also is not a power MOSFET (despite what the datasheet
says) as it has an on resistance of 5 ohms and a max current of 0.3A. It is really a small signal MOSFET.
Look for a device with on-resistance more in the range 0.003 to 0.1 ohms, and max current at least
3 to 5 times the maximum current you want to switch. It also must be logic-level (the on-resistance
will be quoted at "Vgs = 4.5V").
The maximum current rating of a power MOSFET assume you have the device on an infinite heatsink
running at its absolute maximum power level. You never do this!
Here is the one might beat a lot of Audio Amps which is sold at Bestbuy since they are Class-AB.
Pure Class-A 2SK1058 MOSFET Audio Amplifier
2SK1058 is one type power MOSFET suitable for audio power amplifier, and it has very high Ron (~15 Ohms).
Substitute power MOSFET with power JFET will push this to beat a lot of semiconductor Class-A amplifier, very close or match with tube Class-A amplifier.
Don't use this with Arduino, Arduino sounds terrible.
The small footprint can be a problem - though this sort of surface mount package can be soldered
onto stripboard quite nicely (remember to cut the tracks as necessary under the device first!). The DPAK
and D2PAK and this LFPAK packages are common for MOSFETs and carry a better variety of logic-level devices than
the TO220 package (although many devices are available in several package formats).
In general lower voltage MOSFETs are available in lower on-resistances. If you are switching 12V don't
go for a 100V device, a 20, 25, 30V device will typically be better.