TrqCanc_MDD

Module -- TrqCanc

High-Level Description

Figures

Component Diagram

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
EstKe_VpRadpS_f32
MRFMtrVel_MtrRadpS_f32
MtrCurrDaxRef_Amp_f32
MtrCurrQaxRef_Amp_f32
ElecPosDelayComp_Rad_f32MtrCurrQaxRpl_Amp_T_f32
MtrElecPol_Cnt_s8MtrCurrQaxCog_Amp_f32
MtrPosElec_Rev_u0p16
EstKe_VpRadpS_f32
MtrCurrQax12Mag_Amp_f32
MtrCurrQax6Mag_Amp_f32
MtrCurrQax12Ph_Rad_f32
MtrCurrQax6Ph_Rad_f32
MtrCurrQax18Ph_Rad_f32
MtrCurrQax18Mag_Amp_f32
ActWriteAccBufIndex_Cnt_T_u16
ReadBuffer_Cnt_M_u16

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
CogginTrqCancIndex_D_Cnt_u1610511TRQCANC_VAR_CLEARED_16
CoggingTrqCanc_MtrNm_D_f32Single precision float-11TRQCANC_VAR_CLEARED_32
MtrCurrQax6thMag_Amp_D_f32Single precision float-220220TRQCANC_VAR_CLEARED_32
MtrTrqRip6thPhs_Rad_D_f32Single precision float-2*pi2*piTRQCANC_VAR_CLEARED_32
MtrCurrQax18thMag_Amp_D_f32Single precision float-220220TRQCANC_VAR_CLEARED_32
MtrTrqRip18thPhs_Rad_D_f32Single precision float-2*pi2*piTRQCANC_VAR_CLEARED_32
MtrCurrQax12thMag_Amp_D_f32Single precision float-220220TRQCANC_VAR_CLEARED_32
MtrTrqRip12thPhs_Rad_D_f32Single precision float-2*pi2*piTRQCANC_VAR_CLEARED_32
MtrCurrQax6thMagFinal_Amp_D_f32Single precision float-220220TRQCANC_VAR_CLEARED_32
MtrTrqRip6thPhsFinal_Rev_D_f32Single precision float01TRQCANC_VAR_CLEARED_32
MtrCurrQax18thMagFinal_Amp_D_f32Single precision float-220220TRQCANC_VAR_CLEARED_32
MtrTrqRip18thPhsFinal_Rev_D_f32Single precision float01TRQCANC_VAR_CLEARED_32
MtrCurrQax12thMagFinal_Amp_D_f32Single precision float-220220TRQCANC_VAR_CLEARED_32
MtrTrqRip12thPhsFinal_Rad_D_f32Single precision float-2*pi2*piTRQCANC_VAR_CLEARED_32
CoggingTrqMtrPosElec_Rad_D_f32Single precision float-2*pi2*piTRQCANC_VAR_CLEARED_32
MtrCurrQax12Mag_Amp_M_ f32Single precision float-220220TRQCANC_VAR_CLEARED_32
MtrCurrQax12Ph_Rad _M_ f32Single precision float-2*pi2*piTRQCANC_VAR_CLEARED_32
MtrCurrQax6Mag_Amp_ M_ f32Single precision float-220220TRQCANC_VAR_CLEARED_32
MtrCurrQax6Ph_Rad_ M_ f32Single precision float-2*pi2*piTRQCANC_VAR_CLEARED_32
MtrCurrQax18Mag_Amp_ M_ f32Single precision float-220220TRQCANC_VAR_CLEARED_32
MtrCurrQax18Ph_Rad_ M_ f32Single precision float-2*pi2*piTRQCANC_VAR_CLEARED_32
TrqCanc_MtrCurrQaxRpl6X_Amp_M_s6p9[][]2^-9FULLFULLTRQCANC_VAR_CLEARED_16
TrqCanc_MtrCurrQaxRpl6Y_Amp_M_s6p9[][]2^-9FULLFULLTRQCANC_VAR_CLEARED_16
TrqCanc_MtrCurrQaxRpl12X_Amp_M_s6p9[][]2^-9FULLFULLTRQCANC_VAR_CLEARED_16
TrqCanc_MtrCurrQaxRpl12Y_Amp_M_s6p9[][]2^-9FULLFULLTRQCANC_VAR_CLEARED_16
TrqCanc_MtrCurrQaxRpl18X_Amp_M_s6p9[][]2^-9FULLFULLTRQCANC_VAR_CLEARED_16
TrqCanc_MtrCurrQaxRpl18Y_Amp_M_s6p9[][]2^-9FULLFULLTRQCANC_VAR_CLEARED_16
TrqCanc_CorrecNomKe_VpRadpS_M_f32Single precision float.0250.075TRQCANC_VAR_CLEARED_32

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)

