Toyota Gen 3 inverter charger

Topics concerning the Toyota and Lexus inverter drop in boards
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Toyota Gen 3 inverter charger

Post by arber333 »

I succesfully connected battery and mains together to Prius inverter with my interface. Both voltage readout and reporting works through UART.
I made a simple current sensor setup. I soldered my 50A sensor to positive rail and then cut this rail and glued an isolated material underside it. Current sensor reporting works, i tested it with 12V 25A load.
I was not succesful in ordering charger to start providing 5A to 280Vdc battery from 320V rectified mains. I think i have setup my interface with too many safeties. One of them (UVLO) is acting up.
EDIT1: DOH! it is really simple. Charger doesnt work because i didnt connect BMS and EOC pins in a loop. This loop needs to be connected in order for the charger to work. Very simple BMS can be used with this loop.

EDIT2: I also noticed -5 voltage regulator is used to provide reference to HV side voltage reporting. Battery side voltage can work with regular 5Vdc.
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: Toyota Gen 3 inverter charger

Post by celeron55 »

I think you could connect N to an unused phase of the second motor. It will do nothing as long as all three phases are connected as N is always lower in voltage than the highest phase and higher in voltage than the lowest phase, and if battery voltage is too high for buck 1-phase charging, nothing bad will happen, you just can't get current flowing towards the battery. That means that it could be useful as emergency charging even for a pack with a full voltage somewhat higher than rectified 1-phase.
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Toyota Gen 3 inverter charger

Post by arber333 »

Hm... i may try tonight!

I actually use the kind of system for emergency charging from single phase. BUT i connect N line onto the middle junction of my capacitor bank. This upps the voltage from 320V to 640V rectified. A voltage doubler so to speak. i use it so i have an option to buck 400V battery from single phase source.
However Prius main cap cant be center tapped. It is one brick. I am not sure how this will work.

I did try to connect 3phase bridge and another single phase bridge in paralel before and it ended in fuses throwing the towel the instant charger started.
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: Toyota Gen 3 inverter charger

Post by celeron55 »

You will get a lot of current ripple by rectifying single phase without a power factor correction circuit, so you might not be able to use full current according to fuses. It's quite naughty from the power grid's perspective.

Commercial 1-phase EV chargers always have a PFC circuit.

For 3 phase that's not an issue, as rectified 3 phase current is fairly constant.
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Toyota Gen 3 inverter charger

Post by arber333 »

Yes that is why I almost always use 3phase. 1ph is emergency only. R Zoe does not recommend to use single phase charging. Their charger is basically the same...
My current charger is maybe 75% efficient due to lousy inductor but I use it at 11kw as well as up to 15kw.
I expect prius to do 20kW and be a lot more convenient.
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Toyota Gen 3 inverter charger

Post by arber333 »

I must thank to Dima and Johannes for their intervention at my feeble attempts to reprogramm Wifi module.
I had a clear vision of my goal, just not the skill to get it.

In the end Dima presented a solution which looks good and works good enough to be used on working charger as well as in development.
https://github.com/dimecho/ESP8266-EMW-Charger
EMWcharger.png
There are some bugs to iron out still, but i used it today and i must say i went to drive my car just to spend kWh to see how it will charge.
Actually i will append flash code and spiff files here since they are the ones that work best.

When charger is connected it will start spitting serial data. We use that data o find out its parameters.
Also a serial string is used to command charger how much Amps at which Volts to charge.
There is a STOP button and START button.

This can be used on mobile, laptop or PC regardless of software platform...
Attachments
ESP8266-EMW-Charger.rar
(6.73 MiB) Downloaded 115 times
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Toyota Gen 3 inverter charger

Post by arber333 »

JB i strongly suggest to review your Prius inverter design and its Atmega 328 chip pinout.
EMW charger uses exactly the same chip and is actually proven to work. Now we also got a working interface so we do not depend on the expensive uLCD and buttons on wires.

General schematics of V14 unit is appended. Also a review of serial comms. And finally the code.
It is fully PID control loop so current swings are measured in 0.1A!
Though original resistor divider sensing precision leaves something to be desired but Prius code sends stable signal all the way to 400Vdc!
Attachments
EMotorWerksChargers-Serialprotocol.pdf
(76.35 KiB) Downloaded 152 times
Control_Board_Schematic_V14.pdf
(122.26 KiB) Downloaded 154 times
VMCharger_V14_7.zip
(20.71 KiB) Downloaded 129 times
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: Toyota Gen 3 inverter charger

Post by Jack Bauer »

So you have this running Arber? Great news if so. No problem modding the layout. Another benefit of JLC.
I'm going to need a hacksaw
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Toyota Gen 3 inverter charger

Post by arber333 »

First I had to get a reliable interface to have 100% control over new charger.
No I haven't charged with it yet. I made an AC circuit with precharge resistors and contactor. On DC side I am thinking of DC contactor as well.
I tried various scenarios with my working EMW charger. Also I increased its power from 11kw to 16kw! Not bad for air cooled unit.
Hopefully this weekend I will charge mazda with new charger.
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: Toyota Gen 3 inverter charger

Post by celeron55 »

For what it's worth, in my total hack of an implementation I'm using the atmega328 PB2/OC1B pin (arduino pin 10) as boost high side PWM output and low side would be PB1/OC1A (arduino pin 9) if I were to use low side. Timer 1 is a nice oscillator with lots of options for this purpose.

My ADC inputs from the inverter are as follows. These are Arduino pin names which translate to the atmega328 PC0...PC5, A6 and A7 pins:
- A0: DCBUS1 (output side, i.e. where the battery in a Prius is)
- A1: DCBUS2 (input side, i.e. MG1/MG2 HV rail)
- A2: Not in ADC use
- A3: MG2 L1 current (10k/10k resistor divider)
- A4: MG2 L2 current (10k/10k resistor divider)
- A5: BOOST T1
- A6: BOOST T2
- A7: COOLANT T

In my design all the remaining pins are used for CANbus module SPI, EVSE PWM input/output and main + precharge contactor output (to precharge the charger input HV rail).

Actually I'm using another atmega328 on SPI bus to read EVSE PWM and UI buttons as the main chip is too busy talking CHAdeMO :D but with tighter code and no CHAdeMO output that shouldn't be necessary.

Current control is rough as current is measured only at the input side, but this does work when you don't want to add any special components.

Controlling the boost converter with PWM synchronized ADC and canbus communication does keep the 8-bit chip quite busy and it also eats all the pins, maybe something more powerful like the STM32 would be a better idea.

Is this the EMW charger code? https://github.com/dmills483/EMW-charge ... 21_V06.pde
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: Toyota Gen 3 inverter charger

Post by Jack Bauer »

I'm happy to redo the board if we all agree on a common design.
I'm going to need a hacksaw
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Toyota Gen 3 inverter charger

Post by arber333 »

celeron55 wrote: Thu Jan 23, 2020 7:37 pm My ADC inputs from the inverter are as follows. These are Arduino pin names which translate to the atmega328 PC0...PC5, A6 and A7 pins:
- A0: DCBUS1 (output side, i.e. where the battery in a Prius is)
- A1: DCBUS2 (input side, i.e. MG1/MG2 HV rail)
- A2: Not in ADC use
- A3: MG2 L1 current (10k/10k resistor divider)
- A4: MG2 L2 current (10k/10k resistor divider)
- A5: BOOST T1
- A6: BOOST T2
- A7: COOLANT T

Is this the EMW charger code? https://github.com/dmills483/EMW-charge ... 21_V06.pde
What you quote is an old code for EMW charger, maybe V12 with no serial link and no PID interface. Current swings in the old version move as high as +/-5A. And you have to control it through a LCD with 2 button interface with long cable where buttons were tripped by themselves occasionally.

More modern code V14.7 i published couple of posts back. It includes LCD and serial interface, PID code and remapped pins to vary PWM frequency more and use more of the chip EEPROM for actual work.

