I was just looking at my gen2 Leaf Inverter plug, I have fitted my V3 board and soldered on the leaf Socket onto the leaf adapter board.
I just noticed that there is no spare wiring on the plug end.
How do I add the extra wiring for throttle pedal etc to the nissan plug ?
What have other done ?
Thanks
Leaf Invertor Plug-add wiring to plug
-
- Posts: 260
- Joined: Sat Jan 12, 2019 12:39 am
- Location: UK
- Been thanked: 1 time
Re: Leaf Invertor Plug-add wiring to plug
I had the same thought, then decided to control mine over the CAN BUS, so no extra wires needed.
-
- Posts: 209
- Joined: Fri Jan 04, 2019 8:42 am
- Location: United Kingdom
- Has thanked: 71 times
- Been thanked: 3 times
Re: Leaf Invertor Plug-add wiring to plug
I am going to fit mine to classic car, pre can bus era,
feel a bit stuck now unless I try to change the connector,
Is there some invention , where there is a can bus control box to wire too ?
Is there a write here how to connect up to can bus ?
feel a bit stuck now unless I try to change the connector,
Is there some invention , where there is a can bus control box to wire too ?
Is there a write here how to connect up to can bus ?
-
- Posts: 260
- Joined: Sat Jan 12, 2019 12:39 am
- Location: UK
- Been thanked: 1 time
Re: Leaf Invertor Plug-add wiring to plug
There is a section on CAN in the wiki https://openinverter.org/wiki/CAN_communication, but that may be a bit daunting to the less techy. I have some basic arduino code which controls throttle which I've been using for testing FOC which I would be happy to make available after I've tidied it up.
I know others have added extra wiring to that connector.
I know others have added extra wiring to that connector.
- jerrykco
- Posts: 146
- Joined: Thu Dec 12, 2019 5:32 pm
- Location: United States, Colorado
- Has thanked: 49 times
- Been thanked: 22 times
- Contact:
Re: Leaf Invertor Plug-add wiring to plug
I was able to drill two holes through the plug Receptacle.
See my 70MGB roadster project here: viewtopic.php?f=11&t=600
It's on the second page. I drilled two holes one on each side of the Receptacle.
I have not yet soldered it to the board or the pin in the receptacle. I just clipped it for now to test.
See my 70MGB roadster project here: viewtopic.php?f=11&t=600
It's on the second page. I drilled two holes one on each side of the Receptacle.
I have not yet soldered it to the board or the pin in the receptacle. I just clipped it for now to test.
Jerry Kauffman
jerryk48 at gmail dot com
jerryk48 at gmail dot com
- Bratitude
- Posts: 965
- Joined: Thu Jan 02, 2020 7:35 pm
- Location: Canada
- Has thanked: 154 times
- Been thanked: 334 times
- Contact:
Re: Leaf Invertor Plug-add wiring to plug
pls do! Would like to see what others are doindoobedoobedo wrote: ↑Thu Mar 26, 2020 9:29 am There is a section on CAN in the wiki https://openinverter.org/wiki/CAN_communication, but that may be a bit daunting to the less techy. I have some basic arduino code which controls throttle which I've been using for testing FOC which I would be happy to make available after I've tidied it up.
I know others have added extra wiring to that connector.
https://bratindustries.net/ leaf motor couplers, adapter plates, custom drive train components
-
- Posts: 260
- Joined: Sat Jan 12, 2019 12:39 am
- Location: UK
- Been thanked: 1 time
Re: Leaf Invertor Plug-add wiring to plug
OK this is what I put together to find my syncofs, it actually has the set syncofs call commented out now.
It consists of 3 buttons, a 100k pot and an arduino with canbus shield. Hook up the shield to the inverter's can bus don't forget the common ground.
Two of the buttons increment/decrement the syncofs value by 500. I found very near correct syncofs almost immediately so took that bit out as it was easier to tune via the web interface. I've left some of the code in as it demonstrates one way of swapping the byte order of a 16 bit value, which you'll need to do if using an AVR based arduino like the UNO.
Messages are traditionally named by the hex value of their message ID. when you set up CAN on the inverter it uses the decimal value.
I put the commands to use to configure each message on the inverter in the comment at the top (can rx ...) so I didn't have to work them out again later
, along with some other configuration options which needed to be set.
It sends a 206 message every 100ms.
When it starts up the first message contains a START command to the inverter, then you can set the throttle via the pot and when you push the 'run' button it sends FORWARD and the throttle position. I didn't implement pot2(regen).
Message IDs are arbitrary, but they mustn't clash with other messages on the same bus. (ID 206 is used by mazda for throttle position).
There's some heavy, probably excessive, de-bounce on the button handling.
It consists of 3 buttons, a 100k pot and an arduino with canbus shield. Hook up the shield to the inverter's can bus don't forget the common ground.
Two of the buttons increment/decrement the syncofs value by 500. I found very near correct syncofs almost immediately so took that bit out as it was easier to tune via the web interface. I've left some of the code in as it demonstrates one way of swapping the byte order of a 16 bit value, which you'll need to do if using an AVR based arduino like the UNO.
Messages are traditionally named by the hex value of their message ID. when you set up CAN on the inverter it uses the decimal value.
I put the commands to use to configure each message on the inverter in the comment at the top (can rx ...) so I didn't have to work them out again later

