mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-05 02:39:57 +02:00
Add more info page for Atto3
This commit is contained in:
parent
b8cb5fede6
commit
1996c9a850
3 changed files with 50 additions and 7 deletions
|
@ -1,6 +1,7 @@
|
|||
#include "../include.h"
|
||||
#ifdef BYD_ATTO_3_BATTERY
|
||||
#include "../datalayer/datalayer.h"
|
||||
#include "../datalayer/datalayer_extended.h"
|
||||
#include "../devboard/utils/events.h"
|
||||
#include "BYD-ATTO-3-BATTERY.h"
|
||||
|
||||
|
@ -18,13 +19,14 @@ static uint8_t counter_50ms = 0;
|
|||
static uint8_t counter_100ms = 0;
|
||||
static uint8_t frame6_counter = 0xB;
|
||||
static uint8_t frame7_counter = 0x5;
|
||||
|
||||
static uint16_t battery_voltage = 0;
|
||||
static int16_t battery_temperature_ambient = 0;
|
||||
static int16_t battery_daughterboard_temperatures[10];
|
||||
static int16_t battery_lowest_temperature = 0;
|
||||
static int16_t battery_highest_temperature = 0;
|
||||
static int16_t battery_calc_min_temperature = 0;
|
||||
static int16_t battery_calc_max_temperature = 0;
|
||||
static uint16_t battery_highprecision_SOC = 0;
|
||||
static uint16_t BMS_SOC = 0;
|
||||
static uint16_t BMS_voltage = 0;
|
||||
static int16_t BMS_current = 0;
|
||||
|
@ -40,6 +42,7 @@ static int16_t battery2_lowest_temperature = 0;
|
|||
static int16_t battery2_highest_temperature = 0;
|
||||
static int16_t battery2_calc_min_temperature = 0;
|
||||
static int16_t battery2_calc_max_temperature = 0;
|
||||
static uint16_t battery2_highprecision_SOC = 0;
|
||||
static uint16_t BMS2_SOC = 0;
|
||||
static uint16_t BMS2_voltage = 0;
|
||||
static int16_t BMS2_current = 0;
|
||||
|
@ -142,6 +145,14 @@ void update_values_battery() { //This function maps all the values fetched via
|
|||
|
||||
datalayer.battery.status.temperature_min_dC = battery_calc_min_temperature * 10; // Add decimals
|
||||
datalayer.battery.status.temperature_max_dC = battery_calc_max_temperature * 10;
|
||||
|
||||
// Update webserver datalayer
|
||||
datalayer_extended.bydAtto3.SOC_estimated = datalayer.battery.status.real_soc;
|
||||
//Once we implement switching logic, remember to change from where the estimated is taken
|
||||
datalayer_extended.bydAtto3.SOC_highprec = battery_highprecision_SOC;
|
||||
datalayer_extended.bydAtto3.SOC_polled = BMS_SOC;
|
||||
datalayer_extended.bydAtto3.voltage_periodic = battery_voltage;
|
||||
datalayer_extended.bydAtto3.voltage_polled = BMS_voltage;
|
||||
}
|
||||
|
||||
void receive_can_battery(CAN_frame rx_frame) {
|
||||
|
@ -220,6 +231,8 @@ void receive_can_battery(CAN_frame rx_frame) {
|
|||
case 0x444: //9E,01,88,13,64,64,98,65
|
||||
//9A,01,B6,13,64,64,98,3B //407.5V 18deg
|
||||
//9B,01,B8,13,64,64,98,38 //408.5V 14deg
|
||||
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
|
||||
break;
|
||||
case 0x445: //00,98,FF,FF,63,20,4E,98 - Static, values never changes between logs
|
||||
break;
|
||||
|
@ -228,6 +241,7 @@ void receive_can_battery(CAN_frame rx_frame) {
|
|||
case 0x447: // Seems to contain more temperatures, highest and lowest?
|
||||
//06,38,01,3B,E0,03,39,69
|
||||
//06,36,02,36,E0,03,36,72,
|
||||
battery_highprecision_SOC = ((rx_frame.data.u8[5] & 0x0F) << 8) | rx_frame.data.u8[4]; // 03 E0 = 992 = 99.2%
|
||||
battery_lowest_temperature = (rx_frame.data.u8[1] - 40); //Best guess for now
|
||||
battery_highest_temperature = (rx_frame.data.u8[3] - 40); //Best guess for now
|
||||
break;
|
||||
|
@ -540,6 +554,7 @@ void receive_can_battery2(CAN_frame rx_frame) {
|
|||
case 0x447: // Seems to contain more temperatures, highest and lowest?
|
||||
//06,38,01,3B,E0,03,39,69
|
||||
//06,36,02,36,E0,03,36,72,
|
||||
battery2_highprecision_SOC = ((rx_frame.data.u8[5] & 0x0F) << 8) | rx_frame.data.u8[4]; // 03 E0 = 992 = 99.2%
|
||||
battery2_lowest_temperature = (rx_frame.data.u8[1] - 40); //Best guess for now
|
||||
battery2_highest_temperature = (rx_frame.data.u8[3] - 40); //Best guess for now
|
||||
break;
|
||||
|
|
|
@ -45,6 +45,25 @@ typedef struct {
|
|||
uint8_t ST_cold_shutoff_valve = 0;
|
||||
} DATALAYER_INFO_BMWI3;
|
||||
|
||||
typedef struct {
|
||||
/** uint16_t */
|
||||
/** SOC% estimate. Estimated from total pack voltage */
|
||||
uint16_t SOC_estimated = 0;
|
||||
/** uint16_t */
|
||||
/** SOC% raw battery value. Highprecision. Can be locked if pack is crashed */
|
||||
uint16_t SOC_highprec = 0;
|
||||
/** uint16_t */
|
||||
/** SOC% polled OBD2 value. Can be locked if pack is crashed */
|
||||
uint16_t SOC_polled = 0;
|
||||
/** uint16_t */
|
||||
/** Voltage raw battery value */
|
||||
uint16_t voltage_periodic = 0;
|
||||
/** uint16_t */
|
||||
/** Voltage polled OBD2*/
|
||||
uint16_t voltage_polled = 0;
|
||||
|
||||
} DATALAYER_INFO_BYDATTO3;
|
||||
|
||||
typedef struct {
|
||||
/** uint8_t */
|
||||
/** Contactor status */
|
||||
|
@ -119,6 +138,7 @@ typedef struct {
|
|||
class DataLayerExtended {
|
||||
public:
|
||||
DATALAYER_INFO_BMWI3 bmwi3;
|
||||
DATALAYER_INFO_BYDATTO3 bydAtto3;
|
||||
DATALAYER_INFO_TESLA tesla;
|
||||
DATALAYER_INFO_NISSAN_LEAF nissanleaf;
|
||||
};
|
||||
|
|
|
@ -100,6 +100,14 @@ String advanced_battery_processor(const String& var) {
|
|||
|
||||
#endif //BMW_I3_BATTERY
|
||||
|
||||
#ifdef BYD_ATTO_3_BATTERY
|
||||
content += "<h4>SOC estimated: " + String(datalayer_extended.bydAtto3.SOC_estimated) + "</h4>";
|
||||
content += "<h4>SOC highprec: " + String(datalayer_extended.bydAtto3.SOC_highprec) + "</h4>";
|
||||
content += "<h4>SOC OBD2: " + String(datalayer_extended.bydAtto3.SOC_polled) + "</h4>";
|
||||
content += "<h4>Voltage periodic: " + String(datalayer_extended.bydAtto3.voltage_periodic) + "</h4>";
|
||||
content += "<h4>Voltage OBD2: " + String(datalayer_extended.bydAtto3.voltage_polled) + "</h4>";
|
||||
#endif //BYD_ATTO_3_BATTERY
|
||||
|
||||
#ifdef TESLA_BATTERY
|
||||
static const char* contactorText[] = {"UNKNOWN(0)", "OPEN", "CLOSING", "BLOCKED", "OPENING",
|
||||
"CLOSED", "UNKNOWN(6)", "WELDED", "POS_CL", "NEG_CL",
|
||||
|
@ -151,8 +159,8 @@ String advanced_battery_processor(const String& var) {
|
|||
content += "<h4>Heating requested: " + String(datalayer_extended.nissanleaf.HeaterSendRequest) + "</h4>";
|
||||
#endif
|
||||
|
||||
#if !defined(TESLA_BATTERY) && !defined(NISSAN_LEAF_BATTERY) && \
|
||||
!defined(BMW_I3_BATTERY) //Only the listed types have extra info
|
||||
#if !defined(TESLA_BATTERY) && !defined(NISSAN_LEAF_BATTERY) && !defined(BMW_I3_BATTERY) && \
|
||||
!defined(BYD_ATTO_3_BATTERY) //Only the listed types have extra info
|
||||
content += "No extra information available for this battery type";
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue