Added BMS pressure sensor support

This commit is contained in:
Benjamin Vedder 2024-01-12 11:53:47 +01:00
parent 2bc55235d6
commit da955e42c4
4 changed files with 14 additions and 0 deletions

7
bms.c
View File

@ -267,6 +267,9 @@ bool bms_process_can_frame(uint32_t can_id, uint8_t *data8, int len, bool is_ext
m_values.temp_hum = buffer_get_float16(data8, 1e2, &ind);
m_values.hum = buffer_get_float16(data8, 1e2, &ind);
m_values.temp_ic = buffer_get_float16(data8, 1e2, &ind);
if (len == 8) {
m_values.pressure = buffer_get_float16(data8, 1e-1, &ind);
}
}
} break;
@ -441,6 +444,9 @@ void bms_process_cmd(unsigned char *data, unsigned int len,
buffer_append_float32_auto(send_buffer, m_values.ah_cnt_dis_total, &ind);
buffer_append_float32_auto(send_buffer, m_values.wh_cnt_dis_total, &ind);
// Pressure
buffer_append_float16(send_buffer, m_values.pressure, 1e-1, &ind);
reply_func(send_buffer, ind);
} break;
@ -552,6 +558,7 @@ void bms_send_status_can(void) {
buffer_append_float16(buffer, m_values.temp_hum, 1e2, &send_index);
buffer_append_float16(buffer, m_values.hum, 1e2, &send_index);
buffer_append_float16(buffer, m_values.temp_ic, 1e2, &send_index); // Put IC temp here instead of making mew msg
buffer_append_float16(buffer, m_values.pressure, 1e-1, &send_index);
comm_can_transmit_eid(id | ((uint32_t)CAN_PACKET_BMS_HUM << 8), buffer, send_index);
/*

View File

@ -300,6 +300,7 @@ typedef struct {
float temps_adc[50];
float temp_ic;
float temp_hum;
float pressure;
float hum;
float temp_max_cell;
float soc;

View File

@ -234,6 +234,7 @@ Get value from BMS. Examples:
(get-bms-val 'bms-temp-ic) ; Balance IC temperature
(get-bms-val 'bms-temp-hum) ; Humidity sensor temperature
(get-bms-val 'bms-hum) ; Humidity
(get-bms-val 'bms-pres) ; Pressure in PA (Added in 6.05)
(get-bms-val 'bms-temp-cell-max) ; Maximum cell temperature
(get-bms-val 'bms-soc) ; State of charge (0.0 to 1.0)
(get-bms-val 'bms-can-id) ; CAN ID of BMS

View File

@ -78,6 +78,7 @@ typedef struct {
lbm_uint temp_ic;
lbm_uint temp_hum;
lbm_uint hum;
lbm_uint pres;
lbm_uint temp_max_cell;
lbm_uint soc;
lbm_uint soh;
@ -273,6 +274,8 @@ static bool compare_symbol(lbm_uint sym, lbm_uint *comp) {
get_add_symbol("bms-temp-hum", comp);
} else if (comp == &syms_vesc.hum) {
get_add_symbol("bms-hum", comp);
} else if (comp == &syms_vesc.pres) {
get_add_symbol("bms-pres", comp);
} else if (comp == &syms_vesc.temp_max_cell) {
get_add_symbol("bms-temp-cell-max", comp);
} else if (comp == &syms_vesc.soc) {
@ -764,6 +767,8 @@ static lbm_value get_set_bms_val(bool set, lbm_value *args, lbm_uint argn) {
res = get_or_set_float(set, &val->temp_hum, &set_arg);
} else if (compare_symbol(name, &syms_vesc.hum)) {
res = get_or_set_float(set, &val->hum, &set_arg);
} else if (compare_symbol(name, &syms_vesc.pres)) {
res = get_or_set_float(set, &val->pressure, &set_arg);
} else if (compare_symbol(name, &syms_vesc.temp_max_cell)) {
res = get_or_set_float(set, &val->temp_max_cell, &set_arg);
} else if (compare_symbol(name, &syms_vesc.soc)) {