🐛 fix compilation bugs with daly bms

This commit is contained in:
Jakob Löw 2025-02-04 00:32:40 +01:00
parent 5de2af3bdf
commit 1f5bcde8aa
No known key found for this signature in database
GPG key ID: B77685F55C7C46C6
3 changed files with 7 additions and 11 deletions

View file

@ -69,8 +69,8 @@ uint32_t decode_uint32be(uint8_t data[8], uint8_t offset) {
((uint32_t)data[offset + 3]); ((uint32_t)data[offset + 3]);
} }
void decode_packet(uint8_t data[8]) { void decode_packet(uint8_t command, uint8_t data[8]) {
switch (buff[2]) { switch (command) {
case 0x90: case 0x90:
voltage_dV = decode_uint16be(data, 0); voltage_dV = decode_uint16be(data, 0);
current_dA = decode_int16be(data, 4) - 30000; current_dA = decode_int16be(data, 4) - 30000;
@ -139,7 +139,7 @@ void receive_RS485() {
} }
if (recv_len > 12) { if (recv_len > 12) {
decode_packet(&recv_buff[4]); decode_packet(recv_buff[2], &recv_buff[4]);
recv_len = 0; recv_len = 0;
} }
} }

View file

@ -1,7 +1,5 @@
#ifndef DALY_BMS_H #ifndef DALY_BMS_H
#define DALY_BMS_H #define DALY_BMS_H
#include <Arduino.h>
#include "../include.h"
/* Tweak these according to your battery build */ /* Tweak these according to your battery build */
#define CELL_COUNT 14 #define CELL_COUNT 14
@ -10,17 +8,11 @@
#define MIN_PACK_VOLTAGE_DV 518 //518 = 51.8V #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 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 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_DISCHARGE_POWER_ALLOWED_W 1800
#define MAX_CHARGE_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*/ /* Do not modify any rows below*/
#define BATTERY_SELECTED #define BATTERY_SELECTED
#define RS485_BATTERY_SELECTED #define RS485_BATTERY_SELECTED
void setup_battery(void);
void receive_RS485(void);
#endif #endif

View file

@ -109,7 +109,9 @@ void transmit_can() {
return; //Global block of CAN messages return; //Global block of CAN messages
} }
#ifndef RS485_BATTERY_SELECTED
transmit_can_battery(); transmit_can_battery();
#endif
#ifdef CAN_INVERTER_SELECTED #ifdef CAN_INVERTER_SELECTED
transmit_can_inverter(); transmit_can_inverter();
@ -302,7 +304,9 @@ void map_can_frame_to_variable(CAN_frame* rx_frame, int interface) {
#endif #endif
if (interface == can_config.battery) { if (interface == can_config.battery) {
#ifndef RS485_BATTERY_SELECTED
handle_incoming_can_frame_battery(*rx_frame); handle_incoming_can_frame_battery(*rx_frame);
#endif
#ifdef CHADEMO_BATTERY #ifdef CHADEMO_BATTERY
ISA_handleFrame(rx_frame); ISA_handleFrame(rx_frame);
#endif #endif