Skip to content

Commit c1c62cf

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

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

vehicle/OVMS.X/vehicle_nissanleaf.c

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,65 @@ 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, when byte 3 is 0x00 or 0x03, byte 6 is 0x00, correctly
451+
// indicating we're unplugged, so we use that for unplugged detection
452+
//
453+
if (can_databuffer[3] == 0xb3 ||
454+
can_databuffer[3] == 0x00 ||
455+
can_databuffer[3] == 0x03)
456+
{
457+
// can_databuffer[6] is the J1772 pilot current, 0.5A per pit
458+
car_chargetype = J1772_TYPE1;
459+
car_chargelimit = (can_databuffer[6] + 1) / 2;
460+
car_doors1bits.ChargePort = car_chargelimit == 0 ? 0 : 1;
461+
car_doors1bits.PilotSignal = car_chargelimit == 0 ? 0 : 1;
462+
}
463+
switch (can_databuffer[5])
464+
{
465+
case 0x80:
466+
vehicle_nissanleaf_charger_status(CHARGER_STATUS_IDLE);
467+
break;
468+
case 0x83:
469+
vehicle_nissanleaf_charger_status(CHARGER_STATUS_QUICK_CHARGING);
470+
break;
471+
case 0x88:
472+
vehicle_nissanleaf_charger_status(CHARGER_STATUS_CHARGING);
473+
break;
474+
case 0x98:
475+
vehicle_nissanleaf_charger_status(CHARGER_STATUS_PLUGGED_IN_TIMER_WAIT);
476+
break;
477+
}
478+
break;
420479
case 0x54b:
421480
{
422481
BOOL hvac_candidate;
@@ -458,6 +517,7 @@ BOOL vehicle_nissanleaf_poll1(void)
458517
}
459518
break;
460519
case 0x5bf:
520+
// Gen 1 Charger
461521
if (can_databuffer[4] == 0xb0)
462522
{
463523
// Quick Charging

0 commit comments

Comments
 (0)