V1.6
This commit is contained in:
@ -16,10 +16,11 @@
|
||||
#include <stdint.h>
|
||||
|
||||
StateHandle state;
|
||||
int16_t RELAY_BAT_SIDE_VOLTAGE;
|
||||
int16_t RELAY_ESC_SIDE_VOLTAGE;
|
||||
int16_t CURRENT_MEASUREMENT;
|
||||
int32_t RELAY_BAT_SIDE_VOLTAGE;
|
||||
int32_t RELAY_ESC_SIDE_VOLTAGE;
|
||||
int32_t CURRENT_MEASUREMENT;
|
||||
bool CURRENT_MEASUREMENT_ON;
|
||||
float base_offset = 0;
|
||||
|
||||
uint8_t powerground_status;
|
||||
uint32_t precharge_timer;
|
||||
@ -44,15 +45,14 @@ void sm_update(){
|
||||
sm_check_errors();
|
||||
sm_precharge_discharge_manager();
|
||||
sm_calibrate_powerground();
|
||||
if (CAN_timer < HAL_GetTick())
|
||||
state.current_state = state.target_state = STATE_ERROR;
|
||||
//if (CAN_timer < HAL_GetTick())
|
||||
// state.current_state = state.target_state = STATE_ERROR;
|
||||
|
||||
int16_t base_offset = 0;
|
||||
if (state.current_state == STATE_INACTIVE){
|
||||
base_offset = module.auxVoltages[0];
|
||||
}
|
||||
|
||||
CURRENT_MEASUREMENT = (module.auxVoltages[0] - base_offset) * 300;
|
||||
CURRENT_MEASUREMENT = roundf((module.auxVoltages[0] - base_offset) * 350);
|
||||
CURRENT_MEASUREMENT_ON = (module.auxVoltages[1] > 2400);
|
||||
RELAY_ESC_SIDE_VOLTAGE = module.auxVoltages[2] * 11.711;
|
||||
RELAY_BAT_SIDE_VOLTAGE = module.auxVoltages[3] * 11.711; // the calculation says the factor is 11. 11.711 yields the better result
|
||||
@ -120,7 +120,6 @@ State sm_update_ready(){
|
||||
case STATE_DISCHARGE: // if CAN Signal 0000 0000 then shutdown
|
||||
return STATE_DISCHARGE;
|
||||
default:
|
||||
sm_calibrate_powerground();
|
||||
return STATE_READY;
|
||||
}
|
||||
}
|
||||
@ -266,7 +265,7 @@ void sm_calibrate_powerground(){
|
||||
if (powerground_calibration_stage != 4 && state.current_state == STATE_READY){
|
||||
switch (powerground_calibration_stage) {
|
||||
case 0:
|
||||
powerground_calibration_timer = HAL_GetTick() + 5000;
|
||||
powerground_calibration_timer = HAL_GetTick() + 0;
|
||||
powerground_calibration_stage = 1;
|
||||
return;
|
||||
case 1:
|
||||
@ -348,7 +347,7 @@ void sm_check_errors(){
|
||||
state.error_type.bms_timeout = (error_data.error_sources & (1 << 7)) ? 1 : 0;
|
||||
state.error_type.bms_fault = (error_data.error_sources & (1 << 8) || error_data.error_sources & (1 << 10) || error_data.error_sources & (1 << 9)) ? 1 : 0;
|
||||
//SEK_EEPROM_ERR: state.error_type.eeprom_error = 1;
|
||||
state.error_type.current_error = (powerground_status > 10 && CURRENT_MEASUREMENT < 1000) ? 1 : 0;
|
||||
//state.error_type.current_error = (powerground_status > 10 && CURRENT_MEASUREMENT < 500) ? 1 : 0;
|
||||
state.error_type.current_sensor_missing = (!CURRENT_MEASUREMENT_ON) ? 1 : 0;
|
||||
state.error_type.voltage_missing = (RELAY_BAT_SIDE_VOLTAGE < 1000) ? 1 : 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user