# Nissan Leaf Motor test



## MPaulHolmes (Feb 23, 2008)

I recently got a 2011 Nissan Leaf motor from a wrecked Leaf on Ebay, for $550. I was a bit concerned since it used a resolver, and my controller only has an encoder input, but I made a little board using a resolver to encoder emulation chip, and it works! This test was at 48vDC with the peak phase current programmed to 20Amp.  The controller's auto-PI-tuning worked really well. It was up at running in no time. I can't wait to put this in a car!:

https://www.youtube.com/watch?v=qzlLh8xxx1g


----------



## dcb (Dec 5, 2009)

very cool, looks like the knee is at 3500rpm @ 390v (and 225 nm). The 7.9377:1 ratio gearbox looks useful too for a car (duh) 1317 ft lbs at the wheels till ~31mph.

What is involved in switching motor types (i.e. induction)? settings, new firmware?


----------



## MPaulHolmes (Feb 23, 2008)

It's very very complicated... You have to do the following:

motor-type 2
save

(haha. whereas before with induction, it was motor-type 1).

I recently just globbed everything into one hex file. 
When you first "initialize" the motor, you have to find the offset between the encoder index pulse and the rotor flux angle of the magnets. It's fixed for the life of the motor though, so you just do it once, and save to EEProm. I called that "run-angle-offset-test". It just tries all angle offsets from 0 up to MAX_ANGLE, and saves the offset that gave the best RPM. You also have to tune the PI loop, but it's the same process for both motor types. You don't have to lock the rotor or anything. Just run "run-pi-test", and it makes a really cool sound that makes you just want to get up and dance. As soon as you do though, it stops and tells you the Kp and Ki constants. Then you drive away.


----------



## dcb (Dec 5, 2009)

nice  the abrupt end-of-dancing was jarring though, I need a moment.


----------



## Karter2 (Nov 17, 2011)

Which controller are you using ?


----------



## MPaulHolmes (Feb 23, 2008)

I made my own. Here's an instructable for it:
http://www.instructables.com/id/200kW-AC-Motor-Controller-for-Electric-Car/


----------



## bigmouse (Sep 28, 2008)

Very nice. I didn't realize the Leaf motor separated from the gearbox in such a nice and tidy way. I bet it would be possible to find a clutch disk that would fit those splines too. It would greatly simplify building an adapter if so. Alternatively, a taper lock could probably be found that would fit as well.

Cool stuff! Makes no sense to buy any of the AC24 motors floating around with stuff like this available.


----------



## dcb (Dec 5, 2009)

bigmouse said:


> Makes no sense to buy any of the AC24


I'd say it makes less sense, there is still plenty of niche for lower voltage motors. 

Though why not keep the gearbox here? It moves a 3500 pound leaf just fine, would work really well in the back of a metro or an old vw  I say back, because you WILL need the traction boost in a lighter car with a leaf motor/gearbox. and bodging driveshafts is a lot easier than precision adapter plates in my world.

leaf has a F/R, 56/44 weight distribution, so that is like 2000 lbs on the front axle stock, and it is pretty close to the traction limit, so rwd with some batteries in the rear too probably for something vw sized.


----------



## bigmotherwhale (Apr 15, 2011)

Very good work.

Nice capacitor


----------



## MPaulHolmes (Feb 23, 2008)

It's one big mother whale of a capacitor! haha


----------



## bigmotherwhale (Apr 15, 2011)

it most certainly is 

I want to ask your advice, Im building a controller based on a toyota IGBT block, 

I am planning on using five 50uF 850V Vishay MKP1848 PP Film capacitors 
combined with an Epcos B43457 4700uf 450v electrolytic.

Im using it to drive a Remy HVH 250, 
in your opinion will this be enough?


----------



## MPaulHolmes (Feb 23, 2008)

What current is it going to be? I'm not an expert at capacitor choice, but I could make a guess. If it was around 300amp per phase, I'd get more film caps.


----------



## bigmotherwhale (Apr 15, 2011)

I was thinking the same thing, I will double the number of film caps or add a larger one similar to what you have on your controller when i get the chance.


----------



## rmay635703 (Oct 23, 2008)

what is the length, weight and diameter of the leaf motor?

My C-car has a whale of an 11" motor kludged into it with the axle moved back so it fits


----------



## miscrms (Sep 25, 2013)

Really looking forward to see what this motor might be capable of. Based on ORNL testing, 80kW seems to be a continuous rating. 

Lots of good info / dimensions in this presentation:
http://energy.gov/sites/prod/files/2014/03/f13/ape006_burress_2013_o.pdf

Rob


----------



## dcb (Dec 5, 2009)

rmay635703 said:


> My C-car has a whale of an 11" motor kludged into it


would really like to see a picture of that  (tried searching...)


----------



## MPaulHolmes (Feb 23, 2008)

I just got the field oriented control "interior permanent magnet" correction working with the leaf motor. Basically, with a high "saliency" motor, you use Id = 0, Iq = current magnitude. But for buried magnets, , there's also some of the torque from reluctance torque. I guess that's the stator pulling toward the steel laminations between the magnets (I think that's how it works). At any rate, to get the best torque per amp, you start with a current magnitude, and break it up into Id and Iq, where Id is negative. The formula, found here 
at around the 22 minute mark:
https://www.youtube.com/watch?v=bZwLFpXhFbI

But instead of all that crap I think you can just run through all Id from 0 down to -sqrt(currentMagnitude/2). The goal was to find the best torque for the fixed magnitude. To quantify best torque (because who the heck has a torque measuring thing), I started the motor at 0 rpm, and checked what caused the motor to accelerate until the motor ran out of voltage in the shortest time (so, during that whole time, currentMagnitude was constant). 

Then, I tried again with a fixed magnitude of 23amp, and found that the ideal Id was about half of the ideal Id for 12amp. Here's a video:
https://www.youtube.com/watch?v=VTn4fKNVbGc


----------



## bigmouse (Sep 28, 2008)

Nice work! Love your experimental method.

Check out this paper. It's a great primer to control of these motors. I'll be implementing something for my controller that is guided by this paper. I've written the algorithm in excel, now I have to transfer it in to C. http://wwwlea.uni-paderborn.de/file...hung/veroeffentlichungen/2006/06epe-meyer.pdf

You can also measure the saliency of your motor directly if you have an LCR meter. I used this application note to guide that process on my Lexus motors: http://www.nxp.com/doc/AN4680

Keep it up!


----------



## miscrms (Sep 25, 2013)

If it would be helpful I'd be happy to make some measurements if you tell me what you need. I have a 2012 Leaf motor, and happen to have an HP 4192 LF Impedance Analyzer home from work right now. Had borrowed it to check the caps on some vintage audio equipment I was working on recently.

Rob


----------



## MPaulHolmes (Feb 23, 2008)

I think the line to line inductance would be very handy to have. Actually, any measurement that you can think of, I would be very grateful!


----------



## miscrms (Sep 25, 2013)

Ok, will see what I can get. One caveat, I don't currently have a way of changing the motor angle as its still connected to the gear box. For my application I'm using the stock transaxle. Not sure how much of an issue that is.

Also, is there a particular frequency of interest?

Rob


----------



## MPaulHolmes (Feb 23, 2008)

Hmm.. I don't know very much about getting motor parameters. My thing has been to avoid them by modifying parameters and seeing what makes the motor work the "best". By best, I mean, given a fixed current command, fastest acceleration, or highest rpm, ... that sort of thing. I'm sure you know more about this than I do. I've never taken inductance measurements before, so I'm not sure how they work.


----------



## dedlast (Aug 17, 2013)

miscrms said:


> Ok, will see what I can get. One caveat, I don't currently have a way of changing the motor angle as its still connected to the gear box. For my application I'm using the stock transaxle. Not sure how much of an issue that is.
> 
> Also, is there a particular frequency of interest?
> 
> Rob


It wouldn't be too horribly difficult to separate the two. There are only six bolts holding them together. I can see where getting them lined back up and bolted together could be challenge, though, depending on how you're equipped.

Bill


----------



## Tomdb (Jan 28, 2013)

no issue at all.











Both units appear to be stand alone, and even the motor is an outside spline.

here are some good teardown pics

http://www.marklines.com/en/report/rep1104_201209


----------



## miscrms (Sep 25, 2013)

Yeah, I could probably do it ok. Just a bit paranoid  It would likely be a little while until I can pull the motor back out though, its all aligned and wedged in place right now for motor mount / drive shaft measurements.

Is there any value at all to line to line measurements at one unknown rotation, or is that pretty meaningless? Sorry, pretty ignorant about motors, my field is high speed microelectronics.

Rob


----------



## MPaulHolmes (Feb 23, 2008)

YOU think YOU are ignorant about motors! Well, let me tell you! haha. I can look up a bunch of random crap, and convert it to C, and then the motor magically spins, but I'll be danged if I really understand much of anything that's going on. For the saliency tests, you could use a formula that uses Lambda_magnets, and the magnetizing inductance along the direct and quadrature axes. But I'll be gosh danged if I really know what any of those are. That's why I usually just make the motor run the best, and then you end up with knowing the motor's characteristics, but without knowing how to get them, or even what they mean.


----------



## miscrms (Sep 25, 2013)

Sounds like a solid methodology. Frankly the real world trumps the model anyway.

When I have a chance to pull the motor I will see what I can get, it will be interesting to see how the measurement compares to the empirically derived solution. Empirical, that's the word engineers use because it sounds better than "we have no idea why it works." 

Rob


----------



## Tony Bogs (Apr 12, 2014)

Bigmouse said:


> Check out this paper. It's a great primer to control of these motors. I'll be implementing something for my controller that is guided by this paper. I've written the algorithm in excel, now I have to transfer it in to C. http://wwwlea.uni-paderborn.de/filea...6epe-meyer.pdf
> 
> You can also measure the saliency of your motor directly if you have an LCR meter. I used this application note to guide that process on my Lexus motors: http://www.nxp.com/doc/AN4680


 Checked them out. Great Paderborn uni paper with a very important warning regarding strong flux weakening (high power) at elevated temperatures. 
It also addresses the IM (saliency) related reluctance torque. 
AN4680, always handy, such a clear and easy to apply recipe in an application note. Thanks for both.

DRM110 (Freescale, an IPMSM control designer reference manual) is used as a reference in AN4680. 
Pages 3-18 and 3-19 of DRM110 show the important Laplace equations for the plant and closed loop PI system, including the equation for the compensation of the PI command change zero.
It gives a great insight in the internal workings of the control system. Stability is always an issue with a second order system. 
The Freescale manual also shows how the PI loops can be implemented in the discrete time domain. 

The Paderborn paper, AN4680 and DRM110 should make it a lot easier to design a stable and efficient FOC system for the Leaf motor. I may have to reconsider a PM (Leaf) motor.


----------



## MPaulHolmes (Feb 23, 2008)

I made an autotune for the PI loop that works equally well for induction and IPM and PM motors. There are about 5 things you want:
1. Did the error command go to zero in < 0.002 seconds? No? Move to next Kp,Ki (and let Ki = 1/50 *Kp up to Ki = 1/100 * Kp always have worked well with every motor, AC or DC and even a 650v 50amp charger)
2. Did the error go too negative (overshoot)? Move to next Kp,Ki.
3. Did the error cross zero, and then go back up too far into positive territory? That's oscillation! Move to next Kp, Ki.
4. Does the error stay within "noise" of zero error for 0.1 seconds after crossing zero (1000 iterations is an eternity)? It's a keeper!

OK, so there are 4 things! haha. 

The garbage Kp, Ki quickly show that they are garbage. The whole tuning process generally takes about 5-10 seconds, and only has to be done one time for that type of motor. If you double the bus voltage, cut Kp and Ki in half to get the same response. That's not too mathy.

The motor saliency test finds what combination of IdRef and IqRef (currentReference = sqrt(IdRef^2 + IqRef^2)) makes the motor accelerate the fastest, starting at zero RPM, for a given constant Current reference (and thanks to the PI loop, the current feedback IS the current reference, after about 0.001 seconds). Now, if the "true" saliency of the motor is different than what that test finds, I'd be switching to a worse acceleration! I'd be driving down the street, and a friggen pinto would be laughing at me! My only consolation would be that the mathematical model was accurate.

Well, here I am badmouthing mathematical models, and talking about Id and Iq, which are a part of a mathematical model.


----------



## rmay635703 (Oct 23, 2008)

What is the spline count on that motor? What diameter (just curious)


----------

