Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 12:77d493b3320b, committed 2017-09-12
- Comitter:
- DasSidG
- Date:
- Tue Sep 12 05:42:43 2017 +0000
- Parent:
- 11:f578a372be42
- Commit message:
- Added charger and bms timeouts to the charger board CAN packet
Changed in this revision
--- a/CANParserCharger.cpp Sun Sep 10 11:33:19 2017 +0000
+++ b/CANParserCharger.cpp Tue Sep 12 05:42:43 2017 +0000
@@ -71,7 +71,7 @@
return msg;
}
-CANMessage generate_charger_info_msg(float _charger_voltage, float _charger_current, uint8_t _charger_status) {
+CANMessage generate_charger_info_msg(float _charger_voltage, float _charger_current, uint8_t _charger_status, bool _charger_timeout, bool _bms_timeout) {
CANMessage msg;
msg.len = 8;
msg.id = CHARGER_ID;
@@ -79,8 +79,8 @@
data.set_u16(0, (uint16_t) (_charger_voltage/100));
data.set_u16(1, (uint16_t) (_charger_current/100));
data.set_u8(4, _charger_status);
- data.set_u8(5,0);
- data.set_u8(6,0);
+ data.set_u8(5, _charger_timeout);
+ data.set_u8(6, _bms_timeout);
data.set_u8(7,0);
for(int i=0; i<8; i++) {
--- a/CANParserCharger.h Sun Sep 10 11:33:19 2017 +0000 +++ b/CANParserCharger.h Tue Sep 12 05:42:43 2017 +0000 @@ -31,7 +31,7 @@ void CAN_Init(); CANMessage generate_charger_control_msg(float _desired_voltage, float _desired_current, uint8_t _charger_control); -CANMessage generate_charger_info_msg(float _charger_voltage, float _charger_current, uint8_t _charger_status); +CANMessage generate_charger_info_msg(float _charger_voltage, float _charger_current, uint8_t _charger_status, bool _charger_timeout, bool _bms_timeout); CANMessage generate_charging_finished_msg(); //When this packet is received by the BMU, it causes the BMU to reset its SoC value to 100% //CAN stuff. Not that there are two sets because there are two separate CAN buses here; one to communicate with the charger, and one to communicate with the rest of the car (importantly the BMS).
--- a/charger.cpp Sun Sep 10 11:33:19 2017 +0000
+++ b/charger.cpp Tue Sep 12 05:42:43 2017 +0000
@@ -23,6 +23,8 @@
bool charge_finished;
bool bms_error;
bool charging;
+bool bms_timeout = false;
+bool charger_timeout = false;
float min_cell_voltage = 3600; //mV
float max_cell_voltage = 3600;//mV
@@ -81,7 +83,7 @@
t.reset();
car_CAN_data_sent = false;
- car_can.write(generate_charger_info_msg(charger_voltage, charger_current, charger_status)); //charger info message for rest of car
+ car_can.write(generate_charger_info_msg(charger_voltage, charger_current, charger_status, charger_timeout, bms_timeout)); //charger info message for rest of car
while(!car_CAN_data_sent && t.read_ms() < CAN_TIMEOUT_MS);
if (DEBUG) {
@@ -141,12 +143,14 @@
{
if (DEBUG) printf("Error: BMS comms timeout \r\n");
comms_timeout = true;
+ bms_timeout = true;
}
if (timeouts.charger_timeout.read_ms() > CHARGER_MSG_TIMEOUT_MS)
{
if (DEBUG) printf("Error: Charger comms timeout \r\n");
comms_timeout = true;
+ charger_timeout = true;
}
}
--- a/charger.h Sun Sep 10 11:33:19 2017 +0000
+++ b/charger.h Tue Sep 12 05:42:43 2017 +0000
@@ -36,6 +36,8 @@
extern bool charge_finished;
extern bool bms_error;
extern bool charging;
+extern bool bms_timeout;
+extern bool charger_timeout;
extern float min_cell_voltage; //mV
extern float max_cell_voltage;//mV
@@ -48,5 +50,6 @@
extern uint8_t charger_control;
+
#endif
\ No newline at end of file