mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-05 10:49:42 +02:00
Add name and capacity reporting
This commit is contained in:
parent
05dd887d2f
commit
25c60cb42b
2 changed files with 14 additions and 3 deletions
|
@ -33,6 +33,17 @@ void SofarInverter::
|
||||||
SOFAR_356.data.u8[4] = (datalayer.battery.status.temperature_max_dC & 0x00FF);
|
SOFAR_356.data.u8[4] = (datalayer.battery.status.temperature_max_dC & 0x00FF);
|
||||||
SOFAR_356.data.u8[5] = (datalayer.battery.status.temperature_max_dC >> 8);
|
SOFAR_356.data.u8[5] = (datalayer.battery.status.temperature_max_dC >> 8);
|
||||||
|
|
||||||
|
// frame 0x35E – Manufacturer Name ASCII
|
||||||
|
memset(SOFAR_35E.data.u8, 0, 8);
|
||||||
|
strncpy((char*)SOFAR_35E.data.u8, BatteryType, 8);
|
||||||
|
|
||||||
|
//Gets automatically rescaled with SOC scaling. Calculated with max design voltage, better would be to calculate with nominal voltage
|
||||||
|
calculated_capacity_AH =
|
||||||
|
(datalayer.battery.info.reported_total_capacity_Wh / (datalayer.battery.info.max_design_voltage_dV * 0.1));
|
||||||
|
//Battery Nominal Capacity
|
||||||
|
SOFAR_35F.data.u8[4] = calculated_capacity_AH & 0x00FF;
|
||||||
|
SOFAR_35F.data.u8[5] = (calculated_capacity_AH >> 8);
|
||||||
|
|
||||||
// Charge and discharge consent dependent on SoC with hysteresis at 99% soc
|
// Charge and discharge consent dependent on SoC with hysteresis at 99% soc
|
||||||
//SoC deception only to CAN (we do not touch datalayer)
|
//SoC deception only to CAN (we do not touch datalayer)
|
||||||
uint16_t spoofed_soc = datalayer.battery.status.reported_soc;
|
uint16_t spoofed_soc = datalayer.battery.status.reported_soc;
|
||||||
|
@ -56,7 +67,7 @@ void SofarInverter::
|
||||||
enable_flags = 0x03; // Both charge and discharge allowed
|
enable_flags = 0x03; // Both charge and discharge allowed
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ramka 0x30F – operation mode
|
// Frame 0x30F – operation mode
|
||||||
SOFAR_30F.data.u8[0] = 0x00; // Normal mode
|
SOFAR_30F.data.u8[0] = 0x00; // Normal mode
|
||||||
SOFAR_30F.data.u8[1] = enable_flags;
|
SOFAR_30F.data.u8[1] = enable_flags;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@ class SofarInverter : public CanInverterProtocol {
|
||||||
private:
|
private:
|
||||||
unsigned long previousMillis100 = 0; // will store last time a 100ms CAN Message was send
|
unsigned long previousMillis100 = 0; // will store last time a 100ms CAN Message was send
|
||||||
uint8_t battery_index = 0; // Predefined battery ID (0–15)
|
uint8_t battery_index = 0; // Predefined battery ID (0–15)
|
||||||
uint16_t BatteryCapacity_Ah = 180;
|
uint16_t calculated_capacity_AH = 0; // Pack Capacity in AH (Updates based on battery stats)
|
||||||
const char* BatteryType = "BAT-EMU";
|
const char* BatteryType = "BATxEMU"; // Manufacturer name in ASCII
|
||||||
|
|
||||||
//Actual content messages
|
//Actual content messages
|
||||||
//Note that these are technically extended frames. If more batteries are put in parallel,the first battery sends 0x351 the next battery sends 0x1351 etc. 16 batteries in parallel supported
|
//Note that these are technically extended frames. If more batteries are put in parallel,the first battery sends 0x351 the next battery sends 0x1351 etc. 16 batteries in parallel supported
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue