DCL Non-Linear PID Controller Functions

Module: Digital Control Library (DCL)

More…

Structures

Name

struct

DCL_NLPID_SPS
Defines the shadow DCL_NLPID controller structure.

Types

Name

typedef _DCL_VOLATILE struct

DCL_NLPID
Defines the active DCL_NLPID controller structure.

Functions

Name

_DCL_CODE_ACCESS void

DCL_resetNLPID(DCL_NLPID * pid)
Resets NLPID internal storage data with interrupt protection.

_DCL_CODE_ACCESS void

DCL_forceUpdateNLPID(DCL_NLPID * pid)
Loads NLPID tuning parameter from its SPS parameter without interrupt protection.

_DCL_CODE_ACCESS void

DCL_updateNLPIDNoCheck(DCL_NLPID * pid)
Loads PID tuning parameter from its SPS parameter with interrupt protection.

_DCL_CODE_ACCESS bool

DCL_updateNLPID(DCL_NLPID * pid)
A conditional update based on the update flag. If the update status is set, the function will update NLPID parameter from its SPS parameter and clear the status flag on completion.

_DCL_CODE_ACCESS void

DCL_setNLPIDfilterBW(DCL_NLPID * pid, float32_t fc)
Loads the shadow derivative LP filter coefficients.

_DCL_CODE_ACCESS void

DCL_setActiveNLPIDfilterBW(DCL_NLPID * pid, float32_t fc, float32_t T)
Loads the NLPID derivative path filter active coefficients.

_DCL_CODE_ACCESSfloat32_t

DCL_getNLPIDfilterBW(DCL_NLPID * pid)
Returns the derivative LP filter bandwidth in Hz.

_DCL_CODE_ACCESSfloat32_t

DCL_getNLPIDgamma(float32_t alpha, float32_t delta)
Returns the linearized region gain for specified (alpha,delta)

_DCL_CODE_ACCESSfloat32_t

DCL_getNLPIDdelta(float32_t alpha, float32_t gamma)
Returns the semi-width of the linear gain region for specified (alpha,gamma)

_DCL_CODE_ACCESS void

DCL_setNLPIDgamma(DCL_NLPID * pid)
Computes the linearized gains for each path Note: active coefficients not update DCL_updateNLPID() called.

_DCL_CODE_ACCESS void

DCL_setActiveNLPIDgamma(DCL_NLPID * pid)
Computes the linearized gains for each path and loads the parameters in the active NLPID structure.

_DCL_CRIT_ACCESSfloat32_t

DCL_runNLPIDParallel(DCL_NLPID * pid, float32_t rk, float32_t yk, float32_t lk)
Executes a parallel form non-linear PID controller.

_DCL_CRIT_ACCESSfloat32_t

DCL_runNLPIDSeries(DCL_NLPID * pid, float32_t rk, float32_t yk, float32_t lk)
Executes a series form non-linear PID controller.

_DCL_CRIT_ACCESSfloat32_t

DCL_runNLF(float32_t x, float32_t alpha, float32_t delta)
Executes a basic non-linear control function.

Defines

Name

DCL_DELTA_MIN
Sets the lower bound on the linear region semi-width.

DCL_GAMMA_MAX
Sets an upper bound on allowable controller gain, and therefore fixes the minimum linear region semi-width.

NLPID_SPS_DEFAULTS
Defines default values to initialize the DCL_NLPID structure.

NLPID_DEFAULTS
Defines default values to initialize the DCL_NLPID structure.

NLPID_INT_DEFAULTS
Macro for internal default values to initialize DCL_NLPID Example: DCL_NLPID nlpid_ctrl = { .Kp = 1.0f, .Ki = 0.0f, … .Umin = -1.0f, NLPID_INT_DEFAULTS };.

Detailed Description

Contains 32-bit non-linear PID controller with its related structures and functions

Types Documentation

typedef DCL_NLPID

typedef _DCL_VOLATILE struct  DCL_NLPID;

Defines the active DCL_NLPID controller structure.

Functions Documentation

function DCL_resetNLPID

_DCL_CODE_ACCESS void DCL_resetNLPID(
    DCL_NLPID * pid
)

Resets NLPID internal storage data with interrupt protection.

Parameters:

function DCL_forceUpdateNLPID

_DCL_CODE_ACCESS void DCL_forceUpdateNLPID(
    DCL_NLPID * pid
)

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

Parameters:

  • pid Pointer to the active DCL_NLPID controller structure

function DCL_updateNLPIDNoCheck

_DCL_CODE_ACCESS void DCL_updateNLPIDNoCheck(
    DCL_NLPID * pid
)

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

Parameters:

function DCL_updateNLPID

_DCL_CODE_ACCESS bool DCL_updateNLPID(
    DCL_NLPID * pid
)

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

Parameters:

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

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

function DCL_setNLPIDfilterBW

_DCL_CODE_ACCESS void DCL_setNLPIDfilterBW(
    DCL_NLPID * pid,
    float32_t fc
)

Loads the shadow derivative LP filter coefficients.

Parameters:

  • pid Pointer to the DCL_NLPID structure

  • fc The desired filter bandwidth in Hz

Note: Note: active coefficients unchanged DCL_updateNLPID() called

function DCL_setActiveNLPIDfilterBW

_DCL_CODE_ACCESS void DCL_setActiveNLPIDfilterBW(
    DCL_NLPID * pid,
    float32_t fc,
    float32_t T
)

Loads the NLPID derivative path filter active coefficients.

Parameters:

  • pid Pointer to the DCL_NLPID structure

  • fc The desired filter bandwidth in Hz

  • T The controller update rate in seconds

Note: Note: new coefficients take effect immediately. SPS & CSS contents are unaffected.

function DCL_getNLPIDfilterBW

_DCL_CODE_ACCESSfloat32_t DCL_getNLPIDfilterBW(
    DCL_NLPID * pid
)

Returns the derivative LP filter bandwidth in Hz.

Parameters:

Return: The filter bandwidth in Hz

function DCL_getNLPIDgamma

_DCL_CODE_ACCESSfloat32_t DCL_getNLPIDgamma(
    float32_t alpha,
    float32_t delta
)

Returns the linearized region gain for specified (alpha,delta)

Parameters:

  • alpha The non-linear gain

  • delta The linear region semi-width

Return: The linear region gain (gamma)

function DCL_getNLPIDdelta

_DCL_CODE_ACCESSfloat32_t DCL_getNLPIDdelta(
    float32_t alpha,
    float32_t gamma
)

Returns the semi-width of the linear gain region for specified (alpha,gamma)

Parameters:

  • alpha The non-linear gain

  • gamma The linear region gain

Return: The linear region semi-width

function DCL_setNLPIDgamma

_DCL_CODE_ACCESS void DCL_setNLPIDgamma(
    DCL_NLPID * pid
)

Computes the linearized gains for each path Note: active coefficients not update DCL_updateNLPID() called.

Parameters:

function DCL_setActiveNLPIDgamma

_DCL_CODE_ACCESS void DCL_setActiveNLPIDgamma(
    DCL_NLPID * pid
)

Computes the linearized gains for each path and loads the parameters in the active NLPID structure.

Parameters:

function DCL_runNLPIDParallel

_DCL_CRIT_ACCESSfloat32_t DCL_runNLPIDParallel(
    DCL_NLPID * pid,
    float32_t rk,
    float32_t yk,
    float32_t lk
)

Executes a parallel form non-linear PID controller.

Parameters:

  • pid Pointer to the DCL_NLPID structure

  • rk The controller set-point reference

  • yk The measured feedback value

  • lk External output clamp flag

Return: The control effort

function DCL_runNLPIDSeries

_DCL_CRIT_ACCESSfloat32_t DCL_runNLPIDSeries(
    DCL_NLPID * pid,
    float32_t rk,
    float32_t yk,
    float32_t lk
)

Executes a series form non-linear PID controller.

Parameters:

  • pid Pointer to the DCL_NLPID structure

  • rk The controller set-point reference

  • yk The measured feedback value

  • lk External output clamp flag

Return: The control effort

function DCL_runNLF

_DCL_CRIT_ACCESSfloat32_t DCL_runNLF(
    float32_t x,
    float32_t alpha,
    float32_t delta
)

Executes a basic non-linear control function.

Parameters:

  • x The input variable

  • alpha The non-linear exponent

  • delta The linear region semi-width

Return: The non-linear output

Macros Documentation

define DCL_DELTA_MIN

#define DCL_DELTA_MIN 1.0e-04f

Sets the lower bound on the linear region semi-width.

define DCL_GAMMA_MAX

#define DCL_GAMMA_MAX 100

Sets an upper bound on allowable controller gain, and therefore fixes the minimum linear region semi-width.

define NLPID_SPS_DEFAULTS

#define NLPID_SPS_DEFAULTS     {1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.1f, 0.1f, 0.1f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f}

Defines default values to initialize the DCL_NLPID structure.

define NLPID_DEFAULTS

#define NLPID_DEFAULTS     {1.0f,                               \
     0.0f,                               \
     0.0f,                               \
     1.0f,                               \
     1.0f,                               \
     1.0f,                               \
     0.1f,                               \
     0.1f,                               \
     0.1f,                               \
     1.0f,                               \
     1.0f,                               \
     1.0f,                               \
     1.0f,                               \
     0.0f,                               \
     1.0f,                               \
     -1.0f,                              \
     0.0f,                               \
     0.0f,                               \
     0.0f,                               \
     1.0f,                               \
     0.0f,                               \
     &(DCL_NLPID_SPS)NLPID_SPS_DEFAULTS, \
     &(DCL_CSS)DCL_CSS_DEFAULTS}

Defines default values to initialize the DCL_NLPID structure.

define NLPID_INT_DEFAULTS

#define NLPID_INT_DEFAULTS     .d2 = 0.0f, .d3 = 0.0f, .i7 = 0.0f, .i16 = 1.0f, i18 = 0.0f, .sps = &(DCL_PID_SPS)PID_SPS_DEFAULTS, \
    .css = &(DCL_CSS)DCL_CSS_DEFAULTS

Macro for internal default values to initialize DCL_NLPID Example: DCL_NLPID nlpid_ctrl = { .Kp = 1.0f, .Ki = 0.0f, … .Umin = -1.0f, NLPID_INT_DEFAULTS };.