summaryrefslogtreecommitdiff
path: root/battery.h
blob: cb2e1f6262505654fe556866651b11dbc7e3f295 (plain)
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
#ifndef BATTERY_H
#define BATTERY_H

#include <QObject>
#include "math.h"

typedef struct batteryData {
    QString name;
    double nominalVoltage;
    double minimumVoltage;
    double maximumVoltage;
    double specificEnergy; // Wh/Kg
    double cellDischargeRate;
    double cellChargeRate;
}batteryData_t;

static const batteryData_t batteries[]
{
    {.name = "Li-ion Phosphate", .nominalVoltage = 3.3, .minimumVoltage = 2.5, .maximumVoltage = 3.6, .specificEnergy = 105.0, .cellDischargeRate = 30, .cellChargeRate = 10},
    {.name = "Li-ion Manganese", .nominalVoltage = 3.7, .minimumVoltage = 2.5, .maximumVoltage = 4.2, .specificEnergy = 125.0, .cellDischargeRate = 30, .cellChargeRate = 10},
    {.name = "Li-ion Cobalt", .nominalVoltage = 3.6, .minimumVoltage = 2.5, .maximumVoltage = 4.2, .specificEnergy = 200.0, .cellDischargeRate = 2, .cellChargeRate = 1},
    {.name = "NiMH", .nominalVoltage = 1.2, .minimumVoltage = 1.0, .maximumVoltage = 1.3, .specificEnergy = 90.0, .cellDischargeRate = 5, .cellChargeRate = 0.5},
    {.name = "NiCd", .nominalVoltage = 1.2, .minimumVoltage = 1.0, .maximumVoltage = 1.3, .specificEnergy = 60.0, .cellDischargeRate = 20, .cellChargeRate = 1},
};
enum batteryNames
{
    LiionPhosphate = 0,
    LiionManganese,
    LiionCobalt,
    NiMH,
    NICd,
};

class Battery : public QObject
{
    Q_OBJECT
public:
    Battery();

    void setSystemVoltage(double voltage);
    void setPeakSystemPower(double power);
    void changeBatteryChemistry(int name);
    void setMinimumSOC(double SOC);

    int seriesCells(void);
    int parallelCells(void);
    float minimumPackVoltage(void);
    float maximumPackVoltage(void);
    double peakCurrent(void);
public slots:
     void calculate(void);
private:

    batteryData_t activeBattery;
    double systemVoltage;
    double peakPower;
    double minimumAllowableSOC;
    float packDischargeRate;
    float packChargeRate;
    float packWeight;
    float packEnergy;
signals:
    void calculation(void);

};

#endif // BATTERY_H