mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-03 09:49:32 +02:00
Make contactor opening take 9s instead of 60s
This commit is contained in:
parent
3ead4d12d4
commit
0244468624
2 changed files with 20 additions and 16 deletions
|
@ -976,22 +976,22 @@ void TeslaBattery::
|
||||||
if ((datalayer.system.status.inverter_allows_contactor_closing == true) &&
|
if ((datalayer.system.status.inverter_allows_contactor_closing == true) &&
|
||||||
(datalayer.battery.status.bms_status != FAULT) && (!datalayer.system.settings.equipment_stop_active)) {
|
(datalayer.battery.status.bms_status != FAULT) && (!datalayer.system.settings.equipment_stop_active)) {
|
||||||
// Carry on: 0x221 DRIVE state & reset power down timer
|
// Carry on: 0x221 DRIVE state & reset power down timer
|
||||||
vehicleState = 1;
|
vehicleState = CAR_DRIVE;
|
||||||
powerDownTimer = 180; //0x221 50ms cyclic, 20 calls/second
|
powerDownSeconds = 9;
|
||||||
} else {
|
} else {
|
||||||
// Faulted state, or inverter blocks contactor closing
|
// Faulted state, or inverter blocks contactor closing
|
||||||
// Shut down: 0x221 ACCESSORY state for 3 seconds, followed by GOING_DOWN, then OFF
|
// Shut down: 0x221 ACCESSORY state for 3 seconds, followed by GOING_DOWN, then OFF
|
||||||
if (powerDownTimer <= 180 && powerDownTimer > 120) {
|
if (powerDownSeconds <= 9 && powerDownSeconds > 6) {
|
||||||
vehicleState = 2; //ACCESSORY
|
vehicleState = ACCESSORY;
|
||||||
powerDownTimer--;
|
powerDownSeconds--;
|
||||||
}
|
}
|
||||||
if (powerDownTimer <= 120 && powerDownTimer > 60) {
|
if (powerDownSeconds <= 6 && powerDownSeconds > 3) {
|
||||||
vehicleState = 3; //GOING_DOWN
|
vehicleState = GOING_DOWN;
|
||||||
powerDownTimer--;
|
powerDownSeconds--;
|
||||||
}
|
}
|
||||||
if (powerDownTimer <= 60 && powerDownTimer > 0) {
|
if (powerDownSeconds <= 3 && powerDownSeconds > 0) {
|
||||||
vehicleState = 0; //OFF
|
vehicleState = CAR_OFF;
|
||||||
powerDownTimer--;
|
powerDownSeconds--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2059,7 +2059,7 @@ void TeslaBattery::transmit_can(unsigned long currentMillis) {
|
||||||
previousMillis50 = currentMillis;
|
previousMillis50 = currentMillis;
|
||||||
|
|
||||||
//0x221 VCFRONT_LVPowerState
|
//0x221 VCFRONT_LVPowerState
|
||||||
if (vehicleState == 1) { // Drive
|
if (vehicleState == CAR_DRIVE) {
|
||||||
switch (muxNumber_TESLA_221) {
|
switch (muxNumber_TESLA_221) {
|
||||||
case 0:
|
case 0:
|
||||||
generateMuxFrameCounterChecksum(TESLA_221_DRIVE_Mux0, frameCounter_TESLA_221, 52, 4, 56, 8);
|
generateMuxFrameCounterChecksum(TESLA_221_DRIVE_Mux0, frameCounter_TESLA_221, 52, 4, 56, 8);
|
||||||
|
@ -2077,7 +2077,7 @@ void TeslaBattery::transmit_can(unsigned long currentMillis) {
|
||||||
//Generate next new frame
|
//Generate next new frame
|
||||||
frameCounter_TESLA_221 = (frameCounter_TESLA_221 + 1) % 16;
|
frameCounter_TESLA_221 = (frameCounter_TESLA_221 + 1) % 16;
|
||||||
}
|
}
|
||||||
if (vehicleState == 2) { // Accessory
|
if (vehicleState == ACCESSORY) {
|
||||||
switch (muxNumber_TESLA_221) {
|
switch (muxNumber_TESLA_221) {
|
||||||
case 0:
|
case 0:
|
||||||
generateMuxFrameCounterChecksum(TESLA_221_ACCESSORY_Mux0, frameCounter_TESLA_221, 52, 4, 56, 8);
|
generateMuxFrameCounterChecksum(TESLA_221_ACCESSORY_Mux0, frameCounter_TESLA_221, 52, 4, 56, 8);
|
||||||
|
@ -2095,7 +2095,7 @@ void TeslaBattery::transmit_can(unsigned long currentMillis) {
|
||||||
//Generate next new frame
|
//Generate next new frame
|
||||||
frameCounter_TESLA_221 = (frameCounter_TESLA_221 + 1) % 16;
|
frameCounter_TESLA_221 = (frameCounter_TESLA_221 + 1) % 16;
|
||||||
}
|
}
|
||||||
if (vehicleState == 3) { // Going down
|
if (vehicleState == GOING_DOWN) {
|
||||||
switch (muxNumber_TESLA_221) {
|
switch (muxNumber_TESLA_221) {
|
||||||
case 0:
|
case 0:
|
||||||
generateMuxFrameCounterChecksum(TESLA_221_GOING_DOWN_Mux0, frameCounter_TESLA_221, 52, 4, 56, 8);
|
generateMuxFrameCounterChecksum(TESLA_221_GOING_DOWN_Mux0, frameCounter_TESLA_221, 52, 4, 56, 8);
|
||||||
|
@ -2113,7 +2113,7 @@ void TeslaBattery::transmit_can(unsigned long currentMillis) {
|
||||||
//Generate next new frame
|
//Generate next new frame
|
||||||
frameCounter_TESLA_221 = (frameCounter_TESLA_221 + 1) % 16;
|
frameCounter_TESLA_221 = (frameCounter_TESLA_221 + 1) % 16;
|
||||||
}
|
}
|
||||||
if (vehicleState == 0) { // Off
|
if (vehicleState == CAR_OFF) {
|
||||||
switch (muxNumber_TESLA_221) {
|
switch (muxNumber_TESLA_221) {
|
||||||
case 0:
|
case 0:
|
||||||
generateMuxFrameCounterChecksum(TESLA_221_OFF_Mux0, frameCounter_TESLA_221, 52, 4, 56, 8);
|
generateMuxFrameCounterChecksum(TESLA_221_OFF_Mux0, frameCounter_TESLA_221, 52, 4, 56, 8);
|
||||||
|
|
|
@ -78,7 +78,11 @@ class TeslaBattery : public CanBattery {
|
||||||
uint8_t muxNumber_TESLA_221 = 0;
|
uint8_t muxNumber_TESLA_221 = 0;
|
||||||
uint8_t frameCounter_TESLA_221 = 15; // Start at 15 for Mux 0
|
uint8_t frameCounter_TESLA_221 = 15; // Start at 15 for Mux 0
|
||||||
uint8_t vehicleState = 1; // "OFF": 0, "DRIVE": 1, "ACCESSORY": 2, "GOING_DOWN": 3
|
uint8_t vehicleState = 1; // "OFF": 0, "DRIVE": 1, "ACCESSORY": 2, "GOING_DOWN": 3
|
||||||
uint16_t powerDownTimer = 180; // Car power down (i.e. contactor open) tracking timer, 3 seconds per sendingState
|
static const uint8_t CAR_OFF = 0;
|
||||||
|
static const uint8_t CAR_DRIVE = 1;
|
||||||
|
static const uint8_t ACCESSORY = 2;
|
||||||
|
static const uint8_t GOING_DOWN = 3;
|
||||||
|
uint8_t powerDownSeconds = 9; // Car power down (i.e. contactor open) tracking timer, 3 seconds per sendingState
|
||||||
//0x2E1 VCFRONT_status, 6 mux tracker
|
//0x2E1 VCFRONT_status, 6 mux tracker
|
||||||
uint8_t muxNumber_TESLA_2E1 = 0;
|
uint8_t muxNumber_TESLA_2E1 = 0;
|
||||||
//0x334 UI
|
//0x334 UI
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue