Skip to content

Commit 1edb7a0

Browse files
committed
BMS: select IVT pack-voltage channel via macro; identify IVT part
Add FEB_IVT_PACK_VOLTAGE_CHANNEL (FEB_Const.h, default U2/0x523) so the IVT-S voltage channel feeding FEB_CAN_IVT_GetVoltage() -- used by precharge and the BMS|ivt console -- is selectable with one macro. All channels still decode via the generated DBC unpack; the macro only picks the reported one. The console now prints V1/V2/V3 plus the selected pack voltage with its channel label. Also document the exact part (ISAscale IVT-MODULAR) in the IVT interface header.
1 parent 1c3ecfa commit 1edb7a0

6 files changed

Lines changed: 30 additions & 5 deletions

File tree

BMS/Core/User/Inc/FEB_CAN_IVT.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
* @brief IVT (Isabellenhutte) Current/Voltage Sensor CAN Interface
44
* @author Formula Electric @ Berkeley
55
*
6-
* Receives IVT-S sensor data over CAN:
6+
* The IVT we use is the ISAscale IVT-MODULAR (IVT-MOD, or just IVT for short),
7+
* Isabellenhutte's modular high-accuracy current/voltage/temperature sensor.
8+
*
9+
* Receives IVT sensor data over CAN:
710
* - 0x521: Current
811
* - 0x522: Voltage 1 (pack voltage, used for precharge monitoring)
912
* - 0x523: Voltage 2

BMS/Core/User/Inc/FEB_Const.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@
101101
#define ISOSPI_FAILOVER_LOCKOUT_MS 1000 // Milliseconds to wait before allowing failover again
102102
#define ISOSPI_PRIMARY_CHANNEL 1 // Primary channel: 1=SPI1, 2=SPI2
103103

104+
// ********************************** IVT-S Sensor Configuration *****************
105+
106+
// IVT-S voltage channel carrying the HV pack sense line (which IVT input the
107+
// pack is physically wired to). Selects the channel FEB_CAN_IVT_GetVoltage()
108+
// reports — used by precharge and the BMS|ivt console. All channels are always
109+
// decoded via the DBC unpack; this only picks the reported one.
110+
// 1 -> U1 (frame 0x522) 2 -> U2 (0x523) 3 -> U3 (0x524)
111+
#ifndef FEB_IVT_PACK_VOLTAGE_CHANNEL
112+
#define FEB_IVT_PACK_VOLTAGE_CHANNEL 2
113+
#endif
114+
104115
// ********************************** Accumulator Structure **********************
105116

106117
typedef struct

BMS/Core/User/Src/FEB_CAN_IVT.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
#include "FEB_CAN_IVT.h"
11+
#include "FEB_Const.h"
1112
#include "feb_can_lib.h"
1213
#include "feb_can.h"
1314
#include "stm32f4xx_hal.h"
@@ -176,8 +177,17 @@ float FEB_CAN_IVT_GetVoltage(void)
176177
return 0.0f;
177178
}
178179

179-
/* Convert mV to V */
180+
/* Convert mV to V. Channel is selected at compile time by the board wiring
181+
* (FEB_IVT_PACK_VOLTAGE_CHANNEL in FEB_Const.h). */
182+
#if FEB_IVT_PACK_VOLTAGE_CHANNEL == 1
180183
return ivt_data.voltage_1_mV * 0.001f;
184+
#elif FEB_IVT_PACK_VOLTAGE_CHANNEL == 2
185+
return ivt_data.voltage_2_mV * 0.001f;
186+
#elif FEB_IVT_PACK_VOLTAGE_CHANNEL == 3
187+
return ivt_data.voltage_3_mV * 0.001f;
188+
#else
189+
#error "FEB_IVT_PACK_VOLTAGE_CHANNEL must be 1, 2, or 3"
190+
#endif
181191
}
182192

183193
float FEB_CAN_IVT_GetCurrent(void)

BMS/Core/User/Src/FEB_Commands.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,10 @@ static void subcmd_ivt(int argc, char *argv[])
384384

385385
FEB_Console_Printf("\r\n=== IVT Sensor Data ===\r\n");
386386
FEB_Console_Printf("Pack Current: %.2f A\r\n", ivt->current_mA / 1000.0f);
387-
FEB_Console_Printf("Pack Voltage: %.2f V (V1)\r\n", ivt->voltage_1_mV / 1000.0f);
387+
FEB_Console_Printf("Voltage 1: %.2f V\r\n", ivt->voltage_1_mV / 1000.0f);
388388
FEB_Console_Printf("Voltage 2: %.2f V\r\n", ivt->voltage_2_mV / 1000.0f);
389389
FEB_Console_Printf("Voltage 3: %.2f V\r\n", ivt->voltage_3_mV / 1000.0f);
390+
FEB_Console_Printf("Pack Voltage: %.2f V (U%d)\r\n", FEB_CAN_IVT_GetVoltage(), FEB_IVT_PACK_VOLTAGE_CHANNEL);
390391
FEB_Console_Printf("Temperature: %.1f C\r\n", ivt->temperature_C);
391392
FEB_Console_Printf("Data Age: %lu ms (%s)\r\n", (unsigned long)age, fresh ? "FRESH" : "STALE");
392393
}

BMS/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.7.6
1+
1.7.7

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.7.21
1+
1.7.22

0 commit comments

Comments
 (0)