Make LEAF interlock setting configurable

This commit is contained in:
Daniel Öster 2025-09-01 22:03:00 +03:00
parent 955688fec0
commit dabbcd8bcd
9 changed files with 32 additions and 16 deletions

View file

@ -15,18 +15,12 @@
/* Shunt/Contactor settings (Optional) */ /* Shunt/Contactor settings (Optional) */
//#define BMW_SBOX // SBOX relay control & battery current/voltage measurement //#define BMW_SBOX // SBOX relay control & battery current/voltage measurement
/* Select charger used (Optional) */
//#define CHEVYVOLT_CHARGER //Enable this line to control a Chevrolet Volt charger connected to battery - for example, when generator charging or using an inverter without a charging function.
//#define NISSANLEAF_CHARGER //Enable this line to control a Nissan LEAF PDM connected to battery - for example, when generator charging
/* Automatic Precharge settings (Optional) If you have a battery that expects an external voltage applied before opening contactors (within the battery), configure this section */ /* Automatic Precharge settings (Optional) If you have a battery that expects an external voltage applied before opening contactors (within the battery), configure this section */
//#define PRECHARGE_CONTROL //Enable this line to control a modified HIA4V1 via PWM on the HIA4V1_PIN (see Wiki and HAL for pin definition) //#define PRECHARGE_CONTROL //Enable this line to control a modified HIA4V1 via PWM on the HIA4V1_PIN (see Wiki and HAL for pin definition)
//#define INVERTER_DISCONNECT_CONTACTOR_IS_NORMALLY_OPEN //Enable this line if you use a normally open contactor instead of normally closed //#define INVERTER_DISCONNECT_CONTACTOR_IS_NORMALLY_OPEN //Enable this line if you use a normally open contactor instead of normally closed
/* Other options */ /* Other options */
//#define EQUIPMENT_STOP_BUTTON // Enable this to allow an equipment stop button connected to the Battery-Emulator to disengage the battery //#define EQUIPMENT_STOP_BUTTON // Enable this to allow an equipment stop button connected to the Battery-Emulator to disengage the battery
//#define LFP_CHEMISTRY //Tesla specific setting, enable this line to startup in LFP mode
//#define INTERLOCK_REQUIRED //Nissan LEAF specific setting, if enabled requires both high voltage conenctors to be seated before starting
/* CAN options */ /* CAN options */
//#define CAN_ADDON //Enable this line to activate an isolated secondary CAN Bus using add-on MCP2515 chip (Needed for some inverters / double battery) //#define CAN_ADDON //Enable this line to activate an isolated secondary CAN Bus using add-on MCP2515 chip (Needed for some inverters / double battery)
#define CRYSTAL_FREQUENCY_MHZ 8 //CAN_ADDON option, what is your MCP2515 add-on boards crystal frequency? #define CRYSTAL_FREQUENCY_MHZ 8 //CAN_ADDON option, what is your MCP2515 add-on boards crystal frequency?

View file

@ -279,6 +279,8 @@ void setup_battery() {
} }
} }
/* User-selected Nissan LEAF settings */
bool user_selected_LEAF_interlock_mandatory = false;
/* User-selected Tesla settings */ /* User-selected Tesla settings */
bool user_selected_tesla_digital_HVIL = false; bool user_selected_tesla_digital_HVIL = false;
uint16_t user_selected_tesla_GTW_country = 17477; uint16_t user_selected_tesla_GTW_country = 17477;

View file

@ -62,6 +62,7 @@ extern uint16_t user_selected_min_pack_voltage_dV;
extern uint16_t user_selected_max_cell_voltage_mV; extern uint16_t user_selected_max_cell_voltage_mV;
extern uint16_t user_selected_min_cell_voltage_mV; extern uint16_t user_selected_min_cell_voltage_mV;
extern bool user_selected_LEAF_interlock_mandatory;
extern bool user_selected_tesla_digital_HVIL; extern bool user_selected_tesla_digital_HVIL;
extern uint16_t user_selected_tesla_GTW_country; extern uint16_t user_selected_tesla_GTW_country;
extern bool user_selected_tesla_GTW_rightHandDrive; extern bool user_selected_tesla_GTW_rightHandDrive;

View file

@ -150,13 +150,14 @@ void NissanLeafBattery::
clear_event(EVENT_BATTERY_CHG_DISCHG_STOP_REQ); clear_event(EVENT_BATTERY_CHG_DISCHG_STOP_REQ);
} }
#ifdef INTERLOCK_REQUIRED if (user_selected_LEAF_interlock_mandatory) {
//If user requires both large 80kW and small 6kW interlock to be seated for operation
if (!battery_Interlock) { if (!battery_Interlock) {
set_event(EVENT_HVIL_FAILURE, 0); set_event(EVENT_HVIL_FAILURE, 0);
} else { } else {
clear_event(EVENT_HVIL_FAILURE); clear_event(EVENT_HVIL_FAILURE);
} }
#endif }
if (battery_HeatExist) { if (battery_HeatExist) {
if (battery_Heating_Stop) { if (battery_Heating_Stop) {

View file

@ -6,6 +6,8 @@
#include "CanBattery.h" #include "CanBattery.h"
#include "NISSAN-LEAF-HTML.h" #include "NISSAN-LEAF-HTML.h"
extern bool user_selected_LEAF_interlock_mandatory;
class NissanLeafBattery : public CanBattery { class NissanLeafBattery : public CanBattery {
public: public:
// Use this constructor for the second battery. // Use this constructor for the second battery.

View file

@ -105,6 +105,7 @@ void init_stored_settings() {
user_selected_inverter_battery_type = settings.getUInt("INVBTYPE", 0); user_selected_inverter_battery_type = settings.getUInt("INVBTYPE", 0);
user_selected_inverter_ignore_contactors = settings.getBool("INVICNT", false); user_selected_inverter_ignore_contactors = settings.getBool("INVICNT", false);
user_selected_can_addon_crystal_frequency_mhz = settings.getUInt("CANFREQ", 8); user_selected_can_addon_crystal_frequency_mhz = settings.getUInt("CANFREQ", 8);
user_selected_LEAF_interlock_mandatory = settings.getBool("INTERLOCKREQ", false);
user_selected_tesla_digital_HVIL = settings.getBool("DIGITALHVIL", false); user_selected_tesla_digital_HVIL = settings.getBool("DIGITALHVIL", false);
user_selected_tesla_GTW_country = settings.getUInt("GTWCOUNTRY", 0); user_selected_tesla_GTW_country = settings.getUInt("GTWCOUNTRY", 0);
user_selected_tesla_GTW_rightHandDrive = settings.getBool("GTWRHD", false); user_selected_tesla_GTW_rightHandDrive = settings.getBool("GTWRHD", false);

View file

@ -9,7 +9,7 @@ using duration = std::chrono::duration<unsigned long, std::ratio<1, 1000>>;
enum bms_status_enum { STANDBY = 0, INACTIVE = 1, DARKSTART = 2, ACTIVE = 3, FAULT = 4, UPDATING = 5 }; enum bms_status_enum { STANDBY = 0, INACTIVE = 1, DARKSTART = 2, ACTIVE = 3, FAULT = 4, UPDATING = 5 };
enum real_bms_status_enum { BMS_DISCONNECTED = 0, BMS_STANDBY = 1, BMS_ACTIVE = 2, BMS_FAULT = 3 }; enum real_bms_status_enum { BMS_DISCONNECTED = 0, BMS_STANDBY = 1, BMS_ACTIVE = 2, BMS_FAULT = 3 };
enum battery_chemistry_enum { NCA = 1, NMC = 2, LFP = 3, Highest }; enum battery_chemistry_enum { Autodetect = 0, NCA = 1, NMC = 2, LFP = 3, Highest };
enum class comm_interface { enum class comm_interface {
Modbus = 1, Modbus = 1,

View file

@ -203,7 +203,8 @@ String settings_processor(const String& var, BatteryEmulatorSettingsStore& setti
name_for_comm_interface); name_for_comm_interface);
} }
if (var == "BATTCHEM") { if (var == "BATTCHEM") {
return options_for_enum((battery_chemistry_enum)settings.getUInt("BATTCHEM", (int)battery_chemistry_enum::NCA), return options_for_enum(
(battery_chemistry_enum)settings.getUInt("BATTCHEM", (int)battery_chemistry_enum::Autodetect),
name_for_chemistry); name_for_chemistry);
} }
if (var == "INVTYPE") { if (var == "INVTYPE") {
@ -563,6 +564,10 @@ String settings_processor(const String& var, BatteryEmulatorSettingsStore& setti
return String(settings.getUInt("PWMHOLD", 250)); return String(settings.getUInt("PWMHOLD", 250));
} }
if (var == "INTERLOCKREQ") {
return settings.getBool("INTERLOCKREQ") ? "checked" : "";
}
if (var == "DIGITALHVIL") { if (var == "DIGITALHVIL") {
return settings.getBool("DIGITALHVIL") ? "checked" : ""; return settings.getBool("DIGITALHVIL") ? "checked" : "";
} }
@ -777,6 +782,11 @@ const char* getCANInterfaceName(CAN_Interface interface) {
display: contents; display: contents;
} }
form .if-nissan { display: none; }
form[data-battery="21"] .if-nissan {
display: contents;
}
form .if-tesla { display: none; } form .if-tesla { display: none; }
form[data-battery="32"] .if-tesla, form[data-battery="33"] .if-tesla { form[data-battery="32"] .if-tesla, form[data-battery="33"] .if-tesla {
display: contents; display: contents;
@ -841,6 +851,11 @@ const char* getCANInterfaceName(CAN_Interface interface) {
%BATTTYPE% %BATTTYPE%
</select> </select>
<div class="if-nissan">
<label>Interlock required: </label>
<input type='checkbox' name='INTERLOCKREQ' value='on' style='margin-left: 0;' %INTERLOCKREQ% />
</div>
<div class="if-tesla"> <div class="if-tesla">
<label>Digital HVIL (2024+): </label> <label>Digital HVIL (2024+): </label>
<input type='checkbox' name='DIGITALHVIL' value='on' style='margin-left: 0;' %DIGITALHVIL% /> <input type='checkbox' name='DIGITALHVIL' value='on' style='margin-left: 0;' %DIGITALHVIL% />

View file

@ -398,7 +398,7 @@ void init_webserver() {
const char* boolSettingNames[] = { const char* boolSettingNames[] = {
"DBLBTR", "CNTCTRL", "CNTCTRLDBL", "PWMCNTCTRL", "PERBMSRESET", "SDLOGENABLED", "REMBMSRESET", "DBLBTR", "CNTCTRL", "CNTCTRLDBL", "PWMCNTCTRL", "PERBMSRESET", "SDLOGENABLED", "REMBMSRESET",
"USBENABLED", "CANLOGUSB", "WEBENABLED", "CANFDASCAN", "CANLOGSD", "WIFIAPENABLED", "MQTTENABLED", "USBENABLED", "CANLOGUSB", "WEBENABLED", "CANFDASCAN", "CANLOGSD", "WIFIAPENABLED", "MQTTENABLED",
"HADISC", "MQTTTOPICS", "INVICNT", "GTWRHD", "DIGITALHVIL", "PERFPROFILE", "HADISC", "MQTTTOPICS", "INVICNT", "GTWRHD", "DIGITALHVIL", "PERFPROFILE", "INTERLOCKREQ",
}; };
// Handles the form POST from UI to save settings of the common image // Handles the form POST from UI to save settings of the common image