This commit is contained in:
hamza
2024-07-08 23:43:41 +03:00
parent 73194c86ae
commit 4375bfce48
5 changed files with 160 additions and 162 deletions

View File

@ -62,16 +62,20 @@ void can_handle_send_status() {
uint8_t data[8] = {};
int8_t id_highest_temp = -1;
int16_t highest_temp = INT16_MIN;
int8_t id_lowest_volt = -1;
int16_t lowest_volt = INT16_MIN;
sm_check_battery_temperature(&id_highest_temp, &highest_temp);
data[0] = ((state.current_state << 4) | (powerground_status >> 4)); // 1 bit emptyy | 3 bit state | 4 bit powerground
data[1] = ((powerground_status << 4) | (state.error_source >> 4)); // 4 bit powerground | 4 bit error
data[2] = ((state.error_source << 4) | (0)); // 4 bit error | 4 bit state of charge
data[3] = ((RELAY_BAT_SIDE_VOLTAGE >> 8)); // 8 bit battery voltage
data[4] = ((RELAY_BAT_SIDE_VOLTAGE >> 0));
data[5] = ((CURRENT_MEASUREMENT) / 1000);
data[6] = (/*(CURRENT_MEASUREMENT & 0x000F) |*/ (highest_temp >> 12));
data[7] = ((highest_temp) >> 4);
data[3] = ((RELAY_BAT_SIDE_VOLTAGE / 1000)); // 8 bit battery voltage
data[4] = ((RELAY_ESC_SIDE_VOLTAGE / 1000));
//data[5] = (() / 1000);
data[6] = ((CURRENT_MEASUREMENT / 1000));
data[7] = ((highest_temp) >> 8);
//data[6] = (module.cellVoltages[7] >> 8);
//data[7] = (module.cellVoltages[7]);
//data[7] = state.error_source;
ftcan_transmit(CAN_ID_OUT, data, sizeof(data));
/*
@ -128,9 +132,9 @@ to the sm_handle_ams_in() which handles the state machine transition.
This function recieves a command from the Autobox with the CAN ID of 0x501.
with format of:
data[0] = target state
0x0 STATE_INACTIVE | disconnect power to the ESC of powerground. Send it to return the mvbms to idle/monitoring mode. If data[1] != 0 -> assume bad CAN message.
0x1 STATE_READY | conneect power to the ESC of powerground and but with no PWM signal. If data[1] != 0 -> assume bad CAN message.
0x2 STATE_ACTIVE | activate powerground at (data[1]) percent. If data[1] > 100 -> assume bad CAN message.
0x00 STATE_INACTIVE | disconnect power to the ESC of powerground. Send it to return the mvbms to idle/monitoring mode. If data[1] != 0 -> assume bad CAN message.
0x01 STATE_READY | conneect power to the ESC of powerground and but with no PWM signal. If data[1] != 0 -> assume bad CAN message.
0x02 STATE_ACTIVE | activate powerground at (data[1]) percent. If data[1] > 100 -> assume bad CAN message.
allowed transitions:
STATE_INACTIVE -> STATE_READY