diff --git a/Software/src/battery/DALY-BMS.cpp b/Software/src/battery/DALY-BMS.cpp index 77d4e6e6..f81ee01f 100644 --- a/Software/src/battery/DALY-BMS.cpp +++ b/Software/src/battery/DALY-BMS.cpp @@ -69,8 +69,8 @@ uint32_t decode_uint32be(uint8_t data[8], uint8_t offset) { ((uint32_t)data[offset + 3]); } -void decode_packet(uint8_t data[8]) { - switch (buff[2]) { +void decode_packet(uint8_t command, uint8_t data[8]) { + switch (command) { case 0x90: voltage_dV = decode_uint16be(data, 0); current_dA = decode_int16be(data, 4) - 30000; @@ -139,7 +139,7 @@ void receive_RS485() { } if (recv_len > 12) { - decode_packet(&recv_buff[4]); + decode_packet(recv_buff[2], &recv_buff[4]); recv_len = 0; } } diff --git a/Software/src/battery/DALY-BMS.h b/Software/src/battery/DALY-BMS.h index 255234ae..7d00490a 100644 --- a/Software/src/battery/DALY-BMS.h +++ b/Software/src/battery/DALY-BMS.h @@ -1,7 +1,5 @@ #ifndef DALY_BMS_H #define DALY_BMS_H -#include -#include "../include.h" /* Tweak these according to your battery build */ #define CELL_COUNT 14 @@ -10,17 +8,11 @@ #define MIN_PACK_VOLTAGE_DV 518 //518 = 51.8V #define MAX_CELL_VOLTAGE_MV 4250 //Battery is put into emergency stop if one cell goes over this value #define MIN_CELL_VOLTAGE_MV 2700 //Battery is put into emergency stop if one cell goes below this value -#define MAX_CELL_DEVIATION_MV 250 #define MAX_DISCHARGE_POWER_ALLOWED_W 1800 #define MAX_CHARGE_POWER_ALLOWED_W 1800 -#define MAX_CHARGE_POWER_WHEN_TOPBALANCING_W 50 -#define RAMPDOWN_SOC 9000 // (90.00) SOC% to start ramping down from max charge power towards 0 at 100.00% /* Do not modify any rows below*/ #define BATTERY_SELECTED #define RS485_BATTERY_SELECTED -void setup_battery(void); -void receive_RS485(void); - #endif diff --git a/Software/src/communication/can/comm_can.cpp b/Software/src/communication/can/comm_can.cpp index 880d7b5e..264b237a 100644 --- a/Software/src/communication/can/comm_can.cpp +++ b/Software/src/communication/can/comm_can.cpp @@ -109,7 +109,9 @@ void transmit_can() { return; //Global block of CAN messages } +#ifndef RS485_BATTERY_SELECTED transmit_can_battery(); +#endif #ifdef CAN_INVERTER_SELECTED transmit_can_inverter(); @@ -302,7 +304,9 @@ void map_can_frame_to_variable(CAN_frame* rx_frame, int interface) { #endif if (interface == can_config.battery) { +#ifndef RS485_BATTERY_SELECTED handle_incoming_can_frame_battery(*rx_frame); +#endif #ifdef CHADEMO_BATTERY ISA_handleFrame(rx_frame); #endif