# Universal BLDC-ACIM HV controller



## eldis (Sep 3, 2013)

Hello guys,

We are a group of engineers, located on the borders of France and Switzerland (Geneva), building our own EV. First I want to say, that this forum is a great source of EV info and know how, thanks for everything!

We have been working for few months already on a new motor controller, capable to spin almost everything out there - BLDC motors, induction motors (both EV and industry standard ones), supporting large variety of voltages and currents, using Field Oriented Control algorithm.

Now, important thing is, that this is still in initial testing and I didn't want to post it yet, but a number of people started playing with similar technologies or asking if this is possible, so maybe someone can profit already.

Motor controller is using Toyota Prius 2nd gen Converter-Inverter, so one can expect 20-30kW continuous rating, voltage boosting capability (can boost your battery pack up to 500V for HV motors). If you don't need to boost your voltage, the continuous rating will be much higher, as it is limited by booster. I would say 50kW of power, if you're happy with your battery voltage.
*
So a simple summary:*
- CAN based controller, supports pot throttle
- Regen
- Watercooled
- Up to 500V/30kW with booster, ~50kW continuous without it
- Supports external current sensors to match your current needs
- Self learning algorithm - *virtually any new motor can be added by user
- *Based on the new Texas Instruments InstaSPIN FOC technology
- Inv-Conv assembly already contains a 12V battery charger
- Second set of IGBTs used for charging (theoretical charging power 20kW)

So why are we building it?
AC system is cheaper than DC system. I know that there is a strong bias towards DC motors, but I really don't see any advantage in using them. You don't have regen, they are usually very low voltage, wears out, you need to shift much more.. Industrial AC motors are lying everywhere almost for free, it would be a shame not to use them - especially since crashed Prius with Inverter-Converter assembly seems to be easy to get on US market (we are in Europe).

Most likely our design will be released as an open source once finished. This will still take some time.


----------



## eldis (Sep 3, 2013)

Some pictures of low voltage tests


----------



## sergiu tofanel (Jan 13, 2014)

I look forward to more details ...


----------



## bLdC (Jan 21, 2013)

Hi eldis,



eldis said:


> *
> - *Based on the new Texas Instruments InstaSPIN FOC technology


"InstaSPIN" and "FAST" are actually a proprietary program codes written in a ROM segments in the TI controllers with "F" and "M" in the end of the part number. You don't have access to this code and do NOT know what it is doing. For some applications it may be usefull and shorten the development time, but for a car? I don't think there is something really new and revolutionary there.

I am using TI DSC-s and FOC but not the variants with the embedded(enclosed) code, for my projects. I just want to know how it all works and learn to program it myself.  
Already made some tests with the toyotas IPM motors and 160V pack, up to 100A current, and it is exciting. When properly done and tuned the system is stable, with the position sensor in use! 
I tried sensorless(angle estimator), benchtop, but at very low rpm the error is big, and not stable enough.

I look forward to see how it all works with your setup.


----------



## eldis (Sep 3, 2013)

bLdC said:


> Hi eldis,
> 
> 
> 
> ...


Thanks for the feedback. You are right, some parts (especially transformation tables) are located in the ROM, to hide their proprietary code. TI is investing a lot of resources to this system now, and their support was very good so far.

Actually there is one company already using FAST for their electric cars, please see http://www.youtube.com/watch?v=uYapN7RcnW8 .
If the sensorless system is not precise enough at low speed, it's not really a problem, since our motor has an encoder and our system supports it. You can always replace FAST software encoder with a hardware one. It's just about who's providing the angle.


----------



## PStechPaul (May 1, 2012)

I'd be interested in more information, updates, and possibly helping with some of the development. I have a small tractor project which uses a standard VFD and three phase industrial motor, with a DC-DC converter stepping up 12/24/48 VDC to 250-320 VDC for the DC link. My needs at present are just 1 to 5 HP, and the requirements for a tractor are much different from a roadworthy EV, but such a small project involves smaller and less expensive components and can then be scaled up as needed.

I am very interested in switched reluctance motors (SRMs) and reluctance synchronous motors (RSMs) as now produced by ABB and/or Siemens. The RSM apparently can be driven by a standard VFD with sensorless FOC, which is a major advance over the SRM which requires a special (although simpler) controller, and sensors for rotor position and velocity sensing. So it would be advisable to include these motors in your design.


----------



## Tesseract (Sep 27, 2008)

PStechPaul said:


> ...The RSM apparently can be driven by a standard VFD with sensorless FOC, which is a major advance over the SRM which requires a special (although simpler) controller, and sensors for rotor position and velocity sensing. So it would be advisable to include these motors in your design.


A "reluctance synchronous motor" is just another name for an interior permanent magnet synchronous motor (ie - like Remy's HVH250) and so can be driven by standard AC inverter hardware with some modifications to the control software.

As for driving a SR motor with the same controller as used for IPM and AC induction motors... forgetaboutit. Not only is the software (control algorithm) different, but the power stage topology is different as well. The only scheme I know of for driving an SRM with "standard" inverter hardware requires n+1 half bridge modules for an n-phase SRM. Since a 2-phase SRM cannot be guaranteed to start in any particular direction and a 3-phase SRM has high torque ripple, the 4-phase configuration seems most promising, but that would require a 5-phase inverter... hardly an "off-the-shelf" item.

Finally, while I can appreciate the desire to get rid of the rotor position sensor, the fact of the matter is that starting torque will be limited without knowing the precise rotor position and rotational speed (particularly important with PM field AC machines). The best sensorless schemes claim they can get 100% of full load torque when starting from a dead stop, which sounds great until you realize that the breakdown torque for most AC machines is around 3x full load torque and that traction applications, by definition, require a higher starting torque than running torque.


----------



## Nathan219 (May 18, 2010)

http://store.evtv.me/proddetail.php?prod=gevcu make a unit that can easily spin motors the interface is already built.


----------



## Hollie Maea (Dec 9, 2009)

Nathan219 said:


> http://store.evtv.me/proddetail.php?prod=gevcu make a unit that can easily spin motors the interface is already built.


The gevcu sends commands to the controller. It is not itself a controller.


----------



## eldis (Sep 3, 2013)

It could be possible to drive RSM motors - I've never had one in my hands though. 
Yesterday I tested a variac system with an isolation transformer - this very simple setup can deliver 0-200V with several amps - more than enough for some tests with minimal load. I was able to drive ~2kW induction motor with a gearbox (discarded from old machinery). There were some problems with signal conditioning, but nothing unsolvable. I didn't even try to do a proper identification of this motor, just made up some parameters. Still it was possible to spin it in a closed loop, so it's a good start.


----------



## eldis (Sep 3, 2013)

Success 

Today I managed to spin a small industrial AC motor with a field oriented control algorithm. Both speed and torque estimators seems to operate correctly, I can control the speed of motor in RPMs, smooth trajectory changes or manually entering torque in a torque loop. 

Using field weakening, I can spin a three phase 230V motor with less than 200V DC on much higher RPMs that would be possible without weakening (tested only up to 3000rpm for now, I don't want to wake up neighbors under me).

Just by commanding holding a zero speed (like an electric parking brake) I can tell that the torque is quite high, as I cannot move the rotor out of it's position. That doesn't say much about the torque, but I was trying to push quite hard.. :-D

Now I need to transport our 20kW Siemens motor to this flat, to evaluate the near-zero behavior and precision of speed and torque estimators.


----------



## jddcircuit (Mar 18, 2010)

Very good project.

I am also using the Prius inverter in my projects (link in my signature below).

I am not attempting sensorless control like you are but have considered it for other projects. I figured the resolvers on my Prius motors were already there and I wanted to learn how to use them.

I am having lots of fun trying to get things to work.

I just bought 3 more inverters off ebay for $200 each. Pretty cheap stuff.
I only needed two of them but ended up accidentally winning the auction.

I got my motors to spin with my car on jack stands and put a youtube video in my thread.

Since then I switched my focus to getting an integrated battery charger for the high voltage battery. Toyota and others have several patents on using the motor inductance and inverter as part of battery charger which I am researching.

Good luck on your project. I will be following.

Jeff


----------



## McRat (Jul 10, 2012)

I'm clueless about controllers. That being said...

Would it be possible to put a strain gauge on one motor mount, and the 180° opposite mount will rotate?

Now, using a microprocessor, when you go to install a new type of motor, you hit LEARN. It starts at 0 rpm and applies 10% amps. The strain gauge will give a reading. It doesn't matter what the reading is.

Say the instant peak strain reading is 10. (call this S)

The motor stops. Makes an adjustment in timing CCW.

Then starts again.

If NewS is greater than OldS, then Timing=Timing + 1, else Timing = Timing - 1

If NewS = OldS, then TimingArray (0,10) = Timing */ (rpm,throttle)

Next, it increments to TimingArray (0,20) and so on until timing curve is set for all pedal positions a 0 RPM. It will interpolate between steps.

Now go .10 * RPMMax */ a variable that must be input for the "not to exceed" RPM.

Then .20, .30, etc.

You end up with a timing array of (11,10) which is basically a 2D table for throttle position vs. RPM = Timing. 

Now as the car operates, it start in Open Loop mode, using just the table it learned, but as you drive it can store strain readings, and have a short term offset, and by storing short term logs, it can develop long term logs, and make permanent changes to the LEARN table.

This is how modern ICE engines work, except the LEARN is done at the factory, and instead of strain gauges, it uses crankshaft acceleration readings and oxygen sensors and knock sensors.

Cliff Notes: A microprocessor could dynamically optimize the motor settings for all motors.


----------



## eldis (Sep 3, 2013)

jddcircuit said:


> I am also using the Prius inverter in my projects (link in my signature below).


Thanks, I've read your posts as well, very interesting stuff! You are ahead, as we didn't put any motor in the car yet. The charging system that you are proposing is something that we also tried to simulate some time ago, and it seems to work quite well. Since we are using only one of two motor outputs, we can afford to use the second IGBT set just to do the charging. Basically only thing needed to do is to connect the three phase mains to the motor output, and IGBT diodes will rectify it - then by controlling the booster inductor, you can change the charging current by PWM ratio. It seems that for battery charging, some ripple is actually desired, as it increases the life of cells by few percent (that being said, it doesn't kill them). Also batteries have a very low resistance, practically behaving as a capacitor - smoothing the the voltage during charging. It would be cool if someone could comment on that, as mistakes while playing with such schemes are expensive (and releases the magical smoke).

Big plus of the Prius inverter is the complex 12V management system - you don't have to care about charging your 12V battery, or making sure you're not drawing too much current from it.


----------



## eldis (Sep 3, 2013)

McRat said:


> I'm clueless about controllers. That being said...
> 
> Would it be possible to put a strain gauge on one motor mount, and the 180° opposite mount will rotate?


I read it twice, just to make sure I understand what you are proposing. Fact is, that I have no idea how internal combustion engines are calibrated/designed, but I'm pretty sure that it doesn't apply for an electrical motor. That being said, I'm not saying that what you are suggesting would definitely not work, just that I don't see the point/advantage. With BLDC motors the control is fairly easy, you need to know the position of the rotor to know which coils should be used in each moment. Without knowing the position (either by a sensor or by sensing EMF from coils), you cannot get much from it. Okay, you can still spin it just by applying some rotating field, and hope that the motor is actually spinning, but you will get a very shitty controller. With induction motors, I would say it's even more difficult, as there are no permanent magnets and you have to "polarize" the rotor cage to get some rotation. You also have some slip, and the equations to describe the field in time/voltage/load/current are quite complex.

The test you're proposing sounds like something that can be used to estimate the inertia of rotor+load, which is something that can be necessary to get a very stable trajectory control (while already having a good controller). But when you are doing torque control loops, you don't really care about such things, because in a car, you are the velocity controller


----------



## jddcircuit (Mar 18, 2010)

eldis,
I have a few questions about your gen2 prius inverter experience.

1. Are you using the Prius current sensors? If so how is that working out for you?

2. What switching frequency have you experimented with or recommend?

3. I seem to have noticed that some of the modulation schemes that I try don't work out the way I expect. I think (but haven't proven) that the gate drivers need to keep switching in order to work. If I use a scheme that requires a high side or low side switch on for an extended period during commutation I am having strange behavior. Have you had any similar experiences with the switching?

Thanks
Jeff


----------



## eldis (Sep 3, 2013)

jddcircuit said:


> eldis,
> I have a few questions about your gen2 prius inverter experience.
> 
> 1. Are you using the Prius current sensors? If so how is that working out for you?


Not for now. I tested them, they work as expected, maybe a bit noisier - but since my current requirements are much lower for now, I'm using LEM sensors for two phases (third one can always be calculated from those two). Despite the naming of the current signals on the silkscreen, they are not differential, just referenced to the control ground.



jddcircuit said:


> 2. What switching frequency have you experimented with or recommend?


I have been experimenting in the 15-20kHz range, but 30kHz works as well. I didn't have time to measure the efficiency of different frequencies. It's on the TODO list 



jddcircuit said:


> 3. I seem to have noticed that some of the modulation schemes that I try don't work out the way I expect. I think (but haven't proven) that the gate drivers need to keep switching in order to work. If I use a scheme that requires a high side or low side switch on for an extended period during commutation I am having strange behavior. Have you had any similar experiences with the switching?


Yes, you might run into problems there. Toyota probably considered that to be a fault condition. Maybe running it with 99% duty cycle would be enough? In some motor identification tests (like a winding resistance estimation) I'm running basically a controlled DC current through a phase, but never 100%.

Booster seems to be happy with constant levels (on/off), which can pose a certain risk if you don't use proper pullup(down) where appropriate.

Did you have time to check what type of temperature sensors is Prius using? I have them wired on ADCs, but I did not experiment with them yet.


----------



## jddcircuit (Mar 18, 2010)

eldis said:


> Not for now. I tested them, they work as expected, maybe a bit noisier - but since my current requirements are much lower for now, I'm using LEM sensors for two phases (third one can always be calculated from those two). Despite the naming of the current signals on the silkscreen, they are not differential, just referenced to the control ground.
> 
> 
> 
> ...



Thanks

I didn't even wire up the temperature sensors. I wish I had. I have no clue what they require. I think "bldc" who is also using this setup has some experience with temp sensors.


----------



## bLdC (Jan 21, 2013)

eldis said:


> Did you have time to check what type of temperature sensors is Prius using? I have them wired on ADCs, but I did not experiment with them yet.


They use a NTC Thermistor, 47kΩ when 25°C. You have to measure the resistance and calculate the temprature or use a table.
http://educypedia.karadimov.info/library/NTC-Thermistors.pdf



jddcircuit said:


> 3. I seem to have noticed that some of the modulation schemes that I try don't work out the way I expect. I think (but haven't proven) that the gate drivers need to keep switching in order to work. If I use a scheme that requires a high side or low side switch on for an extended period during commutation I am having strange behavior. Have you had any similar experiences with the switching?


How do you measure the currents when switching on for extended periods during commutation, with field orinted control? 

I am limiting the duty cycle to 95% for now.


----------



## eldis (Sep 3, 2013)

So with a field weakening and only 200V DC, I can get almost 7000 rpm out of an old 230V AC two pole motor. I really need to bring that 90kg Siemens motor to test it out 



bLdC said:


> They use a NTC Thermistor, 47kΩ when 25°C. You have to measure the resistance and calculate the temprature or use a table.
> http://educypedia.karadimov.info/library/NTC-Thermistors.pdf


Thanks, that will save me some time!



bLdC said:


> How do you measure the currents when switching on for extended periods during commutation, with field orinted control?
> I am limiting the duty cycle to 95% for now.


The only limitation I can think of right now, is when you're measuring the current using two shunt resistors. Then you actually need a sampling window. With the Hall Effect sensors, you should not have any problems and duty cycle can stay 100% (of course you still have your 50Hz or something waveform generating the field). I read somewhere that Prius is using just a simple square wave on all three phases once you get high enough with RPMs. There is no need to simulate the sine wave then and you maybe gain some efficiency. Then to regulate the speed you just regulate the voltage with a booster circuit.


----------



## jddcircuit (Mar 18, 2010)

bLdC said:


> They use a NTC Thermistor, 47kΩ when 25°C. You have to measure the resistance and calculate the temprature or use a table.
> http://educypedia.karadimov.info/library/NTC-Thermistors.pdf
> 
> 
> ...


bldc,

I am not sure I understand your question about current measurements.
I am using the current sensors in the prius inverter. I don't think it matters what state each half bridges are in when making the current measurements.

My FOC gets me from the desired vd and vq signals to my va,vb,vc. I then have some options with what to do with them as far as modulation. (I think)

I am currently modulating my +/- vx signals around 50% duty cycle so all half bridges are switching all the time if I limit things to 50% +/- 45%. I am using center aligned 5kHz PWM which is like having a 10kHz differential on either side of the high low states. This method seems to work pretty good and is my default sinusoidal method.

I once tried to make it relative to 0% duty instead of 50%. In this modulation the lowest v would be fixed at 0% steady and the other two phases would be ?% above them the appropriate delta. For example if va was the lowest value at a given point in time then it would set to be 0% duty and pwmb= vb-va and pwmc = vc-va. I read that this could reduce switching losses but when I implemented it strange things happened. I don't think the 0% phase was staying tied to battery negative the full cycle.

As I am writing I think this may be why my Space Vector Modulation attempt didn't work out so well.

I am also doing some crazy stuff with my through motor battery charger using the same inverter and running into similar obstacles when my half bridge is in a steady high or low state for any extended duration.

Maybe I am doing something wrong with the way I am driving the UVW control signals. Currently I am using a 0 to 12V control signal to switch each half bridge to its high low states.

Thanks
Jeff


----------



## bLdC (Jan 21, 2013)

jddcircuit said:


> I don't think it matters what state each half bridges are in when making the current measurements.


Yea... when we are not measuring spikes.



jddcircuit said:


> My FOC gets me from the desired vd and vq signals to my va,vb,vc.


You probably mean id and iq, if you are running current loops. 



jddcircuit said:


> I don't think the 0% phase was staying tied to battery negative the full cycle.
> As I am writing I think this may be why my Space Vector Modulation attempt didn't work out so well.


Good point!
It worked fine when I applied a simple SVM. But at that time I was bypassing the processor, applaing the signals directly to the gate drivers. So it may be the proFessor to blame. Well maybe a good protection function too. 
The oscilloscope will tell.


----------



## jddcircuit (Mar 18, 2010)

bLdC said:


> Yea... when we are not measuring spikes.
> 
> 
> 
> ...


I want to reverse engineer this damn thing (Prius inverter) but I sometimes fail to be very scientific with my trials and jump right to the end and scratch my head when it doesn't behave as expected.

I just wanted to share some of my observations in case you guys had seen the same thing and perhaps had some more insight.

I guess I need to devise an experiment to better expose these nuances if they exist.

bldc,
would you be willing to post some details of how you interfaced directly to the gate drivers. I may be forced to do the same if I can't work around some of these restrictions.
What made you go directly to the gate drivers in the first place?


----------



## eldis (Sep 3, 2013)

jddcircuit said:


> I want to reverse engineer this damn thing (Prius inverter) but I sometimes fail to be very scientific with my trials and jump right to the end and scratch my head when it doesn't behave as expected.


We should prepare some document describing what did we learn from it so far. Quite frankly I haven't run into any electrical problems (yet) in terms of the Inverter/Converter assembly. It gives me enough control to perform any task necessary for working sensorless FOC. 

I recall it was not possible to force a constant level on the IGBTs using the standard interface, but I would have to conduct this test again as it was done while still hunting for the HW/FW bugs.


----------



## jddcircuit (Mar 18, 2010)

Here is simple experiment that I must be misunderstanding.

Step 1. With my motor leads physically connected to each other there is a strong braking force resisting me from turning it by hand. This is what I expect for a PM motor.

Step 2. With the leads of my motor connected to my inverter and each phase PWM set to 50% and in phase with each other. The motor spins freely by hand. 

I was expecting Step2 to act like Step 1 since all phases were at the same potential all the time which to me seemed like a short circuit in theory.

My battery is 150V. My scope is showing me the 0 to 150V square wave on each phase. 

As I type I thought that maybe it is free spinning because the braking current is getting interrupted 8 thousand times a second and never has enough voltage/time to build up to anything significant. I also see what looks to be a 12us dead time as the half bridge switches.

Thanks
Jeff


----------



## eldis (Sep 3, 2013)

jddcircuit said:


> Here is simple experiment that I must be misunderstanding.
> 
> Step 1. With my motor leads physically connected to each other there is a strong braking force resisting me from turning it by hand. This is what I expect for a PM motor.


This is a PM behavior. I didn't experience this when playing with my motor. First you have to build the field to get some braking force. There is probably some way how to explain that, what kind of motor were you using?



jddcircuit said:


> Step 2. With the leads of my motor connected to my inverter and each phase PWM set to 50% and in phase with each other. The motor spins freely by hand.
> 
> I was expecting Step2 to act like Step 1 since all phases were at the same potential all the time which to me seemed like a short circuit in theory.


Yes, since all the IGBTs are the same, with the same dead time, those phases should always be on the same potential. It should behave the same way as with leads shorted. 12us sounds reasonable.

Only explanation I can think off is that your rotor is magnetized somehow, maybe from a long exposure to DC current between two phases?


----------



## jddcircuit (Mar 18, 2010)

eldis said:


> This is a PM behavior. I didn't experience this when playing with my motor. First you have to build the field to get some braking force. There is probably some way how to explain that, what kind of motor were you using?
> 
> 
> Yes, since all the IGBTs are the same, with the same dead time, those phases should always be on the same potential. It should behave the same way as with leads shorted. 12us sounds reasonable.
> ...


What I think is happening is that the IGBTs are not going full ON as I would think. Perhaps they need a minimum Drain Source voltage or current to start conducting.

So as I am switching in phase at 50% duty cycle my IGBTs are essentially open circuit so the motor spins freely as it would if it were disconnected.

I am not sure if this is an IGBT issue or if there is something happening in between my control signals and the gate drivers inside the inverter.

These types of unexpected behavior is what makes hacking quite challenging.

Jeff


----------



## eldis (Sep 3, 2013)

jddcircuit said:


> What I think is happening is that the IGBTs are not going full ON as I would think. Perhaps they need a minimum Drain Source voltage or current to start conducting.


Ah, yes sorry, you indeed have a BLDC motor  I was wondering how would you get a braking force with an induction motor. I'll try it today - hooking up a small BLDC hobby motor between phases on 50% duty cycle, it's an easy test.


----------

