Jump to main content

##

# 3.3.1 mcFocI_FieldOrientedControlInit

## C

    /* Initializes the FOC module */
    void  mcFocI_FieldOrientedControlInit( tmcFocI_ModuleData_s * const pModule )

## Summary

Initialize the Field Oriented Control (FOC) module

## Description

This function initializes the field-oriented control (FOC) module by setting up the necessary parameters, linking state variables, and initializing the various control modules. It updates the state variable structure, sets the module parameters using the parameter module structure, and establishes the default direction. The function then proceeds to initialize the following control modules and sets the initialization flag:

- Open Loop Start-Up Module: Initializes the open loop start-up module using `mcSupI_OpenLoopStartupInit`.
- Reference Control Module: Initializes the reference control module using `mcRefI_ReferenceControlInit`.
- Position Control Module: Initializes the position control module using `mcPosI_PositionControlInit` in position control mode.
- Speed Control Module: Initializes the speed control module using `mcSpeI_SpeedControlInit`.
- Torque Control Module: Initializes the torque control module using `mcTorI_TorqueControlInit`.
- Flux Control Module: Initializes the flux control module using `mcFlxI_FluxControlInit`.
- Flux Weakening Module: Initializes the flux weakening module using `mcFlxI_FluxWeakeningInit` if field weakening is enabled.
- MTPA Module: Initializes the Maximum Torque Per Ampere (MTPA) module using `mcFlxI_MTPAInit` if MTPA is enabled.
- Rotor Position Estimation Module: Initializes the rotor position estimation module using `mcRpeI_RotorPositionEstimInit` for sensor-less FOC operation.
- PWM Module: Initializes the Pulse Width Modulation (PWM) module using `mcPwmI_PulseWidthModulationInit`.

## Precondition

None.

## 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 focModuleData;

    // Initialize the FOC module
    mcFocI_FieldOrientedControlInit(&focModuleData);

## Remarks

None.