Page 4 of 14

Re: Leaf Gen 1 Inverter Board

Posted: Sun Mar 29, 2020 9:14 am
by Jack Bauer
So as we now seem to have a complete lack of understanding coupled with confusion as to how the Leaf VCU works i'll jump in here and try my best to explain. I hesitiate as it seems sometimes that for every answer I give two more questions pop up but here goes.

1) The Leaf VCU is designed to run a Gen1 or Gen2 Nissan Leaf inverter and motor in stock form via CAN messages. No inverter modifications are required.

2)The Leaf VCU DOES NOT operate with the openinverter WiFi interface.

3)A pinout for the connectors on the VCU is provided here : https://github.com/damienmaguire/Nissan ... Pinout.pdf

In order to configure the VCU to run your motor it is necessary to modify the software to accept your throttle input. The VCU provides for single or dual channel throttle pedals and in its stock for on github is configured for a BMW E46 hall effect pedal. In order to change this the subroutine responsible for reading the pedal input will need to be modified. Here is the routine :

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.
}

Once this has been done the VCU will now respond to throttle commands and send torque requests to the inverter.

the latest firmware on github looks for a 12v input on IN1 as a start request. It will then control the precharge and main contactors and inverter power via the three low side driver outputs OUT1,2 and 3 as per the comments in the code.

WiFi : A web interface via wifi that runs on the same Olimex ESP8266 module as the openinverter has been released on github. Once loaded and powered up a wifi access point called wifipowernet will appear. Connect to this and goto 192.168.4.1 to see the interface. Goto 192.168.4.1/admin to change the wifi access point settings.

ISA CAN Shunt : The latest release firmware also provides for connectivity with the ISA Can shunt for data display over the wifi interface.

I have created a task here requesting help with documentation etc not that I really expect much :
viewtopic.php?f=18&t=643

I can't explain everything to everyone.

Re: Leaf Gen 1 Inverter Board

Posted: Sun Mar 29, 2020 10:22 am
by Cookie6000
Appreciate it Jack
I am 95% there, everything connected up as it should. This fills in the last few gaps including the use of an alternative pedal. If it helps, I will work on a step by step for the Open Tasks Leaf VCU thread you just started from the aspect of my build to date.

Re: Leaf Gen 1 Inverter Board

Posted: Sun Mar 29, 2020 10:43 am
by Jack Bauer
Much appreciated:)

Re: Leaf Gen 1 Inverter Board

Posted: Sun Mar 29, 2020 10:50 am
by Kevin Sharpe
Cookie6000 wrote: Sun Mar 29, 2020 10:22 am If it helps, I will work on a step by step for the Open Tasks Leaf VCU thread you just started from the aspect of my build to date.
That would be a great help :)

Re: Leaf Gen 1 Inverter Board

Posted: Sat Apr 04, 2020 9:45 am
by Cookie6000
Looking to calibrate the ThrotVal values in the evbmw Leaf VCU for the Leaf pedal. The values 145,620 in the code are from the E46 pedal Damien used in the E46. The E46 signal o/p from having a search are C1 1.64v - 4.64v and C2 0.8v to 3.8v, the latter being the same as the Leaf and Touran pedal Johannes uses. Just want to be sure I calibrate the Leaf pedal correctly.

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.

What do these ThrotVal values reference to and how do I find the relevant Leaf/Prius/a-n-other pedal ThrotVal so I can put a 'how-to' together for future users adapting the Leaf VCU to their project. Thanks.

Re: Leaf Gen 1 Inverter Board

Posted: Thu Apr 09, 2020 11:01 pm
by Thatguyoverthere
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.

Re: Leaf Gen 1 Inverter Board

Posted: Fri Apr 10, 2020 1:08 am
by Thatguyoverthere
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,

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. 
}
I changed to:

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. 
}
Also this section,

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);
I changed to:

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);
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!

Re: Leaf Gen 1 Inverter Board

Posted: Fri Apr 10, 2020 7:09 am
by Jack Bauer
Excellent write up. Thank you.

Re: Leaf Gen 1 Inverter Board

Posted: Fri Apr 10, 2020 10:50 am
by Cookie6000
That's brilliant.
Thanks for the detailed breakdown. Will have a go at that later

Re: Leaf Gen 1 Inverter Board

Posted: Sun Apr 12, 2020 7:13 am
by james@N52E01
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.
FFA59A29-2F9A-4812-90A0-A5A7555B9158.jpeg
FFA59A29-2F9A-4812-90A0-A5A7555B9158.jpeg (16.3 KiB) Viewed 18153 times

Re: Leaf Gen 1 Inverter Board

Posted: Sun Apr 12, 2020 9:56 am
by Cookie6000
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.
20200331_212110v2.jpg
20200331_212153v2.jpg
20200331_212126v2.jpg
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.

Re: Leaf Gen 1 Inverter Board

Posted: Sun Apr 12, 2020 9:04 pm
by Thatguyoverthere
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).

Re: Leaf Gen 1 Inverter Board

Posted: Mon Apr 13, 2020 7:36 am
by Cookie6000
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.
20200413_123350.jpg
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)

Re: Leaf Gen 1 Inverter Board

Posted: Mon Apr 20, 2020 5:31 am
by mackoffgrid
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.

Re: Leaf Gen 1 Inverter Board

Posted: Mon Apr 20, 2020 7:54 am
by Cookie6000
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.
PerfEV.JPG

Re: Leaf Gen 1 Inverter Board

Posted: Mon Apr 20, 2020 10:54 pm
by mackoffgrid
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 (?)

Re: Leaf Gen 1 Inverter Board

Posted: Tue Apr 21, 2020 5:39 am
by zippy500
Not sure, but I think that the Can bus VCU needs 152v min to run

Re: Leaf Gen 1 Inverter Board

Posted: Tue Apr 21, 2020 12:57 pm
by Cookie6000
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 (?)
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,

Re: Leaf Gen 1 Inverter Board

Posted: Tue Apr 21, 2020 5:40 pm
by johu
Equipped with the V3 logic board there is no minimum voltage requirement.

Re: Leaf Gen 1 Inverter Board

Posted: Tue Apr 28, 2020 11:14 am
by james@N52E01
Made some progress with the VCU board. Just got WiFi working :)
BB785A94-EA2B-44EA-A17D-477FE8D3E1B4.jpeg
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.

Re: Leaf Gen 1 Inverter Board

Posted: Tue Apr 28, 2020 11:18 am
by Kevin Sharpe
james@N52E01 wrote: Tue Apr 28, 2020 11:14 am Made some progress with the VCU board. Just got WiFi working :)
Congratulations :)
james@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)
Thanks for the feedback! I posted an issue on GitHub for future reference :)

Re: Leaf Gen 1 Inverter Board

Posted: Tue Apr 28, 2020 1:17 pm
by Cookie6000
james@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.
Great work James. Got me over the hump. I'm seeing the same as you now on the web interface

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.

Re: Leaf Gen 1 Inverter Board

Posted: Tue Apr 28, 2020 2:41 pm
by Jack Bauer
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....

Re: Leaf Gen 1 Inverter Board

Posted: Tue Apr 28, 2020 2:55 pm
by Jack Bauer
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
  
}

}

Re: Leaf Gen 1 Inverter Board

Posted: Tue Apr 28, 2020 6:16 pm
by james@N52E01
Thanks JB! No facepalm emoji on here or I'd be using it...