Jump to main content

##

# 3.3.12 tmcFoc_State_s Struct

## C

    /* Data structure for FOC state: Floating point version */
    typedef struct
     {
        bool enable;                              /* Flag indicating FOC module enable status */
        bool initDone;                            /* Flag indicating FOC module initialization status */
    <#if MCPMSMFOC_POSITION_CALC_ALGORITHM != 'SENSORLESS_ZSMT_HYBRID'>
        tmcFoc_FocState_e FocState;              /* Current state of the FOC. */
    </#if>
        tmcTypes_DQ_s uDQ;                        /* DQ-axis voltage vector. */
    <#if !(( MCPMSMFOC_POSITION_CALC_ALGORITHM == 'SENSORLESS_ZSMT_HYBRID' ) && ( MCPMSMFOC_CONTROL_TYPE != 'OPEN_LOOP' )) >
        float32_t openLoopAngle;                  /* Open loop angle for motor control. */
        float32_t openLoopSpeed;                  /* Open loop speed for motor control. */
    </#if>
        float32_t iQref;                          /* Reference current for the Q-axis. */
        float32_t iDref;                          /* Reference current for the D-axis. */
        float32_t nRef;                           /* Reference speed. */
    <#if MCPMSMFOC_POSITION_CALC_ALGORITHM != 'SENSORLESS_ZSMT_HYBRID'>
    <#if MCPMSMFOC_POSITION_CALC_ALGORITHM != 'SENSORED_ENCODER'>
        float32_t angleDifference;                 /* Angle difference for position calculation */
    </#if>
    </#if>
        float32_t commandDirection;               /* Command direction for the motor. */
        float32_t ratedSpeedInRpm;                /* Rated speed of the motor in RPM. */
    <#if MCPMSMFOC_POSITION_CALC_ALGORITHM != 'SENSORLESS_ZSMT_HYBRID'>
    <#if ( MCPMSMFOC_POSITION_CALC_ALGORITHM != 'SENSORED_ENCODER' ) && ( MCPMSMFOC_ENABLE_FLYING_START == true ) >
        tmcFly_Parameters_s bFlyingStart;        /* Parameters for Flying start control. */
    </#if>
    </#if>
        tmcSup_Parameters_s bOpenLoopStartup;     /* Parameters for open loop startup. */
        tmcPwm_Parameters_s bPwmModulator;        /* Parameters for PWM modulation. */
        tmcFlx_Parameters_s bFluxController;      /* Parameters for flux control. */
        tmcTor_Parameters_s bTorqueController;    /* Parameters for torque control. */
        tmcSpe_Parameters_s bSpeedController;     /* Parameters for speed control. */
    <#if ( MCPMSMFOC_CONTROL_TYPE == 'POSITION_LOOP' ) >
       tmcPos_Parameters_s bPositionController;   /* Parameters for position control. */
    </#if>
        tmcRef_Parameters_s bReferenceController; /* Parameters for reference control. */
    <#if MCPMSMFOC_POSITION_CALC_ALGORITHM != 'SENSORED_ENCODER'>
        tmcRpe_Parameters_s bPositionEstimation; /* Parameters for position estimation module. */
    </#if>
        uint16_t duty[3u];                        /* PWM duty cycle values for three phases. */
    }tmcFoc_State_s;

    /* Data structure for FOC state: Fixed point version */

    typedef struct
     {
        bool enable;                              /* Flag indicating FOC module enable status */
        bool initDone;                            /* Flag indicating FOC module initialization status */
        tmcFoc_FocState_e FocState;               /* Current state of the FOC. */
        tmcTypes_DQ_s uDQ;                        /* DQ-axis voltage vector. */
        tmcTypes_AlphaBeta_s eAlphaBeta;          /* Alpha-beta bemf components */
        uint16_t openLoopAngle;                   /* Open loop angle for motor control. */
        int16_t openLoopSpeed;                    /* Open loop speed for motor control. */
        int16_t iQref;                            /* Reference current for the Q-axis. */
        int16_t iDref;                            /* Reference current for the D-axis. */
        int16_t nRef;                             /* Reference speed. */
    <#if MCPMSMFOC_POSITION_CALC_ALGORITHM != 'SENSORED_ENCODER'>
        int16_t angleDifference;                  /* Angle difference for position calculation */
    </#if>
        int16_t commandDirection;                 /* Command direction for the motor. */
        int16_t ratedSpeedInRpm;                  /* Rated speed of the motor in RPM. */
        tmcSup_Parameters_s bOpenLoopStartup;     /* Parameters for open loop startup. */
        tmcPwm_Parameters_s bPwmModulator;        /* Parameters for PWM modulation. */
        tmcFlx_Parameters_s bFluxController;      /* Parameters for flux control. */
        tmcTor_Parameters_s bTorqueController;    /* Parameters for torque control. */
        tmcSpe_Parameters_s bSpeedController;     /* Parameters for speed control. */
        tmcRef_Parameters_s bReferenceController; /* Parameters for reference control. */
    <#if MCPMSMFOC_POSITION_CALC_ALGORITHM == 'SENSORED_ENCODER'>
        tmcRpc_Parameters_s bPositionCalculation; /**< Position calculation parameters */
    <#else>
        tmcRpe_Parameters_s bPositionEstimation; /**< Position estimation parameters */
    </#if>
        uint16_t duty[3u];                        /* PWM duty cycle values for three phases. */
    }tmcFoc_State_s;

## Summary

Field Oriented Control (FOC) Module Structure

## Description

This structure holds the state and parameters for the Field Oriented Control (FOC) module. It includes control flags, state variables, and parameters for various control modules.

## Remarks

Refer the generated header file for the exact typedef signature.