Jump to main content

##

# 3.3.4 mcFocI_FieldOrientedControlFast

## C

    /* Execute Field Oriented Control (FOC) fast loop tasks */
    oid mcFocI_FieldOrientedControlFast( tmcFocI_ModuleData_s * const pModule )

## Summary

Executes the fast loop tasks of the FOC algorithm.

## Description

This function handles the fast loop tasks of field-oriented control (FOC) in a motor control application. It achieves this by executing the necessary reference frame transformations and control loops, based on the input state and module data.

The following steps summarize the operation of `mcFocI_FieldOrientedControlFast`:

- Reading Inputs: Reads the phase currents and reference speed.
- Clarke Transformation: Performs the Clarke transformation on input phase currents using the `mcFoc_ClarkeTransformation` API, transforming them into two orthogonal currents in the αβ reference frame.
- Rotor Position and Speed Estimation: Estimates the rotor position and speed using the `mcRpeI_RotorPositionEstim` API in sensor-less FOC operation. (Refer to the QSPIN Rotor Position and Speed Estimation module documentation for further details.)
- State Machine Handling: Handles the state machine based on the current FOC state, executing the FOC startup mechanism and closed-loop transition tasks if required in sensor-less operation, as well as speed reference control and the speed control loop. (Refer to the QSPIN startup procedure documentation for further details.)
- Park Transformation: Transforms the αβ reference frame currents to dq reference frame currents using the estimated or calculated rotor position via the Park transformation.
- Flux and Torque Control: Executes the flux control and torque control loops using the `mcFlxI_FluxControlAuto` and `mcTorI_TorqueControlAuto` APIs, respectively, and updates the dq reference frame voltages.
- Inverse Park Transformation: Generates the αβ reference frame voltages using the estimated or calculated rotor position by performing an inverse Park transformation on the dq reference voltages.
- PWM Output Generation: Generates the PWM output duty ratios for the reference voltages using the `mcPwmI_PulseWidthModulation` API.

## Precondition

The FOC module tasks must be initialized and enabled. Please refer to any Harmony QSPIN motor control application example for the FOC module execution sequence.

## Parameters

Param | Description
--- | ---
pModule | A pointer to the module data structure, which contains the parameters and state variables for the FOC module.

## Returns

None

## Example

    // Define the FOC module data structure
    tmcFocI_ModuleData_s moduleData;

    /* Execute Field Oriented Control (FOC) fast loop tasks */
    mcFocI_FieldOrientedControlFast(&moduleData);

## Remarks

None.