DigPhsReasDiag_MDD

Module --

High-Level Description

This module compares the commanded duty cycle to each phase with the feedback from the NHET module. The values are compared, compensated with a previously defined fixed value, filtered, and compared against a valid threshold.

Figures

Component Diagram

Diagram – Function Data Sharing

No Shared Data.


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.

Module InputsModule Outputs
ExpectedOnTimeA_Cnt_u32
ExpectedOnTimeB_Cnt_u32
ExpectedOnTimeC_Cnt_u32
MeasuredOnTimeA_Cnt_u32
MeasuredOnTimeB_Cnt_u32
MeasuredOnTimeC_Cnt_u32
LRPRCorrectedMtrPosCaptured_rev_u0p16
LRPRPhaseadvanceCaptured_Cnt_s16
LRPRModulationIndexCaptured_Uls_f32
MotorVelMRFUnfiltered_MtrRadpS_f32
ElecMechPolarity_Cnt_s08
PDActivateTest_Cnt_lgc

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
SVDiag_FilterSV_Cnt_M_s18p13[3]2-13-210000210000DIGPHSREASDIAG_START_SEC_VAR_CLEARED_32
SVDiag_PrevLRPRHighSector_Cnt_M_lgcN/AFALSETRUEDIGPHSREASDIAG_START_SEC_VAR_CLEARED_BOOLEAN
SVDiag_LRPRHighSector_Cnt_M_lgcN/AFALSETRUEDIGPHSREASDIAG_START_SEC_VAR_CLEARED_BOOLEAN
SVDiag_PrevLRPRLowSector_Cnt_M_lgcN/AFALSETRUEDIGPHSREASDIAG_START_SEC_VAR_CLEARED_BOOLEAN
SVDiag_LRPRLowSector_Cnt_M_lgcN/AFALSETRUEDIGPHSREASDIAG_START_SEC_VAR_CLEARED_BOOLEAN
SVDiag_LRPRAdjModldAComp_Cnt_M_f32Single precision float01DIGPHSREASDIAG_START_SEC_VAR_CLEARED_FLOAT32
SVDiag_PrevLRPRAdjModldComp_Cnt_M_f32Single precision float01DIGPHSREASDIAG_START_SEC_VAR_CLEARED_32
SVDiag_PrevLRPRPhsAdvComp_Cnt_M_u16106144DIGPHSREASDIAG_START_SEC_VAR_CLEARED_16
SVDiag_LRPRPhsAdvComp_Cnt_M_u16106144DIGPHSREASDIAG_START_SEC_VAR_CLEARED_16
SVDiag_PhaseOffset_Rev_M_u0p162-1601DIGPHSREASDIAG_START_SEC_VAR_CLEARED_16
SVDiag_LowPhReasErrorAcc_Cnt_M_u16101000DIGPHSREASDIAG_START_SEC_VAR_CLEARED_16
SVDiag_HighResPhsReasDisable_M_u810100DIGPHSREASDIAG_START_SEC_VAR_CLEARED_8
SVDiag_LowResPhsReasDisable_M_u810100DIGPHSREASDIAG_START_SEC_VAR_CLEARED_8
SVDiag_MaxNrCommOffVltg_Cnt_M_f32Single precision float086400DIGPHSREASDIAG_START_SEC_VAR_CLEARED_FLOAT32
SVDiag_LRPRHighLimit_Cnt_D_f32[3]Single precision float0160000DIGPHSREASDIAG_START_SEC_VAR_CLEARED_FLOAT32
SVDiag_LRPRLowLimit_Cnt_D_f32[3]Single precision float0160000DIGPHSREASDIAG_START_SEC_VAR_CLEARED_FLOAT32

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)

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_PhsReasErrorTerm_Cnt_s16
k_ErrorFiltKn_Cnt_u16
k_ErrorThresh_Cnt_u32
k_PhsReasEnableThresh_Cnt_u32
k_LRPRMtrVelDiagEnable_MtrRadpS_T_f32
k_LowResPhsReas_Cnt_str
k_LowResPhsReasMinTol_Uls_f32
k_LowResPhsReasMaxTol_Uls_f32
t_CommOffsetTblY_Cnt_u16
k_LRPRCommOffsetMargin_Uls_f32

The time constant for the filter is analyzed in the following filter analysis workbook:

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 NameResolutionUnitsValue
D_ERRORLIMIT_CNT_S328Counts262136
D_PHASEA_CNT_U161Counts0
D_PHASEB_CNT_U161Counts1
D_PHASEC_CNT_U161Counts2
D_RESETDIGDIAGACTIVE_CNT_U081Counts0x00U
D_LRPHSREASLOOPRATE_CNT_F321Counts0.002F
D_ERRORLIMIT_CNT_S321Counts262136L/*2^18-8==262136*/
D_PHASEA_CNT_U161Counts0U
D_PHASEB_CNT_U161Counts1U
D_PHASEC_CNT_U161Counts2U
D_NHETFREQUENCY_HZ_F32Single precision floatCounts80000000.0F
D_NHETCTSPERLRPRLOOP_CNT_F32Single precision floatCounts(D_NHETFREQUENCY_HZ_F32*D_LRPHSREASLOOPRATE_CNT_F32)
D_MAXPWMFREQ_HZ_U32Single precision floatCounts18000
D_MAXNRCOMMOFFVLTG_CNT_F32Single precision floatCounts(D_LRPHSREASLOOPRATE_CNT_F32*D_MAXPWMFREQ_CNT_F32*t_CommOffsetTblY_Cnt_u16[0])
D_PHSADVCNTSPERREV_CNT_U161Counts6144U
D_PHSADVCNTS180DEG_CNT_U161Counts3072U/*(D_PHSADVCNTSPERREV_CNT_S16/2U)*/
D_PHSPOSADVCNTS90DEG_CNT_U161Counts1536U/*(D_PHSADVCNTSPERREV_CNT_S16/4U)*/
D_PHSNEGADVCNTS90DEG_CNT_S161Counts-1536/*(-D_PHSADVCNTSPERREV_CNT_S16/4U)*/
D_0DEG_REV_U0P161rev(FPM_InitFixedPoint_m(0.0,u0p16_T))
D_30DEG_REV_U0P161rev(FPM_InitFixedPoint_m(0.0833333333,u0p16_T))
D_60DEG_REV_U0P161rev(FPM_InitFixedPoint_m(0.1666666666,u0p16_T))
D_240DEG_REV_U0P161rev(FPM_InitFixedPoint_m(0.6666666666,u0p16_T))
D_120DEG_REV_U0P161rev(FPM_InitFixedPoint_m(0.3333333333,u0p16_T))
D_180DEG_REV_U0P161rev(FPM_InitFixedPoint_m(0.5,u0p16_T))
D_PHASEAOFFSETNRM_REV_U0P162-16revD_0DEG_REV_U0P16
D_PHASEBOFFSETNRM_REV_U0P162-16rev((uint16)(D_PHASEAOFFSETNRM_REV_U0P16-D_120DEG_REV_U0P16))
D_PHASECOFFSETNRM_REV_U0P162-16rev(D_PHASEAOFFSETNRM_REV_U0P16+D_120DEG_REV_U0P16)
D_PHASEAOFFSETINV_REV_U0P162-16revD_60DEG_REV_U0P16
D_PHASEBOFFSETINV_REV_U0P162-16rev(D_PHASEAOFFSETINV_REV_U0P16+D_120DEG_REV_U0P16)
D_PHASECOFFSETINV_REV_U0P162-16rev((uint16)(D_PHASEAOFFSETINV_REV_U0P16-D_120DEG_REV_U0P16))
D_REVPCNT_ULS_U0P321Uls699051UL/*(FPM_InitFixedPoint_m(1/D_PACNTSPREV_ULS_U16P0,u0p32_T))*/
D_PACNTSPREV_ULS_U16P01Uls6144U
D_SCALER16_CNT_U161cnt16U
D_35DEG_REV_U0P161rev(FPM_InitFixedPoint_m(0.0972222222,u0p16_T))
D_205DEG_REV_U0P161rev(FPM_InitFixedPoint_m(0.5972222222,u0p16_T))
D_245DEG_REV_U0P161rev(FPM_InitFixedPoint_m(0.6805555555,u0p16_T))
D_355DEG_REV_U0P161rev(FPM_InitFixedPoint_m(0.9861111111,u0p16_T))
D_POSITIVEONE_CNT_S81cnt1

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
<None>

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 and functions / Macros that are called by the various sub modules are identified below,

  1. Limit_m

  2. FPM_Fix_m

  3. LPF_SvUpdate_s16InFixKTrunc_m

  4. LPF_OpUpdate_s16InFixKTrunc_m

  5. Max_m

  6. Min_M

  7. Abs_s16_m

  8. Abs_f16_m

Data Hiding Functions

  1. <None>

Global Functions/Macros Defined by this Module

None

Local Functions/Macros Used by this MDD only

Local Function #1

Function NamePhaseGroundTabLookupoffsetTypeMinMaxUTP Tol.
Arguments PassedMtrElecMechPol_Cnt_s8Sint8-11
Return ValueNone

Description

Generates the phase offset
Local Function #2

Function NameRead_CountToRevTypeMinMaxUTP Tol.
Arguments PassedVar_Cnt_T_u16Unit1606144
Return ValueCountToRev_Rev_T_u16Unit1601

Description

Converts Var_Cnt_T_u16 to Unit16 with range of 0 to 1 and precision of 2-16. It coverts Electrical degree(Count) to Rev

Software Module Implementation

Runtime Environment (RTE) Initial Values

This section lists the initial values of data written by this module but controlled by the RTE. After RTE initialization, the data in this table will contain these values.

DataValue
Rte_InitValue_ExpectedOnTimeA_Cnt_u320
Rte_InitValue_ExpectedOnTimeB_Cnt_u320
Rte_InitValue_ExpectedOnTimeC_Cnt_u320
Rte_InitValue_MeasuredOnTimeA_Cnt_u320
Rte_InitValue_MeasuredOnTimeB_Cnt_u320
Rte_InitValue_MeasuredOnTimeC_Cnt_u320
Rte_InitValue_LRPRCorrectedMtrPosCaptured_Rev_f32
Rte_InitValue_LRPRModulationIndexCaptured_Uls_f320
Rte_InitValue_LRPRPhaseadvanceCaptured_Cnt_s160
Rte_InitValue_MotorVelMRFUnfiltered_MtrRadpS_f32
Rte_InitValue_MtrElecMechPolarity_Cnt_s080
Rte_ InitValue_ PDActivateTest_Cnt_lgc0

Initialization Functions

DigPhsReasDiag_Init


Periodic Functions

Per: DigPhsReasDiag_ Per1

Design Rationale

The ParamBits_Cnt_T_u08 variable used in this function, which is passed when calling NxtrDiagMgr_SetNTCStatus, is set according to the following table (derived from the DTC Outline Structure document):

Bit 0Phase A: measured less than expected
Bit 1Phase A: measured greater than expected
Bit 2Phase B: measured less than expected
Bit 3Phase B: measured greater than expected
Bit 4Phase C: measured less than expected
Bit 5Phase C: measured greater than expected
Bit6Systematic diagnostics LRPR Active

Program Flow Start

Rte_Call_DigPhsReasDiag_Per1_CP0_CheckpointReached()

Store Module Inputs to Local copies

MeasuredOnTime_Cnt_T_u32[D_PHASEA_CNT_U16] = Rte_IRead_DigPhsReasDiag_Per1_MeasuredOnTimeA_Cnt_u32();

MeasuredOnTime_Cnt_T_u32[D_PHASEB_CNT_U16] = Rte_Iread_DigPhsReasDiag_Per1_MeasuredOnTimeB_Cnt_u32();

MeasuredOnTime_Cnt_T_u32[D_PHASEC_CNT_U16] = Rte_Iread_DigPhsReasDiag_Per1_MeasuredOnTimeC_Cnt_u32();

ExpectedOnTime_Cnt_T_u32[D_PHASEA_CNT_U16] = Rte_Iread_DigPhsReasDiag_Per1_ExpectedOnTimeA_Cnt_u32();

ExpectedOnTime_Cnt_T_u32[D_PHASEB_CNT_U16] = Rte_Iread_DigPhsReasDiag_Per1_ExpectedOnTimeB_Cnt_u32();

ExpectedOnTime_Cnt_T_u32[D_PHASEC_CNT_U16] = Rte_Iread_DigPhsReasDiag_Per1_ExpectedOnTimeC_Cnt_u32();

LRPRMtrPosCaptured_Rev_T_f32=Rte_IRead_DigPhsReasDiag_Per1_LRPRCorrectedMtrPosCaptured_Rev_f32();

LRPRPhaseadvanceCaptured_Cnt_T_s16 =Rte_IRead_DigPhsReasDiag_Per1_LRPRPhaseadvanceCaptured_Cnt_s16();

LRPRModIdx_Uls_T_f32 = Rte_IRead_DigPhsReasDiag_Per1_LRPRModulationIndexCaptured_Uls_f32();

MotorVelMRFUnfilt_MtrRadpS_T_f32 = Rte_IRead_DigPhsReasDiag_Per1_MotorVelMRFUnfiltered_MtrRadpS_f32();

MtrElecMechPolarity_Cnt_T_s08=Rte_IRead_DigPhsReasDiag_Per1_ElecMechPolarity_Cnt_s08();

PDActivateTest_Cnt_T_lgc = Rte_IRead_DigPhsReasDiag_Per1_PDActivateTest_Cnt_lgc();

Subfunction Execution

Store Local copy of outputs into Module Outputs

None

Program Flow End

Rte_Call_DigPhsReasDiag_Per1_CP1_CheckpointReached()

Per: DigPhsReasDiag_Trans1

Design Rationale

Reset the HighRes Phase Reasonableness and LowRes Phase Reasonableness delay counter to 0 upon entering in Operate mode

Program Flow Start

Fault Recovery Functions

None

Shutdown Functions

None

Interrupt Functions

None

Serial Communication Functions

None


Execution Requirements

Execution Sequence of the Module

Execution Rates for sub-modules called by the Scheduler

This table serves as reference for the Scheduler design

Function NameCalling FrequencySystem State(s) in which the function is called
DigPhsReasDiag_Per12 msOperate
DigPhsReasDiag_Trans1Upon TransitionUpon entering in Operate

Execution Requirements for Serial Communication Functions

Function NameSub-Module called by (Serial Comm Function Name)
<None>


Memory Map Definition Requirements

Sub Modules (Functions)

This table identifies the software segments for functions identified in this module.

Name of Sub ModuleSoftware Segment

Local Functions

This table identifies the software segments for local functions identified in this module.

Name of Sub ModuleSoftware Segment


Known Issues / Limitations With Design

  1. INLINE functions defined in globalmacro.h are not unit tested


Revision Control Log

Item #Rev #Change DescriptionDateAuthor Initials
11.0Initial Version25-Jan-12OT
22.0Changed Input Names to Match FDD27-Jan-12OT
33.0Updated Operation states to show only runs in Operate27Jan12SMW
44.0Updated to latest FDD changes (rev 002-G), consolidated common processing31-Jan-12OT
55Added checkpoints and memmap software segment is updated for static variables26-Sep-12Selva
66Updated for Changes for LRPR26 Oct 12Selva
77.0Updated to FDD V00715 Mar 13SP
88Anamoly 4968,4953 changes7-May-13Selva
99Anamoly 5000 changes13-May-13Selva
1010Fixing Ranges and Data type for unit test results16-May-13Selva
1111Added Cal “k_LRPRCommOffsetMargin_Uls_f32” for FDD v426-Jun-13Selva
1212Corrected anomaly 517430-Jul-13VT
1313Update range per unit test results12-Aug-13VT
1414Update module and display variables with SVDiag3-Oct-13VT
Last modified October 12, 2025: Initial commit (0347a62)