Skip to content

Commit

Permalink
Add contactorclosing allowed for Tesla
Browse files Browse the repository at this point in the history
  • Loading branch information
dalathegreat committed Nov 27, 2023
1 parent 1b297af commit 2d6026e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
2 changes: 2 additions & 0 deletions Software/src/battery/TESLA-MODEL-3-BATTERY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,10 +521,12 @@ the first, for a few cycles, then stop all messages which causes the contactor

if (bms_status == ACTIVE) {
send221still = 50;
batteryAllowsContactorClosing = true;
ESP32Can.CANWriteFrame(&TESLA_221_1);
ESP32Can.CANWriteFrame(&TESLA_221_2);
} else { //bms_status == FAULT
if (send221still > 0) {
batteryAllowsContactorClosing = false;
ESP32Can.CANWriteFrame(&TESLA_221_1);
send221still--;
}
Expand Down
34 changes: 17 additions & 17 deletions Software/src/battery/TESLA-MODEL-3-BATTERY.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@
60000 // 60000W we need to cap this value to max 60kW, most inverters overflow otherwise

// These parameters need to be mapped for the Inverter
extern uint16_t SOC;
extern uint16_t StateOfHealth;
extern uint16_t battery_voltage;
extern uint16_t battery_current;
extern uint16_t capacity_Wh;
extern uint16_t remaining_capacity_Wh;
extern uint16_t max_target_discharge_power;
extern uint16_t max_target_charge_power;
extern uint16_t bms_status;
extern uint16_t bms_char_dis_status;
extern uint16_t stat_batt_power;
extern uint16_t temperature_min;
extern uint16_t temperature_max;
extern uint16_t CANerror;
extern uint16_t cell_max_voltage;
extern uint16_t cell_min_voltage;
extern uint8_t LEDcolor;
extern uint16_t SOC; //SOC%, 0-100.00 (0-10000)
extern uint16_t StateOfHealth; //SOH%, 0-100.00 (0-10000)
extern uint16_t battery_voltage; //V+1, 0-500.0 (0-5000)
extern uint16_t battery_current; //A+1, Goes thru convert2unsignedint16 function (5.0A = 50, -5.0A = 65485)
extern uint16_t capacity_Wh; //Wh, 0-60000
extern uint16_t remaining_capacity_Wh; //Wh, 0-60000
extern uint16_t max_target_discharge_power; //W, 0-60000
extern uint16_t max_target_charge_power; //W, 0-60000
extern uint16_t bms_status; //Enum, 0-5
extern uint16_t bms_char_dis_status; //Enum, 0-2
extern uint16_t stat_batt_power; //W, Goes thru convert2unsignedint16 function (5W = 5, -5W = 65530)
extern uint16_t temperature_min; //C+1, Goes thru convert2unsignedint16 function (15.0C = 150, -15.0C = 65385)
extern uint16_t temperature_max; //C+1, Goes thru convert2unsignedint16 function (15.0C = 150, -15.0C = 65385)
extern uint16_t cell_max_voltage; //mV, 0-4350
extern uint16_t cell_min_voltage; //mV, 0-4350
extern uint8_t LEDcolor; //Enum, 0-10
extern bool batteryAllowsContactorClosing; //Bool, 1=true, 0=false
// Definitions for BMS status
#define STANDBY 0
#define INACTIVE 1
Expand Down

0 comments on commit 2d6026e

Please sign in to comment.