Stand alone OBC/PDModule EV system Can 2015 - SOLVED

My Nissan Leaf Forum

Help Support My Nissan Leaf Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.
Dala said:
You can't use three UNOs, since the timing will be off. Your #1 priority is to setup code that allows you to queue up messages correctly.

See this video for more info on CRC/MPRUN/CSUM
https://www.youtube.com/watch?v=oENNNfy5GSM
Thanks Dala, I guess that makes sense.
I'm working now so I'll take a look this evening.
 
I would suggest taking the GEN1 can messages from trusoln and use them to replace the equivalent can messages in my gen2 code. ie 1f2,11a,1d4.,etc. I know my code works and I also have confidence that trusoln messages are right from a gen1.
The best path forward would be to get a recording of gen1 car while charging and compare the messages and the sequence with what you have.
Dala is 100% right timing, crc and Prun is paramount. Also note the scheduling in my code works you just need to change the can messages. The 3 uno's will not help, one due is your best option. The code works on a gen2. It can not be that different, but I don't know not done it. If you know some one with a working gen1 get a recording. I have a friend who might let me splice into his wiring and grab a recording if you run out of options.

Myabe someone on this forum has a recording already ?

Do you have the interlocks bypassed, in the gen2 there is one in the battery pack and one in the inverter that are connected in the PDM.

It's time consuming, stay at it, working full time and having other commitments like you it took me two years to solve it. If you are under a time crunch you might find it easier to pickup a gen2 charger/pdm from an auto wrecker. Would be cheaper than an off the shelf charger.
 
49thdiver said:
I would suggest taking the GEN1 can messages from trusoln and use them to replace the equivalent can messages in my gen2 code. ie 1f2,11a,1d4.,etc. I know my code works and I also have confidence that trusoln messages are right from a gen1.
The best path forward would be to get a recording of gen1 car while charging and compare the messages and the sequence with what you have.
Dala is 100% right timing, crc and Prun is paramount. Also note the scheduling in my code works you just need to change the can messages. The 3 uno's will not help, one due is your best option. The code works on a gen2. It can not be that different, but I don't know not done it. If you know some one with a working gen1 get a recording. I have a friend who might let me splice into his wiring and grab a recording if you run out of options.

Myabe someone on this forum has a recording already ?

Do you have the interlocks bypassed, in the gen2 there is one in the battery pack and one in the inverter that are connected in the PDM.

It's time consuming, stay at it, working full time and having other commitments like you it took me two years to solve it. If you are under a time crunch you might find it easier to pickup a gen2 charger/pdm from an auto wrecker. Would be cheaper than an off the shelf charger.

LOL, you must have read my mind Peter!
Earlier today I was looking at the codes and suddenly realised you have already done the heavy lifting.
The three CAN messages TrueSoln mentioned are already in your code so I've been REMing out all the bits he didn't mention and hope to try it again later.
 
OK so I managed to turn off the CAN messages I didn't want from your code Peter (or at least the ones TrueSoln didn't mention) and connected the Due to the OBC but no joy. The three CAN messages are being sent as they are in your code and I still see a change to one of the CAN codes coming from the OBC when I plug in the granny cable but no charging and no sound of relays clicking. I will take another look at the low voltage connections for any mistakes and if anyone has any suggestions I'm happy to try them but starting to loose hope that I will get this working in the short term.

I have another crazy idea to use 21 x 19V 6A HP laptop mains adaptors connected in series to give 400V. It may sound daft but I happen to have the HP adaptors so will give it a try with 5. This will give me 5 x 19 = 96V which should be OK to charge 16 cells up to 4V each which should be good enough to confirm the concept. I accept this is probably not suitable as a permanent solution but might be good enough to buy me time to sort the charger I have or to replace it with one that has already been cracked like the Outlander PHEV charger.
It occurred that if one of the chargers failed for any reason it could have a very high voltage across it so I should probably put several fuses inbetween the chargers so hopefully that should help prevent disaster.
Any thoughts?
 