It sends a 206 message every 100ms.
When it starts up the first message contains a START command to the inverter, then you can set the throttle via the pot and when you push the 'run' button it sends FORWARD and the throttle position. I didn't implement pot2(regen).
Message IDs are arbitrary, but they mustn't clash with other messages on the same bus. (ID 206 is used by mazda for throttle position).
There's some heavy, probably excessive, de-bounce on the button handling.
Code: Select all
#include <CAN.h>
/* Inverter Setup
*
* message 0x207 - update syncofs
* can rx syncofs 519 0 16 32
*
* message 0x206 - controls digital IO, throttle position and regen position
* throttle position is sent on Mazda's CAN bus with a range of 0 -> 200 - hence only needs one byte
* can rx canio 518 0 5 32
* can rx pot 518 8 8 32
* can rx pot2 518 16 8 32
*
* Configure potmin=0 and potmax=200
* Configure pot2min=0 and pot2max=200
* Configure potmode=CAN
*/
// buttons
#define pinUp 5
#define pinDown 4
#define pinRun 6
#define pinPot 1
unsigned long lastSend = 0UL, lastBPress = 0UL, runTime = 500UL;
boolean cruise = false, start = false, brake = false, forward = false, reverse = false, bms = false;
byte throttlePosition = 0;
byte regenPosition = 0;
uint16_t syncofs = 500;
void updSyncofs(long ofs){
/*
* byte order is important, inverter is opposite to AVR
* this swaps the order for a 16bit value
*/
byte payload[2];
payload[1] = (byte) ((ofs & 0x0000FF00) >> 8 );
payload[0] = (byte) ((ofs & 0X000000FF) );
CAN.beginPacket(0x207); // message 0x207 - first two bytes syncofs reverse byte order
CAN.write(payload[0]);
CAN.write(payload[1]);
// pad message to 8 bytes long
for (int i=0;i<6;i++){
CAN.write(0x00);
}
CAN.endPacket();
}
void send206(){
byte udio = 0;
if (cruise){
udio += 1;
}
if (start){
udio += 2;
forward = true;
start = false;
}else{
start = true;
}
if (brake){
udio += 4;
}
if (forward){
udio += 8;
}
if (reverse){
udio += 16;
}
if (bms){
udio += 32;
}
CAN.beginPacket(0x206);
CAN.write(udio);
CAN.write(throttlePosition);
CAN.write(regenPosition);
for (int i=0;i<5;i++){
CAN.write(0x00);
}
CAN.endPacket();
}
void every100ms(){
send206();
}
void upPressed(){
if (millis() - lastBPress >= 500){
lastBPress = millis();
Serial.println("Up pressed");
syncofs += 500;
updSyncofs(syncofs);
}
}
void downPressed(){
if (millis() - lastBPress >= 500){
lastBPress = millis();
Serial.println("Down pressed");
syncofs -= 500;
updSyncofs(syncofs);
}
}
void runPressed(){
int pot = analogRead(pinPot);
throttlePosition = map(pot, 0,1023, 0, 200);
}
void setup() {
Serial.begin(115200);
while (!Serial);
Serial.println("CAN Tranceiver");
// start the CAN bus at 250 kbps
if (!CAN.begin(250E3)) {
Serial.println("Starting CAN failed!");
//while (1);
}
pinMode(pinUp, INPUT_PULLUP);
pinMode(pinDown, INPUT_PULLUP);
pinMode(pinRun, INPUT_PULLUP);
pinMode(pinPot, INPUT);
//updSyncofs(syncofs);
}
void loop() {
int upState,downState,runState;
upState = digitalRead(pinUp);
downState = digitalRead(pinDown);
runState = digitalRead(pinRun);
//Serial.println(throttlePosition);
if (upState == LOW) // light the LED
{
upPressed();
}
if (downState == LOW) // light the LED
{
downPressed();
}
if (runState == LOW) // light the LED
{
runPressed();
}else{
throttlePosition = 0;
}
// try to parse packet
int packetSize = CAN.parsePacket();
if (packetSize) {
// received a packet
Serial.print("Received ");
if (CAN.packetExtended()) {
Serial.print("extended ");
}
if (CAN.packetRtr()) {
// Remote transmission request, packet contains no data
Serial.print("RTR ");
}
Serial.print("packet with id 0x");
Serial.print(CAN.packetId(), HEX);
if (CAN.packetRtr()) {
Serial.print(" and requested length ");
Serial.println(CAN.packetDlc());
} else {
Serial.print(" and length ");
Serial.println(packetSize);
// only print packet data for non-RTR packets
while (CAN.available()) {
Serial.println(CAN.read(), HEX);
}
Serial.println();
}
Serial.println();
}
if (millis() - lastSend >= 100){
lastSend = millis();
every100ms();
}
}