mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-03 17:59:27 +02:00
Merge pull request #1232 from dalathegreat/feature/simplify-GPIO-double-battery
Feature: Simplify GPIO for secondary battery
This commit is contained in:
commit
2c554a746a
6 changed files with 12 additions and 33 deletions
|
@ -82,27 +82,17 @@ void init_contactors() {
|
||||||
set(PRECHARGE_PIN, OFF);
|
set(PRECHARGE_PIN, OFF);
|
||||||
#endif // CONTACTOR_CONTROL
|
#endif // CONTACTOR_CONTROL
|
||||||
#ifdef CONTACTOR_CONTROL_DOUBLE_BATTERY
|
#ifdef CONTACTOR_CONTROL_DOUBLE_BATTERY
|
||||||
pinMode(SECOND_POSITIVE_CONTACTOR_PIN, OUTPUT);
|
pinMode(SECOND_BATTERY_CONTACTORS_PIN, OUTPUT);
|
||||||
set(SECOND_POSITIVE_CONTACTOR_PIN, OFF);
|
set(SECOND_BATTERY_CONTACTORS_PIN, OFF);
|
||||||
pinMode(SECOND_NEGATIVE_CONTACTOR_PIN, OUTPUT);
|
|
||||||
set(SECOND_NEGATIVE_CONTACTOR_PIN, OFF);
|
|
||||||
#endif // CONTACTOR_CONTROL_DOUBLE_BATTERY
|
#endif // CONTACTOR_CONTROL_DOUBLE_BATTERY
|
||||||
// Init BMS contactor
|
// Init BMS contactor
|
||||||
#if defined HW_STARK || defined HW_3LB // This hardware has dedicated pin, always enable on start
|
#if defined HW_STARK || defined HW_3LB // This hardware has dedicated pin, always enable on start
|
||||||
pinMode(BMS_POWER, OUTPUT); //LilyGo is omitted from this, only enabled if user selects PERIODIC_BMS_RESET
|
pinMode(BMS_POWER, OUTPUT); //LilyGo is omitted from this, only enabled if user selects PERIODIC_BMS_RESET
|
||||||
digitalWrite(BMS_POWER, HIGH);
|
digitalWrite(BMS_POWER, HIGH);
|
||||||
#ifdef BMS_2_POWER //Hardware supports 2x BMS
|
|
||||||
pinMode(BMS_2_POWER, OUTPUT);
|
|
||||||
digitalWrite(BMS_2_POWER, HIGH);
|
|
||||||
#endif //BMS_2_POWER
|
|
||||||
#endif // HW with dedicated BMS pins
|
#endif // HW with dedicated BMS pins
|
||||||
#if defined(PERIODIC_BMS_RESET) || defined(REMOTE_BMS_RESET) // User has enabled BMS reset, turn on output on start
|
#if defined(PERIODIC_BMS_RESET) || defined(REMOTE_BMS_RESET) // User has enabled BMS reset, turn on output on start
|
||||||
pinMode(BMS_POWER, OUTPUT);
|
pinMode(BMS_POWER, OUTPUT);
|
||||||
digitalWrite(BMS_POWER, HIGH);
|
digitalWrite(BMS_POWER, HIGH);
|
||||||
#ifdef BMS_2_POWER //Hardware supports 2x BMS
|
|
||||||
pinMode(BMS_2_POWER, OUTPUT);
|
|
||||||
digitalWrite(BMS_2_POWER, HIGH);
|
|
||||||
#endif //BMS_2_POWER
|
|
||||||
#endif //PERIODIC_BMS_RESET
|
#endif //PERIODIC_BMS_RESET
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,12 +216,10 @@ void handle_contactors() {
|
||||||
#ifdef CONTACTOR_CONTROL_DOUBLE_BATTERY
|
#ifdef CONTACTOR_CONTROL_DOUBLE_BATTERY
|
||||||
void handle_contactors_battery2() {
|
void handle_contactors_battery2() {
|
||||||
if ((contactorStatus == COMPLETED) && datalayer.system.status.battery2_allowed_contactor_closing) {
|
if ((contactorStatus == COMPLETED) && datalayer.system.status.battery2_allowed_contactor_closing) {
|
||||||
set(SECOND_NEGATIVE_CONTACTOR_PIN, ON);
|
set(SECOND_BATTERY_CONTACTORS_PIN, ON);
|
||||||
set(SECOND_POSITIVE_CONTACTOR_PIN, ON);
|
|
||||||
datalayer.system.status.contactors_battery2_engaged = true;
|
datalayer.system.status.contactors_battery2_engaged = true;
|
||||||
} else { // Closing contactors on secondary battery not allowed
|
} else { // Closing contactors on secondary battery not allowed
|
||||||
set(SECOND_NEGATIVE_CONTACTOR_PIN, OFF);
|
set(SECOND_BATTERY_CONTACTORS_PIN, OFF);
|
||||||
set(SECOND_POSITIVE_CONTACTOR_PIN, OFF);
|
|
||||||
datalayer.system.status.contactors_battery2_engaged = false;
|
datalayer.system.status.contactors_battery2_engaged = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,11 +52,7 @@
|
||||||
#define NEGATIVE_CONTACTOR_PIN 33
|
#define NEGATIVE_CONTACTOR_PIN 33
|
||||||
#define PRECHARGE_PIN 25
|
#define PRECHARGE_PIN 25
|
||||||
#define BMS_POWER 2
|
#define BMS_POWER 2
|
||||||
|
#define SECOND_BATTERY_CONTACTORS_PIN 13
|
||||||
#define SECOND_POSITIVE_CONTACTOR_PIN 13
|
|
||||||
#define SECOND_NEGATIVE_CONTACTOR_PIN 16
|
|
||||||
#define SECOND_PRECHARGE_PIN 18
|
|
||||||
#define BMS_2_POWER 12
|
|
||||||
|
|
||||||
// SMA CAN contactor pins
|
// SMA CAN contactor pins
|
||||||
#define INVERTER_CONTACTOR_ENABLE_PIN 36
|
#define INVERTER_CONTACTOR_ENABLE_PIN 36
|
||||||
|
|
|
@ -50,7 +50,7 @@ The pin layout below supports the following:
|
||||||
#define POSITIVE_CONTACTOR_PIN GPIO_NUM_5
|
#define POSITIVE_CONTACTOR_PIN GPIO_NUM_5
|
||||||
#define NEGATIVE_CONTACTOR_PIN GPIO_NUM_16
|
#define NEGATIVE_CONTACTOR_PIN GPIO_NUM_16
|
||||||
#define PRECHARGE_PIN GPIO_NUM_17
|
#define PRECHARGE_PIN GPIO_NUM_17
|
||||||
|
#define SECOND_BATTERY_CONTACTORS_PIN GPIO_NUM_32
|
||||||
// SMA CAN contactor pins
|
// SMA CAN contactor pins
|
||||||
#define INVERTER_CONTACTOR_ENABLE_PIN GPIO_NUM_14
|
#define INVERTER_CONTACTOR_ENABLE_PIN GPIO_NUM_14
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,8 @@
|
||||||
#define POSITIVE_CONTACTOR_PIN 32
|
#define POSITIVE_CONTACTOR_PIN 32
|
||||||
#define NEGATIVE_CONTACTOR_PIN 33
|
#define NEGATIVE_CONTACTOR_PIN 33
|
||||||
#define PRECHARGE_PIN 25
|
#define PRECHARGE_PIN 25
|
||||||
#define BMS_POWER 18 // Note, this pin collides with CAN add-ons and Chademo
|
#define BMS_POWER 18 // Note, this pin collides with CAN add-ons and Chademo
|
||||||
|
#define SECOND_BATTERY_CONTACTORS_PIN 15 //Note, this pin collides with SD card pins
|
||||||
|
|
||||||
// Automatic precharging
|
// Automatic precharging
|
||||||
#define HIA4V1_PIN 25
|
#define HIA4V1_PIN 25
|
||||||
|
|
|
@ -50,6 +50,7 @@ GPIOs on extra header
|
||||||
#define NEGATIVE_CONTACTOR_PIN 33
|
#define NEGATIVE_CONTACTOR_PIN 33
|
||||||
#define PRECHARGE_PIN 25
|
#define PRECHARGE_PIN 25
|
||||||
#define BMS_POWER 23
|
#define BMS_POWER 23
|
||||||
|
#define SECOND_BATTERY_CONTACTORS_PIN 19 //Available as extra GPIO via pin header
|
||||||
|
|
||||||
// Automatic precharging
|
// Automatic precharging
|
||||||
#define HIA4V1_PIN 19 //Available as extra GPIO via pin header
|
#define HIA4V1_PIN 19 //Available as extra GPIO via pin header
|
||||||
|
|
|
@ -1339,8 +1339,8 @@ String processor(const String& var) {
|
||||||
}
|
}
|
||||||
content += "</h4>";
|
content += "</h4>";
|
||||||
#ifdef CONTACTOR_CONTROL_DOUBLE_BATTERY
|
#ifdef CONTACTOR_CONTROL_DOUBLE_BATTERY
|
||||||
content += "<h4>Cont. Neg.: ";
|
|
||||||
#ifdef PWM_CONTACTOR_CONTROL
|
#ifdef PWM_CONTACTOR_CONTROL
|
||||||
|
content += "<h4>Cont. Neg.: ";
|
||||||
if (datalayer.system.status.contactors_battery2_engaged) {
|
if (datalayer.system.status.contactors_battery2_engaged) {
|
||||||
content += "<span style='color: green;'>Economized</span>";
|
content += "<span style='color: green;'>Economized</span>";
|
||||||
content += " Cont. Pos.: ";
|
content += " Cont. Pos.: ";
|
||||||
|
@ -1350,16 +1350,9 @@ String processor(const String& var) {
|
||||||
content += " Cont. Pos.: ";
|
content += " Cont. Pos.: ";
|
||||||
content += "<span style='color: red;'>✕</span>";
|
content += "<span style='color: red;'>✕</span>";
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // No PWM_CONTACTOR_CONTROL , we can read the pin and see feedback. Helpful if channel overloaded
|
#else // No PWM_CONTACTOR_CONTROL , we can read the pin and see feedback. Helpful if channel overloaded
|
||||||
if (digitalRead(SECOND_NEGATIVE_CONTACTOR_PIN) == HIGH) {
|
content += "<h4>Cont. Neg.: ";
|
||||||
content += "<span style='color: green;'>✓</span>";
|
if (digitalRead(SECOND_BATTERY_CONTACTORS_PIN) == HIGH) {
|
||||||
} else {
|
|
||||||
content += "<span style='color: red;'>✕</span>";
|
|
||||||
}
|
|
||||||
|
|
||||||
content += " Cont. Pos.: ";
|
|
||||||
if (digitalRead(SECOND_POSITIVE_CONTACTOR_PIN) == HIGH) {
|
|
||||||
content += "<span style='color: green;'>✓</span>";
|
content += "<span style='color: green;'>✓</span>";
|
||||||
} else {
|
} else {
|
||||||
content += "<span style='color: red;'>✕</span>";
|
content += "<span style='color: red;'>✕</span>";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue