DCL Direct Form 1 1st Order Functions

Module: Digital Control Library (DCL)

More…

Structures

Name

struct

DCL_DF11_SPS
Defines DCL_DF11 shadow parameter set used for updating compensator parameter.

Types

Name

typedef _DCL_VOLATILE struct

DCL_DF11
DCL_DF11 object for storing df11 specific parameters.

Functions

Name

_DCL_CODE_ACCESS void

DCL_resetDF11(DCL_DF11 * df)
Resets DF11 internal storage data with interrupt protection.

_DCL_CODE_ACCESS void

DCL_forceUpdateDF11(DCL_DF11 * df)
Loads DF11 tuning parameter from its SPS parameter without interrupt protection.

_DCL_CODE_ACCESS void

DCL_updateDF11NoCheck(DCL_DF11 * df)
Loads DF11 tuning parameter from its SPS parameter with interrupt protection.

_DCL_CODE_ACCESS bool

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

_DCL_CODE_ACCESS bool

DCL_isStableDF11(DCL_DF11 * df)
Determines stability of the shadow DF11 compensator.

_DCL_CODE_ACCESS void

DCL_loadDF11asZPK(DCL_DF11 * df, DCL_ZPK3 * zpk)
Loads the DF11 shadow coefficients from a ZPK3 description.

_DCL_CODE_ACCESS void

DCL_loadDF11asPI(DCL_DF11 * df, float32_t Kp, float32_t Ki)
Loads compensator coefficients to emulate series form PI.

_DCL_CRIT_ACCESSfloat32_t

DCL_runDF11(DCL_DF11 * df, float32_t ek)
Executes a 1st order Direct Form 1 controller.

Defines

Name

DF11_SPS_DEFAULTS
brief Defaults for DCL_DF11_SPS

DF11_DEFAULTS
Defines default values to initialize DCL_DF11.

DF11_INT_DEFAULTS
Macro for internal default values to initialize DCL_DF11 Example: DCL_DF11 df11_ctrl = { .b0 = 0.5f, .b1 = 0.5f, .a1 = 1.0f, DF11_INT_DEFAULTS };.

DCL_initDF11()
Initialize DCL_DF11 struct with default parameters Example: DCL_DF11* df11_ctrl = DCL_initDF11();.

DCL_initDF11asParam(_b0, _b1, _a1)
Initialize DCL_DF11 struct with input compensator parameters Example: DCL_DF11* DF11_ctrl = DCL_initDF11asParam(0.5f,0.5f,1.0f);.

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

Detailed Description

Contains direct form 1 1st order DF11 compensator with its related structures and functions

Types Documentation

typedef DCL_DF11

typedef _DCL_VOLATILE struct  DCL_DF11;

DCL_DF11 object for storing df11 specific parameters.

Functions Documentation

function DCL_resetDF11

_DCL_CODE_ACCESS void DCL_resetDF11(
    DCL_DF11 * df
)

Resets DF11 internal storage data with interrupt protection.

Parameters:

function DCL_forceUpdateDF11

_DCL_CODE_ACCESS void DCL_forceUpdateDF11(
    DCL_DF11 * df
)

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

Parameters:

  • df Pointer to the active DCL_DF11 controller structure

function DCL_updateDF11NoCheck

_DCL_CODE_ACCESS void DCL_updateDF11NoCheck(
    DCL_DF11 * df
)

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

Parameters:

  • df Pointer to the DCL_DF11 controller structure

function DCL_updateDF11

_DCL_CODE_ACCESS bool DCL_updateDF11(
    DCL_DF11 * df
)

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

Parameters:

  • df Pointer to the DCL_DF11 controller structure

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

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

function DCL_isStableDF11

_DCL_CODE_ACCESS bool DCL_isStableDF11(
    DCL_DF11 * df
)

Determines stability of the shadow DF11 compensator.

Parameters:

  • df Pointer to the DCL_DF11 controller structure

Return: ‘true’ if the pole has magnitude less than 1, ‘false’ otherwise

function DCL_loadDF11asZPK

_DCL_CODE_ACCESS void DCL_loadDF11asZPK(
    DCL_DF11 * df,
    DCL_ZPK3 * zpk
)

Loads the DF11 shadow coefficients from a ZPK3 description.

Parameters:

  • df Pointer to the DCL_DF11 controller structure

  • zpk Pointer to the ZPK3 structure

Note: Note: Sampling period df->css->T are used in the calculation. New settings take effect after DCL_updateDF11(). Only real z1 & p1 considered, all other roots ignored.

function DCL_loadDF11asPI

_DCL_CODE_ACCESS void DCL_loadDF11asPI(
    DCL_DF11 * df,
    float32_t Kp,
    float32_t Ki
)

Loads compensator coefficients to emulate series form PI.

Parameters:

  • df Pointer to the DCL_DF11 controller structure

  • Kp Proportional gain

  • Ki Integral gain

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

function DCL_runDF11

_DCL_CRIT_ACCESSfloat32_t DCL_runDF11(
    DCL_DF11 * df,
    float32_t ek
)

Executes a 1st order Direct Form 1 controller.

Parameters:

  • df Pointer to the DCL_DF11 controller structure

  • ek The servo error

Return: uk The control effort

Macros Documentation

define DF11_SPS_DEFAULTS

#define DF11_SPS_DEFAULTS {0.5f, 0.5f, 1.0f}

brief Defaults for DCL_DF11_SPS

define DF11_DEFAULTS

#define DF11_DEFAULTS {0.5f, 0.5f, 1.0f, 0.0f, 0.0f, &(DCL_DF11_SPS)DF11_SPS_DEFAULTS, &(DCL_CSS)DCL_CSS_DEFAULTS}

Defines default values to initialize DCL_DF11.

define DF11_INT_DEFAULTS

#define DF11_INT_DEFAULTS     .d1 = 0.0f, .d2 = 0.0f, .sps = &(DCL_DF11_SPS)DF11_SPS_DEFAULTS, .css = &(DCL_CSS)DCL_CSS_DEFAULTS

Macro for internal default values to initialize DCL_DF11 Example: DCL_DF11 df11_ctrl = { .b0 = 0.5f, .b1 = 0.5f, .a1 = 1.0f, DF11_INT_DEFAULTS };.

define DCL_initDF11

#define DCL_initDF11(
    
)
&(DCL_DF11)DF11_DEFAULTS

Initialize DCL_DF11 struct with default parameters Example: DCL_DF11* df11_ctrl = DCL_initDF11();.

Return: A DCL_DF11* pointer

define DCL_initDF11asParam

#define DCL_initDF11asParam(
    _b0,
    _b1,
    _a1
)
    &(DCL_DF11)                                            \
    {                                                      \
        .b0 = _b0, .b1 = _b1, .a1 = _a1, DF11_INT_DEFAULTS \
    }

Initialize DCL_DF11 struct with input compensator parameters Example: DCL_DF11* DF11_ctrl = DCL_initDF11asParam(0.5f,0.5f,1.0f);.

Return: A DCL_DF11* pointer

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

define DCL_initDF11asSPS

#define DCL_initDF11asSPS(
    df_ptr,
    sps_ptr
)
    ({                                                                                  \
        DCL_DF11     *new_df  = (df_ptr) ? df_ptr : DCL_initDF11();                     \
        DCL_DF11_SPS *new_sps = (sps_ptr) ? sps_ptr : &(DCL_DF11_SPS)DF11_SPS_DEFAULTS; \
        if (sps_ptr)                                                                    \
        {                                                                               \
            *new_df = (DCL_DF11){(new_sps)->b0,                                         \
                                 (new_sps)->b1,                                         \
                                 (new_sps)->a1,                                         \
                                 0.0f,                                                  \
                                 0.0f,                                                  \
                                 (DCL_DF11_SPS *)new_sps,                               \
                                 &(DCL_CSS)DCL_CSS_DEFAULTS};                           \
        }                                                                               \
        new_df;                                                                         \
    })

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

Parameters:

  • df_ptr DCL_DF11* pointer that needs to be initialized

  • sps_ptr DCL_DF11_SPS* pointer with assigned parameters

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