Gen 3 inverter converter control software

Topics concerning the Toyota and Lexus inverter drop in boards
Post Reply
User avatar
Jack Bauer
Posts: 3564
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 93 times
Contact:

Gen 3 inverter converter control software

Post by Jack Bauer »

Decided to break off a new thread for development of control software to run on the Atmega328 processor for control of the buck boost converter in Gen 3 Prius and Yaris/Auris inverters.

First attempt here from myself to run in buck mode to drop a 360v nominal HV down to 200v to run the dcdc converter section without modification. Only tested on the bench with low voltages in a Yaris inverter but seems to work well.

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
  SetV=15;  //set at 15v for bench test with 30v input.
  PWMDuty=0;


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

HVLow = (analogRead(A0)/1.85);
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 (HVLow<SetV) PWMDuty++;
if (HVLow>SetV) PWMDuty--;
if (PWMDuty<0)  PWMDuty=0;
if (PWMDuty>250)  PWMDuty=250;

analogWrite(10,PWMDuty);
}
  
}
Attachments
2020-06-11 13.13.47.jpg
I'm going to need a hacksaw
User avatar
Jack Bauer
Posts: 3564
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 93 times
Contact:

Re: Gen 3 inverter converter control software

Post by Jack Bauer »

Figured I'd better test it. annnd....it works:)

Connected 230v mains to mg1, battery on the dcdc output. At 230vac in we were seeing about 320v on the HV main side and about 190v on the hv batt side. DCDC works perfectly.
Attachments
2020-06-11 14.05.28.jpg
2020-06-11 14.05.26.jpg
2020-06-11 14.05.12.jpg
2020-06-11 14.05.09.jpg
2020-06-11 14.05.01.jpg
2020-06-11 14.04.56.jpg
I'm going to need a hacksaw
User avatar
Jack Bauer
Posts: 3564
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 93 times
Contact:

Re: Gen 3 inverter converter control software

Post by Jack Bauer »

So is there anyone willing to pick this up and code it to give us battery charge functionality? If not I'll hire a developer and that will then be closed source available to those who have purchased or purchase a full board kit from me only.

Sorry to be blunt but this just needs to happen, I don't have the skills to do it so we need to make a decision as a community.
I'm going to need a hacksaw
arber333
Posts: 3403
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 96 times
Been thanked: 287 times
Contact:

Re: Gen 3 inverter converter control software

Post by arber333 »

Jack Bauer wrote: Thu Jun 11, 2020 1:25 pm So is there anyone willing to pick this up and code it to give us battery charge functionality? If not I'll hire a developer and that will then be closed source available to those who have purchased or purchase a full board kit from me only.

Sorry to be blunt but this just needs to happen, I don't have the skills to do it so we need to make a decision as a community.
I understand, this is why i wanted you to copy the pinout from EMW code so we could load the code onto it and use it for our personal use... and so every one else who is interested :D. Incidentaly since Dima developed the Wifi interface it works beautifully in my car for like 1/2 year now. At 16kW aircooled 3phase.
Valery said for commercial use rights to ask another company which bought EMW, i didnt bother further. We have everything we need for DIY use right there...

Not so much if one wants to sell a full kit though...
User avatar
Jack Bauer
Posts: 3564
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 93 times
Contact:

Re: Gen 3 inverter converter control software

Post by Jack Bauer »

Yep if it was just for me or a few friends I would have hapillly used the emw software. The license nonsense killed that option. So as I said its open on here now for people to get involved, step up and contribute to the effort. If nothing happens in a few days I'll take it over and it will be a closed project.
I'm going to need a hacksaw
User avatar
Bigpie
Posts: 1707
Joined: Wed Apr 10, 2019 8:11 pm
Location: South Yorkshire, UK
Has thanked: 77 times
Been thanked: 369 times

Re: Gen 3 inverter converter control software

Post by Bigpie »

Didn't celeron55 get something working? I'm not sure I'm skilled enough to help, I'm a developer and have tinkered with arduino. Is there any info anywhere on what the software needs to do?

In my mind I'm assuming it needs on a high level to:
  • Read the pwm signal from the evse to set the max current
  • Read desired voltage from eeprom
  • Adjust pwm for buck or boost to keep at or below these values
  • Close and open contactors as required
BMW E91 2006
ZombieVerter
GS450h
Outlander Charger DC/DC
Renault Kangoo 36kWh battery
User avatar
rstevens81
Posts: 370
Joined: Sun Dec 22, 2019 10:36 am
Location: Bristol, UK
Has thanked: 28 times
Been thanked: 103 times

Re: Gen 3 inverter converter control software

Post by rstevens81 »

I am willing to have a bash at this as long if no one is in too much of a hurry as I can't put the commitment JB does, however it looks like I shall be working P/T for the next few weeks at least, I have basic Arduino skills (lift, steal, adapt from others work) and have created complex Excel/VB stuff through work thou. So hopefully I can create something over the next few months, at present I don't have a HV battery so I shall be using battery simulation AKA oven heating elements / incandecent lightbulb etc.

