Jump to main content

##

# 3.5.15 tmcRpe_State_s Struct

## C

    /* Data structure for Rotor Position Estimation (RPE) module: Floating point version */
    typedef struct
    {
       /** States */
       bool enable;                    /* Flag indicating if the module is enabled */
       bool initDone;                  /* Flag indicating if initialization is done */
       float32_t  eAlpha;              /* Error in alpha axis */
       float32_t  eBeta;               /* Error in beta axis */
       float32_t  eD;                  /* Error in direct axis */
       float32_t  eQ;                  /* Error in quadrature axis */
       float32_t  uAlpha;              /* Alpha axis voltage value */
       float32_t  uBeta;               /* Beta axis voltage value */
       float32_t  iAlpha;              /* Alpha axis current value */
       float32_t  iBeta;               /* Beta axis current value */
       float32_t  n;                   /* Rotor speed */
       float32_t  phi;                 /* Rotor electrical angle */

       /** Parameters */
       float32_t   dt;                 /* Discrete time step or Sample time */
       float32_t   Rs;                 /* Stator resistance value */
       float32_t   dLsByDt;            /* Rate of change of inductance over time */
       float32_t   eABFilterParameter; /* Filter parameter for alpha-beta back-EMF estimation */
       float32_t   eDQFilterParameter; /* Filter parameter for DQ-axis back-EMF estimation */
       float32_t   nFilterParameter;   /* Filter parameter for rotor speed estimation */
       float32_t   oneByKe;            /* Inverse of the back-EMF constant */
       float32_t   speedToAngle;       /* Speed to angle conversion value */
       float32_t phiOffset;            /* Offset to be added to the estimated rotor position angle */
       uint16_t calibCounter;          /* Counter used during the calibration process */
       uint16_t calibTimeinCounts;     /* Calibration duration in counts */
    }tmcRpe_State_s;

    /* Data structure for Rotor position estimation module: Fixed point version */
    typedef struct
    {
        bool enable;                  /* Flag indicating if the module is enabled */
        bool initDone;                /* Flag indicating if initialization is done */
        int16_t Rs;                   /* Stator resistance value */
        int16_t LsFs;                 /* Filtered inductance value */
        int16_t OneByKeVal;           /* Inverse of back EMF constant value */
        uint16_t OneByKeShift;        /* Shift amount for inverse of back EMF constant */
        int16_t SpeedToAngle;         /* Speed to angle conversion value */
        int16_t eAlpha;               /* Error in alpha axis */
        int16_t eBeta;                /* Error in beta axis */
        int16_t eD;                   /* Error in direct axis */
        int16_t eQ;                   /* Error in quadrature axis */
        int16_t iAlphaLast;           /* Last alpha axis current value */
        int16_t iBetaLast;            /* Last beta axis current value */
        int16_t uAlphaLast;           /* Last alpha axis voltage value */
        int16_t uBetaLast;            /* Last beta axis voltage value */
        uint16_t phi;                 /* Rotor electrical angle */
        int16_t speed;                /* Rotor speed */
        int16_t integOffset;          /* Integration offset */
    #if defined ENABLE_FIR_FILTER_STAGE
        int16_t firTapNumbers;        /* Number of taps in the FIR filter */
        int16_t firCoefficients[4U];  /* Coefficients of the FIR filter */
        FIRFilter  firFilter;         /* Structure for FIR filter parameters */
    #endif

    #if defined ENABLE_IIR_FILTER_STAGE
        int16_t  iirStages;           /* Number of stages in the IIR filter */
        int16_t  iirACoefficients[3U];/* 'A' coefficients for the IIR filter */
        int16_t  iirBCoefficients[3U];/* 'B' coefficients for the IIR filter */
        IIRFilter  iirFilter;         /* Structure for IIR filter parameters */
    #endif

    #if defined SRF_PLL
        tmcUtils_PiControl_s bPIController;  /* PI controller for PLL */
    #else
        int16_t phiOffset;            /* Electrical angle offset */
        uint16_t calibCounter;        /* Calibration counter for phase offset correction */
        uint16_t calibTimeinCounts;   /* Calibration time duration in counts */
    #endif
    } tmcRpe_State_s;

## Summary

RPE module parameter state structure.

## Description

This structure holds the input parameters and state variables for the Rotor Position Estimation (RPE) algorithm.

## Remarks

Refer the generated header file for the exact typedef signature.