PDA

View Full Version : Learn me MOSFETS



DaveAK
05 March 2011, 1147
I want to use a PIC microcontroller to operate the gauges on my bike. I can put out a 3.3V PWM signal and I want to convert it to a 12V PWM signal to hopefully drive the gauges. I don't know if they'll work with PWM, but we'll find out. :)

So I think a MOSFET is the way to go. In the PIC manual it shows the MCU feeding a MOSFET driver, and then the MOSFET. What's the driver doing? Other more general circuits I've seen just show a pull down resistor. Is it to do with the frequency of switching under PWM?

I'm confident I can build the circuit from the information I have, but I always like to have a little understanding of what I'm doing. :D

Nuts & Volts
05 March 2011, 1157
Only things I know-
a mosfet is a solid state switch that uses a low power input to control a higher power output. They are quick and efficient. I think the drive simply tells the mosfet to turn off and on with a specific signal. The pull down resistor may just be used to limit high current from destroying something :)

Also faster you switch the higher bit chip you'll need. And if you are switching high currents you will need to heatsink your mosfets or they'll blow up.

Im kinda an idiot to this. Ill be enjoying reading this thread thou.

magicsmoke
05 March 2011, 1250
Won't go into detail about the operation of a FET 'cause there's many excellent resources on the net, but specific to this case .. why use a driver or not ..
Basically, the GATE (input or control) pin of a fet has a capacitance associated with it.
If you wanted to switch a large current on and off quickly, you ideally would like the fet to go from off (v. high resistance) to on (v. low resistance) 'instantly', otherwise the current flowing through the fet would cause a heat loss = I^2 Ron.
The GATE capacitance introduces a time constant which slews the on/off time and so the channel (switch) resistance goes from high to low relatively slowly.
To speed up the charging and discharging of this parasitic capacitance, a gate driver is employed which is itself nothing more than a fast / medium current (typically a few amps) switch. This allows the capacitance to be charged with a much higher current and therefore much quicker than a typical uC could.
They're really only necessary for high power or accurate square wave generators. Definitely not required for a tacho feed as the typical fet gate current would be in the pico / microamp range because unlike a bipolar transistor, fets are voltage controlled.
The pull down (or up) resistor is simply to define the no signal state of the fet. i.e. off or on.
You're right about the current limiting, and for a 'run of the mill' application like this, would normally be done with a 1M to 4M7 resistor in series with the feed to the gate.

EDIT: Forgot to mention that you would probably want to use an Enhancement Mode N-Channel MOSFET for this. Basically, a pos on the gate relative to the source will turn it on, zero volts will turn it off. Other types of fet require that you reverse bias the gate to turn them off.

Rob

harlan
05 March 2011, 1316
What frequency are you switching at? Can't you just use an op amp circuit with a gain of ~4?

magicsmoke
05 March 2011, 1320
What frequency are you switching at? Can't you just use an op amp circuit with a gain of ~4?

Good call, although a comparator would be better. I think there's some unknown regarding the current required to drive the tacho though, so a fet covers both bases.

DaveAK
05 March 2011, 1321
Thanks Rob! As well as logic for the tacho, I'm also going to have a PWM feed to the coil of the gas and temperature gauges. Would the current requirements of these coils dictate the use of a driver? Seems like for the couple of dollars it would cost to add them I might as well.

magicsmoke
05 March 2011, 1327
I'm also going to have a PWM feed to the coil of the gas and temperature gauges. Would the current requirements of these coils dictate the use of a driver?

Hmm, not sure about the temp gauge, but petrol gauges are usually a bimetallic strip. There's a potentiometer with a float on it inside the tank which alters a current flow which in turn alters the heating / deflection of the strip inside the gauge. Maybe not in this case of course!

DaveAK
05 March 2011, 1328
What frequency are you switching at? Can't you just use an op amp circuit with a gain of ~4?
Don't know. Can I? I'm really out of my depth here. :o


Good call, although a comparator would be better. I think there's some unknown regarding the current required to drive the tacho though, so a fet covers both bases.
Current aside, would there be a benefit from something other than a FET? A FET seems pretty simple and cheap to me and I can drive the GATE direct from the MCU. I'm using the MCU to collect the current measurement so I can do coulumb counting for the fuel gauge. I.e. the current to tacho circuit is not a standalone one.

DaveAK
05 March 2011, 1331
Hmm, not sure about the temp gauge, but petrol gauges are usually a bimetallic strip. There's a potentiometer with a float on it inside the tank which alters a current flow which in turn alters the heating / deflection of the strip inside the gauge. Maybe not in this case of course!
Well bugger. Didn't know that. I can see the potentiometer on the wiring diagram, but it doesn't tell me how the gauge operates of course. I just assumed it was a coil. What's the best way to vary the current to the gauge then?

magicsmoke
05 March 2011, 1355
What's the best way to vary the current to the gauge then?

Well, coincidentally, an opamp and fet combo could handle this nicely. The fet would act as the variable resistor, and if you put another resistor in series with the fet then the opamp would sense the voltage across this resistor and so control the current. The input would simply be a variable voltage, and as Harlan pointed out, you could set the gain of the system. A number of the PICs have 'free' opamps in them.
Remember though that by it's nature, the fuel gauge is a slow to act meter.
Thinking more on the temp gauge, again a slow to act unit, this may or may not work exactly the same, although because the sensor itself is a slow device, it doesn't have to!

DaveAK
05 March 2011, 1410
Is that why they're bimetallic strips then, because they don't have to act quickly? That's going to be fine for my purposes I think. Gotta run to town, and then study up on opamps when I get back. :)

To test the gauges if I hook up a 12V signal to them, and then a 6V signal, if they are voltage and not current controlled I should see an appropriate change, right? If I didn't see any movement could I assume that they're current controlled? Or would that short circuit them and put too much current through. Maybe throw a resistor in there to prevent any damage? Just thinking out loud now.

DaveAK
05 March 2011, 1635
I love this learning stuff. :D I now know all there is to know about opamps, well at least I know more than I did a couple of hours ago. :) Now I at least understand what Harlan was suggesting. I also happen to have an opamp in my draw of stuff bought and never used. Off to try this out .....

DaveAK
05 March 2011, 2154
Well, right now my tach works from simple pulses straight from the MCU at 5V. This is an Arduino though, the PIC only puts out 3.3V. Still, if it needs more I'll use the opamp just like has been suggested. Needs a little thought on how best to calibrate it, but I'll probably wait until I get the PIC.

Tony Coiro
06 March 2011, 0059
I wo8iod help but I am in no condition to, mnaybe in the morning. Good stuff so far.

teddillard
06 March 2011, 0420
I wo8iod help but I am in no condition to, mnaybe in the morning. Good stuff so far.

^ PUI

step away from the keyboard sir, and nobody's gonna get hurt. :O

Tony Coiro
06 March 2011, 0938
I wo8iod help but I am in no condition to, mnaybe in the morning. Good stuff so far.

Oh wow.....so I check elmoto after parties, and for what it's worth, it was an electric vehicle party too.

teddillard
06 March 2011, 1217
for what it's worth, it was an electric vehicle party too.

translation: there were no girls. :cool:

DaveAK
06 March 2011, 2241
Well, coincidentally, an opamp and fet combo could handle this nicely. The fet would act as the variable resistor, and if you put another resistor in series with the fet then the opamp would sense the voltage across this resistor and so control the current. The input would simply be a variable voltage, and as Harlan pointed out, you could set the gain of the system.
I'm lost as to how to set this up. :o

Also, out of curiosity, can you have an opamp with a fractional gain by using an appropriate voltage divider? I'm guessing there would be no point as you could just use a voltage divider by itself. The current sensor I'm using is 5V, but the PIC inputs are 3.3V