Leaf Gen 1 Inverter Board
- Thatguyoverthere
- Posts: 34
- Joined: Fri Jun 28, 2019 5:04 am
- Location: California, USA
- Been thanked: 1 time
Re: Leaf Gen 1 Inverter Board
The "map" in the code takes the 145, 620 that you get from the ADC input (throttle) and makes a corresponding value from 0 to MaxTrq (maxtrq is defined later in the code as 2000). The 145, 620 are the values that the ATSAM sees that has been converted from the ADC input. Just as an example, the pedal might output 1.6v at 0% throttle, and the uc sees that 1.6v as 145. To calibrate the throttle, uncomment (remove the two //) in front of the serial println throtvalue and open your serial monitor to see what values you get.
https://github.com/kaelinwilson
Leaf Motor/Gen1 Camry Inverter
Leaf Motor/Gen1 Camry Inverter
- Thatguyoverthere
- Posts: 34
- Joined: Fri Jun 28, 2019 5:04 am
- Location: California, USA
- Been thanked: 1 time
Re: Leaf Gen 1 Inverter Board
I made a short video to try to explain the process for calibrating the throttle.
Here are the changes I made to the code.
This section,
I changed to:
Also this section,
I changed to:
to make the serial monitor easier to read.
You'll notice the values printed in the serial monitor have a wider range than what the code has constrained them to
---ThrotVal = constrain(ThrotVal, 145, 620) ----
This is so you can decide the usable range/travel from your throttle pedal, so set accordingly
Once you determine what range of values you want to use, replace them wherever there was 145, 620 in the .ino.
REMEMBER TO UNDO THE COMMENT/UNCOMMENT CHANGES BEFORE YOU UPLOAD THE NEW CODE! OTHERWISE THE THROTTLE MAY NOT WORK!
Here are the changes I made to the code.
This section,
Code: Select all
void readPedals()
{
ThrotVal = analogRead(Throttle1); //read throttle channel 1 directly
ThrotVal = constrain(ThrotVal, 145, 620);
ThrotVal = map(ThrotVal, 145, 620, 0, MaxTrq); //will need to work here for cal.
if(ThrotVal<0) ThrotVal=0; //no negative numbers for now.
if(digitalRead(Brake)) ThrotVal=0; //if brake is pressed we zero the throttle value.
//Serial.println(ThrotVal); //print for calibration.
}
Code: Select all
void readPedals()
{
ThrotVal = analogRead(Throttle1); //read throttle channel 1 directly
//ThrotVal = constrain(ThrotVal, 145, 620);
//ThrotVal = map(ThrotVal, 145, 620, 0, MaxTrq); //will need to work here for cal.
if(ThrotVal<0) ThrotVal=0; //no negative numbers for now.
if(digitalRead(Brake)) ThrotVal=0; //if brake is pressed we zero the throttle value.
Serial.println(ThrotVal); //print for calibration.
}
Code: Select all
digitalWrite(13,!digitalRead(13));//blink led every time we fire this interrrupt.
Serial.print(inv_volts_local);
Serial.print(F(" Volts"));
Serial.println();
Serial.println(HV_Flag);
Code: Select all
digitalWrite(13,!digitalRead(13));//blink led every time we fire this interrrupt.
//Serial.print(inv_volts_local);
// Serial.print(F(" Volts"));
// Serial.println();
// Serial.println(HV_Flag);
You'll notice the values printed in the serial monitor have a wider range than what the code has constrained them to
---ThrotVal = constrain(ThrotVal, 145, 620) ----
This is so you can decide the usable range/travel from your throttle pedal, so set accordingly
Once you determine what range of values you want to use, replace them wherever there was 145, 620 in the .ino.
REMEMBER TO UNDO THE COMMENT/UNCOMMENT CHANGES BEFORE YOU UPLOAD THE NEW CODE! OTHERWISE THE THROTTLE MAY NOT WORK!
https://github.com/kaelinwilson
Leaf Motor/Gen1 Camry Inverter
Leaf Motor/Gen1 Camry Inverter
- Jack Bauer
- Posts: 3661
- Joined: Wed Dec 12, 2018 5:24 pm
- Location: Ireland
- Has thanked: 10 times
- Been thanked: 335 times
- Contact:
- Cookie6000
- Posts: 247
- Joined: Wed May 08, 2019 9:27 am
- Location: Wicklow, IRL
- Has thanked: 12 times
- Been thanked: 33 times
- Contact:
Re: Leaf Gen 1 Inverter Board
That's brilliant.
Thanks for the detailed breakdown. Will have a go at that later
Thanks for the detailed breakdown. Will have a go at that later
Home of the #Audi8e - https://twitter.com/FiachraCooke
- james@N52E01
- Posts: 144
- Joined: Wed Sep 18, 2019 7:02 am
- Has thanked: 2 times
- Been thanked: 3 times
Re: Leaf Gen 1 Inverter Board
Thanks for the help so far, nearly ready to try turning the motor. I’ve been through the inverter and resolver plug wiring diagrams and everything appears to match with what is connected to the board. Does anyone know what the 5v and second ground connectors are for on the inverter plug? I can’t find corresponding wires on either the inverter or resolver connectors.
- Cookie6000
- Posts: 247
- Joined: Wed May 08, 2019 9:27 am
- Location: Wicklow, IRL
- Has thanked: 12 times
- Been thanked: 33 times
- Contact:
Re: Leaf Gen 1 Inverter Board
Hi James, like you, I have been digging around looking for the 5v source for the board. For now, I have been powering it externally from the breadboard ps.
The closest I got was when I had a look around the leaf board and found that the resolver temp senser sends 5v. From the board to the connector it is the WH BK wire. On the harness side, it is BK PK. When I last tried to use this as a power source for the board, it drops to 1v. Not sure but it may be down to me using the 2 grounds that leave this plug incorrectly? I did have them connected together for initial testing. Like you said, not sure where the 2nd ground is specifically meant to go.
The closest I got was when I had a look around the leaf board and found that the resolver temp senser sends 5v. From the board to the connector it is the WH BK wire. On the harness side, it is BK PK. When I last tried to use this as a power source for the board, it drops to 1v. Not sure but it may be down to me using the 2 grounds that leave this plug incorrectly? I did have them connected together for initial testing. Like you said, not sure where the 2nd ground is specifically meant to go.
Home of the #Audi8e - https://twitter.com/FiachraCooke
- Thatguyoverthere
- Posts: 34
- Joined: Fri Jun 28, 2019 5:04 am
- Location: California, USA
- Been thanked: 1 time
Re: Leaf Gen 1 Inverter Board
The 5v to leaf inverter might just be a spare? From the connector details it doesn't take 5v in, only 2 12v from the battery, 12v key on, and two 12v supply grounds. Also, Damiens board generates its own 5v supply rail, so no need to bring in any 5v to the board. In my configuration the only wires I've got taken out from the main connector are two sets of can wires (spliced from the factory) and the respective 12v, IGN, and grounds (2). Everything else I've left connected (I did untape the entire harness to make things a bit easier).
https://github.com/kaelinwilson
Leaf Motor/Gen1 Camry Inverter
Leaf Motor/Gen1 Camry Inverter
- Cookie6000
- Posts: 247
- Joined: Wed May 08, 2019 9:27 am
- Location: Wicklow, IRL
- Has thanked: 12 times
- Been thanked: 33 times
- Contact:
Re: Leaf Gen 1 Inverter Board
Yes
Correct on the 5v from the board. Just figured that out yesterday when wondering why i was stuck feeding it external 5v via usb to power it. After reviewing the build in design spark, and doing a bit of testing I realised I had the step down reg pin for the 5vcc o/p was not touching the pad.
Fixed now
I did the calibration method you described btw and it worked perfectly. Thanks for the help. Results for the Leaf pedal
CH1 0.4v - 1.95v (35 to 150)
CH2 0.8v - 3.9v (74 to 358)
Correct on the 5v from the board. Just figured that out yesterday when wondering why i was stuck feeding it external 5v via usb to power it. After reviewing the build in design spark, and doing a bit of testing I realised I had the step down reg pin for the 5vcc o/p was not touching the pad.
Fixed now
I did the calibration method you described btw and it worked perfectly. Thanks for the help. Results for the Leaf pedal
CH1 0.4v - 1.95v (35 to 150)
CH2 0.8v - 3.9v (74 to 358)
Home of the #Audi8e - https://twitter.com/FiachraCooke
- mackoffgrid
- Posts: 94
- Joined: Thu Jan 02, 2020 10:18 am
- Location: Brisbane Australia
- Has thanked: 6 times
- Been thanked: 1 time
Re: Leaf Gen 1 Inverter Board
I'm hoping to receive my gen1 motor in a week or so. I haven't got the batteries for the conversion yet. What battery voltage do I need to spin the em61 on the bench using the LEAF VCU ? - I'm hoping I can use 24 or 48v.
- Cookie6000
- Posts: 247
- Joined: Wed May 08, 2019 9:27 am
- Location: Wicklow, IRL
- Has thanked: 12 times
- Been thanked: 33 times
- Contact:
Re: Leaf Gen 1 Inverter Board
Hey
I do not know what the lower limit to enable the Inverter to spin the motor but I'm doing my testing from a 220v Prius pack and the original protocol by 8dromeda (http://productions.8dromeda.net/c55-lea ... tocol.html) refers to a min voltage of 140v
1. Switch on 12V power
2. Start sending CAN messages within 2s, preferably instantly
3. Finish precharging to at least 140V within 10s of switching the power on...
I know that Shane of Performance EV converting the Porsche Boxster used 18 x 12v mobility scooter batteries during testing to give him just above 216v which might be an option if you can land some of these used.
I do not know what the lower limit to enable the Inverter to spin the motor but I'm doing my testing from a 220v Prius pack and the original protocol by 8dromeda (http://productions.8dromeda.net/c55-lea ... tocol.html) refers to a min voltage of 140v
1. Switch on 12V power
2. Start sending CAN messages within 2s, preferably instantly
3. Finish precharging to at least 140V within 10s of switching the power on...
I know that Shane of Performance EV converting the Porsche Boxster used 18 x 12v mobility scooter batteries during testing to give him just above 216v which might be an option if you can land some of these used.
Home of the #Audi8e - https://twitter.com/FiachraCooke
- mackoffgrid
- Posts: 94
- Joined: Thu Jan 02, 2020 10:18 am
- Location: Brisbane Australia
- Has thanked: 6 times
- Been thanked: 1 time
Re: Leaf Gen 1 Inverter Board
Thank Cookie
So 220V works, maybe 140V.
I don't think Shane at Performance EV is using the LEAF VCU, opting for Heubner's inverter instead (?)
So 220V works, maybe 140V.
I don't think Shane at Performance EV is using the LEAF VCU, opting for Heubner's inverter instead (?)
- Cookie6000
- Posts: 247
- Joined: Wed May 08, 2019 9:27 am
- Location: Wicklow, IRL
- Has thanked: 12 times
- Been thanked: 33 times
- Contact:
Re: Leaf Gen 1 Inverter Board
Yep, he is using Johannes' board alright but as Speedy said, there may be a min voltage required of ~150v to get the inverter board to start communicating,mackoffgrid wrote: ↑Mon Apr 20, 2020 10:54 pm
I don't think Shane at Performance EV is using the LEAF VCU, opting for Heubner's inverter instead (?)
Home of the #Audi8e - https://twitter.com/FiachraCooke
- johu
- Site Admin
- Posts: 6713
- Joined: Thu Nov 08, 2018 10:52 pm
- Location: Kassel/Germany
- Has thanked: 369 times
- Been thanked: 1543 times
- Contact:
Re: Leaf Gen 1 Inverter Board
Equipped with the V3 logic board there is no minimum voltage requirement.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
- james@N52E01
- Posts: 144
- Joined: Wed Sep 18, 2019 7:02 am
- Has thanked: 2 times
- Been thanked: 3 times
Re: Leaf Gen 1 Inverter Board
Made some progress with the VCU board. Just got WiFi working
I went through the leaf_wifi.ino code and solid-gauge.js looks like it’s missing from the GitHub repository:
https://github.com/damienmaguire/Nissan ... /WiFi/Data
(you can get it from any of the other WiFi board repositories used here)
The VCU board Is now working with V1.5 software. As you can see the Voltage, Current and Power info is not showing on the WiFi Yes as I still need an ISA shunt.
I’m still having trouble with pre-charging. Looking at the code it seems simple enough, just set the voltage level that you want the main contractor to engage and when you send the 12v ignition signal through IN1, the pre-charge contactor and Main contactor should engage through OUT1 and OUT2. So far not getting any output from either pin.

https://github.com/damienmaguire/Nissan ... /WiFi/Data
(you can get it from any of the other WiFi board repositories used here)
The VCU board Is now working with V1.5 software. As you can see the Voltage, Current and Power info is not showing on the WiFi Yes as I still need an ISA shunt.
I’m still having trouble with pre-charging. Looking at the code it seems simple enough, just set the voltage level that you want the main contractor to engage and when you send the 12v ignition signal through IN1, the pre-charge contactor and Main contactor should engage through OUT1 and OUT2. So far not getting any output from either pin.
- Kevin Sharpe
- Posts: 1339
- Joined: Fri Dec 14, 2018 9:24 pm
- Location: Ireland and US
- Been thanked: 8 times
Re: Leaf Gen 1 Inverter Board
Congratulationsjames@N52E01 wrote: ↑Tue Apr 28, 2020 11:14 am Made some progress with the VCU board. Just got WiFi working![]()

Thanks for the feedback! I posted an issue on GitHub for future referencejames@N52E01 wrote: ↑Tue Apr 28, 2020 11:14 am I went through the leaf_wifi.ino code and solid-gauge.js looks like it’s missing from the GitHub repository:
https://github.com/damienmaguire/Nissan ... /WiFi/Data
(you can get it from any of the other WiFi board repositories used here)

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.
- Cookie6000
- Posts: 247
- Joined: Wed May 08, 2019 9:27 am
- Location: Wicklow, IRL
- Has thanked: 12 times
- Been thanked: 33 times
- Contact:
Re: Leaf Gen 1 Inverter Board
Great work James. Got me over the hump. I'm seeing the same as you now on the web interfacejames@N52E01 wrote: ↑Tue Apr 28, 2020 11:14 am I’m still having trouble with pre-charging. Looking at the code it seems simple enough, just set the voltage level that you want the main contractor to engage and when you send the 12v ignition signal through IN1, the pre-charge contactor and Main contactor should engage through OUT1 and OUT2. So far not getting any output from either pin.
I am also stuck at the same point as you. I have 12v going into IN1 and I trace the voltage all the way over to R14 where it drops to 3v and off to the chip. Tried various times and get nothing out on OP1, 2 or 3 yet. As with James, I'm working through the code to see if I have missed anything.
Home of the #Audi8e - https://twitter.com/FiachraCooke
- Jack Bauer
- Posts: 3661
- Joined: Wed Dec 12, 2018 5:24 pm
- Location: Ireland
- Has thanked: 10 times
- Been thanked: 335 times
- Contact:
Re: Leaf Gen 1 Inverter Board
You have actually answered your own question if you have a think:)
"As you can see the Voltage, Current and Power info is not showing on the WiFi Yes as I still need an ISA shunt."
"I’m still having trouble with pre-charging. "
Join the dots folks....
"As you can see the Voltage, Current and Power info is not showing on the WiFi Yes as I still need an ISA shunt."
"I’m still having trouble with pre-charging. "
Join the dots folks....
I'm going to need a hacksaw
- Jack Bauer
- Posts: 3661
- Joined: Wed Dec 12, 2018 5:24 pm
- Location: Ireland
- Has thanked: 10 times
- Been thanked: 335 times
- Contact:
Re: Leaf Gen 1 Inverter Board
But you can cheat and use the voltage read by the inverter :
Code: Select all
void HV_Con()
{
inv_volts_local=(inverter_status.voltage / INVERTER_BITS_PER_VOLT);
if (T15Status && !Pch_Flag) //if terminal 15 is on and precharge not enabled
{
digitalWrite(OUT3, HIGH); //inverter power on
if(inv_volts_local<200)
{
digitalWrite(OUT1, HIGH); //precharge on
Pch_Flag=true;
}
}
if (T15Status && !HV_Flag && Pch_Flag) //using inverter measured hv for initial tests. Will use ISA derived voltage in final version.
{
if (inv_volts_local>340)
{
digitalWrite(OUT2, HIGH); //main contactor on
HV_Flag=true; //hv on flag
}
}
if (!T15Status)
{
digitalWrite(OUT1, LOW); //precharge off
digitalWrite(OUT2, LOW); //main contactor off
digitalWrite(OUT3, LOW); //inverter power off
}
}
I'm going to need a hacksaw
- james@N52E01
- Posts: 144
- Joined: Wed Sep 18, 2019 7:02 am
- Has thanked: 2 times
- Been thanked: 3 times
- james@N52E01
- Posts: 144
- Joined: Wed Sep 18, 2019 7:02 am
- Has thanked: 2 times
- Been thanked: 3 times
Re: Leaf Gen 1 Inverter Board
I've just checked through the code in V1.5 which Fiachra and I are both using, which is the same code as you have just posted. It looks like everything is based on inv_volts_local and not the ISA Shunt. This is the code I'm using (only changes I have made are the numbers as I'm using a 48s pack for testing)
I know this is going to be something obvious we're doing wrong so thanks for baring with us.
Code: Select all
void HV_Con()
{
inv_volts_local=(inverter_status.voltage / INVERTER_BITS_PER_VOLT);
if (T15Status && !Pch_Flag) //if terminal 15 is on and precharge not enabled
{
digitalWrite(OUT3, HIGH); //inverter power on
if(inv_volts_local<144)
{
digitalWrite(OUT1, HIGH); //precharge on
Pch_Flag=true;
}
}
if (T15Status && !HV_Flag && Pch_Flag) //using inverter measured hv for initial tests. Will use ISA derived voltage in final version.
{
if (inv_volts_local>170)
{
digitalWrite(OUT2, HIGH); //main contactor on
HV_Flag=true; //hv on flag
}
}
if (!T15Status)
{
digitalWrite(OUT1, LOW); //precharge off
digitalWrite(OUT2, LOW); //main contactor off
digitalWrite(OUT3, LOW); //inverter power off
}
}
- Kevin Sharpe
- Posts: 1339
- Joined: Fri Dec 14, 2018 9:24 pm
- Location: Ireland and US
- Been thanked: 8 times
Re: Leaf Gen 1 Inverter Board
What pack voltage do you measure with a multimeter?
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.
- james@N52E01
- Posts: 144
- Joined: Wed Sep 18, 2019 7:02 am
- Has thanked: 2 times
- Been thanked: 3 times
- Cookie6000
- Posts: 247
- Joined: Wed May 08, 2019 9:27 am
- Location: Wicklow, IRL
- Has thanked: 12 times
- Been thanked: 33 times
- Contact:
Re: Leaf Gen 1 Inverter Board
Similar to James
I have just amended the HV values for the pack I am using. Multimeter measured it comes in at 209V. Following the logic, if T15 is receiving 12v (switched IGN) but Precharge is not enabled, OUT3 and OUT1 will be set to HIGH if inv_volts_local is <180, in my case.
I can see what Damien is getting at, needing to know the HV values to get the VCU to activate OP1 to 3 but, how without the Shunt or having the inverter powered on first?
I did try removing the if(inv_volts_local<180) from the steps by adding // before it, thinking it might remove this step, therefore just setting OP1 and OP3 to HIGH but nothing.
I have just amended the HV values for the pack I am using. Multimeter measured it comes in at 209V. Following the logic, if T15 is receiving 12v (switched IGN) but Precharge is not enabled, OUT3 and OUT1 will be set to HIGH if inv_volts_local is <180, in my case.
I can see what Damien is getting at, needing to know the HV values to get the VCU to activate OP1 to 3 but, how without the Shunt or having the inverter powered on first?
Code: Select all
void HV_Con()
{
inv_volts_local=(inverter_status.voltage / INVERTER_BITS_PER_VOLT);
if (T15Status && !Pch_Flag) //if terminal 15 is on and precharge not enabled
{
digitalWrite(OUT3, HIGH); //inverter power on
if(inv_volts_local<180)
{
digitalWrite(OUT1, HIGH); //precharge on
Pch_Flag=true;
}
}
if (T15Status && !HV_Flag && Pch_Flag) //using inverter measured hv for initial tests. Will use ISA derived voltage in final version.
{
if (inv_volts_local>205)
{
digitalWrite(OUT2, HIGH); //main contactor on
HV_Flag=true; //hv on flag
}
}
if (!T15Status)
{
digitalWrite(OUT1, LOW); //precharge off
digitalWrite(OUT2, LOW); //main contactor off
digitalWrite(OUT3, LOW); //inverter power off
}
Home of the #Audi8e - https://twitter.com/FiachraCooke
- Kevin Sharpe
- Posts: 1339
- Joined: Fri Dec 14, 2018 9:24 pm
- Location: Ireland and US
- Been thanked: 8 times
Re: Leaf Gen 1 Inverter Board
I don't know anything about the detailed operation of the inverter but agree this does sound odd. What happens if you enable the inverter by driving OUT3 high when the key is on (i.e. without any dependence on the inverter messages)?Cookie6000 wrote: ↑Wed Apr 29, 2020 1:30 pm I can see what Damien is getting at, needing to know the HV values to get the VCU to activate OP1 to 3 but, how without the Shunt or having the inverter powered on first?
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.