Gen 3 inverter converter control software

Topics concerning the Toyota and Lexus inverter drop in boards
User avatar
jalovick
Posts: 95
Joined: Mon Mar 11, 2019 10:14 am
Location: Sydney, Australia
Has thanked: 10 times
Been thanked: 6 times

Re: Gen 3 inverter converter control software

Post by jalovick »

I know this isn't exactly associated, but I had a thought, is it possible to use any part of the inverter/converter to add a 240V AC 50 Hz single phase output, or is that best done separately?
User avatar
Jack Bauer
Posts: 3563
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 87 times
Contact:

Re: Gen 3 inverter converter control software

Post by Jack Bauer »

Some new simple code for the atmega328. Now working in the E39 using a CT200H inverter (almost same as prius gen3). Bucks 360v down to 220v to run the dcdc unmodified.

Code: Select all

/*
Runs atmega328p buck/boost control on Prius Gen 3 and Yaris/Auris inverters in buck mode to drop Main HV down for DCDC converter.
Experimental code. Only tested on the bench! Use at your own risk!
D.Maguire
*/
#include <Metro.h>

int HVLow = 0;        // voltage on low side of converter
int HVHi = 0;        // voltage on high side of converter
int SetV = 0;       //set point voltage
int PWMDuty = 0;    //pwm duty cycle

Metro timer_pwm=Metro(5); 
Metro timer_serial=Metro(200);

void setup() {
  Serial.begin(9600);//
  TCCR1B = TCCR1B & B11111000 | B00000010;    // set timer 1 divisor to  8 for PWM frequency of  3921.16 Hz
  pinMode(9, OUTPUT); //boost low side
  pinMode(10, OUTPUT); //boost Hi side
  analogWrite(9,0); //low side off
  analogWrite(10,0); //High side off
  SetV=210;  //set at 210v to run dcdc
  PWMDuty=0;


}
// the loop function runs over and over again forever
void loop() {

HVLow = (analogRead(A0)/1.85)-43; //-43 needed for Lexus CT200h variant. Remove for Prius / Auris.
HVHi = (analogRead(A1)*1.25);

updatePWM();  //call pwm update routine.
serialOUT();  //call serial out routine

}

void serialOUT()
{
  if(timer_serial.check()){
  Serial.print("Low Vbus = ");
  Serial.print(HVLow);
  Serial.print("Volts");
  Serial.print("\t High Vbus = ");
  Serial.print(HVHi);
  Serial.print("Volts");
  Serial.print("\t PWMDUTY = ");
  Serial.println(PWMDuty);
  }
}

void updatePWM()
{
if(timer_pwm.check()){
  if(HVHi>300){  //if hv is above 300v start ramping up pwm and regulate to setpoint.
if (HVLow<SetV) PWMDuty++;
if (HVLow>SetV) PWMDuty--;
if (PWMDuty<0)  PWMDuty=0;
if (PWMDuty>250)  PWMDuty=250;
analogWrite(10,PWMDuty);
  }
  if(HVHi<250)
  {
  PWMDuty--;;  //if hv is lower then 250v ramp down pwm
  if (PWMDuty<0)  PWMDuty=0;
  }
}
  
}

I'm going to need a hacksaw
User avatar
Jack Bauer
Posts: 3563
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 87 times
Contact:

Re: Gen 3 inverter converter control software

Post by Jack Bauer »

jalovick wrote: Wed Jun 17, 2020 1:22 pm I know this isn't exactly associated, but I had a thought, is it possible to use any part of the inverter/converter to add a 240V AC 50 Hz single phase output, or is that best done separately?
Working on just that....
I'm going to need a hacksaw
User avatar
jalovick
Posts: 95
Joined: Mon Mar 11, 2019 10:14 am
Location: Sydney, Australia
Has thanked: 10 times
Been thanked: 6 times

Re: Gen 3 inverter converter control software

Post by jalovick »

