123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701 |
- /********************************************************************************
- * 常州易控汽车电子股份有限公司
- * (c) Copyright 2009-2018 ECTEK
- * 保留所有权利
- ********************************************************************************
- * 工程名称:整车管理_车辆运动
- * 文件名: AccPedCD.h
- * 功能描述 : 油门踏板模块驱动
- * 引用记录:
- * 备注:
- * 修订记录:
- * 日期 版本 作者 描述
- * 2018.01.12 00.01.00 李中 第一版
- *******************************************************************************/
- #include "HardwareLib.h"
- #include "AccPedCD.h"
- /*********************************************************************************************/
- /*样例代码*/
- #ifdef _SAMPLE_CODE_
-
- uint16 AccPedCD_rFltUW,AccPedCD_rUW; //油门踏板位置
- uint16 AccPedCD_rRawUW; //类似bosch文档APPCD_rLinAPP1
- uint16 AccPedCD_uUW,AccPedCD_u2UW,AccPedCD_uFltUW;
- uint16 AccPedCD_uOldUW;
- uint8 AccPedCD_idxDeltaMonUB;
- sint16 AccPedCD_drUnFltW; //油门踏板斜率
- uint16 AccPedCD_rOldUW; //上一时刻油门踏板,用于斜率计算
- uint8 AccPedCD_bIdleSwtUB; //怠速开关状态,0:怠速位置 1:全负荷位置
- uint8 AccPedCD_bIdleRawUB; //怠速开关原始信号,怠速开关状态和怠速开关原始信号的关系与怠速开关类型相关
- uint8 AccPedCD_stMaxUB,AccPedCD_stMinUB,AccPedCD_stNplUB;
- uint8 AccPedCD_st2MaxUB,AccPedCD_st2MinUB;
- uint16 AccPedCD_facT1UW;
- uint8 Fid_APP1UB_mp; //加速踏板1故障禁止状态
- uint8 Fid_APP2UB_mp; //加速踏板2故障禁止状态
- uint16 AccPedCD_stAPPLatchUW; //上一循环加速踏板诊断的状态 1 部分故障, 2 完全故障, 3 部分恢复, 4完全正常
- uint16 AccPedCD_stRampUW; //故障恢复的Ramp状态,0 Ramp结束, 1 Ramp使能
- /*************************************************************/
- /*标定数据区开始(请不要在该区域加入非标定数据相关的内容) */
- #define MAPDATA_START_SEC_VAR_CONST
- #include "MemMap.h"
- /*AccPedCD_Cal*/
- PRAGMA_MAPDATA const uint16 AccPedCD_uSRCMaxUW_C=18428; /*AccPedCD_uSRCMaxUW_C,最大值*/
- PRAGMA_MAPDATA const uint16 AccPedCD_uSRCMinUW_C=2048; /*AccPedCD_uSRCMinUW_C,最小值*/
- PRAGMA_MAPDATA const uint16 AccPedCD_uMaxDiffUW_C=2047; /*AccPedCD_uMaxDiffUW_C,AccPed2与AccPed1最大相差多少...*/
- PRAGMA_MAPDATA const uint16 AccPedCD_uHighLimIdleUW_C=18427; /*AccPedCD_uHighLimIdleUW_C,怠速开关高限*/
- PRAGMA_MAPDATA const uint16 AccPedCD_uLowLimIdleUW_C=819; /*AccPedCD_uLowLimIdleUW_C,怠速开关低限*/
- PRAGMA_MAPDATA const uint16 AccPedCD_bPlausEnUW_C=1; /*AccPedCD_bPlausEnUW_C,油门合理性检测是否启用*/
- PRAGMA_MAPDATA const uint16 AccPedCD_rFltUW_C=0; /*数字油门,AccPedCD_rFltUW_C*/
- PRAGMA_MAPDATA const uint16 AccPedCD_bDigEnUW_C=1; /*油门控制模式,AccPedCD_bDigEnUW_C, 1为正常控制, 0为数字油门*/
- PRAGMA_MAPDATA const uint16 AccPedCD_swtUseUW_C=1; /*AccPedCD_swtUseUW_C,油门传感器类型,1:双油门,2:怠速开关,3:单油门*/
- PRAGMA_MAPDATA const uint16 AccPedCD_idxIdleSwtTypeUW_C=0; /*AccPedCD_idxIdleSwtTypeUW_C,怠速开关类型 ,0:接电源常开,1:接电源常闭,2:接地常开,3:接地常闭*/
- PRAGMA_MAPDATA const AccPedCD_rUW_CUR_TYPE AccPedCD_rUW_CUR=
- {
- 4,
- {
- 4505,14169,16380,20475
- },
- {
- 0,25600,25600,25600
- }
- }; /*油门标定,AccPedCD_rUW_CUR,系数256,单位%*/
- PRAGMA_MAPDATA const uint16 AccPedCD_rThresFltLowPosUW_C=3840; /*AccPedCD_rThresFltLowPosUW_C,小油门限*/
- PRAGMA_MAPDATA const uint16 AccPedCD_rThresFltMidPosUW_C=10240; /*AccPedCD_rThresFltMidPosUW_C,中油门限*/
- PRAGMA_MAPDATA const uint16 AccPedCD_facT1LowNegUW_C=0; /*AccPedCD_facT1LowNegUW_C,小油门负向滤波系数*/
- PRAGMA_MAPDATA const uint16 AccPedCD_facT1MidNegUW_C=0; /*AccPedCD_facT1MidNegUW_C,中油门负向滤波系数*/
- PRAGMA_MAPDATA const uint16 AccPedCD_facT1HighNegUW_C=0; /*AccPedCD_facT1HighNegUW_C,大油门负向滤波系数*/
- PRAGMA_MAPDATA const uint16 AccPedCD_facT1LowPosUW_C=750; /*AccPedCD_facT1LowPosUW_C,小油门正向滤波系数*/
- PRAGMA_MAPDATA const uint16 AccPedCD_facT1MidPosUW_C=250; /*AccPedCD_facT1MidPosUW_C,中油门正向滤波系数*/
- PRAGMA_MAPDATA const uint16 AccPedCD_facT1HighPosUW_C=250; /*AccPedCD_facT1HighPosUW_C,大油门正向滤波系数*/
- PRAGMA_MAPDATA const uint16 AccPedCD_duThresStationaryUW_C=123; /*AccPedCD_duThresStationaryUW_C,稳态油门变化范围*/
- PRAGMA_MAPDATA const uint16 AccPedCD_facT1StationaryUW_C=900; /*AccPedCD_facT1StationaryUW_C,稳态滤波系数*/
- PRAGMA_MAPDATA const uint16 AccPedCD_facDualRelUW_C=2; /*AccPedCD_facDualRelUW_C, 双油门两路信号的比例关系,第一路/第二路*/
- PRAGMA_MAPDATA const uint16 AccPedCD_drHealRmpUp_C=2560; /*AccPedCD_drHealRmpUp_C; 加速踏板故障恢复正向Ramp步长。APPCD_drHealRmpUp_C: healing ramp pos. slope<value>*/
- PRAGMA_MAPDATA const uint16 AccPedCD_drHealRmpDwn_C=2560; /*AccPedCD_drHealRmpDwn_C; 故障恢复时向下Ramp步长; APPCD_drHealRmpDwn_C: healing ramp neg. slope<value>*/
- #define MAPDATA_STOP_SEC_VAR_CONST
- #include "MemMap.h"
- /*标定数据区结束 */
- /*************************************************************/
- /***********************************************
- * 函数:油门踏板驱动模块初始化
- * 功能:初始化模块中应用到的各变量。
- ***********************************************/
- void AccPedCD_Init(void)
- {
- AccPedCD_uFltUW=0;
- AccPedCD_idxDeltaMonUB=0;
- AccPedCD_drUnFltW=0;
- AccPedCD_rOldUW=0;
-
- Fid_APP1UB_mp=0;
- Fid_APP2UB_mp=0;
- AccPedCD_stAPPLatchUW = _DFC_INDEX_FINALLY_HEALED_STATUS;
- AccPedCD_stRampUW=0;
-
- if(1==AccPedCD_swtUseUW_C)
- {
- //双油门
-
- //油门1
- AccPedCD_uUW=ATDDrv_GetChanResult(_ATD_INDEX_ACCPED1_CHAN);
- AccPedCD_uOldUW=AccPedCD_uUW;
- //油门2
- AccPedCD_u2UW=ATDDrv_GetChanResult(_ATD_INDEX_ACCPED2_CHAN);
- }
- else
- {
- if(2==AccPedCD_swtUseUW_C)
- {
- //带怠速开关的油门
-
- //油门1
- AccPedCD_uUW=ATDDrv_GetChanResult(_ATD_INDEX_ACCPED1_CHAN);
- AccPedCD_uOldUW=AccPedCD_uUW;
-
- //得到怠速开关状态
- AccPedCD_bIdleRawUB=DINDrv_GetChanState(_DIN_INDEX_BAK1_CHAN);
-
- if((0==AccPedCD_idxIdleSwtTypeUW_C)||(3==AccPedCD_idxIdleSwtTypeUW_C))
- {
- //接电常开或者接地常闭
- //AccPedCD_bIdleRawUB为1表明踏板踩下,在全负荷位置
- AccPedCD_bIdleSwtUB=AccPedCD_bIdleRawUB;
- }
- else
- {
- //接电常闭或者接地常开
- //AccPedCD_bIdleRawUB为0表明踏板踩下,在全负荷位置
- AccPedCD_bIdleSwtUB=(!AccPedCD_bIdleRawUB);
- }
-
- }
- else
- {
- //单油门
- AccPedCD_uUW=ATDDrv_GetChanResult(_ATD_INDEX_ACCPED1_CHAN);
- AccPedCD_uOldUW=AccPedCD_uUW;
- }
- }
-
-
- AccPedCD_Update();
- }
- /***********************************************
- * 函数:油门信号滤波函数
- * 功能:判断油门为小中大油门及正负向,并进行滤波。
- ***********************************************/
- void AccPedCD_Filter(void)
- {
- //参数选取
- if(AccPedCD_rFltUW>AccPedCD_rRawUW)
- {
- //下降,3段滤波
- if(AccPedCD_rFltUW<AccPedCD_rThresFltLowPosUW_C)
- {
- AccPedCD_facT1UW=AccPedCD_facT1LowNegUW_C;
- }
- else
- {
- if(AccPedCD_rFltUW<AccPedCD_rThresFltMidPosUW_C)
- {
- AccPedCD_facT1UW=AccPedCD_facT1MidNegUW_C;
- }
- else
- {
- AccPedCD_facT1UW=AccPedCD_facT1HighNegUW_C;
- }
- }
-
- }
- else
- {
- //上升,3段滤波
- if(AccPedCD_rFltUW<AccPedCD_rThresFltLowPosUW_C)
- {
- AccPedCD_facT1UW=AccPedCD_facT1LowPosUW_C;
- }
- else
- {
- if(AccPedCD_rFltUW<AccPedCD_rThresFltMidPosUW_C)
- {
- AccPedCD_facT1UW=AccPedCD_facT1MidPosUW_C;
- }
- else
- {
- AccPedCD_facT1UW=AccPedCD_facT1HighPosUW_C;
- }
- }
- }
-
- //输出值计算
-
- ComLib_PT1U16(AccPedCD_uUW,(uint16)(_COMLIB_FACTOR_PT1-AccPedCD_facT1UW),AccPedCD_facT1UW,(uint16 *)&AccPedCD_uFltUW); //AD值滤波
- ComLib_PT1U16(AccPedCD_rUW,(uint16)(_COMLIB_FACTOR_PT1-AccPedCD_facT1UW),AccPedCD_facT1UW,(uint16 *)&AccPedCD_rFltUW); //油门滤波
- }
- /***********************************************
- * 函数:计算油门信号数值
- * 功能:根据步长计算油门信号增大或减小的数值。
- ***********************************************/
- void AccPedCD_Ramp(void)
- {
- //ramp
- if(1==AccPedCD_stRampUW)
- {
- //ramp使能状态 Ramp start
- if(AccPedCD_rRawUW>=AccPedCD_rUW)
- {
- //向上
- if((AccPedCD_rRawUW - AccPedCD_rUW)<=AccPedCD_drHealRmpUp_C)
- {
- //差值小于最小步长限制
- AccPedCD_rUW = AccPedCD_rRawUW;
- AccPedCD_stRampUW=0;//Ramp结束
- }
- else
- {
- AccPedCD_rUW += AccPedCD_drHealRmpUp_C;
- }
- }
- else
- {
- //向下
- if((AccPedCD_rUW - AccPedCD_rRawUW)<=AccPedCD_drHealRmpDwn_C)
- {
- //差值小于最小步长限制
- AccPedCD_rUW = AccPedCD_rRawUW;
- AccPedCD_stRampUW=0;//Ramp结束 Ramp end
- }
- else
- {
- AccPedCD_rUW -= AccPedCD_drHealRmpDwn_C;
- }
- }
- }
- else
- {
- AccPedCD_rUW=AccPedCD_rRawUW;
- }
- }
- /***********************************************
- * 函数:双油门信号处理
- * 功能:向DSM模块请求信息,判断当前状态为正常/部分正常/完全故障,根据状态进行更新操作。
- * 结构:请求故障状态信息,判断当前状态后,决定油门信号更新/清零/保持不变。
- ***********************************************/
- void AccPedCD_DualAnalog(void)
- {
- uint16 uDiffUW;
- /*获取油门相关FID状态:加速踏板1/2信号故障失效模式是否开启*/
- //双油门
- Fid_APP1UB_mp=DINH_GetFIDState(_DINH_INDEX_FID_APP1);
- Fid_APP2UB_mp=DINH_GetFIDState(_DINH_INDEX_FID_APP2);
- /*获取油门相关DFC故障水平:油门踏板1/2信号过高/低、油门NPL故障*/
- //第一油门SRC HIGH故障
- AccPedCD_stMaxUB=DFC_GetDebState(_DFC_INDEX_ACCPED_SIGHIGH);
-
- //第一油门SRC LOW故障
- AccPedCD_stMinUB=DFC_GetDebState(_DFC_INDEX_ACCPED_SIGLOW);
-
- //第一油门NPL故障
- AccPedCD_stNplUB=DFC_GetDebState(_DFC_INDEX_ACCPED_SIGHNPL);
-
- //第二油门SRC HIGH故障
- AccPedCD_st2MaxUB=DFC_GetDebState(_DFC_INDEX_ACCPED2_SIGHIGH);
-
- //第二油门SRC LOW故障
- AccPedCD_st2MinUB=DFC_GetDebState(_DFC_INDEX_ACCPED2_SIGLOW);
-
- if((_DFC_INDEX_FINALLY_DEFECTIVE_STATUS==AccPedCD_stMaxUB)||
- (_DFC_INDEX_FINALLY_DEFECTIVE_STATUS==AccPedCD_st2MaxUB)||
- (_DFC_INDEX_FINALLY_DEFECTIVE_STATUS==AccPedCD_stMinUB)||
- (_DFC_INDEX_FINALLY_DEFECTIVE_STATUS==AccPedCD_st2MinUB)||
- (_DFC_INDEX_FINALLY_DEFECTIVE_STATUS==AccPedCD_stNplUB)||
- (Fid_APP1UB_mp==1)||
- (Fid_APP2UB_mp==1))
- {
- //完全故障
- AccPedCD_rUW=0;
- AccPedCD_rFltUW=0; //赋油门值为0
- AccPedCD_stRampUW=1; //Ramp start
- AccPedCD_stAPPLatchUW=_DFC_INDEX_FINALLY_DEFECTIVE_STATUS;
- }
- else
- {
- //非完全故障状态
- //检查合理性
- if(AccPedCD_uUW>=AccPedCD_facDualRelUW_C*AccPedCD_u2UW)
- {
- uDiffUW=AccPedCD_uUW-AccPedCD_facDualRelUW_C*AccPedCD_u2UW;
- }
- else
- {
- uDiffUW=AccPedCD_facDualRelUW_C*AccPedCD_u2UW-AccPedCD_uUW;
- }
-
- if((AccPedCD_uUW>AccPedCD_uSRCMaxUW_C)
- ||(AccPedCD_uUW<AccPedCD_uSRCMinUW_C)
- ||(AccPedCD_facDualRelUW_C*AccPedCD_u2UW>AccPedCD_uSRCMaxUW_C)
- ||(AccPedCD_facDualRelUW_C*AccPedCD_u2UW<AccPedCD_uSRCMinUW_C)
- ||((DINH_GetFIDState(_DINH_INDEX_FID_ACCPED_NPL)==0)&&(uDiffUW>AccPedCD_uMaxDiffUW_C))) //双油门合理性校验
- {
- //任何一项故障的状态,部分故障,则维持上一循环的值不动
- AccPedCD_stAPPLatchUW=_DFC_INDEX_PRELIMINARILY_DEFECTIVE_STATUS;
- }
- else
- {
- if((_DFC_INDEX_FINALLY_HEALED_STATUS==AccPedCD_stMaxUB)&&
- (_DFC_INDEX_FINALLY_HEALED_STATUS==AccPedCD_st2MaxUB)&&
- (_DFC_INDEX_FINALLY_HEALED_STATUS==AccPedCD_stMinUB)&&
- (_DFC_INDEX_FINALLY_HEALED_STATUS==AccPedCD_st2MinUB)&&
- (_DFC_INDEX_FINALLY_HEALED_STATUS==AccPedCD_stNplUB))
- {
- //完全正常的状态
- AccPedCD_stAPPLatchUW=_DFC_INDEX_FINALLY_HEALED_STATUS;
- AccPedCD_Ramp();
- }
- else
- {
- //或部分恢复
- AccPedCD_stAPPLatchUW=_DFC_INDEX_PRELIMINARILY_HEALED_STATUS;
- }
- }
- AccPedCD_Filter();
- }
- }
- /***********************************************
- * 函数:单油门信号处理
- * 功能:向DSM模块请求信息,判断当前状态为正常/部分正常/完全故障,根据状态进行更新操作。
- * 结构:请求故障状态信息,判断当前状态后,决定油门信号更新/清零/保持不变。
- ***********************************************/
- void AccPedCD_SingleAnalog(void)
- {
- Fid_APP1UB_mp=DINH_GetFIDState(_DINH_INDEX_FID_APP1);
-
- //第一油门SRC HIGH故障
- AccPedCD_stMaxUB=DFC_GetDebState(_DFC_INDEX_ACCPED_SIGHIGH);
-
- //第一油门SRC LOW故障
- AccPedCD_stMinUB=DFC_GetDebState(_DFC_INDEX_ACCPED_SIGLOW);
-
-
- if((_DFC_INDEX_FINALLY_DEFECTIVE_STATUS==AccPedCD_stMaxUB)||
- (_DFC_INDEX_FINALLY_DEFECTIVE_STATUS==AccPedCD_stMinUB)||
- (Fid_APP1UB_mp==1))
- {
- //完全故障
- AccPedCD_rUW=0;
- AccPedCD_rFltUW=0; //赋油门值为0
- AccPedCD_stRampUW=1; //Ramp start
- AccPedCD_stAPPLatchUW=_DFC_INDEX_FINALLY_DEFECTIVE_STATUS;
- }
- else
- {
- if((AccPedCD_uUW>AccPedCD_uSRCMaxUW_C)
- ||(AccPedCD_uUW<AccPedCD_uSRCMinUW_C)) //单油门合理性校验
- {
- //任何一项故障的状态,部分故障,则维持上一循环的值不动
- AccPedCD_stAPPLatchUW=_DFC_INDEX_PRELIMINARILY_DEFECTIVE_STATUS;
- }
- else
- {
- if( (_DFC_INDEX_FINALLY_HEALED_STATUS==AccPedCD_stMaxUB)&&
- (_DFC_INDEX_FINALLY_HEALED_STATUS==AccPedCD_stMinUB))
- {
- //完全正常的状态
- AccPedCD_stAPPLatchUW=_DFC_INDEX_FINALLY_HEALED_STATUS;
- AccPedCD_Ramp();
- }
- else
- {
- //或部分恢复
- AccPedCD_stAPPLatchUW=_DFC_INDEX_PRELIMINARILY_HEALED_STATUS;
- }
- }
- AccPedCD_Filter();
- }
- }
- /***********************************************
- * 函数:怠速开关油门信号处理
- * 功能:向DSM模块请求信息,判断当前状态为正常/部分正常/完全故障,根据状态进行更新操作。
- * 结构:请求故障状态信息,判断当前状态后,决定油门信号更新/清零/保持不变。
- ***********************************************/
- void AccPedCD_Switch(void)
- {
-
- //带怠速开关的油门
- Fid_APP1UB_mp=DINH_GetFIDState(_DINH_INDEX_FID_APP1);
- //第一油门SRC HIGH故障
- AccPedCD_stMaxUB=DFC_GetDebState(_DFC_INDEX_ACCPED_SIGHIGH);
-
- //第一油门SRC LOW故障
- AccPedCD_stMinUB=DFC_GetDebState(_DFC_INDEX_ACCPED_SIGLOW);
-
- //第一油门NPL故障
- AccPedCD_stNplUB=DFC_GetDebState(_DFC_INDEX_ACCPED_SIGHNPL);
-
- if((_DFC_INDEX_FINALLY_DEFECTIVE_STATUS==AccPedCD_stMaxUB)||
- (_DFC_INDEX_FINALLY_DEFECTIVE_STATUS==AccPedCD_stMinUB)||
- (_DFC_INDEX_FINALLY_DEFECTIVE_STATUS==AccPedCD_stNplUB)||
- (Fid_APP1UB_mp==1))
- {
- //完全故障
- AccPedCD_rUW=0;
- AccPedCD_rFltUW=0; //赋油门值为0
- AccPedCD_stRampUW=1; //Ramp start
- AccPedCD_stAPPLatchUW=_DFC_INDEX_FINALLY_DEFECTIVE_STATUS;
- }
- else
- {
- if((AccPedCD_uUW>AccPedCD_uSRCMaxUW_C)
- ||(AccPedCD_uUW<AccPedCD_uSRCMinUW_C)
- ||( (1==AccPedCD_bPlausEnUW_C)&&
- (((0==AccPedCD_bIdleSwtUB)&&(AccPedCD_uUW>AccPedCD_uHighLimIdleUW_C))||
- ((1==AccPedCD_bIdleSwtUB)&&(AccPedCD_uUW<AccPedCD_uLowLimIdleUW_C)))))
- {
- //任何一项故障的状态,部分故障,则维持上一循环的值不动
- AccPedCD_stAPPLatchUW=_DFC_INDEX_PRELIMINARILY_DEFECTIVE_STATUS;
- }
- else
- {
- if((_DFC_INDEX_FINALLY_HEALED_STATUS==AccPedCD_stMaxUB)&&
- (_DFC_INDEX_FINALLY_HEALED_STATUS==AccPedCD_stMinUB)&&
- (_DFC_INDEX_FINALLY_HEALED_STATUS==AccPedCD_stNplUB))
- {
- //完全正常的状态
- AccPedCD_stAPPLatchUW=_DFC_INDEX_FINALLY_HEALED_STATUS;
- AccPedCD_Ramp();
- }
- else
- {
- //或部分恢复
- AccPedCD_stAPPLatchUW=_DFC_INDEX_PRELIMINARILY_HEALED_STATUS;
- }
- }
- AccPedCD_Filter();
- }
- }
- /***********************************************
- * 函数:更新油门信号入口函数
- * 功能:根据不同模式,计算并更新油门信号值。
- * 结构:根据标定变量判断当前状态为单油门/双油门/带怠速开关/不使用,确定配置后,再对通过相应函数更新信号。
- ***********************************************/
- void AccPedCD_Update(void)
- {
- if(AccPedCD_bDigEnUW_C==1)
- {
- AccPedCD_rFltUW=AccPedCD_rFltUW_C; //数字油门模式
- AccPedCD_rUW=AccPedCD_rFltUW_C; //滤波前油门也用数字油门接管
- }
- else
- {
- if(1==AccPedCD_swtUseUW_C)
- {
- //双油门
- //油门1
- AccPedCD_uOldUW=AccPedCD_uUW;
- AccPedCD_uUW=ATDDrv_GetChanResult(_ATD_INDEX_ACCPED1_CHAN);
- //油门2
- AccPedCD_u2UW=ATDDrv_GetChanResult(_ATD_INDEX_ACCPED2_CHAN);
- AccPedCD_rRawUW=Intpol_u16u16((uint16 *)&AccPedCD_rUW_CUR,AccPedCD_uUW);
- AccPedCD_DualAnalog();
- }
- else
- {
- if(2==AccPedCD_swtUseUW_C)
- {
- //油门和怠速开关
- //油门1
- AccPedCD_uOldUW=AccPedCD_uUW;
- AccPedCD_uUW=ATDDrv_GetChanResult(_ATD_INDEX_ACCPED1_CHAN);
- //得到怠速开关状态
- AccPedCD_bIdleRawUB=DINDrv_GetChanState(_DIN_INDEX_BAK1_CHAN);
- if(0==AccPedCD_idxIdleSwtTypeUW_C)
- {
- //常地型,AccPedCD_bIdleRawUB为1表明踏板踩下,在全负荷位置
- AccPedCD_bIdleSwtUB=AccPedCD_bIdleRawUB;
- }
- else
- {
- //常电型,AccPedCD_bIdleRawUB为0表明踏板踩下,在全负荷位置
- AccPedCD_bIdleSwtUB=(!AccPedCD_bIdleRawUB);
- }
- AccPedCD_rRawUW=Intpol_u16u16((uint16 *)&AccPedCD_rUW_CUR,AccPedCD_uUW);
- AccPedCD_Switch();
- }
- else
- {
- //单油门
- //油门1
- AccPedCD_uOldUW=AccPedCD_uUW;
- AccPedCD_uUW=ATDDrv_GetChanResult(_ATD_INDEX_ACCPED1_CHAN);
- AccPedCD_rRawUW=Intpol_u16u16((uint16 *)&AccPedCD_rUW_CUR,AccPedCD_uUW);
- AccPedCD_SingleAnalog();
- }
- }
- }
-
-
- AccPedCD_idxDeltaMonUB=(uint8)((AccPedCD_idxDeltaMonUB+1)%_ACCPED_DELTA_MONITOR_TIME);
- if(AccPedCD_idxDeltaMonUB==0)
- {
- //加速踏板斜率计算
-
- AccPedCD_drUnFltW=AccPedCD_rFltUW-AccPedCD_rOldUW;
- AccPedCD_rOldUW=AccPedCD_rFltUW;
- }
-
- }
- /***********************************************
- * 函数:油门相关故障监控
- * 功能:检测油门信号是否超限值/相关功能是否被禁用/信号值是否合理,如出现异常向DSM模块报告异常水平。
- * 结构:根据标定变量判断当前状态为单油门/双油门/带怠速开关/不使用,确定配置后,再对相应油门信号进行检测。
- ***********************************************/
- void AccPedCD_Monitor(void)
- {
- uint16 uDiffUW;
-
-
- //AccPedCD_swtUseUW_C
- //0: 不使用
- //1: 双油门
- //2: 带怠速开关
-
- if(1==AccPedCD_swtUseUW_C)
- {
- //双油门
- if(AccPedCD_uUW>AccPedCD_uSRCMaxUW_C)
- {
- /*对应DFC故障:油门踏板1信号过高*/
- DFC_ReportFaultLevel(_DFC_INDEX_ACCPED_SIGHIGH,_DDRC_MASK_ANA_FT_LV_ERROR); //Max Error
- }
- else
- {
- DFC_ReportFaultLevel(_DFC_INDEX_ACCPED_SIGHIGH,_DDRC_MASK_ANA_FT_LV_OK);
- }
-
- if(AccPedCD_uUW<AccPedCD_uSRCMinUW_C)
- {
- /*对应DFC故障:油门踏板1信号过低*/
- DFC_ReportFaultLevel(_DFC_INDEX_ACCPED_SIGLOW,_DDRC_MASK_ANA_FT_LV_ERROR); //Min Error
- }
- else
- {
- DFC_ReportFaultLevel(_DFC_INDEX_ACCPED_SIGLOW,_DDRC_MASK_ANA_FT_LV_OK);
- }
-
-
- if(AccPedCD_facDualRelUW_C*AccPedCD_u2UW>AccPedCD_uSRCMaxUW_C)
- {
- /*对应DFC故障:油门踏板2信号过高*/
- DFC_ReportFaultLevel(_DFC_INDEX_ACCPED2_SIGHIGH,_DDRC_MASK_ANA_FT_LV_ERROR); //Max Error
- }
- else
- {
- DFC_ReportFaultLevel(_DFC_INDEX_ACCPED2_SIGHIGH,_DDRC_MASK_ANA_FT_LV_OK);
- }
-
- if(AccPedCD_facDualRelUW_C*AccPedCD_u2UW<AccPedCD_uSRCMinUW_C)
- {
- /*对应DFC故障:油门踏板2信号过低*/
- DFC_ReportFaultLevel(_DFC_INDEX_ACCPED2_SIGLOW,_DDRC_MASK_ANA_FT_LV_ERROR); //Min Error
- }
- else
- {
- DFC_ReportFaultLevel(_DFC_INDEX_ACCPED2_SIGLOW,_DDRC_MASK_ANA_FT_LV_OK);
- }
-
- //双油门合理性校验
- /*油门相关功能是否被禁用*/
- if(DINH_GetFIDState(_DINH_INDEX_FID_ACCPED_NPL)==0)
- {
- //检查合理性
- if(AccPedCD_uUW>=AccPedCD_facDualRelUW_C*AccPedCD_u2UW)
- {
- uDiffUW=AccPedCD_uUW-AccPedCD_facDualRelUW_C*AccPedCD_u2UW;
- }
- else
- {
- uDiffUW=AccPedCD_facDualRelUW_C*AccPedCD_u2UW-AccPedCD_uUW;
- }
- /*对应DFC故障:油门信号不合理*/
- if(uDiffUW>AccPedCD_uMaxDiffUW_C)
- {
- DFC_ReportFaultLevel(_DFC_INDEX_ACCPED_SIGHNPL,_DDRC_MASK_ANA_FT_LV_ERROR); //NPL Error
- }
- else
- {
- DFC_ReportFaultLevel(_DFC_INDEX_ACCPED_SIGHNPL,_DDRC_MASK_ANA_FT_LV_OK);
- }
- }
-
- }
- else
- {
- if(2==AccPedCD_swtUseUW_C)
- {
- //带怠速开关的油门
-
- if(AccPedCD_uUW>AccPedCD_uSRCMaxUW_C)
- {
- DFC_ReportFaultLevel(_DFC_INDEX_ACCPED_SIGHIGH,_DDRC_MASK_ANA_FT_LV_ERROR); //Max Error
- }
- else
- {
- DFC_ReportFaultLevel(_DFC_INDEX_ACCPED_SIGHIGH,_DDRC_MASK_ANA_FT_LV_OK);
- }
-
- if(AccPedCD_uUW<AccPedCD_uSRCMinUW_C)
- {
- DFC_ReportFaultLevel(_DFC_INDEX_ACCPED_SIGLOW,_DDRC_MASK_ANA_FT_LV_ERROR); //Min Error
- }
- else
- {
- DFC_ReportFaultLevel(_DFC_INDEX_ACCPED_SIGLOW,_DDRC_MASK_ANA_FT_LV_OK);
- }
-
- //怠速开关和油门的诊断
- if(1==AccPedCD_bPlausEnUW_C)
- {
- //如果合理性检测使能
-
- if(((0==AccPedCD_bIdleSwtUB)&&(AccPedCD_uUW>AccPedCD_uHighLimIdleUW_C))||
- ((1==AccPedCD_bIdleSwtUB)&&(AccPedCD_uUW<AccPedCD_uLowLimIdleUW_C)))
- {
- //油门电压大于高限值后,怠速开关必须处于Full Load状态
- //油门电压小于低限制后,怠速开关必须处于Low Idle状态
- DFC_ReportFaultLevel(_DFC_INDEX_ACCPED_SIGHNPL,_DDRC_MASK_ANA_FT_LV_ERROR); //NPL Error
- }
- else
- {
- DFC_ReportFaultLevel(_DFC_INDEX_ACCPED_SIGHNPL,_DDRC_MASK_ANA_FT_LV_OK);
- }
- }
-
- }
- else
- {
- if(3==AccPedCD_swtUseUW_C)
- {
- //单油门
-
- if(AccPedCD_uUW>AccPedCD_uSRCMaxUW_C)
- {
- DFC_ReportFaultLevel(_DFC_INDEX_ACCPED_SIGHIGH,_DDRC_MASK_ANA_FT_LV_ERROR); //Max Error
- }
- else
- {
- DFC_ReportFaultLevel(_DFC_INDEX_ACCPED_SIGHIGH,_DDRC_MASK_ANA_FT_LV_OK);
- }
-
- if(AccPedCD_uUW<AccPedCD_uSRCMinUW_C)
- {
- DFC_ReportFaultLevel(_DFC_INDEX_ACCPED_SIGLOW,_DDRC_MASK_ANA_FT_LV_ERROR); //Min Error
- }
- else
- {
- DFC_ReportFaultLevel(_DFC_INDEX_ACCPED_SIGLOW,_DDRC_MASK_ANA_FT_LV_OK);
- }
- }
- }
- }
- }
- #endif //_SAMPLE_CODE_
- /*********************************************************************************************/
|