CoggingM_Amp_StrCoggingMX_Amp_s6p9sint16FULLFULL
CoggingMY_Amp_s6p9sint16FULLFULL
CogTrqCalPtr Rte_Pim_CogTrqCal()[512]Uint16-11
CogTrqCalRplCompPtrRte_Pim_CogTrqRplComp()[9]Uint16-11

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_Harmonic6thElec_Uls_f32
k_Harmonic12thElec_Uls_f32
k_Harmonic18thElec_Uls_f32
t_MtrCurrQaxRpl_Amp_u9p7[]
t_MtrCurrDaxRpl_Amp_u9p7[]
t2_MtrCurrQaxRpl6X_Amp_s6p9[]
t2_MtrCurrQaxRpl6Y_Amp_s6p9[]
t2_MtrCurrQaxRpl12X_Amp_s6p9[]
t2_MtrCurrQaxRpl12Y_Amp_s6p9[]
t2_MtrCurrQaxRpl18X_Amp_s6p9[]
t2_MtrCurrQaxRpl18Y_Amp_s6p9[]
t_MtrVelX_MtrRadpS_T_u14p2[10]
t_MtrTrqCancPIMagRP_Uls_u6p10[10]
t_MtrTrqCancPIPhRP_Rev_u0p16[10]
t_MtrCurrQaxRplPIY_Amp_u9p7[]
t2_MtrTrqCancPIMagRP_Uls_u6p10[]
t2_MtrTrqCancPIPhRP_Rev_u0p16[]

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_SQRT3OVR2_ULS_F32Single precision floatUnit less0.866025403784
D_6HARMONICNO_F32Single precision floatUnit less6
D_12HARMONICNO_F32Single precision floatUnit less12
D_COGGINGTBLRES_F32Single precision floatCounts81.48733
D_MAXTBLVALUE_CNT_u161Counts511
D_SCALERADTOCNTS_ULS_F32Single precision floatUnit less10430.3783505
D_30DEGREES_CNT_U161Counts5461
D_DEG2RAD_ULS_F32Singles precision floatUnit less0.0174532925199
D_REVWITHROUND_ULS_F32Singles precision floatUnit less65536.5
D_ONEHALF_ULS_F32Singles precision floatUnit less0.5
D_POSITIVEONE_CNT_S81Counts1
D_COGTRQ_LOOPLMT1Unit less128
D_DAXRPLTBLSZ_CNT_U81CountsTableSize_m(t_MtrCurrDaxRpl_Amp_u9p7)
D_QAXRPLTBLSZ_CNT_U81CountsTableSize_m(t_MtrCurrQaxRpl_Amp_u9p7)
D_COGTRQRPL_LOOPLMT1Counts3U
D_NOOFHARMONIC_CNT_U81Counts9U
D_MINCOGRANGE_NM_S5P10S5P10_TNm-0.1
D_MINCOGRANGE_NM_S5P10S5P10_TNm0.1

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
D_2PI_ULS_F32
D_ONE_ULS_F32
D_ZERO_ULS_F32

Module specific Lookup Tables Constants

(This is for lookup tables (arrays) with fixed values, same name as other tables)

Constant NameResolutionValueSoftware Segment
t_SinTbl_Cnt_u16Uint16TRQCANC_START_SEC_CONST_16


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. Abs_s16_m

  2. FPM_FloatToFixed_m

  3. TableSize_m

  4. FPM_FixedToFloat_m

  5. IntplVarXY_u16_u16Xu16Y_Cnt

  6. BilinearXYM_s16_u16Xs16YM_Cnt

  7. sqrtf

  8. atan2f

  9. sinf

  10. Rte_Pim_CogTrqCal

  11. Rte_Pim_CogTrqRplComp

