Commit 7595644e authored by 李俭双's avatar 李俭双

🐞 fix:规范变更,电压滤波3s

parent fee2eaa7
......@@ -3,25 +3,52 @@
uint8_t voltage_value = 0;
uint8_t voltage_valid = 0;
DataVoltageStruct VoltageStruct;
void Data_Voltage_Init ( void )
{
voltage_value = 0;
voltage_valid = 0;
VoltageStruct.Cnt = 0;
}
void Data_Voltage_Processing_Service ( void )
{
uint8_t voltage = 0;
uint8_t i = 0;
if ( Common_Get_IG_Sts() == COMMON_POWER_ON )
{
if(CAN_MSG_Status(&CAN_CH0_CanMsgOp, CAN_CH0_ID_CAN_0x401_Msg_Count) == CAN_SIG_LOST)
{
voltage_value = 0;
voltage_valid = 0;
VoltageStruct.Cnt = 0;
}
else
{
voltage_value = Get_CAN_CH0_ID_401_Sig_ECU_Battery_Voltage();
voltage_valid = 1;
if(voltage_valid == 0)
{
voltage_value = Get_CAN_CH0_ID_401_Sig_ECU_Battery_Voltage();
voltage_valid = 1;
}
else
{
voltage_valid = 1;
VoltageStruct.Buffer[VoltageStruct.Cnt] = Get_CAN_CH0_ID_401_Sig_ECU_Battery_Voltage();
i = VoltageStruct.Cnt;
while ((i > 0) && (VoltageStruct.Buffer[i] < VoltageStruct.Buffer[i - 1]))
{
voltage = VoltageStruct.Buffer[i];
VoltageStruct.Buffer[i] = VoltageStruct.Buffer[i - 1];
VoltageStruct.Buffer[i - 1] = voltage;
i --;
}
VoltageStruct.Cnt ++ ;
if (VoltageStruct.Cnt >= 30)
{
VoltageStruct.Cnt = 0;
voltage_value = (VoltageStruct.Buffer[14] + VoltageStruct.Buffer[15] + VoltageStruct.Buffer[16]) / 3;
}
}
}
}
else
......
......@@ -3,6 +3,15 @@
#include "common.h"
typedef struct
{
uint32_t Buffer[30];
uint8_t Cnt;
uint8_t time;
uint16_t ResOpen_ActTimer;
uint16_t ResOpen_InActTimer;
}DataVoltageStruct;
void Data_Voltage_Init ( void );
void Data_Voltage_Processing_Service ( void );
uint8_t Get_Battery_Voltage(void);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment