Cell voltages fork (SoC)
Dependencies: CUER_CAN CUER_DS1820 LTC2943 LTC6804 mbed PowerControl
Diff: CANParserBMU.cpp
- Revision:
- 66:c884fba9eaea
- Parent:
- 53:4277cdcff69b
--- a/CANParserBMU.cpp Tue Sep 12 01:29:12 2017 +0000 +++ b/CANParserBMU.cpp Sat Sep 16 01:10:01 2017 +0000 @@ -117,23 +117,6 @@ return msg; } -CANMessage createPackBalanceSOC(float SOC, float percentageCharge) -{ - // @TODO - check is this being used?? section 5.4 trituim BMU CAN data sheet - CANMessage msg; - msg.len = 8; - msg.id = BMS_BASE_ID + BATTERY_SOC_BASE_ID; - - CAN_Data data; - data.setLowerFloat(SOC); - data.setUpperFloat(percentageCharge); - for(int i=0; i<8; i++) { - msg.data[i] = data.get_u8(i); - } - - return msg; -} - /** * decodePackSOC and decodePackSOCPercentage can be used with both of the SOC msg types */ @@ -241,6 +224,21 @@ return msg; } +CANMessage createBatteryPower(uint32_t batteryVoltage, float batteryCurrent) +{ + CANMessage msg; + msg.len = 8; + msg.id = BMS_BASE_ID + BATTERY_POWER_ID; + + CAN_Data data; + data.setLowerFloat(batteryVoltage*batteryCurrent); + + for(int i=0; i<8; i++) { + msg.data[i] = data.get_u8(i); + } + return msg; +} + uint32_t decodeBatteryVoltage(CANMessage msg) { uint32_t result = 0; @@ -284,26 +282,7 @@ return result; } -CANMessage createBatteryPackStatus(uint16_t voltageThreshold[], uint8_t statusFlag,uint8_t BMS_CMU_Count,uint16_t BMS_Firmware_Build) -{ - CANMessage msg; - msg.len = 8; - msg.id = BMS_BASE_ID + BATTERY_PACK_STATUS_ID; - - CAN_Data data; - data.set_u16(0,voltageThreshold[0]); - data.set_u16(1,voltageThreshold[1]); - data.set_16(3,BMS_Firmware_Build); - data.set_u8(4,statusFlag); - data.set_u8(5,BMS_CMU_Count); - - for(int i=0; i<8; i++) { - msg.data[i] = data.get_u8(i); - } - return msg; -} - -CANMessage createExtendedBatteryPackStatus(uint32_t status) +CANMessage createBatteryPackStatus(uint32_t status) { CANMessage msg; msg.len = 8; @@ -321,7 +300,7 @@ return msg; } -uint32_t decodeExtendedBatteryPackStatus(CANMessage msg) +uint32_t decodeBatteryPackStatus(CANMessage msg) { CAN_Data decode; decode.importCANData(msg);