CUER
/
charger_code
Code to run on the charger board (used to charge the car from the mains).
Diff: CANParserCharger.cpp
- Revision:
- 5:756fae795d37
- Parent:
- 3:a7626dffb64a
- Child:
- 7:70cf5bff23f9
--- a/CANParserCharger.cpp Thu Jul 27 21:21:32 2017 +0000 +++ b/CANParserCharger.cpp Sun Jul 30 22:59:37 2017 +0000 @@ -6,16 +6,6 @@ using namespace CAN_IDs; -void get_charger_control_info(CANMessage msg, float &_voltage_error, float &_temp_margin, float &_discharge_error, float &_pack_capacity) { - CAN_Data data; - data.importCANData(msg); - - _voltage_error = (float) data.get_u16(0); - _temp_margin = data.get_u16(1) /10.0; - _discharge_error = (float) data.get_u16(2); - _pack_capacity = (float) data.get_u16(3); -} - void get_max_min_voltage(CANMessage msg, float &_min_cell_voltage, float &_max_cell_voltage) { CAN_Data data; data.importCANData(msg); @@ -41,6 +31,14 @@ _charger_status = data.get_u8(4); } +void check_precharge_status (CANMessage msg, bool &_precharge_ready) { + CAN_Data data; + data.importCANData(msg); + + if(data.get_u8(1) == 4) _precharge_ready = true; + else _precharge_ready = false; +} + CANMessage generate_charger_control_msg(float _desired_voltage, float _desired_current, uint8_t _charger_control) { CANMessage msg; msg.format = CANExtended; //the charger uses the extended CAN frame format @@ -86,7 +84,7 @@ msg.id = BMS_BASE_ID + EEPROM_RESET_ID; CAN_Data data; - data.setLowerFloat(42); //42 is the pack capacity in Ah + data.setLowerFloat(PACK_CAPACITY); //42 is the pack capacity in Ah data.setUpperFloat(100); //100% as fully charged for(int i=0; i<8; i++) {