EMW works by boosting single phase to 450Vdc and then bucking it to whatever is needed. That is why they use PFC chip to run the boost transistor at fixed output. Code only needs to control buck transistor. Boost is HW controlled.
Ok Here is the current pinout for AT328 in V14.7:
//========== analog pins
pin_C=0; // output current pin,
pin_bV=1; // output / battery voltage pin
pin_heatSinkT=2; // charger heatsink temp - for thermal derating
pin_12Vsense=3; // implementing undervoltage protection
pin_temp2=4; // spare pin prewired as temp input
pin_mV=5; // mains HV voltage sense pin
// const byte pin_mC=7; // needed only for full digital PFC control
//========== digital pins
// 0/1 reserved for serial comms with display etc
pin_pwrCtrlButton=2; // this is wired to the button1
pin_pwrCtrl2Button=3; // this is wired to the button2
pin_inrelay=4; // AC relay - precharge is prewired by 3x 330R 20W resistors across contactor
pin_outrelay=5; // output relay - this is needed for CHAdeMO
pin_DELTAQ=6; // deltaQ pin that was meant to get a digital enable to operate
pin_J1772=7; // J1772 pilot input. 1k is hardwired on V14+ pcbs so J1772 will power on on connect
pin_fan=8; // fan control or water pump control
pin_PWM=9; // main PWM pin!
byte pin_110relay=11; //We dont use this, can we use it for anything else?
pin_maxC=10; // max current reference voltage so that we can use higher PWM frequency 20kHz PWM
pin_EOC=12; // end-of-charge output (see pinout diagram) - pulled low when charge is complete
pin_BMS=13; // end-of-charge input from BMS. Pull low / disconnect from positive TTL signal to activate

This pinout was developed after quite a few versions and i find it to be most effective in 3phase buck configuration. No PFC needed then.
Yes even driving Chademo was considered with this charger, but like you said Arduino due was used because of more power. That code was proprietary.
But Prius inverter now can drive boost with very little HW changes.

I still think we do not need to reinvent the wheel for the first iteration. Code has already been written and at least in Europe 3phase is common for EVSE L2. Thus it will involve less programming work and people will understand it better. We can have a fully functioning product with nice interace out there soon and then work on Chademo unit with big processor and functions.
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: Toyota Gen 3 inverter charger

Post by celeron55 »

Under what license is the newest EMW charger code provided?

EDIT: Looks like it's not really a free license, and definitely not any well known one:
This software is released as open source and is free for any personal use.
Commercial use prohibited without written approval from the Author and / or Emotorwerks
Absolutely no warranty is provided and no guarantee for fit for a specific purpose

Original version created Jan 2011 by Valery Miftakhov, Electric Motor Werks, LLC & Inc.
All rights reserved. Copyright 2014
At some point we need some real open source software for charging that anyone can use freely. This one you need to ask for permission from EMW if you're doing a project for anyone other than yourself. Even a non-profit school project would require permission to be asked. Or if you sell your personal EV conversion in which you used the code.
MattsAwesomeStuff
Posts: 898
Joined: Fri Apr 26, 2019 5:40 pm
Has thanked: 291 times
Been thanked: 177 times

Re: Toyota Gen 3 inverter charger

Post by MattsAwesomeStuff »

celeron55 wrote: Fri Jan 24, 2020 9:31 amThis one you need to ask for permission from EMW if you're doing a project for anyone other than yourself.
Language barrier perhaps, but I don't think that's what's meant by "personal use". Personal use covers helping others.
Even a non-profit school project would require permission to be asked.
Under the Bern Convention (just about every country in the world has signed), there are agreed exemptions for copyright. One is educational use. A for-profit school would probably still be fine.
Or if you sell your personal EV conversion in which you used the code.
No, I don't think that's an issue. Something can be for personal use, and still sold.

"Commercial use" in common context would be like an EV shop selling them. Running a business that sells things is different than an individual who built their own vehicle that they owned, and then chose to sell the vehicle.

Regardless of license, factors for copyright exemption still apply. Also, every country defines and weighs these factors differently (for example, I believe either Spain or Switzerland put almost the entire weight on commercial use, so, for example, if you're pirating movies or music and not selling it, any copyright case is dead in the water. In the US, not as much so).

Also, they might've shot themselves in the foot by even using the term Open Source without a more expansive detailing of the license itself.

https://en.wikipedia.org/wiki/The_Open_ ... Definition

Anyway, a real open source project would be nice.
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Toyota Gen 3 inverter charger

Post by arber333 »

celeron55 wrote: Fri Jan 24, 2020 9:31 am Under what license is the newest EMW charger code provided?

EDIT: Looks like it's not really a free license, and definitely not any well known one:
This software is released as open source and is free for any personal use.
Commercial use prohibited without written approval from the Author and / or Emotorwerks
Absolutely no warranty is provided and no guarantee for fit for a specific purpose

Original version created Jan 2011 by Valery Miftakhov, Electric Motor Werks, LLC & Inc.
All rights reserved. Copyright 2014
At some point we need some real open source software for charging that anyone can use freely. This one you need to ask for permission from EMW if you're doing a project for anyone other than yourself. Even a non-profit school project would require permission to be asked. Or if you sell your personal EV conversion in which you used the code.
Yeah well it is technically open source with limitations. But EMW is now not even a company brand https://evcharging.enelx.com/.
I can ask Valery if our community can further develop his work.
EDIT: Every aspect of V14 design is/was open to the public. Nothing hidden, not even the R2 uLCD protocol which Valery had quite some pains with.

I agree though if we want to make DIY portable L2 3phase chademo charger we need a new HW and SW base.
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: Toyota Gen 3 inverter charger

Post by celeron55 »

If they can release the code under a well known license without limitations, it could be a good base for further development. Otherwise it can be a stepping stone but new code has to be written from scratch, or maybe based on my code that I haven't released yet, or someone else's.

I don't know if CHAdeMO is a good goal for this at all, it's difficult to implement properly and not really useful for most EV projects.
User avatar
Kevin Sharpe
Posts: 1345
Joined: Fri Dec 14, 2018 9:24 pm
Location: Ireland and US
Been thanked: 4 times

Re: Toyota Gen 3 inverter charger

Post by Kevin Sharpe »

celeron55 wrote: Fri Jan 24, 2020 1:01 pm I don't know if CHAdeMO is a good goal for this at all, it's difficult to implement properly and not really useful for most EV projects.
Agreed... why not focus on CCS which is clearly the way forward for the DC interface to the EV 8-)
This is a personal post and I disclaim all responsibility for any loss or damage which any person may suffer from reliance on the information and material in this post or any opinion, conclusion or recommendation in the information and material.
User avatar
Kevin Sharpe
Posts: 1345
Joined: Fri Dec 14, 2018 9:24 pm
Location: Ireland and US
Been thanked: 4 times

Re: Toyota Gen 3 inverter charger

Post by Kevin Sharpe »

arber333 wrote: Fri Jan 24, 2020 12:45 pm EDIT: Every aspect of V14 design is/was open to the public. Nothing hidden, not even the R2 uLCD protocol which Valery had quite some pains with.
License is explicit though... no point putting effort into something that has these license restrictions.
This is a personal post and I disclaim all responsibility for any loss or damage which any person may suffer from reliance on the information and material in this post or any opinion, conclusion or recommendation in the information and material.
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: Toyota Gen 3 inverter charger

Post by Jack Bauer »

I think the oppertunity presented by the Prius/Yaris inverter for motor control and charging is too good to pass up. A few options :

1)Use EMW code for development proof of concept. As arber says we know it works and that use does not violate the license.
2)Perhaps use Johannes inverter charger code and an STM32 device in the next rev.
I'm going to need a hacksaw
martii
Posts: 10
Joined: Fri Mar 22, 2019 10:07 am
Has thanked: 2 times

Re: Toyota Gen 3 inverter charger

Post by martii »

celeron55 wrote: Fri Jan 24, 2020 1:01 pm I don't know if CHAdeMO is a good goal for this at all, it's difficult to implement properly and not really useful for most EV projects.
CHAdeMO is way easier to implement (just CAN) compared to CCS that needs some PLC device (more expensive?) and full TCP stack AFAIK.
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: Toyota Gen 3 inverter charger

Post by celeron55 »