Data Hiding Functions

MtrCntrl_Read_MtrElecPol_Cnt_s8

MtrCntrl_Read_MtrPosElec_Rev_u0p16

MtrCntrl_Read_ReadFwdPthAccessBfr_Cnt_u16

Global Functions/Macros Defined by this Module

None

Local Functions/Macros Used by this MDD only


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
EstKe_VpRadpS_f32Rte_IRead_TrqCanc_Init_EstKe_VpRadpS_f32

Initialization Functions

Per: TrqCanc_Init

Design Rationale

Update the lookup table for ripple’s

Processing

Periodic Functions

Per: TrqCanc_Per1

Design Rationale

FastDataAccessBufIndex allows the buffer synchronization between data calculated on slower periodic loop time(2 milli seconds) and are read by faster periodic run time (ie 0.125ms)

Program Flow Start

Rte_Call_TrqCanc_Per1_CP0_CheckpointReached()

Store Module Inputs to Local copies

MRFMtrVel_MtrRadpS_T_f32=Rte_IRead_TrqCanc_Per1_MRFMtrVel_MtrRadpS_f32

DaxRef_Amp_T_f32=Rte_IRead_TrqCanc_Per1_MtrCurrDaxRef_Amp_f32

QaxRef_Amp_T_f32 =Rte_IRead_TrqCanc_Per1_MtrCurrQaxRef_Amp_f32

WriteAccessBufIndex_Cnt_T_u16= (FastDataAccessBufIndex_Cnt_M_u16&1)^1;


Store Local copy of outputs into Module Outputs

Program Flow End

Rte_Call_TrqCanc_Per1_CP1_CheckpointReached()

Periodic Functions

Per: TrqCogCancRefPer1

Design Rationale

FastDataAccessBufIndex allows the buffer synchronization between data calculated on slower periodic loop time(2 milli seconds) and are read by faster periodic run time. SlowDataAccessBufIndex allows the buffer synchronization between data calculated on faster periodic loop time(125 micro seconds) and are read by slower periodic run time (ie 2ms)

Program Flow Start

N/A

Store Module Inputs to Local copies

DataAccessBfr_Cnt_T_u16 =FastDataAccessBufIndex_Cnt_M_u16

MtrCntrl_Read_MtrElecPol_Cnt_s8(&MtrElecPol_Cnt_T_s8)

MtrCntrl_Read_MtrPosElec_Rev_u0p16(&MtrPosElec_Rev_T_u0p16)

MtrPosComputDelay_Rad_T_f32=MtrPosComputationDelay_Rad_M_f32[DataAccessBfr_Cnt_T_u16]

EstKe_VpRadpS_T_f32= MtrEstKe_VpRadpS_M_f32[DataAccessBfr_Cnt_T_u16]

MtrCurrQax6Mag_Amp_T_f32 =MtrCurrQax6Mag_Amp_M_f32[DataAccessBfr_Cnt_T_u16] MtrCurrQax12Mag_Amp_T_f32=MtrCurrQax12Mag_Amp_M_f32[DataAccessBfr_Cnt_T_u16] MtrCurrQax6Ph_Rad_T_f32 =MtrCurrQax6Ph_Rad_M_f32[DataAccessBfr_Cnt_T_u16] MtrCurrQax12Ph_Rad_T_f32 =MtrCurrQax12Ph_Rad_M_f32[DataAccessBfr_Cnt_T_u16]

MtrCurrQax18Mag_Amp_T_f32=MtrCurrQax18Mag_Amp_M_f32[DataAccessBfr_Cnt_T_u16] MtrCurrQax18Ph_Rad_T_f32 =MtrCurrQax18Ph_Rad_M_f32[DataAccessBfr_Cnt_T_u16]

Store Local copy of outputs into Module Outputs

None

Program Flow End

None

Fault Recovery Functions

None

Shutdown Functions

None

Interrupt Functions

None

Serial Communication Functions

SComm: TrqCanc_Scom_ReadCogTrqCal

Design Rationale

#ifdef RTE_PTR2ARRAYBASETYPE_PASSING

