Driving a MOSFET

Other than control. (Navigation, Sonar, Ect.)
CLYON
Posts: 35
Joined: Dec 2nd, 2012, 8:52 am

Driving a MOSFET

Post by CLYON »

I am having some problems and I was hoping someone could help. I am trying to use an UNO to control a brushed motor. The motor is the bilge pump that a lot are using on this site. I am using a IRF510 MOSFET to drive the motor. I chose it because I had it lying around and this was an experiment. The current of the motor is 1/2 amp with no load so this MOSFET is plenty. I hooked it up like an example in the book Getting Started With Arduino. The program is in the same book but it is used to control the brightness of a LED by turning a pot. When I turn the pot the motor has a faint squeal and does not turn. I remove the motor and insert the LED and it will work, with the brightness going from dim to bright. I am also monitoring the voltage there and it goes up and down with the pot. When the motor is there no voltage is present when I turn the pot, just millivolts. If I disconnect the gate from the Arduino and pull it high the motor will run, so I know the MOSFET will switch with the motor. Everything tells me the motor should turn. What am I missing, why wont this motor turn with the Arduino? Thanks.


Chuck
User avatar
thegadgetguy
Posts: 238
Joined: Feb 13th, 2011, 8:27 pm
Location: Pennsylvania

Re: Driving a MOSFET

Post by thegadgetguy »

What voltage is your motor supply at? Do you have good common ground between the two supplies? Can you post a schematic?

What happens if you hook the gate of the MOSFET up to the 5 Volt supply on the Uno? It kind of sounds like your MOSFET isn't turning on all of the way. If the MOSFET turns on when connected to the Arduino's 5 Volt supply, I would try running the Blink sketch with the MOSFET gate hooked up to whatever pin is blinking. That would tell you if it is a problem with PWMing the FET or not. Also, try running both sketches on different Arduino pins, to see if a faulty pin could be the problem.
User avatar
Joe
Posts: 23
Joined: Mar 23rd, 2012, 11:09 pm
Location: Mount Vernon WA

Re: Driving a MOSFET

Post by Joe »

The problem you're experiencing runs deep into the theory of motor control. That being said, when I was learning about building motor controllers it seemed almost a dark art; there was no simple explanation for anything...

The squealing sound you described is normal for a motor controller. Commercial controllers build this out by raising the frequency until it's out (or almost out) of human hearing range.

As for the motor not wanting to turn, if you would post a circuit diagram and perhaps your code we could tell you more. :)

Also, measuring the voltage across the motor in this case will be very deceptive. When a motor is being controlled with PWM (Pulse-Width-Modulation) the voltage will reflect the motor's RPM (and your motor isn't turning so the voltage is practically zero), and the current through the motor will go up and down with the "throttle".
CLYON
Posts: 35
Joined: Dec 2nd, 2012, 8:52 am

Re: Driving a MOSFET

Post by CLYON »

I need to do some more experimenting. When I put the gate to +5 the FET will turn on the motor. I will try the blink program and turn it on for a couple of seconds and then off just to see. The code is from the Getting Started With Arduino book. It is example 06b that sets the brightness of a LED to a brightness specified by the value of the analouge input. It works fine with the LED and the brightness is controlled by PWM. This is through the FET so that proves that much is working. I used the same code with an ESC, without the FET, and it worked. I am using brushed motors and wanted to have a reverse. I was going to use a relay for reverse, but decided I would make a H-Bridge if this worked. This same design is used throughout The Arduino Cookbook to drive high power LED's, motors, etc. The FET turns on for the LED, why doesn't it turn on for the motor? Everything tells me this should work.


Chuck
rossrov
Posts: 383
Joined: Feb 28th, 2013, 5:01 pm
Location: Australia

Re: Driving a MOSFET

Post by rossrov »

Hi Chuck. Sounds like you are not applying enough volts to the gate. If this is the case, the FET will be getting a bit warm while the motor is whining. The voltage out of the port connected to the gate will be a bit less than 5 volts at best.

Also,but probably not significant here, the FET gate has some capacitance to source (ground in this case) which doesen't show up when connecting the gate to a steady voltage such as the 5V rail. When the port is pulsing at several KHz, the real voltage of the pulses is even less, because the port cannot source the amount of current needed to "overcome" this capacitance.

So I recon you need another transistor between the port and the FET's gate. jenswilly has used an optocoupler to do this, which is a good idea as it saves designing a driver network out of other components. Looking at the components on his board, I would say that the opto is switching full motor battery voltage into the gate.

When using FETs to switch motors and other biggish loads, make sure you have something in your code to monitor the volts supplying the gate (the battery in this case). When the battery starts to go flat, not enough volts will be available to turn the FET on properly and it will fry. (been there done that!)

Much better to do your own FET driver than buy a brushed ESC. You will end up with a more compact setup and learn heaps more. Plus its cheaper and fixable. Good on you!
CLYON
Posts: 35
Joined: Dec 2nd, 2012, 8:52 am

Re: Driving a MOSFET

Post by CLYON »

What I found today is the IRF510 that I am using is the most popular and least liked when using with the Arduino. I guess so many people have them and that is why they use them. I read the specs before I used it and I thought the gate voltage was to be between 2-4volts to saturate the FET. After searching around it seems that voltage should be around 10 volts, arduino puts out 5 volts. That still doesn't really explain why the LED would work. What I need is a logic driven MOSFET, which takes around 5 volts to saturate. That is what jenswilly is using and could get by without the optocoupler, but using it makes his board even nicer and adds protection. According to the specs he would only need 5 volts at the gate. So what I am going to do now is order logic driven MOSFETS and maybe optocouplers and play with them. Thanks for everyones help.


Chuck
User avatar
Joe
Posts: 23
Joined: Mar 23rd, 2012, 11:09 pm
Location: Mount Vernon WA

Re: Driving a MOSFET

Post by Joe »

Does your circuit have a freewheel diode? It's a diode wired across the terminals of the motor, and oriented against the direction of the current flow. This means when the motor is being powered the diode will be "off".

When the MOSFET breaks the flow of current (turns off) the motor's inductance (kind of an electrical form of momentum) causes the voltage to spike. Like when you're spraying something with the hose and you suddenly let go of the trigger on the nozzle; the hose jumps because all of the water in the hose wants to keep moving. If you were to measure the pressure right at the hose nozzle you'd see a huge spike for a moment. Same thing here. The Freewheel diode will "short out" that spike back into the motor.

If you don't have that diode those voltage spikes will cause your microprocessor to reset every time it tries to cut the current to the motor... thus the microcontroller will only make it as far as the end of the first pulse, then reset and start again.

That being said, make sure your microprocessor has a good capacitor on it's power supply (preferably separated from the motor circuitry by an inductor or ferrite bead) to keep it from 'browning out' (not having enough voltage for a moment to keep running reliably) when the motor starts.
CLYON
Posts: 35
Joined: Dec 2nd, 2012, 8:52 am

Re: Driving a MOSFET

Post by CLYON »

Yes I have a diode across the motor and also a .1uf cap. I also have a 10k resistor from the gate to ground and a 4.7k resistor from the output of the Arduino to the gate. Power for the Arduino and the motor/FET are seperate, grounds connected. These values were chosen because thats what I had at the moment. Every where I went on the net, including the data sheet, told me that the IRF510 needed 10 volts at the gate. I still want to know why the LED would work. I thought I was measuring the voltage when I had the LED in and saw the FET saturate, not sure now. Maybe the LED wasn't getting full power and I assumed it was. I know I was watching on the motor, because it did not turn on. I ended up popping the FET from all the playing around. If things worked the first time, and everything could be explained, I guess we wouldn't have as much fun.


Chuck
rossrov
Posts: 383
Joined: Feb 28th, 2013, 5:01 pm
Location: Australia

Re: Driving a MOSFET

Post by rossrov »

Hi Chuck. Answer to why LED works and motor doesn't: Motor draws more current than LED so needs more volts at gate. You cannot treat a FET as a substitute for a relay, unless it is one of those fancy logic-level ones :) . Refer the graphs on the datasheet. Also, if doing the H-bridge, your high-side drivers will probably be conventional P-channel FETs. You can use a BC547 and a couple of resistors to drive their gates from the micro ports. Other ways to do it too.

Cheers,

Ross
CLYON
Posts: 35
Joined: Dec 2nd, 2012, 8:52 am

Re: Driving a MOSFET

Post by CLYON »

I did some more experimenting with a transistor that I had. LED would turn on, but motor wouldn't turn until I increased the current to the base, so yes that explained things. One more thing I need to ask is most of the store bought H-Bridges have an enable that connects to the PWM and two enables that decide on direction. Since it is my design is there any reason why I can't use one input for direction and one for the PWM? I don't know why they use all the inputs, that ties up a lot of pins.


Chuck
Post Reply