mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-06 03:50:13 +02:00
Disable precharge bit if not precharging.
This commit is contained in:
parent
7a5202461a
commit
f9132dfd30
4 changed files with 14 additions and 6 deletions
|
@ -1600,8 +1600,8 @@ void transmit_can_battery() {
|
|||
if (MEB_503.data.u8[3] == BMS_TARGET_HV_OFF) {
|
||||
logging.printf("MEB Requesting HV\n");
|
||||
}
|
||||
MEB_503.data.u8[1] = 0xB0;
|
||||
MEB_503.data.u8[3] = BMS_TARGET_AC_CHARGING; //TODO, should we try AC_2 or DC charging?
|
||||
MEB_503.data.u8[1] = 0x30 | (datalayer.battery.status.bms_status == ACTIVE ? 0x00 : 0x80); // Disable precharing if ACTIVE
|
||||
MEB_503.data.u8[3] = BMS_TARGET_HV_ON; //TODO, should we try AC_2 or DC charging?
|
||||
MEB_503.data.u8[5] = 0x82; // Bordnetz Active
|
||||
MEB_503.data.u8[6] = 0xE0; // Request emergency shutdown HV system == 0, false
|
||||
} else if (first_can_msg > 0 && currentMillis > first_can_msg + 2000 && BMS_mode != 0 &&
|
||||
|
|
|
@ -165,7 +165,10 @@ void transmit_can_frame(CAN_frame* tx_frame, int interface) {
|
|||
#ifdef CANFD_ADDON
|
||||
CANFDMessage MCP2518Frame;
|
||||
if (tx_frame->FD) {
|
||||
MCP2518Frame.type = CANFDMessage::CANFD_WITH_BIT_RATE_SWITCH;
|
||||
if (tx_frame->BRS)
|
||||
MCP2518Frame.type = CANFDMessage::CANFD_WITH_BIT_RATE_SWITCH;
|
||||
else
|
||||
MCP2518Frame.type = CANFDMessage::CANFD_NO_BIT_RATE_SWITCH;
|
||||
} else { //Classic CAN message
|
||||
MCP2518Frame.type = CANFDMessage::CAN_DATA;
|
||||
}
|
||||
|
|
|
@ -9,11 +9,10 @@
|
|||
enum State { PRECHARGE_IDLE, START_PRECHARGE, PRECHARGE, PRECHARGE_OFF, COMPLETED };
|
||||
State prechargeStatus = PRECHARGE_IDLE;
|
||||
|
||||
#define MAX_ALLOWED_FAULT_TICKS 1000
|
||||
#define MAX_PRECHARGE_TIME_MS 15000 // Maximum time precharge may be enabled
|
||||
|
||||
#define Precharge_default_PWM_Freq 22000
|
||||
#define Precharge_min_PWM_Freq 18000
|
||||
#define Precharge_default_PWM_Freq 11000
|
||||
#define Precharge_min_PWM_Freq 5000
|
||||
#define Precharge_max_PWM_Freq 34000
|
||||
#define PWM_Res 8
|
||||
#define PWM_OFF_DUTY 0
|
||||
|
@ -58,6 +57,8 @@ void handle_precharge_control() {
|
|||
prechargeStartTime = currentTime;
|
||||
prechargeStatus = PRECHARGE;
|
||||
logging.printf("Precharge: Starting sequence\n");
|
||||
digitalWrite(POSITIVE_CONTACTOR_PIN, HIGH);
|
||||
|
||||
break;
|
||||
|
||||
case PRECHARGE:
|
||||
|
@ -90,11 +91,13 @@ void handle_precharge_control() {
|
|||
datalayer.system.settings.equipment_stop_active) {
|
||||
pinMode(PRECHARGE_PIN, OUTPUT);
|
||||
digitalWrite(PRECHARGE_PIN, LOW);
|
||||
digitalWrite(POSITIVE_CONTACTOR_PIN, LOW);
|
||||
prechargeStatus = PRECHARGE_IDLE;
|
||||
logging.printf("Precharge: Disabling Precharge bms not standby/active or equipment stop\n");
|
||||
} else if (currentTime - prechargeStartTime >= MAX_PRECHARGE_TIME_MS) {
|
||||
pinMode(PRECHARGE_PIN, OUTPUT);
|
||||
digitalWrite(PRECHARGE_PIN, LOW);
|
||||
digitalWrite(POSITIVE_CONTACTOR_PIN, LOW);
|
||||
prechargeStatus = PRECHARGE_OFF;
|
||||
datalayer.battery.status.bms_status = FAULT;
|
||||
logging.printf("Precharge: Disabled (timeout reached) -> PRECHARGE_OFF\n");
|
||||
|
@ -102,6 +105,7 @@ void handle_precharge_control() {
|
|||
} else if (datalayer.system.status.battery_allows_contactor_closing) {
|
||||
pinMode(PRECHARGE_PIN, OUTPUT);
|
||||
digitalWrite(PRECHARGE_PIN, LOW);
|
||||
digitalWrite(POSITIVE_CONTACTOR_PIN, LOW);
|
||||
prechargeStatus = COMPLETED;
|
||||
logging.printf("Precharge: Disabled (contacts closed) -> COMPLETED\n");
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ enum led_color { GREEN, YELLOW, RED, BLUE, RGB };
|
|||
/* CAN Frame structure */
|
||||
typedef struct {
|
||||
bool FD;
|
||||
bool BRS;
|
||||
bool ext_ID;
|
||||
uint8_t DLC;
|
||||
uint32_t ID;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue