Hysteresis_Compensation_MDD
Module -- Hysteresis Compensation
High-Level Description
This module will calculate a motor torque command to add into the low pass assist torque that will compensate for the hysteresis present in the system.
Figures
Diagram – Function Data Sharing
This diagram shows all data that is shared between functions within the module.
Diagram – HystComp_Per1
This diagram describes the functional characteristics and data flow of a given function.
Variable Data Dictionary
For details on module input / output variable, refer to the Data Dictionary for the application. Input / output variable names are listed here for reference.
(Note: Full variable names required in table.)
(Note: All global variables including End Of Line data used should be shown here)
Module Inputs (Global Variable Name) | Module Outputs (Global Variable Name) |
HwTorque_HwNm_f32 | HysteresisComp_MtrNm_f32 |
BaseAssistCmd_MtrNm_f32 | |
DefeatHystService_Cnt_lgc | |
VehicleSpeed_Kph_f32 | |
WIRCmdAmpBlnd_MtrNm_f32 | |
AssistMechTempEst_DegC_f32 | |
FricOffset_HwNm_f32 |
Module Internal Variables
This section identifies the name, range and resolutions for module specific data created by this module. If there are no range restrictions on the variable, the term “FULL” is placed into the table for legal range.
Variable Name | Resolution | Legal Range (min) | Legal Range (max) | Software Segment |
* AssistCmdLPFiltSV_HwNm_M_str | Multiple | Multiple | Multiple | HYSTCOMP_START_SEC_VAR_CLEARED_UNSPECIFIED |
| Single Precision Float | 0.0124877435 | 0.4665119090 | |
| Single Precision Float | -440 | 440 | |
* HwTrqLPFiltSV_HwNm_M_str | Multiple | Multiple | Multiple | HYSTCOMP_START_SEC_VAR_CLEARED_UNSPECIFIED |
| Single Precision Float | 0.0124877435 | 0.4665119090 | |
| Single Precision Float | -10 | 10 | |
* RawHystCompLPFiltSV_HwNm_M_str | Multiple | Multiple | Multiple | HYSTCOMP_START_SEC_VAR_CLEARED_UNSPECIFIED |
| Single Precision Float | 0.0124877435 | 0.4665119090 | |
| Single Precision Float | -15 | 15 | |
HwTrqLastUsed_HwNm_M_f32 | Single Precision Float | -10.0 | 10.0 | HYSTCOMP_START_SEC_VAR_CLEARED_32 |
Fraction_Uls_M_f32 | Single Precision Float | -1.0 | 1.0 | HYSTCOMP_START_SEC_VAR_CLEARED_32 |
RawCalc_HwNm_M_f32 | Single Precision Float | -15.0 | 15.0 | HYSTCOMP_START_SEC_VAR_CLEARED_32 |
RiseX_HwNm_M_f32 | Single Precision Float | -1.0 | 1.0 | HYSTCOMP_START_SEC_VAR_CLEARED_16 |
AstCmdLastUsed_HwNm_ M_s8p7 | 2-7 | -255.0 | 255.0 | HYSTCOMP_START_SEC_VAR_CLEARED_16 |
CompAvail_HwNm_D_f32 | Single Precision Float | -15 | 15.0 | HYSTCOMP_START_SEC_VAR_CLEARED_32 |
HwTrqFilt_HwNm_D_f32 | Single Precision Float | -15.0 | 15.0 | HYSTCOMP_START_SEC_VAR_CLEARED_32 |
CoulFric_HwNm_D_f32 | Single Precision Float | -15.0 | 15.0 | HYSTCOMP_START_SEC_VAR_CLEARED_32 |
PosAvail_HwNm_D_f32 | Single Precision Float | -15.0 | 15.0 | HYSTCOMP_START_SEC_VAR_CLEARED_32 |
NegAvail_HwNm_D_f32 | Single Precision Float | -15.0 | 15.0 | HYSTCOMP_START_SEC_VAR_CLEARED_32 |
EffCompTrq_HwNm_D_f32 | Single Precision Float | -15.0 | 15.0 | HYSTCOMP_START_SEC_VAR_CLEARED_32 |
AssistCmdFilt_HwNm_D_s8p7 | 2-7 | -15.0 | 15.0 | HYSTCOMP_START_SEC_VAR_CLEARED_16 |
User defined typedef definition/declaration
This section documents any user types uniquely used for the module.
Typedef Name | Element Name | User Defined Type | Legal Range (min) | Legal Range (max) |
None |
Constant Data Dictionary
Calibration Constants
This section lists the calibrations used by the module. For details on calibration constants, refer to the Data Dictionary for the application.
Constant Name |
k_CmnSysTrqRatio_HwNmpMtrNm_f32 |
k_HysCmpLPAstLPFKn_Hz_f32 |
k_HysCmpHwTrqLPFKn_Hz_f32 |
k_HysFinalOutLPFKn_Hz_f32 |
k_LpFricIpLim_HwNm_u9p7 |
k_HysRevGain_InvHwNm_f32 |
k_HysOutLIm_HwNm_f32 |
t_HysRiseTblX_HwNm_u2p14 |
t_HysRiseTblY_Uls_u2p14 |
t_CmnVehSpd_Kph_u9p7 |
t_EffOffTblY_HwNm_u9p7 |
t_EffLossTblY_Uls_u4p12 |
t2_HysHwTrqBlndTblX_HwNm_u9p7 |
t2_HysHwTrqBlndTblY_Uls_u4p12 |
t_HysCompCoulFricY_HwNm_u9p7 |
t_HysCompCoulFricTempScaleX_DegC_s14p1 |
t_HysCompCoulFricTempScaleY_HwNm_u9p7 |
t_HysCompHysSatY_HwNm_u9p7 |
t_HysCompCoulFricWIRBlendX_MtrNm_u8p8 |
t_HysCompCoulFricWIRBlendY_Uls_u2p14 |
t_HysCompNegHysCompX_MtrNm_u8p8 |
t_HysCompNegHysCompY_HwNm_u9p7 |
t_HysCompNegHysBlendX_HwNm_u9p7 |
t_HysCompNegHysBlendY_Uls_u2p14 |
Program(fixed) Constants
Embedded Constants
All embedded constants whose values are provided in Eng units will be evaluated to the equivalent counts by using the FPM_InitFixedPoint_m() macro within the #define statement.
Local
Constant Name | Resolution | Value |
D_HYSPOSLMT_ULS_F32 | Single Precision Floating Point | 1.0 |
D_WIROFF_IDX_U16 | 1 | 0 |
D_WIRON_IDX_U16 | 1 | 1 |
D_WIRCMDBLNDFRC_ULS_F32 | Single Precision Floating Point | 1 |
D_HYSSATLOWLMT_HWNM_F32 | Single Precision Floating Point | 0 |
D_HYSOUTLMT_MTRNM_F32 | Single Precision Floating Point | 8.8 |
Global
This section lists the global constants used by the module. For details on global constants, refer to the Data Dictionary for the application.
Constant Name |
BC_HYSTCOMP_FAULTINJECTIONPOINT |
STD_ON |
FLTINJ_HYSTCOMP |
D_2MS_SEC_F32 |
Module specific Lookup Tables Constants
(This is for lookup tables (arrays) with fixed values, same name as other tables)
Constant Name | Resolution | Value | Software Segment |
None |
Functions/Macros used by the Sub-Modules
Library Functions / Macros
The library functions / Macros that are called by the various sub modules are identified below,
FPM_FloatToFixed_m()
FPM_FixedToFloat_m()
LPF_OpUpdate_f32_m ()
IntplVarXY_u16_u16Xu16Y_Cnt()
IntplVarXY_u16_s16Xu16Y_Cnt()
TableSize_m()
Abs_s16_m()
Abs_f32_m()
Sign_s16_m()
Sign_f32_m()
Limit_m()
BilinearXMYM_u16_u16XMu16YM_Cnt
Data Hiding Functions
The data hiding functions / macros used in this module are identified below,
None
Local Functions/Macros Used by this MDD only
(Note if they are defined in another source file, then reference the appropriate header file)
The local functions/macros in this module are identified below,
MoreCompensation()
LessCompensation()
CalcAvailComp()
Software Module Implementation
Initialization Functions
(Note: For multiple init functions, insert new headers at the “Header 2” level – subset of “5.1 Initialization Functions” and follow the same sub-section design shown below)
Init: HystComp_Init1()
Design Rationale
LPF_KUpdate_f32 is used to initialize the LPF filter instead of the full LPF_Init_f32 macro as an optimization since the required initial state of the filter is 0, which is the initialized value of the RAM, so there is no need to explicitly initialize the state variables in this init function.
Module Outputs
None
Module Internal
None
Initialize Low Pass Filters
Periodic Functions
Per: HystComp_Per1
Design Rationale
None
Program Flow Start
Rte_Call_HystComp_Per1_CP0_CheckpointReached()Store Module Inputs to Local copies
DefeatHystService_Cnt_lgc as Boolean
VehSpd_Kph_T_f32 of type float32
AssistCmd_MtrNm_T_f32 as float32
HwTrq_HwNm_T_f32 of type float32
AssistCmd_HwNm_T_f32 of type float32
AssistCmdFilt_HwNm_T_s8p7 of type s8p7_T
AssistCmdFilt_HwNm_T_f32 of type float32
HwTrqFilt_HwNm_T_f32 of type float32
RawHysComp_HwNm_St_f32 of type float32
HysComp_HwNm_T_f32 as float32
HysComp_MtrNm_T_f32 as float32
Fraction_Uls_T_f32 as float32
CompAvail_HwNm_T_f32 as float32
TrqChange_HwNm_T_f32 as type float32
PrevRiseY_Uls_T_f32 as float32
RawHysCompZm1_HwNm_T_f32 as float32
PrevRiseY_Uls_T_f32 = Fraction_Uls_M_f32
RawHysCompZm1_HwNm_T_f32 = RawCalc_HwNm_M_f32
DefeatHystService_Cnt_lgc = Rte_IRead_HystComp_Per1_DefeatHystService_Cnt_lgc();
VehSpd_Kph_T_u9p7 = FPM_FloatToFixed_m(Rte_Iread_HystComp_Per1_VehicleSpeed_Kph_f32(), u9p7_T)
AssistCmd_MtrNm_T_f32 = Rte_Iread_HystComp_Per1_ BaseAssistCmd_MtrNm_f32 ()
HwTrq_HwNm_T_f32 =Rte_Iread_HystComp_Per1_HwTorque_HwNm_f32() Convert Low Pass Assist Command to HwNm
Apply Filtering to Torque Inputs
Freeze Input Values if LP Assist Exceeds Threshold
Calculate Hysteresis Loop Position Based on Quadrant
Calculate Hysteresis and Limit Rate of Change
Store Local copy of outputs into Module Outputs
Rte_Iwrite_HystComp_Per1_HysteresisComp_MtrNm_f32(HysComp_MtrNm_T_f32)
AstCmdLastUsed_HwNm_M_s8p7 = AssistCmdFilt_HwNm_T_s8p7;
HwTrqLastUsed_HwNm_M_f32 = HwTrqFilt_HwNm_T_f32;
Fraction_Uls_M_f32 = Fraction_Uls_T_f32;/*HysComp_Fraction*/
RawCalc_HwNm_M_f32 = RawHysComp_HwNm_T_f32;/*HysComp_RawCalc*/
CompAvail_HwNm_D_f32 = CompAvail_HwNm_T_f32 ;/*HysComp_Avail*/
Program Flow End
Rte_Call_HystComp_Per1_CP1_CheckpointReached()
Fault Recovery Functions
None
Shutdown Functions
None
Interrupt Functions
None
Serial Communication Functions
None
Local Function/Macro Definitions
If these are numerous and defined in a separate source file then reference the source file only.
MoreCompensation Calculation
Function Name | MoreCompensation | Type | Min | Max | UTP Tolerance |
Arguments Passed | TrqChange_HwNm_T_f32 | float32 | -20.0 | 20.0 | N/A |
RiseXPtr_HwNm_T_f32 | float32* | -1.0 | 1.0 | 7.81E-03 | |
Return Value | RiseY_Uls_T_s1p14 | s1p14_T | -1.0 | 1.0 | 7.81E-03 |
Description
LessCompensation Calculation
Function Name | LessCompensation | Type | Min | Max | UTP Tolerance |
Arguments Passed | TrqChange_HwNm_T_f32 | Float32 | -20.0 | 20.0 | N/A |
PrevRiseY_Uls_T_f32 | Float32 | -1.0 | 1.0 | N/A | |
RiseXPtr_HwNm_T_f32 | float32* | -1.0 | 1.0 | 7.81E-03 | |
Return Value | RiseY_Uls_T_f32 | Float32 | -300.0 | 300.0 | 7.81E-03 |
Design Rationale
Two saturation blocks from the partial reversal block were omitted from the design as they were redundant. The limiting of the RiseY happens after the merge block and is redundant and the RiseX is implicitly limited by the interpolation lookup.
Description
Calculate Available Compensation
Function Name | CalcAvailComp | Type | Min | Max | UTP Tolerance |
Arguments Passed | HwTrqFilt_HwNm_T_f32 | Float32 | -10.0 | 10.0 | N/A |
AssistCmdFilt_HwNm_T_s8p7 | s8p7_T | -255.0 | 255.0 | N/A | |
VehSpd_Kph_T_u9p7 | u9p7_T | 0.0 | 511.0 | N/A | |
Return Value | CompAvail_HwNm_T_f32 | Float32 | -15.0 | 15.0 | 7.81E-03 |
Design Rationale
The limit function that bounds HysTrq_HwNm_T_f32 between ZERO and FPSATHILMT was used to match the design in the FDD, however, the HIGH bound of the limit is unreachable as the maximum possible value for the input does not cause a limiting condition. An alternate design choice would have been to use a max() function between HysTrq_HwNm_T_f32 and ZERO as the only limiting factor is the LOWER bound.
Description
Localvariables:
EffOff_HwNm_T_f32
EffLoss_Uls_T_f32
HysTrq_HwNm_T_f32
HysBlend_Uls_T_f32
WIROffFric_HwNm_T_f32
WIROnFric_HwNm_T_f32
WIROffFric_HwNm_T_f32
CoulFricHysBlend_T_f32
HysNegBlend_Uls_T_f32
WIRFric_HwNm_T_f32
TempScale_HwNm_T_f32
CoulFric_HwNm_T_f32
HwTrqFilt_HwNm_T_s7p8
HysSat_HwNm_T_f32
HysNegBlndCmp_T_f32
WIRCmdAmpBlnd_MtrNm_u8p8
WIRCmdBlnd_Uls_T_f32
HysNegComp_Uls_T_f32
WIRFric_HwNm_T_f32
AssistMechTempEst_DegC_T_s14p1
AbsCombinedTrq_HwNm_T_f32
CompAvail_HwNm_T_f32
Execution Requirements
Execution Sequence of the Module
(Describe in words relevant details about the execution sequence of the different sub modules.)
Execution Rates for sub-modules called by the Scheduler
This table serves as reference for the Scheduler design
Function Name | Task List | Calling Frequency | System State(s) in which the function is called |
HystComp_Per1() | 2ms | ALL |
Execution Requirements for Serial Communication Functions
Function Name | Sub-Module called by (Serial Comm Function Name) |
N/A |
Memory Map Definition Requirements
Sub Modules (Functions)
This table identifies the software segments for functions identified in this module.
Name of Sub Module | Software Segment |
HystComp_Init1() | RTE_AP_HYSTCOMP_APPL_CODE |
HystComp_Per1() | RTE_AP_HYSTCOMP_APPL_CODE |
Local Functions
This table identifies the software segments for local functions identified in this module.
Name of Sub Module | Software Segment |
MoreCompensation() | AP_HYSTCOMP_CODE |
LowCompensation() | AP_HYSTCOMP_CODE |
CalcAvailComp() | AP_HYSTCOMP_CODE |
Known Issues / Limitations With Design
INLINE Functions defined in globalmacro.h are not unittested
Revision Control Log
Item # | Rev # | Change Description | Date | Author Initials |
1 | 1.0 | Initial AutoSAR version. | 16Feb11 | L.N. |
2 | 2.0 | Added negative hysteresis and ConstFric Blending interface | 14Jul11 | LWW |
3 | 3.0 | Added ball screw temperature compensation | 16Nov11 | M. Story |
4 | 4.0 | Update section9 for INLINE functions | 6Dec11 | N.Reddy |
5 | 5.0 | Removed Per1 no longer used | 9Dec11 | M. Story |
6 | 6 | Corrections per SWC interface requirements | 12Dec11 | JJW |
7 | 7 | Corrected initialization of HwNmPerMtrNm_Uls_T_f32 | 13Jan12 | M. Story |
8 | 8 | Anomaly Fixes and removed unused Module level variable PrevRiseX_Uls_M_s8p7 | 6March12 | NRAR |
9 | 9 | Changes done as per FaultInjectionTechnique | 1-May-12 | NRAR |
10 | 10 | Changed component over to floating point | 25May12 | JWJ |
11 | 11 | Added design rationale to CalcAvailComp to document unit test limit path failure | 20JUN12 | JWJ |
12 | 12 | Updated to new Average Friction Learninput requirements | 13JUL12 | JWJ |
13 | 13 |
| 23JUL12 | NRAR |
14 | 14 | Added checkpoints and memmap software segment is updated for static variables | 25-Sep-12 | Selva |
15 | 15 | Replaced 1-D AsstMagBlndTbl with 2D HwTrqBlnd Table.Six more Display variables added | 04-Nov-12 | Selva |
16 | 16 | Changed precision of t_HysRiseTblY & t_HysRiseTblX per Anom 6855. | 12-Nov-12 | BWL |
17 | 17 | Anomaly 4110 correction | 28-Nov-12 | KJS |
18 | 17.1.1 | Anom 4937 correction | 1-may-13 | NRAR |
19 | 18 | Update to FDD ver 007 | 2-May-13 | Jared |