'Lowside PWM motor controller for go-cart'
Thanks for all the input! Please pardon the slowness of my response --
I get the piclist in the digest form and it takes me a while to absorb all this.
Answers to questions and more information.
> What are you doing with /mclr ?
I'm using a 16F88 with internal MCLR.
I also understand the current issues for the PIC circuit as far as connecting to +24V.
Since I have two 12V batteries, I can connect to 12V for the PIC power supply and
for the FET gate driver if the (as yet unknown) current requirements make it worthwhile.
This is the motor
M1020 Model 45 500W 24V
>> I plan to use a logic level FET
> Bad idea. You need a true totem pole MOSFET driver.
> The reason why people are telling you that you need a proper FET driver
> is that you actually need significant peak current to drive the FET gate.
I understand that. I'm trying to understand the math and FET specs that go along with this.
Very slow going and probably completely unnecessary -- I should just build a good strong driver.
Why is 'a true totem pole MOSFET driver' necessary?
Could not a small logic level FET driven directly from a PIC pin drive the power FET?
>> I did a search on Digikey and found this one:
>> DIGIKEY IPP0165N03L G 30V 50A Rdson=.0065 $1.03
> Bear in mind that you cannot get very close to the FET max Vds voltage.
> If you are working with a 24V bus voltage, I'd go for at least 50V FETs.
Will do. The FET I picked was sort of a straw man,
the first thing I saw at Digikey that looked in the ballpark.
Digikey has 19475 MOSFETs. Including this one:
IRFP4368PB 75V 195A TO-247AC 1.85 mOhm @ 195A, 10V 19230pF @ 50V 520W $7.78
I hope I can use something a little smaller, but we will see.
> 0.0065 is about 8 times too high for a good motor controller.
> It'll generate a ton of heat that you'll have to dissapate at load.
I don't understand this. 0.0065/8 ~= .0008.
That just looks like a magic number to me. What is the context?
My context is (hopefully) less than 20A for continuous operation.
(Otherwise I don't need to worry about the controller, the motor is going to melt.)
I'm building a go-cart, not an electric car.
I^2 * R loses for 20A at Rdson of .0065 < 400 * .0065 = 2.6W. Is that too high?
The FET(s) will have big heatsink and probably a fan too.
> If you have some time and patience, there is a long standing thread for an
> open system EV motor controller running on EcoModder.com here:
> If you read all 215 pages of the thread, you can become a electric motor controller guru.
This is very interesting and a fun read. But slow going.
There is, however, no chance of my become a electric motor controller guru!
(I am a programmer, not an engineer.)
But I have already found several excellent ideas for the PWM logic that I will be implementing.
Such as gentle PWM ramp up and limiting the PWM duty / motor current combination.
> How about an alternator with a load resistor
I like this idea and think maybe I could actually do it.
But for now I'm going to skip this bit. See 'CURRENT SENSING' below.
> Stall test
> Beware that, in some motors, stalling, even for a split second,
> can begin to demagnetize the magnets (if it is a permanent magnet motor).
My motor is permanent magnet, so I'm going to skip the stall test. (Thanks, Sean!)
> There's no need to actually stall the motor to determine the stall current.
> You can simply measure the winding resistance and divide that into the battery voltage.
I measure something like .2R, probably plus or minus 100%.
My meter is not that accurate at low values.
Is there some trick to get a more accurate reading for low resistance values?
> As has been pointed out, there NEEDS to be a fast current limiting scheme.
> Probably the easiest way would be to use a low-value (perhaps 0.01 ohm)
> resistor in the source-lead of the FET, with a comparator
> and a way of cutting off gate drive when the voltage drop across the resistor exceeds a certain value.
> time = (L*I)/V
> Time is short.
I have everything but L (inductance). Is there a way to measure that with a VOM?
Current sensing is my new highest priority.
I want to add current sensing, and program the PIC to never allow current
anywhere near the maximum (stall) current.
I don't want to put a resistor in the high current path.
I'd like to use a current sensor like Allegro ACS706 that i've heard discussed on the piclist.
Checking for ACS706. Ok, it's discontinued.
Replacement ACS712. Checking Digikey. Max is 30A.
Searching for current sensors at Digikey - 402 items.
Heven't found anything above 30A, except some expensive modules (~ $100).
Any ideas for current sensor? 100A capability would be really nice.
Doesn't have to be very accurate.
Here is my idea. Once I can sense and control current, I can safely experiment.
I'll put a fuse holder in the power supply line and pick a number, say 20A.
I'll set this as the maximum current allowed by my PWM code.
And put a 30A fuse in, just to be safe.
Play with the cart. Can it climb a hill? Good acceleration?
YES - done
NO - bump up the programmed current limit and the fuse value.
Repeat until cart performs adequately or fuse pops.
(Hopefully I'll reach 'YES-done' before something else besides the fuse blows.)
This reminds of the torque-wrench-less method I read about many years ago
for putting the big gland nuts -- "Crank it down until it breaks, then back off a quarter turn."
How bad of an idea is this? No -- my idea, not the wrench one.
> Current sensing is my new highest priority.
> I want to add current sensing, and program the PIC to never allow
> anywhere near the maximum (stall) current.
I personally wouldn't be doing current limiting via the micro, it will
add latency and a level of unreliability, especially in the debug stage.
Make the current limiter work an in the analog domain, and provide a
signal that the PIC can read to see if it's activated.
BTW you need a totem pole (or push pull) driver for a MOSFET because you
need to be able to turn it on and off as quickly as possible, and that
means having a strong current source and sink capability.
This e-mail is intended for the person it is addressed to only. The
information contained in it may be confidential and/or protected by
law. If you are not the intended recipient of this message, you must
not make any use of this information, or copy or show it to any
person. Please contact us immediately to tell us that you have
received this e-mail, and return the original to us. Any use,
forwarding, printing or copying of this message is strictly prohibited.
No part of this message can be considered a request for goods or
On Thu, Aug 6, 2009 at 11:08 PM, Chris Loper<bellsouth.net> wrote: cloper
> Why is 'a true totem pole MOSFET driver' necessary?
> Could not a small logic level FET driven directly from a PIC pin drive the power FET?
Imagine that the MOSFET gate is one end of a capacitor and the other
end goes to ground.
Now imagine that you need to charge this capacitor up to 10v to turn
it on -- and down to 0v to turn it off.
If it's a simple capacitor (we'll say it is) then it might be around 4
nanofarads and let's assume you want to turn it on or off in 200
This means you need an average current of:
I = C*dv/dt = 4nF * 12v / 200nS = 240mA
This sounds about right but I would make it 2 or 3 times higher
because I wouldn't want the MOSFET to hang around in it's linear
region for any longer than necessary (and it's not a simple
capacitor). You can (probably should) do some reading on MOSFETs.
Alan B. Pearce
>You can (probably should) do some reading on MOSFETs.
Also look at the FET drive chips that Microchip make, such as MCP1401 and
Please see my answers below.
On Thu, Aug 6, 2009 at 11:08 PM, Chris Loper<bellsouth.net> wrote: cloper
> This is the motor
> M1020 Model 45 500W 24V
> Torque 1.91nm
That looks like a nice motor. It definitely needs a decent motor
driver. In other words, it is quite capable of drawing LOTS of current
if you stall it or even change speed rapidly.
Looking at their "loaded" specs, the DC resistance is no larger than
0.2 ohms. I know this because At 500W output power at 2500 rpm, 1.91
Nm torque, the input voltage is 24V, current >= 26.7 Amps. 24V*26.7
amps=640W. 640W-500W=140W waste power. The resistance to AC current
(while the motor is rotating) will always be higher than the DC
resistance, so we know that if we compute the resistance which gives
140W power loss at 26.7 amps DC, the actual DC resistance will be
equal to or lower than that value. P=R*I^2 so 140=R*(26.7)^2. R=0.19
>> The reason why people are telling you that you need a proper FET driver
>> is that you actually need significant peak current to drive the FET gate.
> I understand that. I'm trying to understand the math and FET specs that go along with this.
> Very slow going and probably completely unnecessary -- I should just build a good strong driver.
I applaud you for trying to understand this. You can and should do so.
First off, I'd recommend you download a copy (free) of LTSpice (also
called Switcher Cad) from Linear Technologies. It is a wonderful SPICE
electronics simulator which is designed for power electronics. It can
help you to understand what goes on in a motor driver FET.
When a FET is fully ON, it acts like a tiny resistance (about 0.005
ohms in some cases). When it is fully OFF, it acts like an open
circuit. However, when it is partially on, it acts like a resistor of
an intermediate value, say 1 ohm or 10 ohms. If you have a 0.005 ohm
resistor with 26.7 amps flowing through it, you dissipate 3.6 Watts.
If you have a 1 ohm resistor with 13 Amps flowing through it (say,
when the FET is half-way on, that is, conducting half of the full 26
Amps of current), then it is dissipating 170 Watts!
When you are doing PWM and switching the FET on and off thousands of
times per second, there is no way to instantly go from off to on and
vice versa each PWM cycle. There will be some small fraction of time
spent in the partially-on state. You want to keep this fraction of
time as small as possible, which means that you need to force the FET
from the OFF to the ON state and from the ON to the OFF state as
quickly as possible. This means that you need to charge and discharge
the FET's gate quickly.
>> Bear in mind that you cannot get very close to the FET max Vds voltage.
>> If you are working with a 24V bus voltage, I'd go for at least 50V FETs.
> Will do. The FET I picked was sort of a straw man,
> the first thing I saw at Digikey that looked in the ballpark.
> Digikey has 19475 MOSFETs. Including this one:
> IRFP4368PB 75V 195A TO-247AC 1.85 mOhm @ 195A, 10V 19230pF @ 50V 520W $7.78
> I hope I can use something a little smaller, but we will see.
That one sounds very nice. Keep in mind that the power and current
specs for these FETs are very optimistic. You can't actually,
realistically, put 195A continuous through this FET, for example.
There is a fairly simple, and important, thermal analysis that you
should do to see how much current you can actually put through it in
your particular case. There are application notes on this on the
International Rectifier site. Ask me if you can't find one.
>> 0.0065 is about 8 times too high for a good motor controller.
>> It'll generate a ton of heat that you'll have to dissapate at load.
> I don't understand this. 0.0065/8 ~= .0008.
I don't really understand what he meant, either. I don't know of any
>24V rated FET with 0.8 milliohm ON resistance.
> That just looks like a magic number to me. What is the context?
> My context is (hopefully) less than 20A for continuous operation.
> (Otherwise I don't need to worry about the controller, the motor is going to melt.)
> I'm building a go-cart, not an electric car.
> I^2 * R loses for 20A at Rdson of .0065 < 400 * .0065 = 2.6W. Is that too high?
> The FET(s) will have big heatsink and probably a fan too.
2.6W is perfectly reasonable for a TO-220 or similar package on a good
heatsink. It would be really pushing it for a TO-220 which was not
heatsunk - perhaps that's what he was thinking.
Also, though, bear in mind that you need to perform this calculation
for power in a rigorous, conservative way. You need to look at the
maximum sustained current you could have, consider where that current
goes during both the ON and the OFF times of the PWM, compute the
power dissipation during each time. Then, compute the power dissipated
by the FET and catch diode(s) during the ON to OFF and OFF to ON
transients, as well as the fraction of time spent in each. You then
need to add all this up for a total per PWM cycle, and multiply by the
PWM frequency. This should be done for the worst case RdsON over both
manufacturing variation and temperature. You then also need to perform
the same calculation again for the highest transient current you may
have (i.e., while accelerating) if that is significantly higher than
the max continuous current. You can then apply a conservative duty
cycle to the this (that is, the fraction of time spent drawing this
transient current, like the fraction of time spent accelerating).
All of this together will give you an average and peak power
dissipation which the FET and catch diode(s) must dissipate (I have
plural because there is one across the motor and there is also one
internal to the FET) The average dissipation can be used in your heat
budget to see what average temperature the die inside the FET will
reach. You then also need to look at how high the temp of the die will
get during each transient high current situation and make sure that
neither of these (average or transient) exceeds the max junction temp
of the FET - accounting for the max temperature which the heatsink
will reach at the max ambient temperature you want this to work in.
Bear in mind that you may have to deal with diode reverse recovery
current, too, although you may be able to avoid that if you use a
Schottky diode for the catch diode across the motor.
> This is very interesting and a fun read. But slow going.
> There is, however, no chance of my become a electric motor controller guru!
> (I am a programmer, not an engineer.)
You may surprise yourself :)
> MOTOR LOADING
>> How about an alternator with a load resistor
> I like this idea and think maybe I could actually do it.
It does not have to be a special "alternator" - it can simply by a
second motor with a shorted output or a resistor across its output.
>> Beware that, in some motors, stalling, even for a split second,
>> can begin to demagnetize the magnets (if it is a permanent magnet motor).
> My motor is permanent magnet, so I'm going to skip the stall test. (Thanks, Sean!)
You're welcome :)
>> There's no need to actually stall the motor to determine the stall current.
>> You can simply measure the winding resistance and divide that into the battery voltage.
> I measure something like .2R, probably plus or minus 100%.
> My meter is not that accurate at low values.
> Is there some trick to get a more accurate reading for low resistance values?
0.2 is probably close, but a multimeter is usually very poor for
resistance below 1 ohm.
Yes, there is a "trick" for this. Do you have an accurate current
limited power supply? If you put a controlled current through the
motor (say, 1 Amp), and then use your meter in voltage mode to read
the voltage drop across the motor, you can divide the voltage drop by
the (known) current to get the motor resistance. This is the same
thing that your multimeter does but by using a much larger current
than the meter does typically, you can accurately measure much smaller
>> time = (L*I)/V
>> Time is short.
> I have everything but L (inductance). Is there a way to measure that with a VOM?
Not easily. A good motor datasheet lists the inductance. If you do not
have that info for this motor, the only way I can see to really test
it is to guess, pick a capacitor to resonate with the motor
inductance, and then use a signal generator to find the resonant
frequency, then back out the inductance value from that.
I have used the Allegro current sensors and they are nice. You should
be able to find one that works for you. Take a look at their web site.
Digikey does sell some which work for much higher currents. Take a
look at the ACS756 series.
More... (looser matching)
- Last day of these posts
- In 2009
, 2010 only
- New search...