To show my commitment I have just ordered a £90 Yaris inverter from flee-bay... [I did try to get a Prius inverter but the cheapest quote I got was £160 (and the most expensive £500, also got told by a local broker it was illegal to break a Prius without a licence!)]

I shall probably try to Hotwire an Arduino in in the initial stages to prove the concept as I don't actually have a car to convert to EV my Long term plans are to build a Haynes 7 powered by a Outlander/Leaf powered motor/gearbox.

Feel free to flame me :)
Rule 1 of EV Club is don't buy a rust bucket....
Which rule does everyone forget 🤪
User avatar
celeron55
Posts: 800
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 37 times
Been thanked: 131 times
Contact:

Re: Gen 3 inverter converter control software

Post by celeron55 »

I am going to get to the charger code, but as a hobby my timeline is tied to the timelines of my projects that it's part of.

I'm not going to code it blind, I need a high power test setup for it. I currently have a Yaris inverter sitting on my desk, with all original wiring harness connectors. But before I can get to work on making it charge, I need to obtain a 3x400VAC input contactor and either decide to stuff a Prius board into it or obtain a Yaris board (Yes, Damien sent me a Prius board but I only could get a Yaris inverter for cheap...). Also I'm yet to source an HV connector for my BMW hybrid pack (not going to cut the original wiring as I plan to use the entire thing as-is and solder and heatshrink tubing for repairing cut wires isn't a good idea for high voltage high current). Haven't begun checking whether I have the 3 phase cable, connector, high current crimp terminals and whatever hardware for doing this yet. And my bank account is reading about zero right now. The car in which my existing hacky prius gen3 charger is in is a daily driver, I can't just go take it apart willy nilly.

So, if you need the code from me this fast, now you know what's currently blocking me. Throw money and/or parts at me and it'll happen faster.

I'd start programming and testing the charge function tomorrow if I had everything I needed.
User avatar
jnsaff
Posts: 177
Joined: Fri Oct 18, 2019 7:42 am
Location: Tallinn, Estonia
Has thanked: 3 times
Been thanked: 8 times

Re: Gen 3 inverter converter control software

Post by jnsaff »

celeron55 wrote: Thu Jun 11, 2020 8:15 pm I need to obtain a 3x400VAC input contactor
I have this sitting on my desk unused, if it helps I’m happy to send it to you and cover the postage as well.
71AEEA2C-FFE9-4C6A-9B72-F33EC5FB5161.jpeg
01A3FC98-7A7B-43C6-9001-CD14AC61133E.jpeg
MattsAwesomeStuff
Posts: 936
Joined: Fri Apr 26, 2019 5:40 pm
Has thanked: 343 times
Been thanked: 204 times

Re: Gen 3 inverter converter control software

Post by MattsAwesomeStuff »

I'd love to be able to help, but my coding skills are rudimentary at best, and I've never used a microcontroller so I'd be a terrible lead.

Perhaps I could assist with documentation if there is any, but programming sounds like something that'll either work or not, not much need for documentation.

We're such a small community here, I wonder if we'd be better served by asking for help in Prius forums for example? Probably lots of tech nerds there. But, are those people going to benefit from what we're doing here?

Would this software be applicable to other Prius's (like my Gen2 for example?) or other hardware entirely? Or is it pretty specific to this narrow task?
doobedoobedo
Posts: 260
Joined: Sat Jan 12, 2019 12:39 am
Location: UK

Re: Gen 3 inverter converter control software

Post by doobedoobedo »

I've not really been following the Prius/Yaris stuff, so humour me.

Is this the inverter it needs to be coded for?
https://www.ebay.co.uk/itm/Genuine-OEM- ... SwtIdc3UVo

Would I need any other control boards?

I can probably code it.
User avatar
Jack Bauer
Posts: 3564
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 93 times
Contact:

Re: Gen 3 inverter converter control software

Post by Jack Bauer »

Yep that is a Yaris inverter. Basically the same as prius but presumed to be less powerful but no one has bothered to test this of course:) You would need a control board kit which I would provide free of charge if you undertake to write the software.
I'm going to need a hacksaw
User avatar
Jack Bauer
Posts: 3564
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 93 times
Contact:

Re: Gen 3 inverter converter control software

Post by Jack Bauer »

In fact here is a better idea. If you undertake to do the code I'll send you my yaris inverter complete with tested logic board.
I'm going to need a hacksaw
User avatar
celeron55
Posts: 800
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 37 times
Been thanked: 131 times
Contact:

Re: Gen 3 inverter converter control software

Post by celeron55 »

I've taken jnsaff's contactor offer so I'm getting closer to having a test setup.

Don't be so hurried and worried about this, it's going to happen and you don't need to waste your time and resources on it.
doobedoobedo
Posts: 260
Joined: Sat Jan 12, 2019 12:39 am
Location: UK

Re: Gen 3 inverter converter control software

Post by doobedoobedo »

No need to send the inverter, in fact I'd rather you kept it. The one I linked is local to me. I can't believe how cheap they are :). I wouldn't say no to a board though, happy to change out the resistors myself.

I'm assuming there are current sensors the 328p will have access to, or would it need to talk to the brain over serial to get these?

Of course if Celeron55 would rather undertake this, then I'm happy for that too.
User avatar
rstevens81
Posts: 370
Joined: Sun Dec 22, 2019 10:36 am
Location: Bristol, UK
Has thanked: 28 times
Been thanked: 103 times

Re: Gen 3 inverter converter control software

Post by rstevens81 »

Lucky you doobedoobedo, I saw that one too, Im on the other side of the country so I paid a little extra for mine, but agreed the Yaris inverters are insanely cheap and I would be very surprised if the inverter was not as powerful as a gen2 prius inverter.

Based on JB Schematic (Note to JB the resistor values e.g. R41/42 need updating on the digram... but no rush as hopefully everyone here willing to undertake brain surgery on a inverter would at least read thread first) MG1 Current sensors are connected to pins 27/28 on the ATmega328P and then pins 1/2 on MG1 current sensor connector (via the usual resitor/divider).

From my point of view I am happy the help if I can on anything I can.
Rule 1 of EV Club is don't buy a rust bucket....
Which rule does everyone forget 🤪
User avatar
Jack Bauer
Posts: 3564
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 93 times
Contact:

Re: Gen 3 inverter converter control software

Post by Jack Bauer »

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: Fri Jun 12, 2020 12:02 pm Lucky you doobedoobedo, I saw that one too, Im on the other side of the country so I paid a little extra for mine, but agreed the Yaris inverters are insanely cheap and I would be very surprised if the inverter was not as powerful as a gen2 prius inverter.

Based on JB Schematic (Note to JB the resistor values e.g. R41/42 need updating on the digram... but no rush as hopefully everyone here willing to undertake brain surgery on a inverter would at least read thread first) MG1 Current sensors are connected to pins 27/28 on the ATmega328P and then pins 1/2 on MG1 current sensor connector (via the usual resitor/divider).

From my point of view I am happy the help if I can on anything I can.
I was looking at the wrong schematic, the one on github V1, just been reading through the inverter charger thread and came across V1c which does indeed have curent sensors on those pins.
User avatar
rstevens81
Posts: 370
Joined: Sun Dec 22, 2019 10:36 am
Location: Bristol, UK
Has thanked: 28 times
Been thanked: 103 times

Re: Gen 3 inverter converter control software

Post by rstevens81 »

Ah feck... This is going to get confusing ... I was looking at the Yaris V2 diagram on github. Most of us seem to have Yaris inverters but we are talking on a Prius Inverter thread 🤔
Rule 1 of EV Club is don't buy a rust bucket....
Which rule does everyone forget 🤪
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: Fri Jun 12, 2020 7:26 pm Ah feck... This is going to get confusing ... I was looking at the Yaris V2 diagram on github. Most of us seem to have Yaris inverters but we are talking on a Prius Inverter thread 🤔
OK I see the Auris V2 schematic on github. Also current sensors on those pins - pretty sure that's the right one now - thanks.

From the threads I've been reading the prius and yaris inverters are very similar, which does make sense.
User avatar
Jack Bauer
Posts: 3564
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 93 times
Contact:

Re: Gen 3 inverter converter control software

Post by Jack Bauer »

So latest Auris is V2 and Prius V1c. Both are almost identical save the current sensor connectors and physical board size.
I'm going to need a hacksaw
User avatar
celeron55
Posts: 800
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 37 times
Been thanked: 131 times
Contact:

Re: Gen 3 inverter converter control software

Post by celeron55 »

Jack Bauer wrote: Sat Jun 13, 2020 8:29 am So latest Auris is V2 and Prius V1c. Both are almost identical save the current sensor connectors and physical board size.
Plopped the prius V1c board into my Yaris inverter. Here we go then.

The current sensor pinout is the same, right?
20200615_001107.jpg
EDIT: Yeah it is the same, no smoke and getting some readings!
20200615_024028.jpg
doobedoobedo
Posts: 260
Joined: Sat Jan 12, 2019 12:39 am
Location: UK

Re: Gen 3 inverter converter control software

Post by doobedoobedo »

Picked up the inverter today. It's considerably more compact than my leaf inverter considering everything that's in there.
User avatar
celeron55
Posts: 800
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 37 times
Been thanked: 131 times
Contact:

Re: Gen 3 inverter converter control software

Post by celeron55 »

Hmm... I feel like my Yaris inverter, on the scale from inverter to paperweight, just turned slightly more towards paperweight.

I connected it to my car in place of the previous hacky prius inverter charger for testing, with the intention of leaving it installed if it works.

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.

Now, to strip it off the car so that I can go on this trip I planned for tonight...
User avatar
Jack Bauer
Posts: 3564
Joined: Wed Dec 12, 2018 5:24 pm
Location: Ireland
Has thanked: 1 time
Been thanked: 93 times
Contact:

Re: Gen 3 inverter converter control software

Post by Jack Bauer »

Ouch! I can sympathise...
I'm going to need a hacksaw
Post Reply