OK, first off, I am a total noob to using MOSFETs, so bear with me on this one.
I have some large electromagnets I need to control with my Arduino. These monsters run at 12v/4a, so yeah not gonna be running them off the board.
The solutions seems simple. A MOSFET and some PWM. That way I can turn up the power or drop it as I need to.
I hit up Sparkfun, and got a RFP30N06LE (sorry, it won't let me link to it yet)
Specs seem to make them a good fit.
Here is where it is getting problematic. I wired these up very simply. literally a wire from pin 9 to gate, source and drain with a big old magnet in middle and a flyback diode to handle things when the magnet turns off.
Here is where I am having trouble.
The magnet won't turn off. It is always on. Now usually when I screw up with electronics the exact OPPOSITE happens. I even tried reversing the source and drain and it STILL just turns on at full power. Which is VERY annoying because if it just broke I would at least know what not to do!
I really can't figure this out. I am assuming it isn't a code issue since it does this regardless if the Arduino is even on.
Any ideas on what would cause this? Again, I am more used to the smell of smoke and things not working when I do something wrong.
Here is where it is getting problematic. I wired these up very simply. literally a wire from pin 9 to gate, source and drain with a big old magnet in middle and a flyback diode to handle things when the magnet turns off.
It's not clear where things are hooked up from your description. First, I would put a resistor between pin 9 and the gate, else pin 9 will be driving into a very large capacitance that can damage the pin driver. Second, exactly what is going on with source and drain? I'm thinking you want the source connected to 0V and the drain connected to one end of your electromagnet, with the other end connected to 12V.
If the magnet is always on it means it's either miswired or the MOSFET has been destroyed and it is shorted. Any chance you can sketch up a quick schematic to see what you've got wired up?
--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, light sensor, potentiometers, pushbuttons
If red is positive and black is negative then you do have drain and source swapped. Red (+12V) should go to the magnet. The other magnet wire should go to the drain. The source should be connected to 0V.
Also, don't forget to connect the ground of the +12V supply to the ground of the Arduino.
--
The Quick Shield: breakout all 28 pins to quick-connect terminals
Also as drawn that diode is the wrong way round, the cathode should be to the positive side of the supply. In other words it is normally reversed biased.
OK, a few questions if you will indulge my massive ignorance.
One, a resistor was mentioned on the line going to gate from the arduino. What kind?
Secondly,
Also, don't forget to connect the ground of the +12V supply to the ground of the Arduino.
Ok, makes sense. And by this do you mean the ground on the digital side? I see two on the board. One for each side. I just want to confirm I'm not doing this backwards.
Thirdly,
Also as drawn that diode is the wrong way round, the cathode should be to the positive side of the supply. In other words it is normally reversed biased.
Gotcha. I checked and realized that I drew it wrong. I need to follow the "valve rule," right where the cathode hooks up to the positive so that it can shut off at positive.
And yes, pin9 is set to output, but I'm not so worried about that yet. Need to get the wiring right. Then I can get the software going.
I usually feed the gate of a mosfet through a 10k resistor, but I always have a 220k resistor between the gate and ground,
This will take away any charge on the gate if there is an open circuit somewhere on the gate circuit.
If you measure a fet with a multi meter for example, and have charged the gate by measuring between gate and the source, then when you measure between the drain and source you will read a short circuit. This is because the gate stays charged, having the 220k res fitted avoids this happening with open or intermittent circuits while fault finding.
I just question the need for the series 10k resistor from the Arduino output pin to gate terminal. This would just slow down the switching time for the mosfet (RC time constant) leaving it in transition period longer and thus raising the power dissipation. I've seen low value resistors used for mosfet gates, say 330 ohms but never as high as 10K. What benefit does the 10k bring to the table?
As dumb as this may sound, the ground thing is confusing for me.
I am using an Uno, and as the good Mr. crowley pointed out, there are three grounds on the board.
One on the PWM side, and two on the power/analog side. One is paired with Vin and the other with the 3.3/5v supply. Do I use the 3.3/5v ground or the ground on the digital side? Or does it matter?
I use epoxy thermal compound quite often. We use it for two applications one of which is to provide a thermal connection for a cold junction sensor and another is to adhere a heat sink to a mosfet.
It's extreme temperature stuff and a bit pricey but it saved having to rework the boards for a rather idiotic design flaw. I think it's only alumina filled.
We are in the design stages of developing some high intensity LED lighting fixtures and engineering is evaluating several compounds one of which uses an aluminum nitride filled epoxy.