Gen 3 inverter converter control software

Topics concerning the Toyota and Lexus inverter drop in boards
User avatar
celeron55
Posts: 774
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 27 times
Been thanked: 110 times
Contact:

Re: Gen 3 inverter converter control software

Post by celeron55 »

Adding to the broken buck/boost converter workaround:

The ultimate budget version would be to use only the AC phases L1+L2 or L1+N, connect them to MG1 B and C phases and rewire the inductor from the broken converter bridge to the MG1 A phase. Then you have MG2 free for a motor, and can charge using whatever power you're comfortable with putting through the single MG1 phase.

If you get a broken inverter for almost free and pick whatever motor you can get the cheapest, your conversion's most expensive component after the battery and motor will end up being the replacement logic board. Excluding batteries, a 500€ AC motor conversion, no luck, haggling or part shortages involved, starts looking like an everyday thing.

The power factor is a no-go for a commercial conversion though. For personal tinkering, I don't think anyone cares. Not being nice to the grid is a minus, but not releasing poisonous gases to the atmosphere is a plus.
MattsAwesomeStuff
Posts: 871
Joined: Fri Apr 26, 2019 5:40 pm
Has thanked: 278 times
Been thanked: 165 times

Re: Gen 3 inverter converter control software

Post by MattsAwesomeStuff »

I understand what power factor correction is, and why it's important... but I don't really know what the typical solution to it is.

I recall once upon a time you'd just add a bunch of capacitance to the circuit to balance out inductive loads. Is that still a thing people do, or, what's the modern way of correcting PF?
User avatar
celeron55
Posts: 774
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 27 times
Been thanked: 110 times
Contact:

Re: Gen 3 inverter converter control software

Post by celeron55 »

Just to clarify for all the newbies out there:

The problem with all power supplies taking in AC is that when you rectify 1-phase AC into a capacitor, there's zero current when the instantaneous AC voltage is below the capacitor voltage, and a lot of current when the instantaneous AC voltage is at the capacitor voltage. In the ideal situation (and which would be perfect power factor) you always want your device to take in current like a resistive load would, i.e. if you take 10A at 100V, then when voltage is 50V you take 5A.

Notably 3 phase AC largely doesn't have this problem because the voltage between the highest and lowest phase doesn't fluctuate that much, and certainly never goes to 0V. Using the prius inverter in the 3 phase input configuration isn't too bad for the grid other than possibly some switching noise entering the grid. Maybe someone with some experience can figure out what kind of filtering it should ideally have.
MattsAwesomeStuff wrote: Tue Jun 23, 2020 9:33 pm I understand what power factor correction is, and why it's important... but I don't really know what the typical solution to it is.

I recall once upon a time you'd just add a bunch of capacitance to the circuit to balance out inductive loads. Is that still a thing people do, or, what's the modern way of correcting PF?
You can't offset the current with capacitance or inductance because it's not offset that much - it's mainly just way too spiky.

Commercial high power devices don't just have a rectifier, but they also have a boost circuit that synchronizes with the AC waveform and boosts the appropriate current into the capacitor when the instantaneous AC voltage is below the capacitor voltage. You can often see this stage quite clearly, as at initial glance it looks like it should be just a rectifier, but then you notice there are large inductors and transistors alongside a control chip in there before the voltage is fed to the actual switch mode converter.

EDIT: I've attached a photo of the Nissan Leaf 1 phase AC charger. AC comes in via the small copper bars to the left edge of the PCB, then there's a suspiciously long row of through hole transistors + 2 diodes mounted on the heatsink below the PCB, then there's the capacitor bank. The weird wires that attach to the PCB between the input copper bars and the transistors go to the plastic-encased inductors at the top left. That's the boost converter at the input.

To the right of the capacitors below the PCB that you can't really see are the actual transistors of the charger's flyback converter. The output of the transistors leaves the PCB via wires to a transformer and from there to another PCB to be rectified again.
Attachments
P1150317s.JPG
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: Tue Jun 23, 2020 7:59 pm The power factor is a no-go for a commercial conversion though. For personal tinkering, I don't think anyone cares. Not being nice to the grid is a minus, but not releasing poisonous gases to the atmosphere is a plus.
Can probably still get a reasonable power factor considering the bus capacitance is quite low for the power levels being dealt with. Just needs better control over the buck/boost converter.

Another trick, if the battery voltage is above the 340V or so of rectified 240V, is to use an external bridge rectifier to the buck/boost and then just use the buck/boost as a more conventional PFC. In the US, the trick can even be done with batteries as low as 170V by using a full wave rectifier from 240V, but that would require the neutral and is therefore incompatible with J1772.
My first solar power system helped Naomi Wu, now I want to do even more with DIY solar.
User avatar
celeron55
Posts: 774
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 27 times
Been thanked: 110 times
Contact:

Re: Gen 3 inverter converter control software

Post by celeron55 »

Yeah there's room for extra trickery in controlling the converter in single phase buck application, and a future boost version for charging higher voltage packs from single phase will have better pf by default.

I'm a european 3 phase guy though. 22kW type 2 is where you get the most power for the cheapest and most ubiquitously around here.
User avatar
celeron55
Posts: 774
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 27 times
Been thanked: 110 times
Contact:

Re: Gen 3 inverter converter control software

Post by celeron55 »

I finally found and fixed a PWM control bug that was messing with the boost precharge and causing large enough voltages (650-700V) to make the inverter make its characteristic "pop" sound. Now it also precharges really fast as the code doesn't need to try to work around the PWM glitch.
User avatar
celeron55
Posts: 774
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 27 times
Been thanked: 110 times
Contact:

Re: Gen 3 inverter converter control software

Post by celeron55 »

I just realized a non-isolated charger like this is actually a safety feature in a conversion: Every time you connect to an EVSE to charge, you get checked for ground leaks without having any ground leak detection circuitry in the vehicle.
User avatar
rstevens81
Posts: 349
Joined: Sun Dec 22, 2019 10:36 am
Location: Bristol, UK
Has thanked: 21 times
Been thanked: 91 times

Re: Gen 3 inverter converter control software

Post by rstevens81 »

Now we wait for winter when the wet stuff arrives to test the rcd's in the Evse's if not we could Gert some arcing around the tyres :)
btw thanks for your effort on this it is most appreciated by everyone here, even if some poor inverters had to die in the process.
Rule 1 of EV Club is don't buy a rust bucket....
Which rule does everyone forget 🤪
MattsAwesomeStuff
Posts: 871
Joined: Fri Apr 26, 2019 5:40 pm
Has thanked: 278 times
Been thanked: 165 times

Re: Gen 3 inverter converter control software

Post by MattsAwesomeStuff »

celeron55 wrote: Tue Jun 23, 2020 10:03 pmYou can't offset the current with capacitance or inductance because it's not offset that much - it's mainly just way too spiky.
Ohh, I had no idea that spiking was an issue. I thought power factor specifically meant the waveform leading or lagging from inductive/capacitive loads. Wouldn't almost every household electronic device (anything other than motors and things that heat) cause this same issue? They all have an FWB and capacitor, don't they? I guess in the scale of things, most of the power used by a home is resistive heating elements, not a lot for high power electronics.

My business' power meter has both watts and volt-amps, and often 70% of my bill is demand charges. I haven't seen, but I've been told that many commercial places will have a power factor multiplier as part of their bill. Is this spiking something that would affect my power factor in that respect (something I'd get billed for?) or does it not affect it in that way? I presume I'll be charging my car mostly at the business (no garage at home).
NiHaoMike wrote:Can probably still get a reasonable power factor considering the bus capacitance is quite low for the power levels being dealt with. Just needs better control over the buck/boost converter.
Wouldn't higher capacitance help, rather than hinder how spiky the current flow is, by better ballasting the load? Or... I guess the better it ballasts the load, the more aggressively it pulls current during the peaks of the AC?
User avatar
celeron55
Posts: 774
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 27 times
Been thanked: 110 times
Contact:

Re: Gen 3 inverter converter control software

Post by celeron55 »

MattsAwesomeStuff wrote: Thu Jun 25, 2020 5:53 pm My business' power meter has both watts and volt-amps, and often 70% of my bill is demand charges. I haven't seen, but I've been told that many commercial places will have a power factor multiplier as part of their bill. Is this spiking something that would affect my power factor in that respect (something I'd get billed for?) or does it not affect it in that way? I presume I'll be charging my car mostly at the business (no garage at home).
If they bill you based on volt-amps, a bad power factor will increase your bill, quite simply. Of course the power factor will be the sum of everything that's connected to the grid, but you can be fairly certain there's nothing that would offset the spikes, unlike how a capacitive load can offset an inductive load.
MattsAwesomeStuff wrote: Thu Jun 25, 2020 5:53 pm Wouldn't higher capacitance help, rather than hinder how spiky the current flow is, by better ballasting the load? Or... I guess the better it ballasts the load, the more aggressively it pulls current during the peaks of the AC?
With small enough capacitance compared to the power being throughput, the capacitor will start following the rectified AC waveform, which extends the time when current is flowing into the capacitor. Of course with that the AC waveform at the capacitor can start transferring into pulsating current at the output depending what kind of converter is designed after it. In some uses pulsating current won't even matter, like let's say... a battery charger. :mrgreen:

When you think about it, the boost converter based PFC can be just that - a rectifier feeding very little capacitance, fed into a boost converter that is designed to be able to modulate its PWM in sync with the AC voltage waveform to create the perfect current waveform.
User avatar
rstevens81
Posts: 349
Joined: Sun Dec 22, 2019 10:36 am
Location: Bristol, UK
Has thanked: 21 times
Been thanked: 91 times

Re: Gen 3 inverter converter control software

Post by rstevens81 »

A (potential) warning to anyone who wants to use this a Yaris inverter (as stated in Celeron's GitHub) the dc capacitors are rated at 300v (low) and 650v (high) (as stamped on the capacitor casing - attached).
This does also beg the question that if the high side capacitor is 650v then it makes it highly unlikely that the inverter ever runs at 650v.
Attachments
capacitor.jpg
Rule 1 of EV Club is don't buy a rust bucket....
Which rule does everyone forget 🤪
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 »

Good info thanks. The 650v thing is an internet myth that will probably never die. Along with the 100A "current limit" ....
I'm going to need a hacksaw
doobedoobedo
Posts: 260
Joined: Sat Jan 12, 2019 12:39 am
Location: UK

Re: Gen 3 inverter converter control software

Post by doobedoobedo »

rstevens81 wrote: Mon Jun 29, 2020 12:20 pm A (potential) warning to anyone who wants to use this a Yaris inverter (as stated in Celeron's GitHub) the dc capacitors are rated at 300v (low) and 650v (high) (as stamped on the capacitor casing - attached).
This does also beg the question that if the high side capacitor is 650v then it makes it highly unlikely that the inverter ever runs at 650v.
I spotted that when I took mine apart. Making me a bit nervous about using mg* to boost to 400V...
User avatar
celeron55
Posts: 774
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 27 times
Been thanked: 110 times
Contact:

Re: Gen 3 inverter converter control software

Post by celeron55 »

If you read any of Toyota's gen3 or newer publications, they do always say "650V maximum".

The IGBT driver board enforces that voltage limit. If you set the boost converter at a low PWM and just wait, it'll stop when the MG rail reaches about 650V. At high PWM it will overshoot and then you're watching it drain down from some semi scary voltage from 650V up to over 1000V.

Telling it's 650V could be a marketing strategy, or something lazily taken from their safety documents. I think it probably goes to 650V, but only when you absolutely floor the throttle, and their control system is accurate enough for operating right at the limit for brief periods of time.

So who's going to buy a gen3 Prius or Yaris... for science?
User avatar
rstevens81
Posts: 349
Joined: Sun Dec 22, 2019 10:36 am
Location: Bristol, UK
Has thanked: 21 times
Been thanked: 91 times

Re: Gen 3 inverter converter control software

Post by rstevens81 »

I think the thing to remember is that inspite of this, it's a high-powered Inverter and a DC-DC so the loss of budget 3 phase charging is not the end of the world as it's still insanely good value.

It is not long ago when an inverter if much lesser power would cost thousands.
I think if you want really high powered 3 phase charging then the poor/rich man's chademo would be a better start (if you have the necessary electrical understanding and experience).

EDIT: I am talking about the Yaris inverters here, [Prius inverters all good!] Sorry Celeron
Rule 1 of EV Club is don't buy a rust bucket....
Which rule does everyone forget 🤪
User avatar
celeron55
Posts: 774
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 27 times
Been thanked: 110 times
Contact:

Re: Gen 3 inverter converter control software

Post by celeron55 »

It works fine as a charger. The MG side is still rated for continuous 650V, even in the Yaris one. You need a lower voltage battery for it of course. And if you feel you'd rather have more margin for error, that's fine, one can always use something else. But that doesn't mean it doesn't work.

I just did a 35 minute 18kW 3 phase charging session earlier today using the Prius gen3 inverter at 10kHz. Yes, it's still in one piece.
doobedoobedo
Posts: 260
Joined: Sat Jan 12, 2019 12:39 am
Location: UK

Re: Gen 3 inverter converter control software

Post by doobedoobedo »

I'm looking at single phase charging (240V AC rectified is ~340V). My intention was to use the MG inputs then the buck/boost converter to boost up to battery voltage (100S in my case so aroung 415V) but seeing the 300V on the cap in the Yaris inverter has made me think twice.
User avatar
celeron55
Posts: 774
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 27 times
Been thanked: 110 times
Contact:

Re: Gen 3 inverter converter control software

Post by celeron55 »

Yeah that's correct. The Prius gen3 inverter would be able to handle that but as there's quite some cost difference from Yaris to Prius including external charging components, sometimes you can find an actual single phase charger with the same budget. Three phase not so much - that's where this solution shines.
User avatar
Bigpie
Posts: 1585
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 74 times
Been thanked: 299 times

Re: Gen 3 inverter converter control software

Post by Bigpie »

I'm having trouble getting a bootloader burnt on the atmega. Is there anything unusual in the procedure?
I've tried using an UNO as ISP and USBTinyISP.
I've got the board powered using 12v, the ground is connected from the arduino/ISP but not the 5v. Checked the wiring multiple times.
I've used the Ardunio IDE to burn a bootloader on to the UNO with the USBTinyISP so I know that's fine.

Below is the command generated by the IDE

Code: Select all

avrdude -Cavrdude.conf -v -patmega328p -cusbtiny -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xFF:m 
and the response (when I've added an extra -vvvv)

Code: Select all

avrdude: Using SCK period of 10 usec
CMD: [ac 53 00 00] [00 00 00 00]
CMD: [ac 53 00 00] [00 00 00 00]
CMD: [ac 53 00 00] [00 00 00 00]
CMD: [ac 53 00 00] [00 00 00 00]
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

Any suggestions?
VW Beetle 2003
Outlander front generator
Prius Gen 3 inverter (EVBMW logic board)
Outlander charger
3x Golf GTE batteries
Chademo Charging
Outlander water heater
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Gen 3 inverter converter control software

Post by arber333 »

celeron55 wrote: Mon Jun 29, 2020 8:08 pm It works fine as a charger. The MG side is still rated for continuous 650V, even in the Yaris one. You need a lower voltage battery for it of course. And if you feel you'd rather have more margin for error, that's fine, one can always use something else. But that doesn't mean it doesn't work.

I just did a 35 minute 18kW 3 phase charging session earlier today using the Prius gen3 inverter at 10kHz. Yes, it's still in one piece.
Very good!

I have tested Yaris control hardware up to 400Vdc on the battery side and up to 610Vdc at MG side. This is as far as firmware will feedback.
I had the cap off at the time true! While i could have it on i decide to leave off just because i had better access. I think i saved myself some magic smoke.
arber333
Posts: 3241
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 74 times
Been thanked: 223 times
Contact:

Re: Gen 3 inverter converter control software

Post by arber333 »

doobedoobedo wrote: Mon Jun 29, 2020 8:31 pm I'm looking at single phase charging (240V AC rectified is ~340V). My intention was to use the MG inputs then the buck/boost converter to boost up to battery voltage (100S in my case so aroung 415V) but seeing the 300V on the cap in the Yaris inverter has made me think twice.
If you have space you could use some elcaps or a smaller HV film cap (100uF) on the battery side. You would just need to cut the + connections from that 300Vdc rated cap. Granted it would look somewhat odd, but i found out that on the output side you dont need much capacitance. Battery acts as a large elcap by its own. 100uF is enough to smooth the switching noise in/out the inductor and since you would use 3phase you get HV smoothing naturaly since the phases overlap.

A
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 »

An alternative is to connect the output of the bridge rectifier from the positive of the low side to the positive of the high side.
My first solar power system helped Naomi Wu, now I want to do even more with DIY solar.
User avatar
Bigpie
Posts: 1585
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 74 times
Been thanked: 299 times

Re: Gen 3 inverter converter control software

Post by Bigpie »

@celeron55 should the #TEST_BOOST flag in your code work? Just wondering if it's a problem with my setup or that's not working in your code at the moment.

Code: Select all

#define TEST_BOOST true
#define TEST_BOOST_VOLTAGE 30
Ive done the above and connected 12v to DC BUS 2 but not getting output on DC bus 1.

I am able to buck from DC Bus 2 to 1 by adjusting the PWM on pin 10 so my setup at least partially works.
VW Beetle 2003
Outlander front generator
Prius Gen 3 inverter (EVBMW logic board)
Outlander charger
3x Golf GTE batteries
Chademo Charging
Outlander water heater
User avatar
celeron55
Posts: 774
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 27 times
Been thanked: 110 times
Contact:

Re: Gen 3 inverter converter control software

Post by celeron55 »

Bigpie wrote: Wed Aug 05, 2020 8:05 pm @celeron55 should the #TEST_BOOST flag in your code work? Just wondering if it's a problem with my setup or that's not working in your code at the moment.

Code: Select all

#define TEST_BOOST true
#define TEST_BOOST_VOLTAGE 30
Ive done the above and connected 12v to DC BUS 2 but not getting output on DC bus 1.

I am able to buck from DC Bus 2 to 1 by adjusting the PWM on pin 10 so my setup at least partially works.
"#define TEST_BOOST true" will boost using 1% PWM up to 400V. Boosting should turn on and off every 500ms. I think it should work, as I don't remember breaking it, but I can't test at the moment.

There's no TEST_BOOST_VOLTAGE in the code. If you want to change the maximum test voltage or change something else as you sure might when testing, you can edit the test code at the beginning of loop().
User avatar
Bigpie
Posts: 1585
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 74 times
Been thanked: 299 times

Re: Gen 3 inverter converter control software

Post by Bigpie »

TEST_BOOST_VOLTAGE is what I added to do just that. Bucking works (not tested using your software) but not boosting, looks like I might need to dig further and spend some time to understand timers and registers.

Am I right is assuming boosting is just doing PWM on pin 9 instead of 10 or am I reading this code wrong?

Code: Select all

...
        if(input_voltage_V < DESIRED_OUPUT_VOLTAGE && ((millis()/1000)&1)==0){
		set_pwm_boost_active(ICR1 * 0.01);
	} else {
		set_pwm_inactive();
	}
	...
static void set_pwm_boost_active(uint16_t lowswitch_ontime)
{
	if(!current_sensor_zero_offsets_calibrated)
		return;
	if(lowswitch_ontime > ICR1)
		lowswitch_ontime = ICR1;
	uint16_t lowswitch_offtime = ICR1 - lowswitch_ontime;
#if 0 //ignored
	const float deadtime_ns = 10000;
	const uint16_t deadtime = (uint16_t)((float)deadtime_ns/(1.0/16e6*1e9));
	set_ontimes(lowswitch_offtime, lowswitch_offtime - deadtime);
#else
	set_ontimes(lowswitch_offtime, 0);
#endif
}

// Times are referenced to ICR1 value (ICR1 = 100%, 0 = 0%)
static void set_ontimes(uint16_t lowswitch_offtime, uint16_t highswitch_ontime)
{
	// OC1A: Low side
	OCR1A = lowswitch_offtime;
	// OC1B: High side
	OCR1B = highswitch_ontime;

	// We need to rewind TCNT1 to OCR1A so that the lowside gets turned off.
	// Otherwise it will stay on for a full PWM cycle until it reaches the
	// lowered OC1A on the next cycle and by that point we've had quite the
	// boost pulse. At 10kHz such a pulse will create about 50V of extra voltage
	// on the MG side.
	if(TCNT1 >= OCR1A)
		TCNT1 = OCR1A-1;
}
VW Beetle 2003
Outlander front generator
Prius Gen 3 inverter (EVBMW logic board)
Outlander charger
3x Golf GTE batteries
Chademo Charging
Outlander water heater
Post Reply