Gen 3 inverter converter control software

Topics concerning the Toyota and Lexus inverter drop in boards
arber333
Posts: 3261
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 232 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: 1594
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 75 times
Been thanked: 303 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: 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 »

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: 1594
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 75 times
Been thanked: 303 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
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 »

Bigpie wrote: Thu Aug 06, 2020 6:51 am 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?
Yes, it is supposed to just do PWM on the other pin. Do you have a scope or something handy to measure it directly on the atmega328 pin?
User avatar
Bigpie
Posts: 1594
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 75 times
Been thanked: 303 times

Re: Gen 3 inverter converter control software

Post by Bigpie »

So as a test I've pulled the board out, set 9 and 10 at 50% duty.
Output from the pins looks good.
Screenshot 2020-08-06 at 1.02.15 pm.png
I've followed this to TR8 and TR9 then the R88 and R87 to the 50way connector, both the same
Screenshot 2020-08-06 at 1.15.30 pm.png
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: 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 »

That looks ok assuming the IGBT driver board is disconnected. Once connected it will supply the 5V pull-up to the lines. If it doesn't supply 5V, that means it's detecting a fault in the IGBT.
User avatar
Bigpie
Posts: 1594
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 75 times
Been thanked: 303 times

Re: Gen 3 inverter converter control software

Post by Bigpie »

Both look good when hooked up. I'll put the inverter back together tomorrow and stuck a voltage on the DC bus and see if I get any boosting with just setting the PWM and 50%.
Attachments
Screenshot 2020-08-06 at 9.03.33 pm.png
Screenshot 2020-08-06 at 9.02.43 pm.png
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
Bigpie
Posts: 1594
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 75 times
Been thanked: 303 times

Re: Gen 3 inverter converter control software

Post by Bigpie »

I must be doing something wrong.

I've got 83v on the RHS side as in the photo. I've got a multimeter on LHS (1 & 2) an no load

Code: Select all

|.  RHS (in).    |.    LHS (out).        |.    Pin 9 PWM.        |.    Pin 10 PWM.     |
|.    83         |         0             |            0          |          0          |
|     83         |         0             |           50%         |          0          |
|     83         |        83             |            0          |         50%         |
|     83         |        83             |            0          |         20%         |
|     83         |         0             |           20%         |          0          |
|     83         |         0             |           80%         |          0          |
I've checked BOOST_FAULT and it remains at 5v.
I've noticed a lower value for PWM results in a higher percentage PWM.

PWM = 50 gives 80%
PWM = 200 gives 20%


I must be missing something. I don't seem to be able to buck or boost

Code: Select all

#include <Arduino.h>

#define DCBUS1_PIN               A0
#define DCBUS2_PIN               A1
#define BOOST_LOW_SWITCH_PIN      9
#define BOOST_HIGH_SWITCH_PIN    10

int PWMDuty = 0;    //pwm duty cycle

void setup() {
  Serial.begin(115200);//
  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
  pinMode(A0, INPUT); //boost Hi side
  pinMode(A1, INPUT); //boost Hi side

  analogWrite(9,0); //low side off
  analogWrite(10,0); //low side off

  PWMDuty=0;
}
// the loop function runs over and over again forever
void loop() {

PWMDuty=20;
//  analogWrite(10,PWMDuty);
analogWrite(9, PWMDuty); //low side off

delay(1500);
}
Attachments
1600px-20200705_190723.jpg
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
Bigpie
Posts: 1594
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 75 times
Been thanked: 303 times

Re: Gen 3 inverter converter control software

Post by Bigpie »

Right, now I can buck from dc bus 2 down to dc bus 1. Is this thing able to buck and boost in both directions?
VW Beetle 2003
Outlander front generator
Prius Gen 3 inverter (EVBMW logic board)
Outlander charger
3x Golf GTE batteries
Chademo Charging
Outlander water heater
johnstef
Posts: 2
Joined: Sat Oct 03, 2020 2:46 pm
Been thanked: 1 time

Re: Gen 3 inverter converter control software

Post by johnstef »

Jack Bauer wrote: Wed Jun 17, 2020 2:13 pm
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....
Any progress on outputting 240v AC from the Inverter? My interest is for the USA grid, 240v AC 60 Hz. The inverter would supply AC mains current to my home from a 7kw to 10kw Li battery pack.
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 »

viewtopic.php?f=14&t=969

Lets keep this thread on topic please.
I'm going to need a hacksaw
User avatar
Bigpie
Posts: 1594
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 75 times
Been thanked: 303 times

Re: Gen 3 inverter converter control software

Post by Bigpie »

So I was running the prius3charger_buck (latest version), and all was well. I had single phase connected through a lightbulb, to MG1 (1&3) it light briefly and went out. Using TEST_BUCK = true.

