Skip to content

Commit 5d2cde1

Browse files
committed
Nissan Leaf: Gen2 Charger support
1 parent 2b0da17 commit 5d2cde1

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

vehicle/OVMS.X/vehicle_nissanleaf.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,66 @@ BOOL vehicle_nissanleaf_poll1(void)
417417
car_speed = car_speed16 / 92;
418418
}
419419
break;
420+
case 0x390:
421+
// Gen 2 Charger
422+
//
423+
// When the data is valid, can_databuffer[6] is the J1772 maximum
424+
// available current if we're plugged in, and 0 when we're not.
425+
// can_databuffer[3] seems to govern when it's valid, and is probably a
426+
// bit field, but I don't have a full decoding
427+
//
428+
// specifically the last few frames before shutdown to wait for the charge
429+
// timer contain zero in can_databuffer[6] so we ignore them and use the
430+
// valid data in the earlier frames
431+
//
432+
// During plug in with charge timer activated, byte 3 & 6:
433+
//
434+
// 0x390 messages start
435+
// 0x00 0x21
436+
// 0x60 0x21
437+
// 0x60 0x00
438+
// 0xa0 0x00
439+
// 0xb0 0x00
440+
// 0xb2 0x15 -- byte 6 now contains valid j1772 pilot amps
441+
// 0xb3 0x15
442+
// 0xb1 0x00
443+
// 0x71 0x00
444+
// 0x69 0x00
445+
// 0x61 0x00
446+
// 0x390 messages stop
447+
//
448+
// byte 3 is 0xb3 during charge, and byte 6 contains the valid pilot amps
449+
//
450+
// so far, except briefly during startup, when byte 3 is 0x00 or 0x03,
451+
// byte 6 is 0x00, correctly indicating we're unplugged, so we use that
452+
// for unplugged detection.
453+
//
454+
if (can_databuffer[3] == 0xb3 ||
455+
can_databuffer[3] == 0x00 ||
456+
can_databuffer[3] == 0x03)
457+
{
458+
// can_databuffer[6] is the J1772 pilot current, 0.5A per bit
459+
car_chargetype = J1772_TYPE1;
460+
car_chargelimit = (can_databuffer[6] + 1) / 2;
461+
car_doors1bits.ChargePort = car_chargelimit == 0 ? 0 : 1;
462+
car_doors1bits.PilotSignal = car_chargelimit == 0 ? 0 : 1;
463+
}
464+
switch (can_databuffer[5])
465+
{
466+
case 0x80:
467+
vehicle_nissanleaf_charger_status(CHARGER_STATUS_IDLE);
468+
break;
469+
case 0x83:
470+
vehicle_nissanleaf_charger_status(CHARGER_STATUS_QUICK_CHARGING);
471+
break;
472+
case 0x88:
473+
vehicle_nissanleaf_charger_status(CHARGER_STATUS_CHARGING);
474+
break;
475+
case 0x98:
476+
vehicle_nissanleaf_charger_status(CHARGER_STATUS_PLUGGED_IN_TIMER_WAIT);
477+
break;
478+
}
479+
break;
420480
case 0x54b:
421481
{
422482
BOOL hvac_candidate;
@@ -458,6 +518,7 @@ BOOL vehicle_nissanleaf_poll1(void)
458518
}
459519
break;
460520
case 0x5bf:
521+
// Gen 1 Charger
461522
if (can_databuffer[4] == 0xb0)
462523
{
463524
// Quick Charging

0 commit comments

Comments
 (0)