mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-05 10:49:42 +02:00
Use base class for SIMP BMS battery
This commit is contained in:
parent
52ffa5289b
commit
862a5b8133
2 changed files with 48 additions and 40 deletions
|
@ -4,34 +4,7 @@
|
|||
#include "../devboard/utils/events.h"
|
||||
#include "SIMPBMS-BATTERY.h"
|
||||
|
||||
#define SIMPBMS_MAX_CELLS 128
|
||||
|
||||
/* Do not change code below unless you are sure what you are doing */
|
||||
static unsigned long previousMillis1000 = 0; // will store last time a 1s CAN Message was sent
|
||||
|
||||
//Actual content messages
|
||||
|
||||
static int16_t celltemperature_max_dC = 0;
|
||||
static int16_t celltemperature_min_dC = 0;
|
||||
static int16_t current_dA = 0;
|
||||
static uint16_t voltage_dV = 0;
|
||||
static uint16_t cellvoltage_max_mV = 3700;
|
||||
static uint16_t cellvoltage_min_mV = 3700;
|
||||
static uint16_t charge_cutoff_voltage = 0;
|
||||
static uint16_t discharge_cutoff_voltage = 0;
|
||||
static int16_t max_charge_current = 0;
|
||||
static int16_t max_discharge_current = 0;
|
||||
static uint8_t ensemble_info_ack = 0;
|
||||
static uint8_t cells_in_series = 0;
|
||||
static uint8_t voltage_level = 0;
|
||||
static uint8_t ah_total = 0;
|
||||
static uint8_t SOC = 0;
|
||||
static uint8_t SOH = 99;
|
||||
static uint8_t charge_forbidden = 0;
|
||||
static uint8_t discharge_forbidden = 0;
|
||||
static uint16_t cellvoltages_mV[SIMPBMS_MAX_CELLS] = {0};
|
||||
|
||||
void update_values_battery() {
|
||||
void SimpBmsBattery::update_values() {
|
||||
|
||||
datalayer.battery.status.real_soc = (SOC * 100); //increase SOC range from 0-100 -> 100.00
|
||||
|
||||
|
@ -67,7 +40,7 @@ void update_values_battery() {
|
|||
datalayer.battery.info.number_of_cells = cells_in_series;
|
||||
}
|
||||
|
||||
void handle_incoming_can_frame_battery(CAN_frame rx_frame) {
|
||||
void SimpBmsBattery::handle_incoming_can_frame(CAN_frame rx_frame) {
|
||||
datalayer.battery.status.CAN_battery_still_alive = CAN_STILL_ALIVE;
|
||||
switch (rx_frame.ID) {
|
||||
case 0x355:
|
||||
|
@ -115,11 +88,11 @@ void handle_incoming_can_frame_battery(CAN_frame rx_frame) {
|
|||
}
|
||||
}
|
||||
|
||||
void transmit_can_battery(unsigned long currentMillis) {
|
||||
void SimpBmsBattery::transmit_can(unsigned long currentMillis) {
|
||||
// No periodic transmitting for this battery type
|
||||
}
|
||||
|
||||
void setup_battery(void) { // Performs one time setup at startup
|
||||
void SimpBmsBattery::setup(void) { // Performs one time setup at startup
|
||||
strncpy(datalayer.system.info.battery_protocol, "SIMPBMS battery", 63);
|
||||
datalayer.system.info.battery_protocol[63] = '\0';
|
||||
datalayer.battery.info.number_of_cells = CELL_COUNT;
|
||||
|
|
|
@ -3,17 +3,52 @@
|
|||
#include <Arduino.h>
|
||||
#include "../include.h"
|
||||
|
||||
#include "CanBattery.h"
|
||||
|
||||
#define BATTERY_SELECTED
|
||||
#define SELECTED_BATTERY_CLASS SimpBmsBattery
|
||||
|
||||
/* DEFAULT VALUES BMS will send configured */
|
||||
#define MAX_PACK_VOLTAGE_DV 5000 //5000 = 500.0V
|
||||
#define MIN_PACK_VOLTAGE_DV 1500
|
||||
#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
|
||||
#define MAX_CELL_DEVIATION_MV 500
|
||||
#define CELL_COUNT 96
|
||||
class SimpBmsBattery : public CanBattery {
|
||||
public:
|
||||
virtual void setup(void);
|
||||
virtual void handle_incoming_can_frame(CAN_frame rx_frame);
|
||||
virtual void update_values();
|
||||
virtual void transmit_can(unsigned long currentMillis);
|
||||
|
||||
void setup_battery(void);
|
||||
void transmit_can_frame(CAN_frame* tx_frame, int interface);
|
||||
private:
|
||||
/* DEFAULT VALUES BMS will send configured */
|
||||
static const int MAX_PACK_VOLTAGE_DV = 5000; //5000 = 500.0V
|
||||
static const int MIN_PACK_VOLTAGE_DV = 1500;
|
||||
static const int MAX_CELL_VOLTAGE_MV = 4250; //Battery is put into emergency stop if one cell goes over this value
|
||||
static const int MIN_CELL_VOLTAGE_MV = 2700; //Battery is put into emergency stop if one cell goes below this value
|
||||
static const int MAX_CELL_DEVIATION_MV = 500;
|
||||
static const int CELL_COUNT = 96;
|
||||
|
||||
static const int SIMPBMS_MAX_CELLS = 128;
|
||||
|
||||
unsigned long previousMillis1000 = 0; // will store last time a 1s CAN Message was sent
|
||||
|
||||
//Actual content messages
|
||||
|
||||
int16_t celltemperature_max_dC = 0;
|
||||
int16_t celltemperature_min_dC = 0;
|
||||
int16_t current_dA = 0;
|
||||
uint16_t voltage_dV = 0;
|
||||
uint16_t cellvoltage_max_mV = 3700;
|
||||
uint16_t cellvoltage_min_mV = 3700;
|
||||
uint16_t charge_cutoff_voltage = 0;
|
||||
uint16_t discharge_cutoff_voltage = 0;
|
||||
int16_t max_charge_current = 0;
|
||||
int16_t max_discharge_current = 0;
|
||||
uint8_t ensemble_info_ack = 0;
|
||||
uint8_t cells_in_series = 0;
|
||||
uint8_t voltage_level = 0;
|
||||
uint8_t ah_total = 0;
|
||||
uint8_t SOC = 0;
|
||||
uint8_t SOH = 99;
|
||||
uint8_t charge_forbidden = 0;
|
||||
uint8_t discharge_forbidden = 0;
|
||||
uint16_t cellvoltages_mV[SIMPBMS_MAX_CELLS] = {0};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue