-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBMSModuleManager.h
82 lines (72 loc) · 1.89 KB
/
BMSModuleManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "Arduino.h"
#include "BMSModule.h"
#include "driver/gpio.h"
#include "driver/twai.h"
#define MAX_MODULE_ADDR 0x3E
typedef struct {
float OverVSetpoint;
float UnderVSetpoint;
float ChargeVsetpoint;
float DischVsetpoint;
float OverTSetpoint;
float UnderTSetpoint;
float DisTSetpoint;
float CellGap;
float balanceVoltage;
float balanceHyst;
int series_cells;
int parallel_strings;
int capacity;
int DischargeTaper;
int chargecurrentmax;
int discurrentmax;
int nominal_cell_voltage;
int internal_resistance; //in mOhm
int ocv[100];
} EEPROMSettings;
class BMSModuleManager {
public:
BMSModuleManager();
int seriescells();
void clearmodules();
void sendcommand();
void decodecan(twai_message_t &msg, int debug);
void decodetemp(twai_message_t &msg, int debug, int type);
void getAllVoltTemp();
void setPstrings(int Pstrings);
void setUnderVolt(float newVal);
void setOverVolt(float newVal);
void setOverTemp(float newVal);
void setBalanceV(float newVal);
void setBalanceHyst(float newVal);
void balanceCells(int debug, int onoff);
float getPackVoltage();
float getAvgTemperature();
float getHighTemperature();
float getLowTemperature();
float getAvgCellVolt();
float getLowCellVolt();
float getHighCellVolt();
float getHighVoltage();
float getLowVoltage();
void printPackSummary();
void printPackDetails(int digits);
String htmlPackDetails(int digits);
int getNumModules();
bool checkcomms();
private:
float packVolt;
int Pstring;
float LowCellVolt;
float HighCellVolt;
float highTemp;
float lowTemp;
float BalHys;
BMSModule modules[MAX_MODULE_ADDR + 1]; // store data for as many modules as
// we've configured for.
int numFoundModules; // The number of modules that seem to exist
bool isFaulted;
bool balancing;
uint8_t balcnt;
int spack;
};