CUER
/
charger_code
Code to run on the charger board (used to charge the car from the mains).
charger.h@12:77d493b3320b, 2017-09-12 (annotated)
- Committer:
- DasSidG
- Date:
- Tue Sep 12 05:42:43 2017 +0000
- Revision:
- 12:77d493b3320b
- Parent:
- 10:839e8f984d28
Added charger and bms timeouts to the charger board CAN packet
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DasSidG | 3:a7626dffb64a | 1 | #ifndef CHARGER_H |
DasSidG | 3:a7626dffb64a | 2 | #define CHARGER_H |
DasSidG | 3:a7626dffb64a | 3 | |
drajan | 0:6d930d0d13a1 | 4 | #include "mbed.h" |
drajan | 0:6d930d0d13a1 | 5 | |
DasSidG | 5:756fae795d37 | 6 | #define DEBUG 1 |
DasSidG | 5:756fae795d37 | 7 | |
DasSidG | 7:70cf5bff23f9 | 8 | #define MAX_PACK_VOLTAGE 138600.0 // 33 * 4.2 |
DasSidG | 7:70cf5bff23f9 | 9 | #define MAX_CURRENT 10000.0 //limited by charger |
DasSidG | 7:70cf5bff23f9 | 10 | #define MAX_CELL_VOLTAGE 4250 |
DasSidG | 7:70cf5bff23f9 | 11 | #define CHARGING_FINISHED_THRESHOLD_VOLTAGE 4200 |
DasSidG | 7:70cf5bff23f9 | 12 | #define DEEP_DISCHARGE_THRESHOLD_VOLTAGE 3000 |
DasSidG | 7:70cf5bff23f9 | 13 | #define CHARGING_FINISHED_THRESHOLD_CURRENT 800 |
DasSidG | 7:70cf5bff23f9 | 14 | #define DEEP_DISCHARGE_MAX_CURRENT 2000 |
DasSidG | 7:70cf5bff23f9 | 15 | #define PACK_CAPACITY 42 //in Ah |
drajan | 0:6d930d0d13a1 | 16 | |
DasSidG | 1:0c77e20b4d4c | 17 | #define CHARGER_MSG_TIMEOUT_MS 6000 |
DasSidG | 1:0c77e20b4d4c | 18 | #define BMS_MSG_TIMEOUT_MS 2000 |
DasSidG | 1:0c77e20b4d4c | 19 | |
DasSidG | 5:756fae795d37 | 20 | //Macros for charging to avoid confusion and potentioal errors |
DasSidG | 5:756fae795d37 | 21 | #define START_CHARGING 0 |
DasSidG | 5:756fae795d37 | 22 | #define STOP_CHARGING 1 |
DasSidG | 1:0c77e20b4d4c | 23 | |
DasSidG | 1:0c77e20b4d4c | 24 | #define CAN_BUFFER_SIZE 255 //Setting this to be quite large, should be equal to max # of ids expected to receive |
drajan | 0:6d930d0d13a1 | 25 | |
DasSidG | 1:0c77e20b4d4c | 26 | // CAN pins |
DasSidG | 1:0c77e20b4d4c | 27 | #define CAR_CAN_WRITE_PIN p29 |
DasSidG | 1:0c77e20b4d4c | 28 | #define CAR_CAN_READ_PIN p30 |
DasSidG | 1:0c77e20b4d4c | 29 | #define CHARGER_CAN_WRITE_PIN p10 |
DasSidG | 1:0c77e20b4d4c | 30 | #define CHARGER_CAN_READ_PIN p9 |
drajan | 0:6d930d0d13a1 | 31 | |
DasSidG | 7:70cf5bff23f9 | 32 | extern uint8_t charger_status; //status packet given by charger, see Elcon CAN Specification in google drive |
DasSidG | 7:70cf5bff23f9 | 33 | extern bool precharge_status; |
DasSidG | 7:70cf5bff23f9 | 34 | extern bool comms_timeout; |
DasSidG | 7:70cf5bff23f9 | 35 | extern bool charger_failure; |
DasSidG | 7:70cf5bff23f9 | 36 | extern bool charge_finished; |
DasSidG | 7:70cf5bff23f9 | 37 | extern bool bms_error; |
DasSidG | 7:70cf5bff23f9 | 38 | extern bool charging; |
DasSidG | 12:77d493b3320b | 39 | extern bool bms_timeout; |
DasSidG | 12:77d493b3320b | 40 | extern bool charger_timeout; |
DasSidG | 1:0c77e20b4d4c | 41 | |
DasSidG | 7:70cf5bff23f9 | 42 | extern float min_cell_voltage; //mV |
DasSidG | 7:70cf5bff23f9 | 43 | extern float max_cell_voltage;//mV |
DasSidG | 7:70cf5bff23f9 | 44 | |
DasSidG | 7:70cf5bff23f9 | 45 | extern float charger_current; //mA |
DasSidG | 7:70cf5bff23f9 | 46 | extern float charger_voltage; //mV |
DasSidG | 7:70cf5bff23f9 | 47 | |
DasSidG | 7:70cf5bff23f9 | 48 | extern float desired_current; //mA |
DasSidG | 7:70cf5bff23f9 | 49 | extern float desired_voltage; //mV |
DasSidG | 7:70cf5bff23f9 | 50 | |
DasSidG | 7:70cf5bff23f9 | 51 | extern uint8_t charger_control; |
DasSidG | 3:a7626dffb64a | 52 | |
DasSidG | 12:77d493b3320b | 53 | |
DasSidG | 3:a7626dffb64a | 54 | #endif |
drajan | 0:6d930d0d13a1 | 55 |