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_f32HysteresisComp_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 NameResolution

Legal Range

(min)

Legal Range

(max)

Software Segment
* AssistCmdLPFiltSV_HwNm_M_strMultipleMultipleMultipleHYSTCOMP_START_SEC_VAR_CLEARED_UNSPECIFIED
  • K_Uls_f32

Single Precision Float0.01248774350.4665119090
  • SV_HwNm_f32

Single Precision Float-440440
* HwTrqLPFiltSV_HwNm_M_strMultipleMultipleMultipleHYSTCOMP_START_SEC_VAR_CLEARED_UNSPECIFIED
  • K_Uls_f32

Single Precision Float0.01248774350.4665119090
  • SV_HwNm_f32

Single Precision Float-1010
* RawHystCompLPFiltSV_HwNm_M_strMultipleMultipleMultipleHYSTCOMP_START_SEC_VAR_CLEARED_UNSPECIFIED
  • K_Uls_f32

Single Precision Float0.01248774350.4665119090
  • SV_HwNm_f32

Single Precision Float-1515
HwTrqLastUsed_HwNm_M_f32Single Precision Float-10.010.0HYSTCOMP_START_SEC_VAR_CLEARED_32
Fraction_Uls_M_f32Single Precision Float-1.01.0HYSTCOMP_START_SEC_VAR_CLEARED_32
RawCalc_HwNm_M_f32Single Precision Float-15.015.0HYSTCOMP_START_SEC_VAR_CLEARED_32
RiseX_HwNm_M_f32Single Precision Float-1.01.0HYSTCOMP_START_SEC_VAR_CLEARED_16
AstCmdLastUsed_HwNm_ M_s8p72-7-255.0255.0HYSTCOMP_START_SEC_VAR_CLEARED_16
CompAvail_HwNm_D_f32Single Precision Float-1515.0HYSTCOMP_START_SEC_VAR_CLEARED_32
HwTrqFilt_HwNm_D_f32Single Precision Float-15.015.0HYSTCOMP_START_SEC_VAR_CLEARED_32
CoulFric_HwNm_D_f32Single Precision Float-15.015.0HYSTCOMP_START_SEC_VAR_CLEARED_32
PosAvail_HwNm_D_f32Single Precision Float-15.015.0HYSTCOMP_START_SEC_VAR_CLEARED_32
NegAvail_HwNm_D_f32Single Precision Float-15.015.0HYSTCOMP_START_SEC_VAR_CLEARED_32
EffCompTrq_HwNm_D_f32Single Precision Float-15.015.0HYSTCOMP_START_SEC_VAR_CLEARED_32
AssistCmdFilt_HwNm_D_s8p72-7-15.015.0HYSTCOMP_START_SEC_VAR_CLEARED_16

User defined typedef definition/declaration

This section documents any user types uniquely used for the module.

Typedef NameElement NameUser 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 NameResolutionValue
D_HYSPOSLMT_ULS_F32Single Precision Floating Point1.0
D_WIROFF_IDX_U1610
D_WIRON_IDX_U1611
D_WIRCMDBLNDFRC_ULS_F32Single Precision Floating Point1
D_HYSSATLOWLMT_HWNM_F32Single Precision Floating Point0
D_HYSOUTLMT_MTRNM_F32Single Precision Floating Point8.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 NameResolutionValueSoftware 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,

  1. FPM_FloatToFixed_m()

  2. FPM_FixedToFloat_m()

  3. LPF_OpUpdate_f32_m ()

  4. IntplVarXY_u16_u16Xu16Y_Cnt()

  5. IntplVarXY_u16_s16Xu16Y_Cnt()

  6. TableSize_m()

  7. Abs_s16_m()

  8. Abs_f32_m()

  9. Sign_s16_m()

  10. Sign_f32_m()

  11. Limit_m()

  12. BilinearXMYM_u16_u16XMu16YM_Cnt

Data Hiding Functions

The data hiding functions / macros used in this module are identified below,

  1. 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,

  1. MoreCompensation()

  2. LessCompensation()

  3. 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 NameMoreCompensationTypeMinMaxUTP Tolerance
Arguments PassedTrqChange_HwNm_T_f32float32-20.020.0N/A
RiseXPtr_HwNm_T_f32float32*-1.01.07.81E-03
Return ValueRiseY_Uls_T_s1p14s1p14_T-1.01.07.81E-03

Description

LessCompensation Calculation

Function NameLessCompensationTypeMinMaxUTP Tolerance
Arguments PassedTrqChange_HwNm_T_f32Float32-20.020.0N/A
PrevRiseY_Uls_T_f32Float32-1.01.0N/A
RiseXPtr_HwNm_T_f32float32*-1.01.07.81E-03
Return ValueRiseY_Uls_T_f32Float32-300.0300.07.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 NameCalcAvailCompTypeMinMaxUTP Tolerance
Arguments PassedHwTrqFilt_HwNm_T_f32Float32-10.010.0N/A
AssistCmdFilt_HwNm_T_s8p7s8p7_T-255.0255.0N/A
VehSpd_Kph_T_u9p7u9p7_T0.0511.0N/A
Return ValueCompAvail_HwNm_T_f32Float32-15.015.07.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 NameTask ListCalling FrequencySystem State(s) in which the function is called
HystComp_Per1()2msALL

Execution Requirements for Serial Communication Functions

Function NameSub-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 ModuleSoftware 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 ModuleSoftware Segment
MoreCompensation()AP_HYSTCOMP_CODE
LowCompensation()AP_HYSTCOMP_CODE
CalcAvailComp()AP_HYSTCOMP_CODE


Known Issues / Limitations With Design

  1. INLINE Functions defined in globalmacro.h are not unittested

Revision Control Log

Item #Rev #Change DescriptionDateAuthor Initials
11.0Initial AutoSAR version.16Feb11L.N.
22.0Added negative hysteresis and ConstFric Blending interface14Jul11LWW
33.0Added ball screw temperature compensation16Nov11M. Story
44.0Update section9 for INLINE functions6Dec11N.Reddy
55.0Removed Per1 no longer used9Dec11M. Story
66Corrections per SWC interface requirements12Dec11JJW
77Corrected initialization of HwNmPerMtrNm_Uls_T_f3213Jan12M. Story
88Anomaly Fixes and removed unused Module level variable PrevRiseX_Uls_M_s8p76March12NRAR
99Changes done as per FaultInjectionTechnique1-May-12NRAR
1010Changed component over to floating point25May12JWJ
1111Added design rationale to CalcAvailComp to document unit test limit path failure20JUN12JWJ
1212Updated to new Average Friction Learninput requirements13JUL12JWJ
1313
  1. Removed SlewRate limit in 6.2.1.7 section

  2. Replaced Limit with Max and removed D_FPSATHILMT_ULS_F32 in sec 6.7.3.2

23JUL12NRAR
1414Added checkpoints and memmap software segment is updated for static variables25-Sep-12Selva
1515Replaced 1-D AsstMagBlndTbl with 2D HwTrqBlnd Table.Six more Display variables added04-Nov-12Selva
1616Changed precision of t_HysRiseTblY & t_HysRiseTblX per Anom 6855.12-Nov-12BWL
1717Anomaly 4110 correction28-Nov-12KJS
1817.1.1Anom 4937 correction1-may-13NRAR
1918Update to FDD ver 0072-May-13Jared
Last modified October 12, 2025: Initial commit (0347a62)