Skip to content

Commit

Permalink
Merge pull request #712 from lenvm/feature/add-bmw-i3-wake-up-pin-for…
Browse files Browse the repository at this point in the history
…-battery2

Add wake up pin for second BMW I3 battery
  • Loading branch information
dalathegreat authored Dec 30, 2024
2 parents aa8ed59 + ca1da7e commit 688952c
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 8 deletions.
18 changes: 14 additions & 4 deletions Software/src/battery/BMW-I3-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,15 @@ void update_values_battery2() { //This function maps all the values fetched via

void update_values_battery() { //This function maps all the values fetched via CAN to the battery datalayer
if (datalayer.system.settings.equipment_stop_active == true) {
digitalWrite(WUP_PIN, LOW); // Turn off WUP_PIN
digitalWrite(WUP_PIN1, LOW); // Turn off WUP_PIN1
#if defined(WUP_PIN2) && defined(DOUBLE_BATTERY)
digitalWrite(WUP_PIN2, LOW); // Turn off WUP_PIN2
#endif // defined(WUP_PIN2) && defined (DOUBLE_BATTERY)
} else {
digitalWrite(WUP_PIN, HIGH); // Wake up the battery
digitalWrite(WUP_PIN1, HIGH); // Wake up the battery
#if defined(WUP_PIN2) && defined(DOUBLE_BATTERY)
digitalWrite(WUP_PIN2, HIGH); // Wake up the battery2
#endif // defined(WUP_PIN2) && defined (DOUBLE_BATTERY)
}

if (!battery_awake) {
Expand Down Expand Up @@ -1134,8 +1140,12 @@ void setup_battery(void) { // Performs one time setup at startup
datalayer.battery2.status.voltage_dV =
0; //Init voltage to 0 to allow contactor check to operate without fear of default values colliding
#endif
pinMode(WUP_PIN, OUTPUT);
digitalWrite(WUP_PIN, HIGH); // Wake up the battery
pinMode(WUP_PIN1, OUTPUT);
digitalWrite(WUP_PIN1, HIGH); // Wake up the battery
#if defined(DOUBLE_BATTERY) && defined(WUP_PIN2)
pinMode(WUP_PIN2, OUTPUT);
digitalWrite(WUP_PIN2, HIGH); // Wake up the battery
#endif // defined(WUP_PIN2) && defined (DOUBLE_BATTERY)
}

#endif
1 change: 0 additions & 1 deletion Software/src/battery/BMW-I3-BATTERY.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#define BATTERY_SELECTED

#define WUP_PIN 25
#define MAX_CELL_VOLTAGE_60AH 4110 // Battery is put into emergency stop if one cell goes over this value
#define MIN_CELL_VOLTAGE_60AH 2700 // Battery is put into emergency stop if one cell goes below this value
#define MAX_CELL_VOLTAGE_94AH 4140 // Battery is put into emergency stop if one cell goes over this value
Expand Down
1 change: 0 additions & 1 deletion Software/src/battery/BMW-IX-BATTERY.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#define BATTERY_SELECTED

//#define WUP_PIN 25 //Not used
#define MAX_PACK_VOLTAGE_DV 4650 //4650 = 465.0V
#define MIN_PACK_VOLTAGE_DV 3000
#define MAX_CELL_DEVIATION_MV 250
Expand Down
13 changes: 12 additions & 1 deletion Software/src/devboard/hal/hw_3LB.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@
// Equipment stop pin
#define EQUIPMENT_STOP_PIN 35

// BMW_I3_BATTERY wake up pin
#ifdef BMW_I3_BATTERY
#define WUP_PIN1 GPIO_NUM_25 // Wake up pin for battery 1
#ifdef DOUBLE_BATTERY
#define WUP_PIN2 GPIO_NUM_32 // Wake up pin for battery 2
#endif // DOUBLE_BATTERY
#endif // BMW_I3_BATTERY

/* ----- Error checks below, don't change (can't be moved to separate file) ----- */
#ifndef HW_CONFIGURED
#define HW_CONFIGURED
Expand All @@ -98,9 +106,12 @@
#endif

#ifdef BMW_I3_BATTERY
#ifdef CONTACTOR_CONTROL
#if defined(CONTACTOR_CONTROL) && defined(WUP_PIN1)
#error GPIO PIN 25 cannot be used for both BMWi3 Wakeup and contactor control. Disable CONTACTOR_CONTROL
#endif
#if defined(CONTACTOR_CONTROL) && defined(WUP_PIN2)
#error GPIO PIN 32 cannot be used for both BMWi3 Wakeup and contactor control. Disable CONTACTOR_CONTROL
#endif
#endif

#endif
13 changes: 12 additions & 1 deletion Software/src/devboard/hal/hw_lilygo.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@
// Equipment stop pin
#define EQUIPMENT_STOP_PIN 35

// BMW_I3_BATTERY wake up pin
#ifdef BMW_I3_BATTERY
#define WUP_PIN1 GPIO_NUM_25 // Wake up pin for battery 1
#ifdef DOUBLE_BATTERY
#define WUP_PIN2 GPIO_NUM_32 // Wake up pin for battery 2
#endif // DOUBLE_BATTERY
#endif // BMW_I3_BATTERY

/* ----- Error checks below, don't change (can't be moved to separate file) ----- */
#ifndef HW_CONFIGURED
#define HW_CONFIGURED
Expand All @@ -94,9 +102,12 @@
#endif

#ifdef BMW_I3_BATTERY
#ifdef CONTACTOR_CONTROL
#if defined(CONTACTOR_CONTROL) && defined(WUP_PIN1)
#error GPIO PIN 25 cannot be used for both BMWi3 Wakeup and contactor control. Disable CONTACTOR_CONTROL
#endif
#if defined(CONTACTOR_CONTROL) && defined(WUP_PIN2)
#error GPIO PIN 32 cannot be used for both BMWi3 Wakeup and contactor control. Disable CONTACTOR_CONTROL
#endif
#endif

#endif
16 changes: 16 additions & 0 deletions Software/src/devboard/hal/hw_stark.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,27 @@ GPIOs on extra header
// Equipment stop pin
#define EQUIPMENT_STOP_PIN 2

// BMW_I3_BATTERY wake up pin
#ifdef BMW_I3_BATTERY
#define WUP_PIN1 GPIO_NUM_25 // Wake up pin for battery 1
#ifdef DOUBLE_BATTERY
#define WUP_PIN2 GPIO_NUM_32 // Wake up pin for battery 2
#endif // DOUBLE_BATTERY
#endif // BMW_I3_BATTERY

/* ----- Error checks below, don't change (can't be moved to separate file) ----- */
#ifndef HW_CONFIGURED
#define HW_CONFIGURED
#else
#error Multiple HW defined! Please select a single HW
#endif

#ifdef BMW_I3_BATTERY
#if defined(CONTACTOR_CONTROL) && defined(WUP_PIN1)
#error GPIO PIN 25 cannot be used for both BMWi3 Wakeup and contactor control. Disable CONTACTOR_CONTROL
#endif
#if defined(CONTACTOR_CONTROL) && defined(WUP_PIN2)
#error GPIO PIN 32 cannot be used for both BMWi3 Wakeup and contactor control. Disable CONTACTOR_CONTROL
#endif

#endif

0 comments on commit 688952c

Please # to comment.