From 691173c9c06d2668d22919955ced6ff20ad916d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20=C3=96ster?= Date: Sun, 8 Dec 2024 18:33:52 +0200 Subject: [PATCH] Fix scaling on 7E7 polls --- Software/src/battery/BOLT-AMPERA-BATTERY.cpp | 228 +++++++++---------- Software/src/datalayer/datalayer_extended.h | 12 +- 2 files changed, 120 insertions(+), 120 deletions(-) diff --git a/Software/src/battery/BOLT-AMPERA-BATTERY.cpp b/Software/src/battery/BOLT-AMPERA-BATTERY.cpp index a113d3a93..ac15f68c7 100644 --- a/Software/src/battery/BOLT-AMPERA-BATTERY.cpp +++ b/Software/src/battery/BOLT-AMPERA-BATTERY.cpp @@ -59,12 +59,12 @@ static uint16_t battery_crash_event = 0; static uint16_t battery_HVIL = 0; static uint16_t battery_HVIL_status = 0; static uint16_t battery_5V_ref = 0; -static uint16_t battery_module_temp_1 = 0; -static uint16_t battery_module_temp_2 = 0; -static uint16_t battery_module_temp_3 = 0; -static uint16_t battery_module_temp_4 = 0; -static uint16_t battery_module_temp_5 = 0; -static uint16_t battery_module_temp_6 = 0; +static int16_t battery_module_temp_1 = 0; +static int16_t battery_module_temp_2 = 0; +static int16_t battery_module_temp_3 = 0; +static int16_t battery_module_temp_4 = 0; +static int16_t battery_module_temp_5 = 0; +static int16_t battery_module_temp_6 = 0; static uint16_t battery_cell_average_voltage = 0; static uint16_t battery_cell_average_voltage_2 = 0; static uint16_t battery_terminal_voltage = 0; @@ -146,7 +146,7 @@ void update_values_battery() { //This function maps all the values fetched via //datalayer.battery.status.voltage_dV = battery_voltage * 0.52; datalayer.battery.status.voltage_dV = (battery_voltage_periodic / 8) * 10; - datalayer.battery.status.current_dA = (battery_current / 20) - 400; + datalayer.battery.status.current_dA = battery_current; datalayer.battery.info.total_capacity_Wh; @@ -275,325 +275,325 @@ void receive_can_battery(CAN_frame rx_frame) { battery_current = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; break; case POLL_7E7_5V_REF: - battery_5V_ref = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_5V_ref = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5) / 65535); break; case POLL_7E7_MODULE_TEMP_1: - battery_module_temp_1 = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_module_temp_1 = (rx_frame.data.u8[4] - 40); break; case POLL_7E7_MODULE_TEMP_2: - battery_module_temp_2 = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_module_temp_2 = (rx_frame.data.u8[4] - 40); break; case POLL_7E7_MODULE_TEMP_3: - battery_module_temp_3 = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_module_temp_3 = (rx_frame.data.u8[4] - 40); break; case POLL_7E7_MODULE_TEMP_4: - battery_module_temp_4 = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_module_temp_4 = (rx_frame.data.u8[4] - 40); break; case POLL_7E7_MODULE_TEMP_5: - battery_module_temp_5 = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_module_temp_5 = (rx_frame.data.u8[4] - 40); break; case POLL_7E7_MODULE_TEMP_6: - battery_module_temp_6 = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_module_temp_6 = (rx_frame.data.u8[4] - 40); break; case POLL_7E7_CELL_AVG_VOLTAGE: - battery_cell_average_voltage = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_average_voltage = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_AVG_VOLTAGE_2: - battery_cell_average_voltage_2 = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_average_voltage_2 = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) / 8000) * 1000); break; case POLL_7E7_TERMINAL_VOLTAGE: - battery_terminal_voltage = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_terminal_voltage = rx_frame.data.u8[4] * 2; break; case POLL_7E7_IGNITION_POWER_MODE: - battery_ignition_power_mode = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_ignition_power_mode = rx_frame.data.u8[4]; break; case POLL_7E7_CELL_01: - battery_cell_voltages[0] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[0] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_02: - battery_cell_voltages[1] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[1] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_03: - battery_cell_voltages[2] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[2] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_04: - battery_cell_voltages[3] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[3] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_05: - battery_cell_voltages[4] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[4] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_06: - battery_cell_voltages[5] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[5] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_07: - battery_cell_voltages[6] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[6] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_08: - battery_cell_voltages[7] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[7] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_09: - battery_cell_voltages[8] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[8] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_10: - battery_cell_voltages[9] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[9] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_11: - battery_cell_voltages[10] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[10] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_12: - battery_cell_voltages[11] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[11] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_13: - battery_cell_voltages[12] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[12] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_14: - battery_cell_voltages[13] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[13] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_15: - battery_cell_voltages[14] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[14] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_16: - battery_cell_voltages[15] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[15] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_17: - battery_cell_voltages[16] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[16] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_18: - battery_cell_voltages[17] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[17] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_19: - battery_cell_voltages[18] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[18] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_20: - battery_cell_voltages[19] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[19] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_21: - battery_cell_voltages[20] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[20] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_22: - battery_cell_voltages[21] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[21] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_23: - battery_cell_voltages[22] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[22] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_24: - battery_cell_voltages[23] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[23] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_25: - battery_cell_voltages[24] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[24] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_26: - battery_cell_voltages[25] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[25] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_27: - battery_cell_voltages[26] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[26] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_28: - battery_cell_voltages[27] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[27] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_29: - battery_cell_voltages[28] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[28] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_30: - battery_cell_voltages[29] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[29] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_31: - battery_cell_voltages[30] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[30] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_32: - battery_cell_voltages[31] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[31] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_33: - battery_cell_voltages[32] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[32] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_34: - battery_cell_voltages[33] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[33] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_35: - battery_cell_voltages[34] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[34] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_36: - battery_cell_voltages[35] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[35] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_37: - battery_cell_voltages[36] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[36] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_38: - battery_cell_voltages[37] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[37] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_39: - battery_cell_voltages[38] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[38] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_40: - battery_cell_voltages[39] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[39] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_41: - battery_cell_voltages[40] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[40] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_42: - battery_cell_voltages[41] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[41] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_43: - battery_cell_voltages[42] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[42] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_44: - battery_cell_voltages[43] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[43] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_45: - battery_cell_voltages[44] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[44] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_46: - battery_cell_voltages[45] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[45] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_47: - battery_cell_voltages[46] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[46] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_48: - battery_cell_voltages[47] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[47] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_49: - battery_cell_voltages[48] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[48] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_50: - battery_cell_voltages[49] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[49] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_51: - battery_cell_voltages[50] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[50] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_52: - battery_cell_voltages[51] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[51] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_53: - battery_cell_voltages[52] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[52] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_54: - battery_cell_voltages[53] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[53] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_55: - battery_cell_voltages[54] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[54] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_56: - battery_cell_voltages[55] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[55] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_57: - battery_cell_voltages[56] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[56] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_58: - battery_cell_voltages[57] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[57] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_59: - battery_cell_voltages[58] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[58] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_60: - battery_cell_voltages[59] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[59] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_61: - battery_cell_voltages[60] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[60] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_62: - battery_cell_voltages[61] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[61] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_63: - battery_cell_voltages[62] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[62] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_64: - battery_cell_voltages[63] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[63] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_65: - battery_cell_voltages[64] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[64] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_66: - battery_cell_voltages[65] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[65] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_67: - battery_cell_voltages[66] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[66] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_68: - battery_cell_voltages[67] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[67] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_69: - battery_cell_voltages[68] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[68] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_70: - battery_cell_voltages[69] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[69] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_71: - battery_cell_voltages[70] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[70] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_72: - battery_cell_voltages[71] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[71] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_73: - battery_cell_voltages[72] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[72] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_74: - battery_cell_voltages[73] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[73] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_75: - battery_cell_voltages[74] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[74] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_76: - battery_cell_voltages[75] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[75] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_77: - battery_cell_voltages[76] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[76] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_78: - battery_cell_voltages[77] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[77] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_79: - battery_cell_voltages[78] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[78] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_80: - battery_cell_voltages[79] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[79] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_81: - battery_cell_voltages[80] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[80] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_82: - battery_cell_voltages[81] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[81] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_83: - battery_cell_voltages[82] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[82] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_84: - battery_cell_voltages[83] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[83] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_85: - battery_cell_voltages[84] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[84] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_86: - battery_cell_voltages[85] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[85] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_87: - battery_cell_voltages[86] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[86] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_88: - battery_cell_voltages[87] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[87] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_89: - battery_cell_voltages[88] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[88] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_90: - battery_cell_voltages[89] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[89] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_91: - battery_cell_voltages[90] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[90] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_92: - battery_cell_voltages[91] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[91] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_93: - battery_cell_voltages[92] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[92] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_94: - battery_cell_voltages[93] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[93] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_95: - battery_cell_voltages[94] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[94] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; case POLL_7E7_CELL_96: - battery_cell_voltages[95] = (rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]; + battery_cell_voltages[95] = ((((rx_frame.data.u8[4] << 8) | rx_frame.data.u8[5]) * 5000) / 65535); break; default: break; diff --git a/Software/src/datalayer/datalayer_extended.h b/Software/src/datalayer/datalayer_extended.h index 55cfde9b1..77efc6427 100644 --- a/Software/src/datalayer/datalayer_extended.h +++ b/Software/src/datalayer/datalayer_extended.h @@ -7,12 +7,12 @@ typedef struct { /** uint16_t */ /** PID polling parameters */ uint16_t battery_5V_ref = 0; - uint16_t battery_module_temp_1 = 0; - uint16_t battery_module_temp_2 = 0; - uint16_t battery_module_temp_3 = 0; - uint16_t battery_module_temp_4 = 0; - uint16_t battery_module_temp_5 = 0; - uint16_t battery_module_temp_6 = 0; + int16_t battery_module_temp_1 = 0; + int16_t battery_module_temp_2 = 0; + int16_t battery_module_temp_3 = 0; + int16_t battery_module_temp_4 = 0; + int16_t battery_module_temp_5 = 0; + int16_t battery_module_temp_6 = 0; uint16_t battery_cell_average_voltage = 0; uint16_t battery_cell_average_voltage_2 = 0; uint16_t battery_terminal_voltage = 0;