DCL Direct Form 1 3rd Order Functions

Module: Digital Control Library (DCL)

More…

Structures

Name

struct

DCL_DF13_SPS
Defines the DCL_DF13 shadow parameter set used for updating compensator parameter.

Types

Name

typedef _DCL_VOLATILE struct

DCL_DF13
DCL_DF13 object for storing df13 specific parameters.

Functions

Name

_DCL_CODE_ACCESS void

DCL_resetDF13(DCL_DF13 * df)
Resets DF13 internal storage data with interrupt protection Implemented as inline C function.

_DCL_CODE_ACCESS void

DCL_forceUpdateDF13(DCL_DF13 * df)
Loads DF13 tuning parameter from its SPS parameter without interrupt protection.

_DCL_CODE_ACCESS void

DCL_updateDF13NoCheck(DCL_DF13 * df)
Loads DF13 tuning parameter from its SPS parameter with interrupt protection.

_DCL_CODE_ACCESS bool

DCL_updateDF13(DCL_DF13 * df)
A conditional update based on the update flag. If the update status is set, the function will update DF13 parameter from its SPS parameter and clear the status flag on completion…

_DCL_CODE_ACCESS bool

DCL_isStableDF13(DCL_DF13 * df)
Determines stability of the shadow compensator.

_DCL_CODE_ACCESS void

DCL_loadDF13asZPK(DCL_DF13 * df, DCL_ZPK3 * zpk)
Loads the DF13 shadow coefficients from a ZPK3 description.

_DCL_CRIT_ACCESSfloat32_t

DCL_runDF13(DCL_DF13 * df, float32_t ek)
Executes a 3rd order Direct Form 1 controller.

_DCL_CRIT_ACCESSfloat32_t

DCL_runDF13PartialCompute(DCL_DF13 * df, float32_t ek)
Immediate computation to obtain DF13 servo error without updating the controller.

_DCL_CRIT_ACCESS void

DCL_runDF13PartialUpdate(DCL_DF13 * df, float32_t ek, float32_t uk)
Update DF13 controller based on pre-computed control effort.

_DCL_CRIT_ACCESSfloat32_t

DCL_runDF13Clamp(DCL_DF13 * df, float32_t ek, float32_t Umax, float32_t Umin)
Executes a 3rd order Direct Form 1 controller with clamp.

_DCL_CRIT_ACCESSfloat32_t

DCL_runDF13_C5(DCL_DF13 * p, float32_t ek, float32_t vk)
Legacy C28 Function for maintaining backwards compatibility. It Executes an immediate 3rd order Direct Form 1 controller.

_DCL_CRIT_ACCESSfloat32_t

DCL_runDF13_C6(DCL_DF13 * p, float32_t ek, float32_t uk)
Legacy C28 Function for maintaining backwards compatibility. It executes a partial pre-computed 3rd order Direct Form 1 controller.

Defines

Name

DF13_SPS_DEFAULTS
Defaults for DCL_DF13_SPS.

DF13_DEFAULTS
Defines default values to initialize DCL_DF13.

DF13_INT_DEFAULTS
Macro for internal default values to initialize DCL_DF13 Example: DCL_DF13 df13_ctrl = { .b0 = 0.25f, .b1 = 0.25f, … .a3 = 0.0f, DF13_INT_DEFAULTS };.

DCL_initDF13()
Initialize DCL_DF13 struct with default parameters Example: DCL_DF13* df13_ctrl = DCL_initDF13();.

DCL_initDF13asParam(_b0, _b1, _b2, _b3, _a1, _a2, _a3)
Initialize DCL_DF13 struct with input compensator parameters Example: DCL_DF13* DF13_ctrl = DCL_initDF13asParam(0.25f,0.25f,0.25f,0.25f,0.0f,0.0f,0.0f);.

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

Detailed Description