Kevin Sharpe wrote: Fri Jan 24, 2020 1:04 pm
celeron55 wrote: Fri Jan 24, 2020 1:01 pm I don't know if CHAdeMO is a good goal for this at all, it's difficult to implement properly and not really useful for most EV projects.
Agreed... why not focus on CCS which is clearly the way forward for the DC interface to the EV 8-)
martii wrote: Fri Jan 24, 2020 5:39 pm
celeron55 wrote: Fri Jan 24, 2020 1:01 pm I don't know if CHAdeMO is a good goal for this at all, it's difficult to implement properly and not really useful for most EV projects.
CHAdeMO is way easier to implement (just CAN) compared to CCS that needs some PLC device (more expensive?) and full TCP stack AFAIK.
Well I didn't mean that. What I mean is CHAdeMO simply isn't a good application for this Toyota inverter charger project due to it not being directly suited for it. (And I hate CCS, but that's not the topic of this discussion. The inverter is even less suitable for CCS of course.)
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: Toyota Gen 3 inverter charger

Post by celeron55 »

Back to the actual topic at hand:

If I were to design the boost converter section with charging in mind, I would make sure it's capable of working as a charger independently of the STM32 motor control portion. I also like to integrate things on CANbus.

This makes it important for the charger atmega328 to:
- have its own access to the CANbus (maybe MCP2515 + some PHY) and
- be able to directly ADC the
- input and output voltage
- the MG1 currents
- the boost and coolant temperatures and
- read the EVSE PWM signal (with correct diode+pulldown to activate an EVSE).
- In addition to that it needs an analog input for an extra current sensor at the output when accurate current control is desired (I think the EMW software requires this sensor).
- I guess some users want to have some buttons or an LED directly wired to it. Personally I would just implement charger UI on some display device on the CANbus.

The exact pinout doesn't really matter as long as
- a high resolution PWM pin is connected to the half bridge high side input and
- the EVSE PWM is connected to an external interrupt capable pin.
- If I can have my MCP2515, it of course has to live at the SPI pins.
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: Toyota Gen 3 inverter charger

Post by Jack Bauer »

That's all very doable.
I'm going to need a hacksaw
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Toyota Gen 3 inverter charger

Post by arber333 »

I am not inclined of using Prius current sensors for charger function. It is on the wrong side and the mechanism which would control output definitely has some phase shift. Not a good idea anyways also for CAN control.

My application is designed around ACS758LCB-100U sensor. I am sure we wont need more :).
What i did is solder the ACS758LCB-100U onto the positive battery track of large cap and then used dremel cutter to cut the track between sensor prongs. Then i reinforced the joint with some PCB plastic sheet and generous ammount of gasket sealant. Sealant hardens and provides good adhesion to reinforce soldered track against vibration.
IMG_20200124_210049.jpg
IMG_20200124_210104.jpg
Charger board design includes space for 3x relays. One AC/DC relay, one liquid pump relay and enable relay for DCDC part and interlock function. This means if i have connected charger then car wont drive as well as charger wont function if car is started.
IMG_20200124_210123.jpg
Another option would be to cut/remove the positive track from the cap and use a 10mm2 cable and 100A rated 5V hall current sensor. It would require some calibration in software but would maybe be cleaner installation. See here how i would cut positive track from Yaris cap and install cable from that bolt to positive battery connection. Current sensor could be some 100A LEM on the side.
IMG_20200124_211552.jpg
arber333
Posts: 3265
Joined: Mon Dec 24, 2018 1:37 pm
Location: Slovenia
Has thanked: 80 times
Been thanked: 234 times
Contact:

Re: Toyota Gen 3 inverter charger

Post by arber333 »

celeron55 wrote: Fri Jan 24, 2020 5:49 pm Well I didn't mean that. What I mean is CHAdeMO simply isn't a good application for this Toyota inverter charger project due to it not being directly suited for it. (And I hate CCS, but that's not the topic of this discussion. The inverter is even less suitable for CCS of course.)
What would be your caveat in using Chademo protocol with Toyota inverter chargers? I think f we use charger as the source of CC at specified voltage that is drawn from 3phase home charging plug directly into a Leaf then we got a winner.
Not only is the Leaf charged at fast 11kW rate also the network doesnt suffer since the load is then much more uniform.
also you could charge at 22kW at L2 EVSE directly into a chademo port. Only Zoe and Smart EV have such a fast L2 charging capability as far as i know.

Now last one is a bit stretched, but what about open chademo V2G and V2H? This charger would suitt perfectly if we would implement Boost-Buck function in the same process. But i think this could be made only with STM32 or similar chip.
Post Reply