FUNC(void, RTE_AP_TRQCANC_APPL_CODE) TrqCanc_Scom_ReadCogTrqCal(P2VAR(UInt16, AUTOMATIC, RTE_AP_TRQCANC_APPL_VAR) CogTrqCalPtr, UInt16 ID)

#else

FUNC(void, RTE_AP_TRQCANC_APPL_CODE) TrqCanc_Scom_ReadCogTrqCal(P2VAR(CoggingCancTrq, AUTOMATIC, RTE_AP_TRQCANC_APPL_VAR) CogTrqCalPtr, UInt16 ID)

#endif

Program Flow Start

None

Store Module Inputs to Local copies

None

Processing

Store Local copy of outputs into Module Outputs

None

Program Flow End

None

SComm: TrqCanc_Scom_SetCogTrqCal

Design Rationale

Function NameCoggingTrqTableUpdateTypeMinMaxUTP Tol.
Arguments Passed*CogTrqCalPtrSint16-11
IDUnit1604
Return ValueNone

#ifdef RTE_PTR2ARRAYBASETYPE_PASSING

FUNC(void, RTE_AP_TRQCANC_APPL_CODE) TrqCanc_Scom_SetCogTrqCal(P2CONST(UInt16, AUTOMATIC, RTE_AP_TRQCANC_APPL_DATA) CogTrqCalPtr, UInt16 ID)

#else

FUNC(void, RTE_AP_TRQCANC_APPL_CODE) TrqCanc_Scom_SetCogTrqCal(P2CONST(CoggingCancTrq, AUTOMATIC, RTE_AP_TRQCANC_APPL_DATA) CogTrqCalPtr, UInt16 ID)

#endif

Program Flow Start

None

Store Module Inputs to Local copies

None

Processing

Store Local copy of outputs into Module Outputs

None

Program Flow End

None

Local Function/Macro Definitions

CoggingTrqTableUpdate#1

Function NameCoggingTrqTableUpdateTypeMinMaxUTP Tol.
Arguments PassedN/AN/A--
Return ValueN/AN/AN/AN/A

Description

SinLookup #2

Function NameSinLookupTypeMinMaxUTP Tol.
Arguments PassedTheta_Rad_T_f32Float32--2*pi2*pi
Return ValueResult_Uls_T_f32Float32-11

Description

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 NameCalling FrequencySystem State(s) in which the function is called
TrqCanc_Per12msALL
TrqCogCancRefPer1125usALL
TrqCanc_InitInitAt Startup

Execution Requirements for Serial Communication Functions

Function NameSub-Module called by (Serial Comm Function Name)
TrqCanc_Scom_ReadCogTrqCalEPS_DiagSrvc
TrqCanc_Scom_SetCogTrqCalEPS_DiagSrvc


Memory Map Definition Requirements

Sub Modules (Functions)

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

Name of Sub ModuleSoftware Segment
TrqCanc_Per1RTE_START_SEC_AP_TRQCANC_APPL_CODE
TrqCanc_InitRTE_START_SEC_AP_TRQCANC_APPL_CODE

Local Functions

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

Name of Sub ModuleSoftware Segment
CoggingTrqTableUpdateRTE_START_SEC_AP_TRQCANC_APPL_CODE
SinLookupRTE_START_SEC_AP_TRQCANC_APPL_CODE

Known Issues / Limitations With Design

Note for UNIT TEST:

  1. Rte_Pim_CogTrqCal and CogTrqRplComp is declared as unit16 with size of 521 with 512 values are used in the look up and 9 values are used in the harmonic table compensation.

Eventhough the values are read as uint16 it will be used as sint16 ( s5p10 preciously) with the range of -1 to 1 .

Revision Control Log

Rev #Change DescriptionDateAuthor Initials
1.0Initial version (v8 FDD SF99B)23-Mar-13Selva
2Updated to version 9 FDD SF99B5-June-13Selva
3Updated to version 10 FDD SF99B21-Oct-13Selva
4Updated to version 10 FDD SF99B23-Oct-13Selva
5Updated to version 11 FDD SF99B7-Nov-13Selva
Last modified October 12, 2025: Initial commit (0347a62)