Note: Due to compatibility reason, this file maintains a copy of legacy function DCL_runDF13_C5(), DCL_runDF13_C6(). It is advised to not use these legacy functions for new development.

Contains direct form 1 3rd order DF13 compensator with its related structures and functions

Types Documentation

typedef DCL_DF13

typedef _DCL_VOLATILE struct  DCL_DF13;

DCL_DF13 object for storing df13 specific parameters.

Functions Documentation

function DCL_resetDF13

_DCL_CODE_ACCESS void DCL_resetDF13(
    DCL_DF13 * df
)

Resets DF13 internal storage data with interrupt protection Implemented as inline C function.

Parameters:

  • df Pointer to the DCL_DF13 controller structure

function DCL_forceUpdateDF13

_DCL_CODE_ACCESS void DCL_forceUpdateDF13(
    DCL_DF13 * df
)

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

Parameters:

  • df Pointer to the active DCL_DF13 controller structure

function DCL_updateDF13NoCheck

_DCL_CODE_ACCESS void DCL_updateDF13NoCheck(
    DCL_DF13 * df
)

Loads DF13 tuning parameter from its SPS parameter with interrupt protection.

Parameters:

  • df Pointer to the DCL_DF13 controller structure

function DCL_updateDF13

_DCL_CODE_ACCESS bool DCL_updateDF13(
    DCL_DF13 * df
)

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

Parameters:

  • df Pointer to the DCL_DF13 controller structure

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

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

function DCL_isStableDF13

_DCL_CODE_ACCESS bool DCL_isStableDF13(
    DCL_DF13 * df
)

Determines stability of the shadow compensator.

Parameters:

  • df Pointer to the DCL_DF13 controller structure

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

function DCL_loadDF13asZPK

_DCL_CODE_ACCESS void DCL_loadDF13asZPK(
    DCL_DF13 * df,
    DCL_ZPK3 * zpk
)

Loads the DF13 shadow coefficients from a ZPK3 description.

Parameters:

  • df Pointer to the DCL_DF13 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_updateDF13().

function DCL_runDF13

_DCL_CRIT_ACCESSfloat32_t DCL_runDF13(
    DCL_DF13 * df,
    float32_t ek
)

Executes a 3rd order Direct Form 1 controller.

Parameters:

  • df Pointer to the DCL_DF13 controller structure

  • ek The servo error

Return: The control effort

function DCL_runDF13PartialCompute

_DCL_CRIT_ACCESSfloat32_t DCL_runDF13PartialCompute(
    DCL_DF13 * df,
    float32_t ek
)

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

Parameters:

  • df Pointer to the DCL_DF13 controller structure

  • ek The servo error

Return: The control effort

function DCL_runDF13PartialUpdate

_DCL_CRIT_ACCESS void DCL_runDF13PartialUpdate(
    DCL_DF13 * df,
    float32_t ek,
    float32_t uk
)

Update DF13 controller based on pre-computed control effort.

Parameters:

  • df Pointer to the DCL_DF13 controller structure

  • ek The servo error

  • uk The controller output in the previous sample interval

function DCL_runDF13Clamp

_DCL_CRIT_ACCESSfloat32_t DCL_runDF13Clamp(
    DCL_DF13 * df,
    float32_t ek,
    float32_t Umax,
    float32_t Umin
)

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

Parameters:

  • df Pointer to the DCL_DF13 controller structure

  • ek The servo error

  • Umax Upper saturation limit

  • Umin Lower saturation limit

Return: uk The control effort

function DCL_runDF13_C5

_DCL_CRIT_ACCESSfloat32_t DCL_runDF13_C5(
    DCL_DF13 * p,
    float32_t ek,
    float32_t vk
)

Legacy C28 Function for maintaining backwards compatibility. It Executes an immediate 3rd order Direct Form 1 controller.

Parameters:

  • p Pointer to the DCL_DF13 controller structure

  • ek The servo error

  • vk The partial pre-computed control effort

Return: uk The control effort

function DCL_runDF13_C6

_DCL_CRIT_ACCESSfloat32_t DCL_runDF13_C6(
    DCL_DF13 * p,
    float32_t ek,
    float32_t uk
)

Legacy C28 Function for maintaining backwards compatibility. It executes a partial pre-computed 3rd order Direct Form 1 controller.

Parameters:

  • p Pointer to the DCL_DF13 controller structure

  • ek The servo error

  • uk The controller output in the previous sample interval

Return: vk The control effort

Macros Documentation

define DF13_SPS_DEFAULTS

#define DF13_SPS_DEFAULTS {0.25f, 0.25f, 0.25f, 0.25f, 0.0f, 0.0f, 0.0f, 0.0f}

Defaults for DCL_DF13_SPS.

define DF13_DEFAULTS

#define DF13_DEFAULTS     {0.25f,                            \
     0.25f,                            \
     0.25f,                            \
     0.25f,                            \
     0.0f,                             \
     0.0f,                             \
     0.0f,                             \
     0.0f,                             \
     0.0f,                             \
     0.0f,                             \
     0.0f,                             \
     0.0f,                             \
     0.0f,                             \
     0.0f,                             \
     0.0f,                             \
     0.0f,                             \
     &(DCL_DF13_SPS)DF13_SPS_DEFAULTS, \
     &(DCL_CSS)DCL_CSS_DEFAULTS}

Defines default values to initialize DCL_DF13.

define DF13_INT_DEFAULTS

#define DF13_INT_DEFAULTS     .d1 = 0.0f, .d2 = 0.0f, .d3 = 0.0f, .d4 = 0.0f, .d5 = 0.0f, .d6 = 0.0f, .a0 = 0.0f, .d0 = 0.0f, .d7 = 0.0f, \
    .sps = &(DCL_DF13_SPS)DF13_SPS_DEFAULTS, .css = &(DCL_CSS)DCL_CSS_DEFAULTS

Macro for internal default values to initialize DCL_DF13 Example: DCL_DF13 df13_ctrl = { .b0 = 0.25f, .b1 = 0.25f, … .a3 = 0.0f, DF13_INT_DEFAULTS };.

define DCL_initDF13

#define DCL_initDF13(
    
)
&(DCL_DF13)DF13_DEFAULTS

Initialize DCL_DF13 struct with default parameters Example: DCL_DF13* df13_ctrl = DCL_initDF13();.

Return: A DCL_DF13* pointer

define DCL_initDF13asParam

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

Initialize DCL_DF13 struct with input compensator parameters Example: DCL_DF13* DF13_ctrl = DCL_initDF13asParam(0.25f,0.25f,0.25f,0.25f,0.0f,0.0f,0.0f);.

Return: A DCL_DF13* pointer

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

define DCL_initDF13asSPS

#define DCL_initDF13asSPS(
    df_ptr,
    sps_ptr
)
    ({                                                                                  \
        DCL_DF13     *new_df  = (df_ptr) ? df_ptr : DCL_initDF13();                     \
        DCL_DF13_SPS *new_sps = (sps_ptr) ? sps_ptr : &(DCL_DF13_SPS)DF13_SPS_DEFAULTS; \
        if (sps_ptr)                                                                    \
        {                                                                               \
            *new_df = (DCL_DF13){(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,                                                  \
                                 0.0f,                                                  \
                                 0.0f,                                                  \
                                 0.0f,                                                  \
                                 0.0f,                                                  \
                                 0.0f,                                                  \
                                 0.0f,                                                  \
                                 (DCL_DF13_SPS *)new_sps,                               \
                                 &(DCL_CSS)DCL_CSS_DEFAULTS};                           \
        }                                                                               \
        new_df;                                                                         \
    })

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

Parameters:

  • df_ptr DCL_DF13* pointer that needs to be initialized

  • sps_ptr DCL_DF13_SPS* pointer with assigned parameters

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