I turned the mains power off and when I turned it off I heard a click sound from the inverter. Now when I turn mains back on the bulb stays on. Any clues what I've done and what I've killed?
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: 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 »

Do some continuity measurements and you'll probably find out. Definitely sounds like the converter high or low side died.
User avatar
Bigpie
Posts: 1594
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 75 times
Been thanked: 303 times

Re: Gen 3 inverter converter control software

Post by Bigpie »

Would be be kind enough to point me to where I'd be probing? I'm not sure which legs are for the buck boost mosfets

EDIT found this: Image

I have a short between + and -, It's dead, Jim.
20201031_144655.jpg
1/ If I cut the legs of the boost IGBTs I'm guessing that would allow me to still drive a motor with MG1/MG2?
2/ I'm assuming I've had both the high and low on at the same time? I was only running test_buck, does some dead time need bringing in to stop the happening when I get another inverter?
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
Bigpie
Posts: 1594
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 75 times
Been thanked: 303 times

Re: Gen 3 inverter converter control software

Post by Bigpie »

20201103_191139.jpg
A bad thing has happened. I've been in to the goo and cut away. Hopefully can still use mg2 for now.

I'll pick up another inverter at some point.
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: 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 »

In these cases it's difficult to tell what the root cause is.

I think some of the used inverters on sale do have problems with the boost IGBTs, so there's a chance it's bad luck.

My code might just suck, altough I've personally ran it more than enough to give it a chance to destroy my IGBTs.

It could also be that some versions of the inverter have worse protection than others, and only the better ones survive the code. Who knows.
User avatar
Bigpie
Posts: 1594
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 75 times
Been thanked: 303 times

Re: Gen 3 inverter converter control software

Post by Bigpie »

I'm not sure, it went pop when I'd turned the mains off but with no load on the dc bus, the 12v supply was still on to the inverter, using test buck. Not sure if thats anything to do with it.

I don't know much about using timers so I get lost following your code there. I did wonder why the code that appears to set deadtime isn't used?

Code: Select all

// Sets high side switch PWM, and low side switch PWM based on it
static void set_pwm_buck_active(uint16_t highswitch_ontime)
{
	if(!current_sensor_zero_offsets_calibrated)
		return;
#if 0
	const float deadtime_ns = 2500;
	const uint16_t deadtime = (uint16_t)((float)deadtime_ns/(1.0/16e6*1e9));
	set_ontimes(highswitch_ontime + deadtime, highswitch_ontime);
#else
	set_ontimes(ICR1+1, highswitch_ontime);
#endif
}

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

It doesn't activate the low side IGBT at all. The low side is just used as a diode. If you change it to #if 1, then the lowside is also driven, but I didn't test that option at all because on my inverter the low side IGBT is toast. The diode works and it isn't shorted, but it can't be activated.

Note that set_ontimes() has weird parameters. The first parameter is lowside offtime and the second parameter is highside hightime. I wrote it to directly match to how the underlying timer is set up.
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 »

going to make this a sticky as it seems to have fallen off the radar and is an important development.
I'm going to need a hacksaw
User avatar
Bigpie
Posts: 1594
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 75 times
Been thanked: 303 times

Re: Gen 3 inverter converter control software

Post by Bigpie »

I've started working on a basic web interface for this so I don't have to plug in.

https://github.com/jamiejones85/PriusCh ... bInterface

So far it uses Web Sockets to display the serial output from the charger.
Screenshot 2021-01-11 at 3.45.21 pm.png
Plans are to allow uploading of new firmware and set configuration options at least, someones written code https://github.com/rene-win/esp_avr_programmer that I'm going to be ripping off for that.

I'm using a Wemos D1 mini, even though it's supposed to be 3.3v hooking the RX and TX pins up directly seems to work.

Contributions will be greatly appreciated.

EDIT
It's a bit rough round the edges, but you can now upload a hex file to flash the attached atmega.
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: 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 you directly connect (taking care of different pinout) the Wemos D1 mini to GND, 5V, RX, TX and RST in the "FTDI 5V" connector and it just works?
User avatar
Bigpie
Posts: 1594
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 75 times
Been thanked: 303 times

Re: Gen 3 inverter converter control software

Post by Bigpie »

pretty much, yea. I'd read https://hackaday.com/2016/07/28/ask-hac ... -tolerant/ and though what the hell, I'll give it a go.

I've flashed a hex with the web interface that prints a serial message and this started appearing in the output. So on to cleaning up the code.
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
Bigpie
Posts: 1594
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 75 times
Been thanked: 303 times

Re: Gen 3 inverter converter control software

Post by Bigpie »

Screenshot 2021-01-13 at 12.07.44 pm.png
Web Interface now supports
-Updating the Atmega Firmware
-Sending Commands
-Viewing Output Log

I'll have to look at some changes to the charger code next, moving the configuration parameters in to EEPROM and allowing this to be set from the Web Interface.
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