Jump to main content

##

# 3.9.6 mcUtils_PiControlInit

## C

    /* Initializes the PI control structure with the given parameters. */
    void mcUtils_PiControlInit( float32_t Kp, float32_t Ki, float32_t dt,
                                           tmcUtils_PiControl_s  * const pControl)

## Summary

Initializes the PI control structure with the given parameters.

## Description

The function initializes the PI controller by setting its proportional gain (`Kp`) and calculating the effective integral gain (`Ki`). The integral gain is scaled by the sampling time (`dt`) to accommodate discrete-time integration.

## Precondition

None.

## Parameters

Param | Description
--- | ---
Kp | Proportional gain of the PI controller.
Ki | Integral gain of the PI controller
dt | Sampling time
pControl | Pointer to the PI control structure that needs to be initialized.

## Returns

None

## Example

    tmcUtils_PiControl_s piControl;
    float32_t Kp = 1.0f;
    float32_t Ki = 0.5f;
    float32_t dt = 0.0001f;

    mcUtils_PiControlInit(Kp, Ki, dt, &piControl);

## Remarks

None.