DCL Direct Form 2 3rd Order Functions

Module: Digital Control Library (DCL)

More…

Structures

Name

struct

DCL_DF23_SPS
Defines DCL_DF23 shadow parameter set used for updating compensator parameter.

Types

Name

typedef _DCL_VOLATILE struct

DCL_DF23
DCL_DF23 object for storing df23 specific parameters.

Functions

Name

_DCL_CODE_ACCESS void

DCL_resetDF23(DCL_DF23 * df)
Resets DF23 internal storage data with interrupt protection.

_DCL_CODE_ACCESS void

DCL_forceUpdateDF23(DCL_DF23 * df)
Loads DF23 tuning parameter from its SPS parameter without interrupt protection.

_DCL_CODE_ACCESS void

DCL_updateDF23NoCheck(DCL_DF23 * df)
Updates DF23 parameter from its SPS parameter with interrupt protection.

_DCL_CODE_ACCESS bool

DCL_updateDF23(DCL_DF23 * df)
A conditional update based on the update flag. If the update status is set, the function will update DF23 parameter from its SPS parameter and clear the status flag on completion.

_DCL_CODE_ACCESS bool

DCL_isStableDF23(DCL_DF23 * df)
Determines stability of the shadow compensator.

_DCL_CODE_ACCESS void

DCL_loadDF23asZPK(DCL_DF23 * df, DCL_ZPK3 * zpk)
Loads the DF23 shadow coefficients from a ZPK3 description.

_DCL_CRIT_ACCESSfloat32_t

DCL_runDF23(DCL_DF23 * df, float32_t ek)
Executes a 3rd order Direct Form 2 controller.

_DCL_CRIT_ACCESSfloat32_t

DCL_runDF23PartialCompute(DCL_DF23 * df, float32_t ek)
Immediate computation to obtain DF23 servo error without updating the controller.

_DCL_CRIT_ACCESS void

DCL_runDF23PartialUpdate(DCL_DF23 * df, float32_t ek, float32_t uk)
Update DF22 controller based on pre-computed control effort.

_DCL_CRIT_ACCESSfloat32_t

DCL_runDF23Clamp(DCL_DF23 * df, float32_t ek, float32_t Umax, float32_t Umin)
Executes a 3rd order Direct Form 2 controller with clamp.

Defines

Name

DF23_SPS_DEFAULTS
Defaults for DCL_DF23_SPS.

DF23_DEFAULTS
Defines default values to initialize DCL_DF23.

DF23_INT_DEFAULTS
Macro for internal default values to initialize DCL_DF23 Example: DCL_DF23 df23_ctrl = { .b0 = 1.0f, .b1 = 0.0f, … .a3 = 0.0f, DF23_INT_DEFAULTS };.

DCL_initDF23()
Initialize DCL_DF23 struct with default parameters Example: DCL_DF23* df23_ctrl = DCL_initDF23();.

DCL_initDF23asParam(_b0, _b1, _b2, _b3, _a1, _a2, _a3)
Initialize DCL_DF23 struct with input compensator parameters Example: DCL_DF23* DF23_ctrl = DCL_initDF23asParam(1.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f);.

DCL_initDF23asSPS(df_ptr, sps_ptr)
Initialize DCL_DF23 struct with sps parameters Example: DCL_DF23_SPS df_sps = { .b0 = , .b1 = , …}; //initial parameter DCL_DF23 df_ctrl; DCL_initDF23asSPS(&df_ctrl,&df_sps);.

Detailed Description

Contains direct form 2 3rd order DF23 compensator with its related structures and functions

Types Documentation

typedef DCL_DF23

typedef _DCL_VOLATILE struct  DCL_DF23;

DCL_DF23 object for storing df23 specific parameters.

Functions Documentation

function DCL_resetDF23

_DCL_CODE_ACCESS void DCL_resetDF23(
    DCL_DF23 * df
)

Resets DF23 internal storage data with interrupt protection.

Parameters:

  • df Pointer to the DCL_DF23 controller structure

function DCL_forceUpdateDF23

_DCL_CODE_ACCESS void DCL_forceUpdateDF23(
    DCL_DF23 * df
)

Loads DF23 tuning parameter from its SPS parameter without interrupt protection.

Parameters:

  • df Pointer to the active DCL_DF23 controller structure

function DCL_updateDF23NoCheck

_DCL_CODE_ACCESS void DCL_updateDF23NoCheck(
    DCL_DF23 * df
)

Updates DF23 parameter from its SPS parameter with interrupt protection.

Parameters:

  • df Pointer to the DCL_DF23 controller structure

function DCL_updateDF23

_DCL_CODE_ACCESS bool DCL_updateDF23(
    DCL_DF23 * df
)

A conditional update based on the update flag. If the update status is set, the function will update DF23 parameter from its SPS parameter and clear the status flag on completion.

Parameters:

  • df Pointer to the DCL_DF23 controller structure

Return: ‘true’ if an update is applied, otherwise ‘false’

Note: Note: Use DCL_setUpdateStatus(df) to set the update status.

function DCL_isStableDF23

_DCL_CODE_ACCESS bool DCL_isStableDF23(
    DCL_DF23 * df
)

Determines stability of the shadow compensator.

Parameters:

  • df Pointer to the DCL_DF23 controller structure

Return: ‘true’ if all poles have magnitude less than 1, ‘false’ otherwise

function DCL_loadDF23asZPK

_DCL_CODE_ACCESS void DCL_loadDF23asZPK(
    DCL_DF23 * df,
    DCL_ZPK3 * zpk
)

Loads the DF23 shadow coefficients from a ZPK3 description.

Parameters:

  • df Pointer to the DCL_DF23 controller structure

  • zpk Pointer to the DCL_ZPK3 structure

Note: Note: Sampling period df->css->T are used in the calculation. New settings take effect after DCL_updateDF23().

function DCL_runDF23

_DCL_CRIT_ACCESSfloat32_t DCL_runDF23(
    DCL_DF23 * df,
    float32_t ek
)

Executes a 3rd order Direct Form 2 controller.

Parameters:

  • df Pointer to the DCL_DF23 controller structure

  • ek The servo error

Return: The control effort

function DCL_runDF23PartialCompute

_DCL_CRIT_ACCESSfloat32_t DCL_runDF23PartialCompute(
    DCL_DF23 * df,
    float32_t ek
)

Immediate computation to obtain DF23 servo error without updating the controller.

Parameters:

  • df Pointer to the DCL_DF23 controller structure

  • ek The servo error

Return: The control effort

function DCL_runDF23PartialUpdate

_DCL_CRIT_ACCESS void DCL_runDF23PartialUpdate(
    DCL_DF23 * df,
    float32_t ek,
    float32_t uk
)

Update DF22 controller based on pre-computed control effort.

Parameters:

  • df Pointer to the DCL_DF23 controller structure

  • ek The servo error

  • uk The controller output in the previous sample interval

function DCL_runDF23Clamp

_DCL_CRIT_ACCESSfloat32_t DCL_runDF23Clamp(
    DCL_DF23 * df,
    float32_t ek,
    float32_t Umax,
    float32_t Umin
)

Executes a 3rd order Direct Form 2 controller with clamp.

Parameters:

  • df Pointer to the DCL_DF23 controller structure

  • ek The servo error

  • Umax Upper saturation limit

  • Umin Lower saturation limit

Return: uk The control effort

Macros Documentation

define DF23_SPS_DEFAULTS

#define DF23_SPS_DEFAULTS {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}

Defaults for DCL_DF23_SPS.

define DF23_DEFAULTS

#define DF23_DEFAULTS     {1.0f,                             \
     0.0f,                             \
     0.0f,                             \
     0.0f,                             \
     0.0f,                             \
     0.0f,                             \
     0.0f,                             \
     0.0f,                             \
     0.0f,                             \
     0.0f,                             \
     &(DCL_DF23_SPS)DF23_SPS_DEFAULTS, \
     &(DCL_CSS)DCL_CSS_DEFAULTS}

Defines default values to initialize DCL_DF23.

define DF23_INT_DEFAULTS

#define DF23_INT_DEFAULTS     .x1 = 0.0f, .x2 = 0.0f, .x3 = 0.0f, .sps = &(DCL_DF23_SPS)DF23_SPS_DEFAULTS, .css = &(DCL_CSS)DCL_CSS_DEFAULTS

Macro for internal default values to initialize DCL_DF23 Example: DCL_DF23 df23_ctrl = { .b0 = 1.0f, .b1 = 0.0f, … .a3 = 0.0f, DF23_INT_DEFAULTS };.

define DCL_initDF23

#define DCL_initDF23(
    
)
&(DCL_DF23)DF23_DEFAULTS

Initialize DCL_DF23 struct with default parameters Example: DCL_DF23* df23_ctrl = DCL_initDF23();.

Return: A DCL_DF23* pointer

define DCL_initDF23asParam

#define DCL_initDF23asParam(
    _b0,
    _b1,
    _b2,
    _b3,
    _a1,
    _a2,
    _a3
)
    &(DCL_DF23)                                                                                        \
    {                                                                                                  \
        .b0 = _b0, .b1 = _b1, .b2 = _b2, .b3 = _b3, .a1 = _a1, .a2 = _a2, .a3 = _a3, DF23_INT_DEFAULTS \
    }

Initialize DCL_DF23 struct with input compensator parameters Example: DCL_DF23* DF23_ctrl = DCL_initDF23asParam(1.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f);.

Return: A DCL_DF23* pointer

Note: Note: input parameter needs to be in the same order as listed in DF23_SPS struct.

define DCL_initDF23asSPS

#define DCL_initDF23asSPS(
    df_ptr,
    sps_ptr
)
    ({                                                                                                               \
        DCL_DF23     *new_df  = (df_ptr) ? df_ptr : DCL_initDF23();                                                  \
        DCL_DF23_SPS *new_sps = (sps_ptr) ? sps_ptr : &(DCL_DF23_SPS)DF23_SPS_DEFAULTS;                              \
        if (sps_ptr)                                                                                                 \
        {                                                                                                            \
            *new_df = (DCL_DF23){(new_sps)->b0, (new_sps)->b1, (new_sps)->b2,           (new_sps)->b3,               \
                                 (new_sps)->a1, (new_sps)->a2, (new_sps)->a3,           0.0f,                        \
                                 0.0f,          0.0f,          (DCL_DF23_SPS *)new_sps, &(DCL_CSS)DCL_CSS_DEFAULTS}; \
        }                                                                                                            \
        new_df;                                                                                                      \
    })

Initialize DCL_DF23 struct with sps parameters Example: DCL_DF23_SPS df_sps = { .b0 = , .b1 = , …}; //initial parameter DCL_DF23 df_ctrl; DCL_initDF23asSPS(&df_ctrl,&df_sps);.

Parameters:

  • df_ptr DCL_DF23* pointer that needs to be initialized

  • sps_ptr DCL_DF23_SPS* pointer with assigned parameters

Return: Returns DCL_DF23* with set sps parameters, default parameter will be used if sps_ptr is not specified