Quadrant_Detection_MDD

Module --

High-Level Description

This module takes the cumulative motor position and determines the motor direction (using a previously saved state variable and a calibration constant for hysteresis). It then computes the torque command sign from the scaled torque command and uses both of these values to determine the motor quadrant.

Figures

Component Diagram

Diagram – Function QuadDet_Per1


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
MRFMtrTrqCmdScl_MtrNm_f32InstMtrDir_Cnt_s08
MRFCumMtrPos_Deg_f32MtrQuad_Cnt_u08

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
MtrTrqCmdSign_Cnt_D_s081-1, 1AP_QUADRANTDETECT_VAR_NOINIT
PrevCumMtrPos_Deg_M_f32Single Precision Float-11AP_QUADRANTDETECT_VAR_INIT
PrevInstMtrDir_Cnt_M_s081-11AP_QUADRANTDETECT_VAR_INIT

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_InstMtrDirHyst_Deg_f32

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_CUMMTRPOSLOLMT_DEG_F32Single Precision FloatDegreesmin value of MRFCumMtrPos_Deg_f32
D_CUMMTRPOSHILMT_DEG_F32Single Precision FloatDegreesmax value of MRFCumMtrPos_Deg_f32
D_MTRTRQCMDTOL_MTRNM_F32Single Precision FloatMtrNm0.00390625

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_QUADRANT1_CNT_U8
D_QUADRANT2_CNT_U8
D_QUADRANT3_CNT_U8
D_QUADRANT4_CNT_U8

Module specific Lookup Tables Constants

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. Abs_f32_m()

  2. Sign_f32_m()

Data Hiding Functions

None

Global Functions/Macros Defined by this Module

None

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_InstMtrDir_Cnt_s080
Rte_InitValue_MRFCumMtrPos_Deg_f320
Rte_InitValue_MRFMtrTrqCmdScl_MtrNm_f320
Rte_InitValue_MtrQuad_Cnt_u081

Initialization Functions

None


Periodic Functions

Per: _Per1

Design Rationale

None

Program Flow Start

N/A

Store Module Inputs to Local copies

MtrTrqCmdScl_MtrNm_T_f32 = Rte_IRead_QuadDet_Per1_MRFMtrTrqCmdScl_MtrNm_f32();

CumMtrPos_Deg_T_f32 = Rte_IRead_QuadDet_Per1_MRFCumMtrPos_Deg_f32();

Determine Motor Direction

Determine Instantaneous Torque Command Sign

Determine Motor Quadrant

Store Local copy of outputs into Module Outputs

Rte_IWrite_QuadDet_Per1_InstMtrDir_Cnt_s08(PrevInstMtrDir_Cnt_M_s08);

Rte_IWrite_QuadDet_Per1_MtrQuad_Cnt_u08(MtrQuad_Cnt_T_u08);

Program Flow End

N/A


Fault Recovery Functions

None

Shutdown Functions

None

Interrupt Functions

None

Serial Communication Functions

None


Execution Requirements

Execution Sequence of the Module

QuadDet_Per1 executes every 2 milliseconds.

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
QuadDet_Per12 msWARM INIT, OPERATE, DISABLE, OFF

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
QuadDet_Per1RTE_START_SEC_AP_QUADDET_APPL_CODE

Local Functions

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

Name of Sub ModuleSoftware Segment
None


Known Issues / Limitations With Design

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

Item #Rev #Change DescriptionDateAuthor Initials
11Initial MDD for component based design23-Dec-11O.T.
22.0Fixed Inconsistencies, UTP issues25-Jan-12OT
Last modified October 12, 2025: Initial commit (0347a62)