Jack Bauer wrote: Wed Jun 17, 2020 2:13 pm Working on just that....
Nice! I look forward to hearing more.
User avatar
TheSilverBuick
Posts: 187
Joined: Mon Jun 08, 2020 5:01 pm
Location: Nevada, United States
Has thanked: 3 times
Been thanked: 1 time

Re: Gen 3 inverter converter control software

Post by TheSilverBuick »

celeron55 wrote: Tue Jun 16, 2020 3:54 pm I was implementing the input side precharge by boosting battery voltage to 600V to the MG1/MG2 HV bus. As it turned out, my PWM went way too high for just charging a capacitor. There were a series of bangs and the last MG side voltage values I saw were over 1000 volts.

Now when I power it up with the car, the logic board shows 0 volts on both the battery side and the MG side. And no, there's no 0 volts there, the car still succesfully precharges to a little under 300V.
Is this a settings error? And/or change in set parameter from the Gen3 inverter to the Yaris inverter?
Need to learn. Starting from the basics.
User avatar
celeron55
Posts: 776
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 28 times
Been thanked: 110 times
Contact:

Re: Gen 3 inverter converter control software

Post by celeron55 »

TheSilverBuick wrote: Wed Jun 17, 2020 5:07 pm Is this a settings error? And/or change in set parameter from the Gen3 inverter to the Yaris inverter?
Well, I probably need to change a bunch my code. And the inverter.
User avatar
rstevens81
Posts: 352
Joined: Sun Dec 22, 2019 10:36 am
Location: Bristol, UK
Has thanked: 23 times
Been thanked: 92 times

Re: Gen 3 inverter converter control software

Post by rstevens81 »

My Early Christmas Presents have arrived!
Looks like i'm going to having some fun over the weekend to see if I can de solder the old connectors, then if all goes well on to some low voltage experiments!
I think I might have to tidy the shed first !!
Yaris inverter
Yaris inverter
Rule 1 of EV Club is don't buy a rust bucket....
Which rule does everyone forget 🤪
User avatar
celeron55
Posts: 776
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 28 times
Been thanked: 110 times
Contact:

Re: Gen 3 inverter converter control software

Post by celeron55 »

I haven't checked on the capacitors much (other than that they are still in one piece) but it seems that the only things that went seriously wrong with my Yaris inverter is that the boost high side IGBT is now shorted and I get bogus voltage measurements from the MG rail. I can probably still drive a motor using this if I want to.

It's like a box of candies. If you drop some, you still have some left...

If I was in Africa with no spare inverters in sight, I'd probably connect the boost inductor to one of the MG outputs, do some cutting and soldering and be on my way again :mrgreen:

For some reason the 3.3V rail can't get past 1.5V. Have to see what's up with the stm32. At initial inspection it seems to be dead, and taking lots of current.

EDIT: We may have to conclude that if you are switching 1500V into a dead short an inch away from an stm32, the stm32 may die. On the other hand, the atmega328 still runs code just fine and at least the ADC is still working correctly.
User avatar
Jack Bauer
Posts: 3563
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 87 times
Contact:

Re: Gen 3 inverter converter control software

Post by Jack Bauer »

Wow:) I have a few boards left so if its dead just let me know.
I'm going to need a hacksaw
User avatar
celeron55
Posts: 776
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 28 times
Been thanked: 110 times
Contact:

Re: Gen 3 inverter converter control software

Post by celeron55 »

So really if we put what happened on a timeline it went like this:
1) Crazy person drives boost low side at like 10% PWM with nothing but the capacitor on the high side
2) Boost high side IGBT sees the most voltage out of all the IGBTs because boost low side IGBT is pulling its other side to negative rail
3) Boost high side IGBT shorts out and permanently connects boost low and high side together
4) Continued switching now just momentarily shorts the battery to ground, but doesn't create permanent high voltage, capacitors eat some of the spikes and Toyota's over current limiting probably saves the low side IGBT
5) Boost high side IGBT is the dead hero that saved everyone else

EDIT: Oh, I think it was actually more like 90% PWM. No wonder. Now we have two ways to destroy a Toyota inverter... I mean some parts of a Toyota inverter. Either use 0 deadtime for a long period of time to make the capacitor overheat, or if you're in a hurry, clock in some 90% PWM into the boost low side while having nothing connected to the high side. :mrgreen:
User avatar
celeron55
Posts: 776
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 28 times
Been thanked: 110 times
Contact:

Re: Gen 3 inverter converter control software

Post by celeron55 »

I swapped the logic board into my Prius gen3 inverter (after removing the dead stm32 from it) and I now have a problem.

The IGBT driver board releases the boost low side pull-up about 160µs after the logic board pulls it down for the active part of the PWM cycle and leaves it floating for 120ms before activating the pull-up again. This repeats when the driver board sees the logic board's transistor activate on the next PWM cycle.

As a result, I don't see much useful IGBT activity. Powering or not powering any of the high voltage rails using 12V doesn't have an effect. The high side works as expected. I am not aware of this inverter being faulty.

I'm fairly sure the Yaris inverter didn't behave like this, because I managed to destroy it using this type of control. Has anyone seen something like this? Damien?

Pictured is the TR8 transistor output when a 10% 5kHz PWM is generated by the atmega328.

EDIT: Am I going to guess that this inverter has some safety feature that the Yaris inverter doesn't have, like... shutting down the boost low side if there is no simultaneous MG1/MG2 action? That's crazy. No other option than to test I guess.

EDIT: Oh yeah now I remember: When I originally tried to do bucking with the converter, I tried to drive both sides of the half bridge, and it just shut down the thing just like now. Then I stopped driving the low side and it worked just fine. This is the same effect here, except that now I cannot avoid driving the low side if I'm going to do any boosting. Any time I've tried to drive the low side of the buck/boost converter in this Prius gen3 inverter I've found out both sides of the converter shut down, disabling their pull-ups.

EDIT: I paralleled the buck/boost converter transistor control to one of the MG2 half bridges just to see if it wants to see action there. That did nothing. I'm starting to think there could be a battery low voltage limit for the low side and it won't work unless it sees 200V.

EDIT: Supplying 240V didn't help. I used non-isolated rectified AC so if it checks for HV isolation it would have found a leak, but that's a long shot. There has to be some reasonable reason for this not co-operating.

EDIT: Maybe the relatively small inductor already saturates during a 20us or so on-time, the IGBT driver board protects it and it needs more like 1MHz with more like 100ns pulses? The transistor stage on the logic board can't even do that because it's so slow, need to add some base pulldowns to get the transistors saturate less probably. That seems crazy though, isn't it well known that at least the gen2 boost converter doesn't even work properly beyond 25kHz or so?
Attachments
20200619_220523s.jpg
20200619_220510s.jpg
User avatar
Jack Bauer
Posts: 3563
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 87 times
Contact:

Re: Gen 3 inverter converter control software

Post by Jack Bauer »

What switching frequency are you running? I don't have a Prius Gen 3 with a working booster at the minute (the 40 euro one has a busted boost stage) but do have a CT200H variant working in the E39 now quite happilly at 3.9khz.
I'm going to need a hacksaw
User avatar
celeron55
Posts: 776
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 28 times
Been thanked: 110 times
Contact:

Re: Gen 3 inverter converter control software

Post by celeron55 »

I've tried a lot of frequencies and pulse widths from 2kHz to 20kHz and 5-50%. Getting the same result at 3.9kHz.

I think I'll switch to buck only with precharge contactor on the AC side like I had before. More external components but it's what I already had working.

EDIT: The TJA1050 was also dead. No wonder as it was like 5mm away from where the short circuit current was going. Happened to have a replacement chip for it.
User avatar
celeron55
Posts: 776
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 28 times
Been thanked: 110 times
Contact:

Re: Gen 3 inverter converter control software

Post by celeron55 »

What on earth just happened?! I was merrily precharging the AC side and then bucking some reasonable output voltages to the capacitor with nothing connected to it, which I have done before with no issues as my control code is careful enough to do that. Now in my log the last output voltage was 278 volts. After that I heard a pop and each one of the four circuit breakers along the way from the house to the MG2 terminal opened, including one phase of the main 25A breaker of the house.

Both of the buck/boost converter IGBTs are dead shorts now and by quick glance there was no other damage.

I was doing buck converting with my previous total hack of a control solution for many hours at powers from 0 to 14kW in the car with no major issues, with this exact same inverter.

I guess the IGBT voltages are rated so much higher than the capacitor that if the voltage measurement was giving somewhat erroneus values, and there was slight over voltage over the total time of the test, the capacitor should have gone first. And the Prius gen3 buck output side is known to be rated for 400V all around so there's quite some headroom.

I was not driving the low side IGBT at all, because if I was, as I've tested many times now, the inverter would have stopped allowing me to drive the high side IGBT and I wouldn't have had any output voltage.

So... what caused this?

Was this inverter after all faulty to begin with and the low side IGBT just happened to give up during that specific test? That seems very unlikely after all the heavy use I previously gave to this buck converter, but I might have triggered development of the kaboom when I was trying to get the low side IGBT to do any boosting at all on the bench. So some kind of DESAT event might have been happening due to the low side IGBT being faulty, and at the same time the IGBT was getting worse.

Does that sound like a good theory?

And does anyone happen to have more inverters lying around or do I finally have to do the Africa thing and connect the boost inductor to one of the "spare" MG half bridges?
Eflyers
Posts: 26
Joined: Thu Apr 11, 2019 4:08 pm
Location: NW USA

Re: Gen 3 inverter converter control software

Post by Eflyers »

I hope none of this is related to the ongoing Gen 3 inverter failure and recall problems showing-up in the US: https://www.latimes.com/local/californi ... story.html
User avatar
celeron55
Posts: 776
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 28 times
Been thanked: 110 times
Contact:

Re: Gen 3 inverter converter control software

Post by celeron55 »

Eflyers wrote: Sat Jun 20, 2020 11:04 pm I hope none of this is related to the ongoing Gen 3 inverter failure and recall problems showing-up in the US: https://www.latimes.com/local/californi ... story.html
I think the recall must be due to the boost converter. We might have to expect the cheapest inverters to have a broken one.
User avatar
celeron55
Posts: 776
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 28 times
Been thanked: 110 times
Contact:

Re: Gen 3 inverter converter control software

Post by celeron55 »

Jack Bauer wrote: Fri Jun 19, 2020 1:36 pm Wow:) I have a few boards left so if its dead just let me know.
A spare board wouldn't hurt as I try to make what I can out of these rather quickly decaying inverters of mine. :-) At this rate I'm running out of replacement components too.
User avatar
NiHaoMike
Posts: 64
Joined: Mon Dec 02, 2019 4:11 am
Location: Austin, TX
Been thanked: 1 time
Contact:

Re: Gen 3 inverter converter control software

Post by NiHaoMike »

celeron55 wrote: Sat Jun 20, 2020 8:43 pm What on earth just happened?! I was merrily precharging the AC side and then bucking some reasonable output voltages to the capacitor with nothing connected to it, which I have done before with no issues as my control code is careful enough to do that. Now in my log the last output voltage was 278 volts. After that I heard a pop and each one of the four circuit breakers along the way from the house to the MG2 terminal opened, including one phase of the main 25A breaker of the house.

Both of the buck/boost converter IGBTs are dead shorts now and by quick glance there was no other damage.

I was doing buck converting with my previous total hack of a control solution for many hours at powers from 0 to 14kW in the car with no major issues, with this exact same inverter.

I guess the IGBT voltages are rated so much higher than the capacitor that if the voltage measurement was giving somewhat erroneus values, and there was slight over voltage over the total time of the test, the capacitor should have gone first. And the Prius gen3 buck output side is known to be rated for 400V all around so there's quite some headroom.

I was not driving the low side IGBT at all, because if I was, as I've tested many times now, the inverter would have stopped allowing me to drive the high side IGBT and I wouldn't have had any output voltage.

So... what caused this?

Was this inverter after all faulty to begin with and the low side IGBT just happened to give up during that specific test? That seems very unlikely after all the heavy use I previously gave to this buck converter, but I might have triggered development of the kaboom when I was trying to get the low side IGBT to do any boosting at all on the bench. So some kind of DESAT event might have been happening due to the low side IGBT being faulty, and at the same time the IGBT was getting worse.

Does that sound like a good theory?

And does anyone happen to have more inverters lying around or do I finally have to do the Africa thing and connect the boost inductor to one of the "spare" MG half bridges?
Do you have a way to check if it's actually the IGBTs themselves that are shorted or rather the parallel diodes? The diodes are not protected by the driver circuit and it's all up to the control circuit to make sure they're operating within their ratings.

Also, did you have the low side drive signal tied to the inactive state (which I recall is 5V on the gen 3) or left it floating? EMI can cause unwanted switching on floating inputs, and (much less intuitively) large loops can also pick up stray signals.

It would also be helpful to know what's the "correct" frequency to run the converter at. Too high causes excessive switching and reverse recovery losses, too low causes excessive ripple current.
My first solar power system helped Naomi Wu, now I want to do even more with DIY solar.
User avatar
celeron55
Posts: 776
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 28 times
Been thanked: 110 times
Contact:

Re: Gen 3 inverter converter control software

Post by celeron55 »

Some modding:
20200621_143249.jpg
20200621_144055.jpg
20200621_152505.jpg
The end result looks a bit suspicious to the experienced eye:
20200621_165737.jpg
I cut off the aluminium where the inductor goes to the half bridge midpoint and re-wired it from there to the MG1 phases A and B. Then bent off the boost high side from the MG rail and wired those MG1 phases to be driven by the atmega328's outputs. (Seen also in the photos is my coupling of the current sensor inputs together so that I can read the MG2 sensors using the atmega328, as my 3 phase input cable doesn't reach MG1.)

I did some bucking using this and it appears to work. I've yet to put more power than a kW or two through this.

But it seems like doing this is perfectly fine if you don't have the big bucks to spend on an actually working inverter. If you have a motor on MG2 you just need to add an external rectifier from AC to the MG rail, which is not very expensive but needs to have its own heatsink if you intend to put 10 or 20 kilowatts through it.

I blew my 100A 450VDC fuse I have on the charger cables during the Yaris inverter mess-up and don't have a spare so I need to improvise a bit or wait for a spare to arrive. (Yes, looking back the blown fuse was why I saw 0V in the inactive charger output, so the Yaris inverter is slightly less messed up than I thought.)
User avatar
celeron55
Posts: 776
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 28 times
Been thanked: 110 times
Contact:

Re: Gen 3 inverter converter control software

Post by celeron55 »

NiHaoMike wrote: Sun Jun 21, 2020 8:19 pm Do you have a way to check if it's actually the IGBTs themselves that are shorted or rather the parallel diodes? The diodes are not protected by the driver circuit and it's all up to the control circuit to make sure they're operating within their ratings.
I don't know how to check that without destroying the otherwise perfectly working inverter, which I don't intend to destroy.
NiHaoMike wrote: Sun Jun 21, 2020 8:19 pm Also, did you have the low side drive signal tied to the inactive state (which I recall is 5V on the gen 3) or left it floating? EMI can cause unwanted switching on floating inputs, and (much less intuitively) large loops can also pick up stray signals.
Damien's board always leaves them floating when they aren't active. The output circuit is this: MCU -> 1k resistor -> MMBT3904 npn transistor -> 100 ohm resistor -> IGBT driver board.
NiHaoMike wrote: Sun Jun 21, 2020 8:19 pm It would also be helpful to know what's the "correct" frequency to run the converter at. Too high causes excessive switching and reverse recovery losses, too low causes excessive ripple current.
Sure would be. The converter is really loud at audible frequencies though, even at low powers like 1kW. It's embarrassingly loud if you want to use it on a public charge point and almost ear-breakingly loud if you use it in an indoor space at high power. I wonder if Toyota's sound insulation is heavy enough to make it unhearable from the driver's seat when driving an actual gen3 Prius (at high speed when it's actually in use), or if Toyota uses 20kHz to make it silent.
User avatar
NiHaoMike
Posts: 64
Joined: Mon Dec 02, 2019 4:11 am
Location: Austin, TX
Been thanked: 1 time
Contact:

Re: Gen 3 inverter converter control software

Post by NiHaoMike »

celeron55 wrote: Sun Jun 21, 2020 10:46 pm I don't know how to check that without destroying the otherwise perfectly working inverter, which I don't intend to destroy.
Shine a flashlight at an angle into the side with the top cover removed. You can get a partial view of the chips.
Damien's board always leaves them floating when they aren't active. The output circuit is this: MCU -> 1k resistor -> MMBT3904 npn transistor -> 100 ohm resistor -> IGBT driver board.
Perhaps pulldowns on the input side of the buffer transistors would be a good idea? The stock control board uses 10k pulldowns. (I'm pretty sure the ASICs are designed to always have the signals in a defined state, so the pulldowns are just extra protection.) Also, the stock control board appears to use signal MOSFETs (or something even more exotic like current loop line drivers?) rather than bipolar transistors. Thus the threshold voltage is likely higher than the 0.7V of a bipolar transistor. Perhaps put the pulldowns right at base to emitter to raise the voltage needed at the input to switch it on? Need to do some testing to find some good values, but I would say 1k would probably be a good start. (With the high voltage off and the microcontrollers held in reset, see what voltage on the pin transitions the output to the on state. Ideally, it should be about half the logic supply voltage.)

I'm using 7400 series chips between the FPGA and power board in my design. The (DIY) translator and control power board (mounted in place of the original control board) connects to the FPGA board (outside the inverter) via a shielded cable.
My first solar power system helped Naomi Wu, now I want to do even more with DIY solar.
User avatar
celeron55
Posts: 776
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 28 times
Been thanked: 110 times
Contact:

Re: Gen 3 inverter converter control software

Post by celeron55 »

Just got AC side boost precharge working. Now my AC contactor box looks like this, nice and minimal (and messy - you aren't allowed to be this messy when you do yours :mrgreen:):
20200622_152209.jpg
That's a 39A @ 660VAC contactor, an economizer based on a huge 47000uF capacitor and some resistors, some relays wrapped in electrical tape, a 32A 3-phase RCD and not really much else.
User avatar
celeron55
Posts: 776
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 28 times
Been thanked: 110 times
Contact:

Re: Gen 3 inverter converter control software

Post by celeron55 »

Ok the code hasn't exploded my inverter anymore and on the other hand it has charged my battery at maybe 15kW or so on a public charge point (didn't have cooling and was in a hurry so had to stop there) so I think I can release it.

I did try to clean it up a lot and I haven't tested the changes, so good luck.

I'll maybe get to drawing some wiring diagrams maybe, but if you take a good read at the comments at the beginning of the .ino file and then all the #defines afterwards, you should get an idea how to put it into use.

This, of course, is an excellent piece of software and electronics to absolutely blow up your battery and set everything near it into flames, so be careful. If not for yourself, then at least for the credibility of the EV conversion community.

https://github.com/celeron55/prius3charger_buck
doobedoobedo
Posts: 260
Joined: Sat Jan 12, 2019 12:39 am
Location: UK

Re: Gen 3 inverter converter control software

Post by doobedoobedo »

I fear your avoid_explosions function may get optimised away by the compiler.
User avatar
Jack Bauer
Posts: 3563
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 87 times
Contact:

Re: Gen 3 inverter converter control software

Post by Jack Bauer »

Much appreciated. Will be testing soon.
I'm going to need a hacksaw
Post Reply