mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-03 09:49:32 +02:00
Using a more robust way to check that voltage is available from BMS
This commit is contained in:
parent
b349482f20
commit
100e7e6eff
2 changed files with 3 additions and 1 deletions
|
@ -393,6 +393,7 @@ void BydAttoBattery::handle_incoming_can_frame(CAN_frame rx_frame) {
|
|||
datalayer_battery->status.CAN_battery_still_alive = CAN_STILL_ALIVE;
|
||||
battery_voltage = ((rx_frame.data.u8[1] & 0x0F) << 8) | rx_frame.data.u8[0];
|
||||
//battery_temperature_something = rx_frame.data.u8[7] - 40; resides in frame 7
|
||||
BMS_voltage_available = true;
|
||||
break;
|
||||
case 0x445:
|
||||
datalayer_battery->status.CAN_battery_still_alive = CAN_STILL_ALIVE;
|
||||
|
@ -542,7 +543,7 @@ void BydAttoBattery::transmit_can(unsigned long currentMillis) {
|
|||
}
|
||||
|
||||
if (counter_100ms > 3) {
|
||||
if (battery_voltage > 0) {
|
||||
if (BMS_voltage_available) { // Transmit battery voltage back to BMS when confirmed it's available, this closes the contactors
|
||||
ATTO_3_441.data.u8[4] = (uint8_t)(battery_voltage - 1);
|
||||
ATTO_3_441.data.u8[5] = ((battery_voltage - 1) >> 8);
|
||||
ATTO_3_441.data.u8[6] = 0xFF;
|
||||
|
|
|
@ -98,6 +98,7 @@ class BydAttoBattery : public CanBattery {
|
|||
unsigned long previousMillis100 = 0; // will store last time a 100ms CAN Message was send
|
||||
unsigned long previousMillis200 = 0; // will store last time a 200ms CAN Message was send
|
||||
bool SOC_method = false;
|
||||
bool BMS_voltage_available = false;
|
||||
uint8_t counter_50ms = 0;
|
||||
uint8_t counter_100ms = 0;
|
||||
uint8_t frame6_counter = 0xB;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue