diff --git a/Core/Inc/state_machine.h b/Core/Inc/state_machine.h index 716ad3b..b7726f3 100644 --- a/Core/Inc/state_machine.h +++ b/Core/Inc/state_machine.h @@ -64,9 +64,9 @@ typedef struct { extern StateHandle state; static bool relay_closed = 0; static bool precharge_closed = 0; -static int16_t RELAY_BAT_SIDE_VOLTAGE; -static int16_t RELAY_ESC_SIDE_VOLTAGE; -static int16_t CURRENT_MEASUREMENT; +extern int16_t RELAY_BAT_SIDE_VOLTAGE; +extern int16_t RELAY_ESC_SIDE_VOLTAGE; +extern int16_t CURRENT_MEASUREMENT; void sm_init(); void sm_update(); diff --git a/Core/Src/state_machine.c b/Core/Src/state_machine.c index 9b44794..144ae14 100644 --- a/Core/Src/state_machine.c +++ b/Core/Src/state_machine.c @@ -2,7 +2,10 @@ #include "stm32f3xx_hal.h" StateHandle state; -static uint32_t timestamp; +int16_t RELAY_BAT_SIDE_VOLTAGE; +int16_t RELAY_ESC_SIDE_VOLTAGE; +int16_t CURRENT_MEASUREMENT; +uint32_t timestamp; void sm_init(){ state.current_state = STATE_INACTIVE; @@ -11,9 +14,9 @@ void sm_init(){ } void sm_update(){ - RELAY_BAT_SIDE_VOLTAGE = module.auxVoltages[0] * 11.989; - RELAY_ESC_SIDE_VOLTAGE = module.auxVoltages[1] * 11.989; - CURRENT_MEASUREMENT = module.auxVoltages[2] ; + RELAY_BAT_SIDE_VOLTAGE = module.auxVoltages[0] * 12.42; // the calculation says the factor is 11.989. 12.42 yields the better result + RELAY_ESC_SIDE_VOLTAGE = module.auxVoltages[1] * 12.42; + CURRENT_MEASUREMENT = module.auxVoltages[2] / 2.2; switch (state.current_state) { case STATE_INACTIVE: