Thunderstruck: Update CAN handler for Thunderstruck#2144
Thunderstruck: Update CAN handler for Thunderstruck#2144dalathegreat wants to merge 4 commits intomainfrom
Conversation
|
Hi, This is the recommendation from Thunderstruck : "
The .dbc should make it pretty clear what is where, but heres a list of the more important messages: Summary Message (0xff20) Pack Summary (0xff21) Cell Summary (0xff22) Thermistor Summray (0xff23) SOC Summary (0xff24) Current Limits Summary (0xff25) Power Limits Summary (0xff28) I can do a full code review another time.. Even though it is short a full review requires me to fully understand how the system works with a BMS as well as make sure there arent any dangerous edge cases. For now, here are a few things I see in my once over.
Dont hard-code this... It is fine to grab things like cell voltage and temperature for telemetry - but fault handling should be done by the MCU. Look at things like the fault map (HVC and LVC specifically in this case) so that the MCU can handle all the faults itself. This way we arent relying on the emulator implementation to handle all the lithium safety stuff, and the MCU can be configured for different cells/packs without having to modify the emulator configuration.
Kelan " |
|
Hi @veriqster I have fixed the "I tried the new file and it has the same issue as the one I compiled localy before the Thunderstruck was pulled into the Main - it doesn't save any changes in the configuration." Main was broken, but 10.4.dev is now fixed. I just pulled new main into the branch, so now if you re-test, it will work. I also added back the 0xFF instead of 0x00 |
|
I finally managed to compile a local one that allows saving the settings (redownloaded the code). |
|
Use the Events page: https://github.com/dalathegreat/Battery-Emulator/wiki/Webserver-guide#events |
|
I loaded the log file into SavvyCAN and it looks like the MCU is sending the correct data as requested but the values are being mapped wrong into the Emulator. Below are the cpp and h files as I modified: void ThunderstruckBMS:: datalayer.battery.status.real_soc = (SOC * 100); //increase SOC range from 0-100 -> 100.00 datalayer.battery.status.soh_pptt = 9900; //Not in CAN data, hardcoded to 99% datalayer.battery.status.voltage_dV = packvoltage_dV; datalayer.battery.status.current_dA = pack_curent_dA; datalayer.battery.status.remaining_capacity_Wh = static_cast<uint32_t>( datalayer.battery.status.max_discharge_power_W = DCLMax * (packvoltage_dV / 10); datalayer.battery.status.max_charge_power_W = CCLMax * (packvoltage_dV / 10); datalayer.battery.status.cell_max_voltage_mV = highest_cell_voltage / 10; datalayer.battery.status.cell_min_voltage_mV = lowest_cell_voltage / 10; datalayer.battery.status.temperature_min_dC = lowest_cell_temperature * 10; datalayer.battery.status.temperature_max_dC = highest_cell_temperature * 10; void ThunderstruckBMS::handle_incoming_can_frame(CAN_frame rx_frame) { // Send 500ms CAN Message } void ThunderstruckBMS::setup(void) { // Performs one time setup at startup #include "CanBattery.h" class ThunderstruckBMS : public CanBattery { private: unsigned long previousMillis500 = 0; // will store last time a 500ms CAN Message was send uint16_t lowest_cell_voltage = 3700; int16_t pack_curent_dA = 0; uint8_t SOC = 50; int8_t highest_cell_temperature = 0; CAN_frame THUND_14ebd0d8_21 = {.FD = false, }; #endif |
|
I will retest tomorrow as I went through the code and at least to my limited understanding the handling of the messages from MCU looks correct (I know nothing about bit shifting). |
|
I updated the CAN handler to work LSB | MSB byte wise and IT WORKS. H: " #include "CanBattery.h" class ThunderstruckBMS : public CanBattery { private: unsigned long previousMillis500 = 0; // will store last time a 500ms CAN Message was send uint16_t lowest_cell_voltage = 3700; int16_t pack_curent_dA = 0; uint8_t SOC = 50; int8_t highest_cell_temperature = 0; }; #endif CPP: " void ThunderstruckBMS:: datalayer.battery.status.real_soc = (SOC * 100); //increase SOC range from 0-100 -> 100.00 datalayer.battery.status.soh_pptt = 9900; //Not in CAN data, hardcoded to 99% datalayer.battery.status.voltage_dV = packvoltage_dV; datalayer.battery.status.current_dA = pack_curent_dA; datalayer.battery.status.remaining_capacity_Wh = static_cast<uint32_t>( datalayer.battery.status.max_discharge_power_W = DCLMax * (packvoltage_dV / 10); datalayer.battery.status.max_charge_power_W = CCLMax * (packvoltage_dV / 10); datalayer.battery.status.cell_max_voltage_mV = highest_cell_voltage / 10; datalayer.battery.status.cell_min_voltage_mV = lowest_cell_voltage / 10; datalayer.battery.status.temperature_min_dC = lowest_cell_temperature * 10; datalayer.battery.status.temperature_max_dC = highest_cell_temperature * 10; void ThunderstruckBMS::handle_incoming_can_frame(CAN_frame rx_frame) { // Send 500ms CAN Message } void ThunderstruckBMS::setup(void) { // Performs one time setup at startup
|
|
I updated the CPP and H files. |
|
Thanks for the investigation @veriqster , and I agree with your asessment, we need some input from Thunderstruck on how to proceed. Anyways, I also updated the PR with your findings on the byteorder. So we are a bit closer atleast! |
|
Got a response from Thunderstruck. I would also like some help with figuring out how the SIDs play into the "creation" of the EID for the CAN message. Looks like there's quite a few parameters and data types that can be obtained from the MCU but they are only described by EID and I'm not knowledgeable enough to see how modifying the SID of the message would affect the EID. |




What
This PR improves the J1939_MCU_ReadRequest handling
Why
User feedback, initial implementation did not work
How
We follow the newer v1.3.4 protocol
Tip
You can help test this PR with this guide