Commit c7c3d7e8 authored by 张金硕's avatar 张金硕

🐞 fix:新版机油压力功能

parent 2a596bfb
...@@ -748,6 +748,16 @@ ...@@ -748,6 +748,16 @@
<FileType>4</FileType> <FileType>4</FileType>
<FilePath>..\..\..\..\Source\Application\Hysteresis_V10_239.lib</FilePath> <FilePath>..\..\..\..\Source\Application\Hysteresis_V10_239.lib</FilePath>
</File> </File>
<File>
<FileName>Data_OilPressure.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\Source\Application\Data_OilPressure.c</FilePath>
</File>
<File>
<FileName>Data_OilPressure.h</FileName>
<FileType>5</FileType>
<FilePath>..\..\..\..\Source\Application\Data_OilPressure.h</FilePath>
</File>
</Files> </Files>
</Group> </Group>
<Group> <Group>
......
#include "Data_OilPressure.h"
#include "Components.h"
#define OIL_DATA_TIME 25u /*这里填写多长时间采集一个数据,单位ms*/
#define OIL_DATA_NUM 20u /*机油压力电阻采集数据总数 最大255*/
#define OIL_CAL_START 5u /*数据排序后取中间部分计算平均:起始*/
#define OIL_CAL_END 15u /*数据排序后取中间部分计算平均:结束*/
uint16_t g_u16OilData[OIL_DATA_NUM];
uint8_t g_u8OilDataCount = 0u;
// uint8_t g_u8OILStateInitFlag = 0u;
uint16_t OilPressureR = 0u; /*滤波后的机油压力电阻,精度0.1*/
uint8_t g_u8OilADCompleteFlg = 0u;
void Oil_Pressure_KL30_Init(void)
{
// g_u8OILStateInitFlag = 1u;
g_u8OilADCompleteFlg = 0u;
}
void Oil_Pressure_KL15_Init(void)
{
// g_u8OILStateInitFlag = 1u;
g_u8OilADCompleteFlg = 0u;
}
void Oil_R_Cal(uint8_t deltaTime)
{
uint16_t OilPressureRes = 0;
uint8_t i, j;
uint32_t temp32;
static uint16_t timeCount = 0;
// if(g_u8OILStateInitFlag)
// {
// OilPressureR = ADC_Read_Signal(ADC_CH_OIL_PRESSURE_R);
// }
if (timeCount >= OIL_DATA_TIME)
{
timeCount = 0;
if (g_u8OilDataCount < OIL_DATA_NUM)
{
/*获取机油压力电阻*/
OilPressureRes = ADC_Read_Signal(ADC_CH_OIL_PRESSURE_R);
/*四舍五入*/
if (OilPressureRes < 60000) //针对此项目机油压力采集电路补偿后的阻值
{
if (OilPressureRes % 10 >= 5)
{
OilPressureRes += 5;
}
}
else
{
OilPressureRes = 0xFFFF;
}
/*由小到大插入数据*/
for (i = 0; i < g_u8OilDataCount; i++)
{
if (OilPressureRes < g_u16OilData[i])
{
break;
}
}
for (j = g_u8OilDataCount; j > i; j--)
{
g_u16OilData[j] = g_u16OilData[j - 1];
}
g_u16OilData[i] = OilPressureRes;
g_u8OilDataCount++;
}
else
{
/*一组数据采集完毕,取中间部分计算平均值*/
temp32 = 0;
for (i = OIL_CAL_START; i < OIL_CAL_END; i++)
{
temp32 += g_u16OilData[i];
}
OilPressureR = temp32 / (OIL_CAL_END - OIL_CAL_START);
g_u8OilDataCount = 0;
g_u8OilADCompleteFlg = 1;
}
}
timeCount += deltaTime;
}
uint8_t Get_OilPressureStauts(void)
{
if(OilPressureR < 59500)
{
return 1U;
}
else
{
return 0u;
}
}
\ No newline at end of file
#ifndef DATA_OILPRESSURE_H
#define DATA_OILPRESSURE_H
#include "stdint.h"
void Oil_Pressure_KL30_Init(void);
void Oil_Pressure_KL15_Init(void);
void Oil_R_Cal(uint8_t deltaTime);
uint8_t Get_OilPressureStauts(void);
#endif
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* \attention * \attention
* *
* This file is automatically generated by analog signals configuration tool. * This file is automatically generated by analog signals configuration tool.
* Date : 2024/10/25 18:44:13 * Date : 2024/11/6 19:09:16
* Cfg Tool Ver : 1.1.0 * Cfg Tool Ver : 1.1.0
* Engineer : ShiHao * Engineer : ShiHao
* (c) Heilongjiang TYW electronics co., LTD * (c) Heilongjiang TYW electronics co., LTD
...@@ -74,7 +74,7 @@ ADC_Data_st_t stADCData[ADC_SIGNAL_CH_NUMBER]; ...@@ -74,7 +74,7 @@ ADC_Data_st_t stADCData[ADC_SIGNAL_CH_NUMBER];
const uint8_t __attribute__((aligned(4))) u8ADCChList[ADC_CONV_CH_NUMBER] = const uint8_t __attribute__((aligned(4))) u8ADCChList[ADC_CONV_CH_NUMBER] =
{ {
2U, 3U, 7U, 5U, 6U, 12U, 4U, 2U, 3U, 7U, 5U, 6U, 12U, 11U, 4U,
}; };
const __attribute__((aligned(4))) ADC_Ch_Cfg_st_t stADCChCfg[ADC_SIGNAL_CH_NUMBER] = const __attribute__((aligned(4))) ADC_Ch_Cfg_st_t stADCChCfg[ADC_SIGNAL_CH_NUMBER] =
...@@ -85,7 +85,8 @@ const __attribute__((aligned(4))) ADC_Ch_Cfg_st_t stADCChCfg[ADC_SIGNAL_CH_NUMBE ...@@ -85,7 +85,8 @@ const __attribute__((aligned(4))) ADC_Ch_Cfg_st_t stADCChCfg[ADC_SIGNAL_CH_NUMBE
{ 3U, 2U, 0U, 2U, 0U, 1U, ADC_Res_Calc_Circuit101,}, { 3U, 2U, 0U, 2U, 0U, 1U, ADC_Res_Calc_Circuit101,},
{ 4U, 2U, 0U, 2U, 0U, 1U, ADC_Res_Calc_Circuit101,}, { 4U, 2U, 0U, 2U, 0U, 1U, ADC_Res_Calc_Circuit101,},
{ 5U, 0U, 0U, 0U, 0U, 1U, ADC_Voltage_Calc_Circuit101,}, { 5U, 0U, 0U, 0U, 0U, 1U, ADC_Voltage_Calc_Circuit101,},
{ 6U, 3U, 0U, 5000U, 0U, 10U, ADC_Res_Calc_Circuit201,}, { 6U, 3U, 0U, 5000U, 0U, 1U, ADC_Res_Calc_Circuit101,},
{ 7U, 3U, 0U, 5000U, 0U, 10U, ADC_Res_Calc_Circuit201,},
}; };
const __attribute__((aligned(4))) ADC_Res_List_st_t stADCResList[ADC_SIGNAL_CH_NUMBER] = const __attribute__((aligned(4))) ADC_Res_List_st_t stADCResList[ADC_SIGNAL_CH_NUMBER] =
...@@ -96,6 +97,7 @@ const __attribute__((aligned(4))) ADC_Res_List_st_t stADCResList[ADC_SIGNAL_CH_N ...@@ -96,6 +97,7 @@ const __attribute__((aligned(4))) ADC_Res_List_st_t stADCResList[ADC_SIGNAL_CH_N
{ 0U, 0U, 500U, 300U,}, { 0U, 0U, 500U, 300U,},
{ 0U, 0U, 500U, 0U,}, { 0U, 0U, 500U, 0U,},
{ 0U, 100000U, 0U, 0U,}, { 0U, 100000U, 0U, 0U,},
{ 47000U, 0U, 47000U, 0U,},
{ 47000U, 0U, 100000U, 0U,}, { 47000U, 0U, 100000U, 0U,},
}; };
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* \attention * \attention
* *
* This file is automatically generated by analog signals configuration tool. * This file is automatically generated by analog signals configuration tool.
* Date : 2024/10/25 18:44:13 * Date : 2024/11/6 19:09:16
* Cfg Tool Ver : 1.1.0 * Cfg Tool Ver : 1.1.0
* Engineer : ShiHao * Engineer : ShiHao
* (c) Heilongjiang TYW electronics co., LTD * (c) Heilongjiang TYW electronics co., LTD
...@@ -34,12 +34,13 @@ enum ADCChName ...@@ -34,12 +34,13 @@ enum ADCChName
ADC_CH_FUEL1, ADC_CH_FUEL1,
ADC_CH_COOLANT_TEMP1_R, ADC_CH_COOLANT_TEMP1_R,
ADC_CH_LIGHT_SENSITIVE, ADC_CH_LIGHT_SENSITIVE,
ADC_CH_OIL_PRESSURE_R,
ADC_CH_NTC_TEMP, ADC_CH_NTC_TEMP,
}; };
/* Exported macro ------------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/
#define ADC_TOTAL_CH_NUMBER (7U) #define ADC_TOTAL_CH_NUMBER (8U)
#define ADC_SIGNAL_CH_NUMBER (7U) #define ADC_SIGNAL_CH_NUMBER (8U)
#define ADC_REF_VOLTAGE u16ADCRefVoltage #define ADC_REF_VOLTAGE u16ADCRefVoltage
/* Exported variables --------------------------------------------------------*/ /* Exported variables --------------------------------------------------------*/
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "Data_VSpeed.h" #include "Data_VSpeed.h"
#include "Data_Coolant.h" #include "Data_Coolant.h"
#include "Data_Fuel.h" #include "Data_Fuel.h"
#include "Data_OilPressure.h"
#include "Hysteresis.h" #include "Hysteresis.h"
#include "Mileage\Services_Mileage_User.h" #include "Mileage\Services_Mileage_User.h"
#include "BackLight.h" #include "BackLight.h"
......
...@@ -95,13 +95,13 @@ Linelib_uint8_t Get_LINE_IN_Auto_Start_Stop(void) ...@@ -95,13 +95,13 @@ Linelib_uint8_t Get_LINE_IN_Auto_Start_Stop(void)
Linelib_uint8_t Get_LINE_IN_Oil_Pressure_Alert(void) Linelib_uint8_t Get_LINE_IN_Oil_Pressure_Alert(void)
{ {
Linelib_uint8_t ret = 0U; Linelib_uint8_t ret = 0U;
if (RTE_GPIO_Get_Level(MCU_SPI_MOSI)) if (Get_OilPressureStauts())
{ {
ret = 1u; ret = 0u;
} }
else else
{ {
ret = 0UL; ret = 1UL;
} }
return ret; return ret;
} }
......
...@@ -55,6 +55,7 @@ static void Power_KL30_Init(void) ...@@ -55,6 +55,7 @@ static void Power_KL30_Init(void)
Key_KL30_Init_EXample(); Key_KL30_Init_EXample();
Data_User_Mileage_KL30Init(); Data_User_Mileage_KL30Init();
Fuel_KL30_Init(); Fuel_KL30_Init();
Oil_Pressure_KL30_Init();
BackLight_30_Init(); BackLight_30_Init();
Amt630hInit(); Amt630hInit();
Telltales_Init(); Telltales_Init();
...@@ -91,6 +92,7 @@ static void Power_Wakeup_Init(void) ...@@ -91,6 +92,7 @@ static void Power_Wakeup_Init(void)
Key_Wakeup_Init_EXample(); Key_Wakeup_Init_EXample();
Line_In_KL15_ON_Init(); Line_In_KL15_ON_Init();
Fuel_KL30_Init(); Fuel_KL30_Init();
Oil_Pressure_KL30_Init();
BackLight_WakeUp_Init(); BackLight_WakeUp_Init();
RTE_UART_Sleep_Init(UART_CH2); RTE_UART_Sleep_Init(UART_CH2);
loc_config.u32UARTChEn = 1U; loc_config.u32UARTChEn = 1U;
...@@ -131,6 +133,7 @@ static void Power_IG_ON_Init(void) ...@@ -131,6 +133,7 @@ static void Power_IG_ON_Init(void)
Line_In_KL15_ON_Init(); Line_In_KL15_ON_Init();
Telltales_KL15_Init(); Telltales_KL15_Init();
Fuel_KL15_Init(); Fuel_KL15_Init();
Oil_Pressure_KL15_Init();
TEMP_KL15_Init(); TEMP_KL15_Init();
//RTE_GPIO_Set_Level(Blacklight_PWM, 1); //RTE_GPIO_Set_Level(Blacklight_PWM, 1);
FaultCode_Init(); FaultCode_Init();
......
...@@ -41,6 +41,7 @@ void Sys_10ms_Tasks(void) ...@@ -41,6 +41,7 @@ void Sys_10ms_Tasks(void)
Key_Clear_Time(); Key_Clear_Time();
Key_TimeOut_Service(); Key_TimeOut_Service();
Fuel_R_Cal(10u); Fuel_R_Cal(10u);
Oil_R_Cal(10u);
Data_Light_Res_service(10); Data_Light_Res_service(10);
BackLight_Process(); BackLight_Process();
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* \attention * \attention
* *
* This file is automatically generated by analog signals configuration tool. * This file is automatically generated by analog signals configuration tool.
* Date : 2024/10/25 18:44:13 * Date : 2024/11/9 15:54:41
* Cfg Tool Ver : 1.1.0 * Cfg Tool Ver : 1.1.0
* Engineer : ShiHao * Engineer : ShiHao
* (c) Heilongjiang TYW electronics co., LTD * (c) Heilongjiang TYW electronics co., LTD
...@@ -34,12 +34,13 @@ enum ADCChName ...@@ -34,12 +34,13 @@ enum ADCChName
ADC_CH_FUEL1, ADC_CH_FUEL1,
ADC_CH_COOLANT_TEMP1_R, ADC_CH_COOLANT_TEMP1_R,
ADC_CH_LIGHT_SENSITIVE, ADC_CH_LIGHT_SENSITIVE,
ADC_CH_OIL_PRESSURE_R,
ADC_CH_NTC_TEMP, ADC_CH_NTC_TEMP,
}; };
/* Exported macro ------------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/
#define ADC_TOTAL_CH_NUMBER (7U) #define ADC_TOTAL_CH_NUMBER (8U)
#define ADC_SIGNAL_CH_NUMBER (7U) #define ADC_SIGNAL_CH_NUMBER (8U)
#define ADC_REF_VOLTAGE u16ADCRefVoltage #define ADC_REF_VOLTAGE u16ADCRefVoltage
/* Exported variables --------------------------------------------------------*/ /* Exported variables --------------------------------------------------------*/
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* \attention * \attention
* *
* This file is automatically generated by analog signals configuration tool. * This file is automatically generated by analog signals configuration tool.
* Date : 2024/10/25 18:44:13 * Date : 2024/11/9 15:54:41
* Cfg Tool Ver : 1.1.0 * Cfg Tool Ver : 1.1.0
* Engineer : ShiHao * Engineer : ShiHao
* (c) Heilongjiang TYW electronics co., LTD * (c) Heilongjiang TYW electronics co., LTD
...@@ -74,7 +74,7 @@ ADC_Data_st_t stADCData[ADC_SIGNAL_CH_NUMBER]; ...@@ -74,7 +74,7 @@ ADC_Data_st_t stADCData[ADC_SIGNAL_CH_NUMBER];
const uint8_t __attribute__((aligned(4))) u8ADCChList[ADC_CONV_CH_NUMBER] = const uint8_t __attribute__((aligned(4))) u8ADCChList[ADC_CONV_CH_NUMBER] =
{ {
2U, 3U, 7U, 5U, 6U, 12U, 4U, 2U, 3U, 7U, 5U, 6U, 12U, 11U, 4U,
}; };
const __attribute__((aligned(4))) ADC_Ch_Cfg_st_t stADCChCfg[ADC_SIGNAL_CH_NUMBER] = const __attribute__((aligned(4))) ADC_Ch_Cfg_st_t stADCChCfg[ADC_SIGNAL_CH_NUMBER] =
...@@ -85,7 +85,8 @@ const __attribute__((aligned(4))) ADC_Ch_Cfg_st_t stADCChCfg[ADC_SIGNAL_CH_NUMBE ...@@ -85,7 +85,8 @@ const __attribute__((aligned(4))) ADC_Ch_Cfg_st_t stADCChCfg[ADC_SIGNAL_CH_NUMBE
{ 3U, 2U, 0U, 2U, 0U, 1U, ADC_Res_Calc_Circuit101,}, { 3U, 2U, 0U, 2U, 0U, 1U, ADC_Res_Calc_Circuit101,},
{ 4U, 2U, 0U, 2U, 0U, 1U, ADC_Res_Calc_Circuit101,}, { 4U, 2U, 0U, 2U, 0U, 1U, ADC_Res_Calc_Circuit101,},
{ 5U, 0U, 0U, 0U, 0U, 1U, ADC_Voltage_Calc_Circuit101,}, { 5U, 0U, 0U, 0U, 0U, 1U, ADC_Voltage_Calc_Circuit101,},
{ 6U, 3U, 0U, 5000U, 0U, 10U, ADC_Res_Calc_Circuit201,}, { 6U, 3U, 0U, 5000U, 0U, 1U, ADC_Res_Calc_Circuit101,},
{ 7U, 3U, 0U, 5000U, 0U, 10U, ADC_Res_Calc_Circuit201,},
}; };
const __attribute__((aligned(4))) ADC_Res_List_st_t stADCResList[ADC_SIGNAL_CH_NUMBER] = const __attribute__((aligned(4))) ADC_Res_List_st_t stADCResList[ADC_SIGNAL_CH_NUMBER] =
...@@ -96,6 +97,7 @@ const __attribute__((aligned(4))) ADC_Res_List_st_t stADCResList[ADC_SIGNAL_CH_N ...@@ -96,6 +97,7 @@ const __attribute__((aligned(4))) ADC_Res_List_st_t stADCResList[ADC_SIGNAL_CH_N
{ 0U, 0U, 500U, 300U,}, { 0U, 0U, 500U, 300U,},
{ 0U, 0U, 500U, 0U,}, { 0U, 0U, 500U, 0U,},
{ 0U, 100000U, 0U, 0U,}, { 0U, 100000U, 0U, 0U,},
{ 47000U, 0U, 47000U, 0U,},
{ 47000U, 0U, 100000U, 0U,}, { 47000U, 0U, 100000U, 0U,},
}; };
......
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