More later but to prevent a house fire you need to be very cautious. Conceptual it might work. The trouble with that scenario is the maximum voltage differential across all the adapters ie. 400 volts
Fuses wold be a minimum and of course each charger would have to spam X number of cells up to the 19 volts maximum. I have done this kind of thing with 12 volt chargers in older EV's up to 120VDC but not at the 400 volt level. Keep in mind cell balancing is often done at the battery pack level not in the charger. I think thi swould be less than optimal as balancing the pack may be a challenge with the nissan BMS competing with the laptop chargers and limited ability to manage the chargers.

Again a recycled GEN2 charger may be a good option for you.
 
Yes it occurred to me that having potentially 400V across a single charger could be sub optimal. :eek:

Here is my thinking on using the laptop chargers.
Each charger is 19V therefore 21 x 19 = 399V

399V / 96 cells = 4.156V. This would be an acceptable voltage for these cells so ending the charging at a particular time would not be critical, so long as the chargers were not left connected for days.

The BMS can take care of individual cells to prevent them getting out of balance as it is already doing.

If I do this it will be purely as a temporary solution should I fail to get the Gen1 charger working.
 
Understood, and it may work. The issue I have identified is in the nature of switching power supplies which laptop chargers are. Its the maximum differential voltage across all the chargers that may cause cause the chargers to not work at all or blow in the worst case if one of the chargers fails which may cause an open circuit voltage swing over the rated DC outout voltage of the charger. I am not an engineer I discovered this in my research. It made sense at the time and I think I observed a situation where the chargers simply did not work. I was successful in using 12 volt wheel chair chargers and If I recall correctly was less successful using other chargers. Give it a try, just be safe as you have indicated you plan to be. I am just providing heads up.
 
I've connected three together in the past and saw no issues when turning them off and on randomly however they were not under load, nor did they have batteries in parallel with them so this could still end up being a very bad idea. :eek:
I plan to do a test this evening with 5 chargers and 24 cells to see what happens.
 
Unfortunately today has been a big fat fail.
I tried linking 5 PSU's in series as mentioned and could see 99V (as each were a little over 19V) however as soon as I connected them to the battery modules which were sitting around 92V the PSU's turned themselves off and refused to turn back on until I disconnected them from the battery pack. :?
As this was always a bit dodgy I'm not going to pursue it. :oops:
So then I had another look at the wiring and tried a few things to see if I could persuade the Gen1 OBC to work but still no joy.
I tried turning on the 12V to the OBC in different sequences as there are several 12V inputs which in the car come from different relays.
I tried your original code again Peter and my reduced version but nothing.

Here is a photo of the CAN with the reduced version.
MlWKNmX.jpg


I'm using a CANalyst-II here as I find CANHacker can be a bit flaky but the result unfortunately is the same.
So unless someone smarter than me can find a way to make the GEN 1 charger work I will have to either get a Gen 2 version or a charger from an Outlander PHEV. In the meantime I'm going to give up on this for now and concentrate on putting the batteries in the car.

Thanks to everyone who has tried to help me with this and if anyone has any more suggestions I will give them a try.
 
Just in case anyone is following this and is interested in the multiple laptop PSU's idea I mentioned earlier, I got it working with 16 cells and 5 PSU's in series.
The pack was sitting at 92V and when powered on the laptop psu's were at 99V.
Connecting the psu's to the pack directly caused a surge last time which made them shut down.
So this time I connected a 12V, 60W halogen lamp in series with the psu's and turned them on before connecting to the batteries.
As soon as they were connected the light came on and the batteries started charging at 3A.
For various reasons this is very dodgy and could go badly wrong so if I end up doing it for the EV pack at 400V it will be very much a one off emergency thing but I thought it worth mentioning.
 
Having given up on the Leaf OBC I bought one from a Mitsubishi Outlander PHEV as it has been recommended by a few people. Getting the dc to dc working was as simple as with the Nissan Leaf PDM but the ac charging was a bit more challenging
but after two days working at it
IT'S WORKING!!!!! :D

I connected the PP (proximity Pilot) lead from the Leaf charger socket to ground via a 220R resistor
The CP (control pilot) lead goes to the charger pin 9
Hooked up the HV leads to the switched side of the contactors.
Connected the low voltage connector as described here. https://openinverter.org/wiki/Mitsubishi_Outlander_DCDC_OBC
Plugged in the granny charger and as expected nothing as I hadn't sent any CAN messages yet.

I tried using code from Openinverter.org but couldn't get it to work. I don't have the right hardware so maybe that was the reason, I'm not sure but decided to try sending the CAN messages another way and after a few hours tweaking 49thdiver's code it's now working.

The messages sent were
msg ID 0x285 data 00 00 B6 00 00 00 00 00 every 100ms
msg ID 0x286 data 28 0F 78 37 00 00 0A 00 every 800ms

I don't have any cooling yet so didn't leave it charging for long but saw the battery pack voltage rising from 350V to 351V.
I still need to confirm it will cut off at 390V as one of the guys over there said it should but I'm not sure I have everything connected correctly for this to happen.

This is a massive step as it is it means I have pretty much everything under the bonnet in place and working so now need to tidy everything up.

So thank you Peter, I may not have succeeded with the Leaf hardware but your code worked a treat with the Outlander charger with only small changes.
 
49thdiver said:
That is amazing, thanks for the info.

I might have been able to do it using examples of CAN code but your code made it much easier.

Just to be clear I was able to start it charging but still need to automate stopping the charging as the Outlander OBC will continue charge up to 420V but hopefully a bit more time will sort that out.
 
@TrueSoln
I am working OBC gen1 and trying to get the charger working. I used @49driver code for gen2 and it seems like it is now woking. Can you send or upload code foe gen1.
 
Here is my latest video on the topic. I didn't go into detail but posted links to sources.

https://youtu.be/mGNyog4xDnY
 
ETrrijal2 said:
@TrueSoln
I am working OBC gen1 and trying to get the charger working. I used @49driver code for gen2 and it seems like it is now woking. Can you send or upload code for gen1.
 
I am trying to run OBC 2012 and used the code by @49driver(for timing) and TrueSoln(message needs to be sent). Below are the messages that needed to be sent but my charger is still off. In the TrueSoln code snipped he has nissan_crc(messageData, 0x85); function which does-not provide any detail but I have used 49driver code which is supposed to include CRC. What could be done?

///This is header file msg.h
//1d4 8 bytes including prun & crc for 10ms
byte message1d4_0[8] = {0xF7,0x07,0x00,0x04,0x87,0x46,0xe0,0x64};
byte message1d4_1[8] = {0xf7,0x07,0x00,0x04,0xC7,0x46,0xe0,0xA3};
byte message1d4_2[8] = {0xf7,0x07,0x00,0x04,0x07,0x46,0xe0,0x6F};
byte message1d4_3[8] = {0xf7,0x07,0x00,0x04,0x47,0x46,0xe0,0xA8};
//1f2 8 bytes including prun & crc for 10ms
byte message1f2_0[8] = {0x30,0x64,0x20,0x00,0x00,0x82,0x00,0x0B};
byte message1f2_1[8] = {0x30,0x64,0x20,0x00,0x00,0x82,0x01,0x0C};
byte message1f2_2[8] = {0x30,0x64,0x20,0x00,0x00,0x82,0x02,0x0D};
byte message1f2_3[8] = {0x30,0x64,0x20,0x00,0x00,0x82,0x03,0x0E};
//50b 7 bytes no prun or crc for 100ms
byte message50b[6] = {0x00,0x00,0x00,0xC0,0x00,0x00};




// This code written by Peter Luckham known as 49thdiver

#include <DueTimer.h> //© 2021 GitHub, Inc.
#include "variant.h" //due support
#include <due_can.h> // Collin Kidder et alb
#include "msg.h"


void setup(){

// setup 10ms 100MS and 500ms timers
Timer3.attachInterrupt(SendChargeStateCan10msMessage);
Timer3.start(10000); // Calls every 10ms
Timer4.attachInterrupt(SendChargingSimBattery100msMessage);
Timer4.start(100000); // Calls every 100ms
Timer2.attachInterrupt(StatusLed_On);
Timer2.start(1000000);// bink led
//pinMode(buttonPin, INPUT_PULLUP); // output indicators and button inout for diagnostics
pinMode(RelayLED, OUTPUT);
// Initialize serial I/O for debug messages
Serial.begin(115200); delay(100);

// Initialize CAN0 and CAN1, Set the proper baud rates here
Can0.begin(CAN_BPS_500K); //Transmit
Can0.watchFor();

// Send first 500ms message to get things started and sync charger
SendChargingSimBattery500msMessage();
}

void loop(){} // Nothing here all interupt driven
// Blink status LED
void StatusLed_On(){
digitalWrite(RelayLED, LOW); //Inititalize relay to BMS ON
}



// Send 1F2 message every 10ms
void VCM_1F2_Charging_Message(){
bool sendState = false;
switch(counter_1f2){
case 0:
sendState = SendCanMessage(0x1f2,0, 8, message1f2_0);
break;
case 1:
sendState = SendCanMessage(0x1f2,0, 8, message1f2_1);
break;
case 2:
sendState = SendCanMessage(0x1f2,0, 8, message1f2_2);
break;
case 3:
sendState = SendCanMessage(0x1f2,0, 8, message1f2_3);
break;}

counter_1f2++;
if (counter_1f2 >= 4)
counter_1f2 = 0;
return;
}
// Send 1d4 message every 10ms
void VCM_1d4_Charging_Message(){
bool sendState = false;
switch(counter_1d4){
case 0:
sendState = SendCanMessage(0x1d4,0, 8, message1d4_0);
break;
case 1:
sendState = SendCanMessage(0x1d4,0, 8, message1d4_1);
break;
case 2:
sendState = SendCanMessage(0x1d4,0, 8, message1d4_2);
break;
case 3:
sendState = SendCanMessage(0x1d4,0, 8, message1d4_3);
break;}
counter_1d4++;
if (counter_1d4 >= 4)
counter_1d4 = 0;
return;
}
// Send 1dc message every 10ms


// Send 50b message every 100ms
void VCM_50B_Charging_Message(){
bool sendState = SendCanMessage(0x50b,0, 6, message50b);
return;
}

void SendChargeStateCan10msMessage()
{
VCM_1F2_Charging_Message();
VCM_1d4_Charging_Message();
}

void SendChargingSimBattery100msMessage()
{
VCM_50B_Charging_Message();
}

void SendChargingSimBattery500msMessage(){

digitalWrite(RelayLED, HIGH); // turn status led off
}

bool SendCanMessage(unsigned int messageId, unsigned short extendedId, unsigned int payloadLength, byte * messageData)
{
OBCFrame.id = messageId;
OBCFrame.length = payloadLength;
OBCFrame.extended = false;
OBCFrame.rtr=1;
OBCFrame.priority = 15;
for( int i=0; i< payloadLength;i++)
{
OBCFrame.data.bytes = messageData;
}
bool sent = Can0.sendFrame(OBCFrame);
return sent;
}
 
Code will not work with a Gen1 Leaf 2013 or earlier. The code was written for 2014/2015 which are Gen2 the charger architecture is completely different as well as the Can Messages. In theory if you can figure out the correct can messages by making a recording of a 2012 car that is working you should be able to use my code to send the messages. Good luck.

Peter
 
Thanks Peter,
I have changed the message bytes that you used and replaced with message that Truesoln used. I read in page 5 of this page that he was able to turn the charger on and used his message. I would love if anyone has recording of the CAN message. Since I don't have the working 2012 leaf. I also want to make sure the charger that he turned on was of 2012 or later?
Simply I have sent 0x1d4 and 0x1f2 in 10ms and 0x50a in 100ms.

Rrijal
 
Back
Top