mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-05 19:42:08 +02:00
Merge pull request #971 from dalathegreat/feature/CMFA-EV
New battery: Add support for CMFA-EV battery
This commit is contained in:
commit
71449caf4e
7 changed files with 1229 additions and 1 deletions
1
.github/workflows/compile-all-batteries.yml
vendored
1
.github/workflows/compile-all-batteries.yml
vendored
|
@ -55,6 +55,7 @@ jobs:
|
|||
- BYD_ATTO_3_BATTERY
|
||||
- CELLPOWER_BMS
|
||||
- CHADEMO_BATTERY
|
||||
- CMFA_EV_BATTERY
|
||||
- FOXESS_BATTERY
|
||||
- IMIEV_CZERO_ION_BATTERY
|
||||
- JAGUAR_IPACE_BATTERY
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
//#define FOXESS_BATTERY
|
||||
//#define CELLPOWER_BMS
|
||||
//#define CHADEMO_BATTERY //NOTE: inherently enables CONTACTOR_CONTROL below
|
||||
//#define CMFA_EV_BATTERY
|
||||
//#define IMIEV_CZERO_ION_BATTERY
|
||||
//#define JAGUAR_IPACE_BATTERY
|
||||
//#define KIA_E_GMP_BATTERY
|
||||
|
|
|
@ -38,6 +38,10 @@ void setup_can_shunt();
|
|||
#include "CHADEMO-SHUNTS.h"
|
||||
#endif
|
||||
|
||||
#ifdef CMFA_EV_BATTERY
|
||||
#include "CMFA-EV-BATTERY.h"
|
||||
#endif
|
||||
|
||||
#ifdef FOXESS_BATTERY
|
||||
#include "FOXESS-BATTERY.h"
|
||||
#endif
|
||||
|
|
1019
Software/src/battery/CMFA-EV-BATTERY.cpp
Normal file
1019
Software/src/battery/CMFA-EV-BATTERY.cpp
Normal file
File diff suppressed because it is too large
Load diff
158
Software/src/battery/CMFA-EV-BATTERY.h
Normal file
158
Software/src/battery/CMFA-EV-BATTERY.h
Normal file
|
@ -0,0 +1,158 @@
|
|||
#ifndef CMFA_EV_BATTERY_H
|
||||
#define CMFA_EV_BATTERY_H
|
||||
#include "../include.h"
|
||||
|
||||
#define BATTERY_SELECTED
|
||||
#define MAX_PACK_VOLTAGE_DV 3040 //5000 = 500.0V
|
||||
#define MIN_PACK_VOLTAGE_DV 2150
|
||||
#define MAX_CELL_DEVIATION_MV 100
|
||||
#define MAX_CELL_VOLTAGE_MV 4250 //Battery is put into emergency stop if one cell goes over this value
|
||||
#define MIN_CELL_VOLTAGE_MV 2700 //Battery is put into emergency stop if one cell goes below this value
|
||||
|
||||
// OBD2 PID polls. Some of these have been reverse engineered, but there are many unknown values still
|
||||
#define PID_POLL_SOCZ 0x9001 //122 in log
|
||||
#define PID_POLL_USOC 0x9002 //5531 (Possible SOC candidate)
|
||||
#define PID_POLL_SOH_AVERAGE 0x9003
|
||||
#define PID_POLL_AVERAGE_VOLTAGE_OF_CELLS 0x9006
|
||||
#define PID_POLL_HIGHEST_CELL_VOLTAGE 0x9007
|
||||
#define PID_POLL_CELL_NUMBER_HIGHEST_VOLTAGE 0x9008
|
||||
#define PID_POLL_LOWEST_CELL_VOLTAGE 0x9009
|
||||
#define PID_POLL_CELL_NUMBER_LOWEST_VOLTAGE 0x900A
|
||||
#define PID_POLL_CURRENT_OFFSET 0x900C
|
||||
#define PID_POLL_INSTANT_CURRENT 0x900D
|
||||
#define PID_POLL_MAX_REGEN 0x900E
|
||||
#define PID_POLL_MAX_DISCHARGE_POWER 0x900F
|
||||
#define PID_POLL_12V_BATTERY 0x9011
|
||||
#define PID_POLL_AVERAGE_TEMPERATURE 0x9012 //749 in log
|
||||
#define PID_POLL_MIN_TEMPERATURE 0x9013 //736 in log
|
||||
#define PID_POLL_MAX_TEMPERATURE 0x9014 //752 in log
|
||||
#define PID_POLL_MAX_CHARGE_POWER 0x9018
|
||||
#define PID_POLL_END_OF_CHARGE_FLAG 0x9019
|
||||
#define PID_POLL_INTERLOCK_FLAG 0x901A
|
||||
#define PID_POLL_BATTERY_IDENTIFICATION 0x901B // Multi frame message
|
||||
#define PID_POLL_CELL_1 0x9021
|
||||
#define PID_POLL_CELL_2 0x9022
|
||||
#define PID_POLL_CELL_3 0x9023
|
||||
#define PID_POLL_CELL_4 0x9024
|
||||
#define PID_POLL_CELL_5 0x9025
|
||||
#define PID_POLL_CELL_6 0x9026
|
||||
#define PID_POLL_CELL_7 0x9027
|
||||
#define PID_POLL_CELL_8 0x9028
|
||||
#define PID_POLL_CELL_9 0x9029
|
||||
#define PID_POLL_CELL_10 0x902A
|
||||
#define PID_POLL_CELL_11 0x902B
|
||||
#define PID_POLL_CELL_12 0x902C
|
||||
#define PID_POLL_CELL_13 0x902D
|
||||
#define PID_POLL_CELL_14 0x902E
|
||||
#define PID_POLL_CELL_15 0x902F
|
||||
#define PID_POLL_CELL_16 0x9030
|
||||
#define PID_POLL_CELL_17 0x9031
|
||||
#define PID_POLL_CELL_18 0x9032
|
||||
#define PID_POLL_CELL_19 0x9033
|
||||
#define PID_POLL_CELL_20 0x9034
|
||||
#define PID_POLL_CELL_21 0x9035
|
||||
#define PID_POLL_CELL_22 0x9036
|
||||
#define PID_POLL_CELL_23 0x9037
|
||||
#define PID_POLL_CELL_24 0x9038
|
||||
#define PID_POLL_CELL_25 0x9039
|
||||
#define PID_POLL_CELL_26 0x903A
|
||||
#define PID_POLL_CELL_27 0x903B
|
||||
#define PID_POLL_CELL_28 0x903C
|
||||
#define PID_POLL_CELL_29 0x903D
|
||||
#define PID_POLL_CELL_30 0x903E
|
||||
#define PID_POLL_CELL_31 0x903F
|
||||
#define PID_POLL_DIDS_SUPPORTED_IN_RANGE_9041_9060 0x9040
|
||||
#define PID_POLL_CELL_32 0x9041
|
||||
#define PID_POLL_CELL_33 0x9042
|
||||
#define PID_POLL_CELL_34 0x9043
|
||||
#define PID_POLL_CELL_35 0x9044
|
||||
#define PID_POLL_CELL_36 0x9045
|
||||
#define PID_POLL_CELL_37 0x9046
|
||||
#define PID_POLL_CELL_38 0x9047
|
||||
#define PID_POLL_CELL_39 0x9048
|
||||
#define PID_POLL_CELL_40 0x9049
|
||||
#define PID_POLL_CELL_41 0x904A
|
||||
#define PID_POLL_CELL_42 0x904B
|
||||
#define PID_POLL_CELL_43 0x904C
|
||||
#define PID_POLL_CELL_44 0x904D
|
||||
#define PID_POLL_CELL_45 0x904E
|
||||
#define PID_POLL_CELL_46 0x904F
|
||||
#define PID_POLL_CELL_47 0x9050
|
||||
#define PID_POLL_CELL_48 0x9051
|
||||
#define PID_POLL_CELL_49 0x9052
|
||||
#define PID_POLL_CELL_50 0x9053
|
||||
#define PID_POLL_CELL_51 0x9054
|
||||
#define PID_POLL_CELL_52 0x9055
|
||||
#define PID_POLL_CELL_53 0x9056
|
||||
#define PID_POLL_CELL_54 0x9057
|
||||
#define PID_POLL_CELL_55 0x9058
|
||||
#define PID_POLL_CELL_56 0x9059
|
||||
#define PID_POLL_CELL_57 0x905A
|
||||
#define PID_POLL_CELL_58 0x905B
|
||||
#define PID_POLL_CELL_59 0x905C
|
||||
#define PID_POLL_CELL_60 0x905D
|
||||
#define PID_POLL_CELL_61 0x905E
|
||||
#define PID_POLL_CELL_62 0x905F
|
||||
#define PID_POLL_DIDS_SUPPORTED_IN_RANGE_9061_9080 0x9060
|
||||
#define PID_POLL_CELL_63 0x9061
|
||||
#define PID_POLL_CELL_64 0x9062
|
||||
#define PID_POLL_CELL_65 0x9063
|
||||
#define PID_POLL_CELL_66 0x9064
|
||||
#define PID_POLL_CELL_67 0x9065
|
||||
#define PID_POLL_CELL_68 0x9066
|
||||
#define PID_POLL_CELL_69 0x9067
|
||||
#define PID_POLL_CELL_70 0x9068
|
||||
#define PID_POLL_CELL_71 0x9069
|
||||
#define PID_POLL_CELL_72 0x906A
|
||||
/*
|
||||
#define PID_POLL_UNKNOWNX 0x912F // Multi frame message, empty
|
||||
#define PID_POLL_UNKNOWNX 0x9129
|
||||
#define PID_POLL_UNKNOWNX 0x9131
|
||||
#define PID_POLL_UNKNOWNX 0x9132
|
||||
#define PID_POLL_UNKNOWNX 0x9133
|
||||
#define PID_POLL_UNKNOWNX 0x9134
|
||||
#define PID_POLL_UNKNOWNX 0x9135
|
||||
#define PID_POLL_UNKNOWNX 0x9136
|
||||
#define PID_POLL_UNKNOWNX 0x9137
|
||||
#define PID_POLL_UNKNOWNX 0x9138
|
||||
#define PID_POLL_UNKNOWNX 0x9139
|
||||
#define PID_POLL_UNKNOWNX 0x913A
|
||||
#define PID_POLL_UNKNOWNX 0x913B
|
||||
#define PID_POLL_UNKNOWNX 0x913C
|
||||
#define PID_POLL_UNKNOWN5 0x912F
|
||||
#define PID_POLL_UNKNOWNX 0x91B7
|
||||
*/
|
||||
#define PID_POLL_SOH_AVAILABLE_POWER_CALCULATION 0x91BC // 0-100%
|
||||
#define PID_POLL_SOH_GENERATED_POWER_CALCULATION 0x91BD // 0-100%
|
||||
/*
|
||||
#define PID_POLL_UNKNOWNX 0x91C1
|
||||
#define PID_POLL_UNKNOWNX 0x91CD
|
||||
#define PID_POLL_UNKNOWNX 0x91CF
|
||||
#define PID_POLL_UNKNOWNX 0x91F6
|
||||
#define PID_POLL_UNKNOWNX 0x91F7
|
||||
#define PID_POLL_UNKNOWNX 0x920F
|
||||
#define PID_POLL_UNKNOWNx 0x9242
|
||||
*/
|
||||
#define PID_POLL_CUMULATIVE_ENERGY_WHEN_CHARGING 0x9243
|
||||
#define PID_POLL_CUMULATIVE_ENERGY_WHEN_DISCHARGING 0x9245
|
||||
#define PID_POLL_CUMULATIVE_ENERGY_IN_REGEN 0x9247
|
||||
/*
|
||||
#define PID_POLL_UNKNOWNx 0x9256
|
||||
#define PID_POLL_UNKNOWNx 0x9261
|
||||
#define PID_POLL_UNKNOWN7 0x9284
|
||||
#define PID_POLL_UNKNOWNx 0xF012
|
||||
#define PID_POLL_UNKNOWNx 0xF1A0
|
||||
#define PID_POLL_UNKNOWNx 0xF182
|
||||
#define PID_POLL_UNKNOWNx 0xF187
|
||||
#define PID_POLL_UNKNOWNx 0xF188
|
||||
#define PID_POLL_UNKNOWNx 0xF18A
|
||||
#define PID_POLL_UNKNOWNx 0xF18C
|
||||
#define PID_POLL_UNKNOWNx 0xF191
|
||||
#define PID_POLL_UNKNOWNx 0xF194
|
||||
#define PID_POLL_UNKNOWNx 0xF195
|
||||
*/
|
||||
|
||||
void setup_battery(void);
|
||||
void transmit_can_frame(CAN_frame* tx_frame, int interface);
|
||||
|
||||
#endif
|
|
@ -252,6 +252,26 @@ typedef struct {
|
|||
bool warning_Charger_not_responding = false;
|
||||
} DATALAYER_INFO_CELLPOWER;
|
||||
|
||||
typedef struct {
|
||||
uint16_t soc_z = 0;
|
||||
uint16_t soc_u = 0;
|
||||
uint16_t soh_average = 0;
|
||||
uint16_t max_regen_power = 0;
|
||||
uint16_t max_discharge_power = 0;
|
||||
int16_t average_temperature = 0;
|
||||
int16_t minimum_temperature = 0;
|
||||
int16_t maximum_temperature = 0;
|
||||
uint16_t maximum_charge_power = 0;
|
||||
uint16_t SOH_available_power = 0;
|
||||
uint16_t SOH_generated_power = 0;
|
||||
uint16_t lead_acid_voltage = 0;
|
||||
uint8_t highest_cell_voltage_number = 0;
|
||||
uint8_t lowest_cell_voltage_number = 0;
|
||||
uint64_t cumulative_energy_when_discharging = 0;
|
||||
uint64_t cumulative_energy_when_charging = 0;
|
||||
uint64_t cumulative_energy_in_regen = 0;
|
||||
} DATALAYER_INFO_CMFAEV;
|
||||
|
||||
typedef struct {
|
||||
uint8_t total_cell_count = 0;
|
||||
int16_t battery_12V = 0;
|
||||
|
@ -734,6 +754,7 @@ class DataLayerExtended {
|
|||
DATALAYER_INFO_BMWI3 bmwi3;
|
||||
DATALAYER_INFO_BYDATTO3 bydAtto3;
|
||||
DATALAYER_INFO_CELLPOWER cellpower;
|
||||
DATALAYER_INFO_CMFAEV CMFAEV;
|
||||
DATALAYER_INFO_KIAHYUNDAI64 KiaHyundai64;
|
||||
DATALAYER_INFO_TESLA tesla;
|
||||
DATALAYER_INFO_NISSAN_LEAF nissanleaf;
|
||||
|
|
|
@ -432,6 +432,30 @@ String advanced_battery_processor(const String& var) {
|
|||
String(falseTrue[datalayer_extended.cellpower.warning_Charger_not_responding]) + "</h4>";
|
||||
#endif //CELLPOWER_BMS
|
||||
|
||||
#ifdef CMFA_EV_BATTERY
|
||||
content += "<h4>SOC U: " + String(datalayer_extended.CMFAEV.soc_u) + "percent</h4>";
|
||||
content += "<h4>SOC Z: " + String(datalayer_extended.CMFAEV.soc_z) + "percent</h4>";
|
||||
content += "<h4>SOH Average: " + String(datalayer_extended.CMFAEV.soh_average) + "pptt</h4>";
|
||||
content += "<h4>12V voltage: " + String(datalayer_extended.CMFAEV.lead_acid_voltage) + "mV</h4>";
|
||||
content += "<h4>Highest cell number: " + String(datalayer_extended.CMFAEV.highest_cell_voltage_number) + "</h4>";
|
||||
content += "<h4>Lowest cell number: " + String(datalayer_extended.CMFAEV.lowest_cell_voltage_number) + "</h4>";
|
||||
content += "<h4>Max regen power: " + String(datalayer_extended.CMFAEV.max_regen_power) + "</h4>";
|
||||
content += "<h4>Max discharge power: " + String(datalayer_extended.CMFAEV.max_discharge_power) + "</h4>";
|
||||
content += "<h4>Max charge power: " + String(datalayer_extended.CMFAEV.maximum_charge_power) + "</h4>";
|
||||
content += "<h4>SOH available power: " + String(datalayer_extended.CMFAEV.SOH_available_power) + "</h4>";
|
||||
content += "<h4>SOH generated power: " + String(datalayer_extended.CMFAEV.SOH_generated_power) + "</h4>";
|
||||
content += "<h4>Average temperature: " + String(datalayer_extended.CMFAEV.average_temperature) + "dC</h4>";
|
||||
content += "<h4>Maximum temperature: " + String(datalayer_extended.CMFAEV.maximum_temperature) + "dC</h4>";
|
||||
content += "<h4>Minimum temperature: " + String(datalayer_extended.CMFAEV.minimum_temperature) + "dC</h4>";
|
||||
content +=
|
||||
"<h4>Cumulative energy discharged: " + String(datalayer_extended.CMFAEV.cumulative_energy_when_discharging) +
|
||||
"Wh</h4>";
|
||||
content += "<h4>Cumulative energy charged: " + String(datalayer_extended.CMFAEV.cumulative_energy_when_charging) +
|
||||
"Wh</h4>";
|
||||
content +=
|
||||
"<h4>Cumulative energy regen: " + String(datalayer_extended.CMFAEV.cumulative_energy_in_regen) + "Wh</h4>";
|
||||
#endif //CMFA_EV_BATTERY
|
||||
|
||||
#ifdef KIA_HYUNDAI_64_BATTERY
|
||||
content += "<h4>Cells: " + String(datalayer_extended.KiaHyundai64.total_cell_count) + "S</h4>";
|
||||
content += "<h4>12V voltage: " + String(datalayer_extended.KiaHyundai64.battery_12V / 10.0, 1) + "</h4>";
|
||||
|
@ -1447,7 +1471,7 @@ String advanced_battery_processor(const String& var) {
|
|||
!defined(TESLA_BATTERY) && !defined(NISSAN_LEAF_BATTERY) && !defined(BMW_I3_BATTERY) && \
|
||||
!defined(BYD_ATTO_3_BATTERY) && !defined(RENAULT_ZOE_GEN2_BATTERY) && !defined(CELLPOWER_BMS) && \
|
||||
!defined(MEB_BATTERY) && !defined(VOLVO_SPA_BATTERY) && !defined(VOLVO_SPA_HYBRID_BATTERY) && \
|
||||
!defined(KIA_HYUNDAI_64_BATTERY) //Only the listed types have extra info
|
||||
!defined(KIA_HYUNDAI_64_BATTERY) && !defined(CMFA_EV_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