DCL PI Controller Functions
Module: Digital Control Library (DCL)
Structures
Name |
|
|---|---|
struct |
DCL_PI_SPS |
Types
Name |
|
|---|---|
typedef _DCL_VOLATILE struct |
Functions
Name |
|
|---|---|
_DCL_CODE_ACCESS void |
DCL_resetPI(DCL_PI * pi) |
_DCL_CODE_ACCESS void |
DCL_forceUpdatePI(DCL_PI * pi) |
_DCL_CODE_ACCESS void |
DCL_updatePINoCheck(DCL_PI * pi) |
_DCL_CODE_ACCESS bool |
DCL_updatePI(DCL_PI * pi) |
_DCL_CODE_ACCESS void |
DCL_loadSeriesPIasZPK(DCL_PI * pi, DCL_ZPK3 * zpk) |
_DCL_CODE_ACCESS void |
DCL_loadParallelPIasZPK(DCL_PI * pi, DCL_ZPK3 * zpk) |
DCL_runPISeries(DCL_PI * pi, float32_t rk, float32_t yk) |
|
DCL_runPIParallel(DCL_PI * pi, float32_t rk, float32_t yk) |
|
DCL_runPIParallelEnhanced(DCL_PI * pi, float32_t rk, float32_t yk) |
|
DCL_runPISeriesTustin(DCL_PI * pi, float32_t rk, float32_t yk) |
Defines
Name |
|
|---|---|
PI_SPS_DEFAULTS |
|
PI_DEFAULTS |
|
PI_INT_DEFAULTS |
|
DCL_initPI() |
|
DCL_initPIasParam(kp, ki, umax, umin) |
|
DCL_initPIasSPS(pi_ptr, sps_ptr) |
Detailed Description
Contains PI controller with its related structures and functions
Types Documentation
typedef DCL_PI
typedef _DCL_VOLATILE struct DCL_PI;
DCL_PI object for storing PI specific parameters.
Functions Documentation
function DCL_resetPI
_DCL_CODE_ACCESS void DCL_resetPI(
DCL_PI * pi
)
Resets PI internal storage data with interrupt protection.
Parameters:
pi Pointer to the DCL_PI structure
function DCL_forceUpdatePI
_DCL_CODE_ACCESS void DCL_forceUpdatePI(
DCL_PI * pi
)
Loads PI tuning parameter from its SPS parameter without interrupt protection.
Parameters:
pi Pointer to the DCL_PI controller structure
function DCL_updatePINoCheck
_DCL_CODE_ACCESS void DCL_updatePINoCheck(
DCL_PI * pi
)
Loads PI tuning parameter from its SPS parameter with interrupt protection.
Parameters:
pi Pointer to the DCL_PI controller structure
function DCL_updatePI
_DCL_CODE_ACCESS bool DCL_updatePI(
DCL_PI * pi
)
A conditional update based on the update flag. If the update status is set, the function will update PI parameter from its SPS parameter and clear the status flag on completion.
Parameters:
pi Pointer to the DCL_PI controller structure
Return: ‘true’ if an update is applied, otherwise ‘false’
Note: Note: Use DCL_setUpdateStatus(pi) to set the update status.
function DCL_loadSeriesPIasZPK
_DCL_CODE_ACCESS void DCL_loadSeriesPIasZPK(
DCL_PI * pi,
DCL_ZPK3 * zpk
)
Configures a series PI controller in “zero-pole-gain” form.
Parameters:
pi Pointer to the DCL_PI controller structure
zpk Pointer to the ZPK3 structure
Note: Note: Sampling period pi->css->T are used in the calculation. New settings take effect after DCL_updatePI(). Only z1 considered in DCL_ZPK3, other poles & zeros ignored. Zero frequency assumed to be in radians/sec.
function DCL_loadParallelPIasZPK
_DCL_CODE_ACCESS void DCL_loadParallelPIasZPK(
DCL_PI * pi,
DCL_ZPK3 * zpk
)
Configures a parallel PI controller in “zero-pole-gain” form.
Parameters:
pi Pointer to the active DCL_PI controller structure
zpk Pointer to the ZPK3 structure
Note: Note: Sampling period pi->css->T are used in the calculation. New settings take effect after DCL_updatePI(). Zero frequency assumed to be in radians/sec.
function DCL_runPISeries
_DCL_CRIT_ACCESSfloat32_t DCL_runPISeries(
DCL_PI * pi,
float32_t rk,
float32_t yk
)
Executes an inline series form PI controller.
Parameters:
pi Pointer to the DCL_PI structure
rk The controller set-point reference
yk The measured feedback value
Return: The control effort
function DCL_runPIParallel
_DCL_CRIT_ACCESSfloat32_t DCL_runPIParallel(
DCL_PI * pi,
float32_t rk,
float32_t yk
)
Executes a parallel form PI controller Implemented as inline C function.
Parameters:
pi Pointer to the DCL_PI structure
rk The controller set-point reference
yk The measured feedback value
Return: The control effort
function DCL_runPIParallelEnhanced
_DCL_CRIT_ACCESSfloat32_t DCL_runPIParallelEnhanced(
DCL_PI * pi,
float32_t rk,
float32_t yk
)
Executes a parallel form PI controller with enhanced anti-windup logic incorporating an additional integrator saturation clamp.
Parameters:
pi Pointer to the DCL_PI structure
rk The controller set-point reference
yk The measured feedback value
Return: The control effort
function DCL_runPISeriesTustin
_DCL_CRIT_ACCESSfloat32_t DCL_runPISeriesTustin(
DCL_PI * pi,
float32_t rk,
float32_t yk
)
Executes a series form PI controller with Tustin integrator.
Parameters:
pi Pointer to the DCL_PI structure
rk The controller set-point reference
yk The measured feedback value
Return: The control effort
Macros Documentation
define PI_SPS_DEFAULTS
#define PI_SPS_DEFAULTS {1.0f, 0.0f, 1.0f, -1.0f, 1.0f, -1.0f}
Defines default values to initialize DCL_PI_SPS.
define PI_DEFAULTS
#define PI_DEFAULTS {1.0f, 0.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 0.0f, &(DCL_PI_SPS)PI_SPS_DEFAULTS, &(DCL_CSS)DCL_CSS_DEFAULTS}
Defines default values to initialize DCL_PI.
define PI_INT_DEFAULTS
#define PI_INT_DEFAULTS .i6 = 1.0f, .i10 = 0.0f, .i11 = 0.0f, .sps = &(DCL_PI_SPS)PI_SPS_DEFAULTS, .css = &(DCL_CSS)DCL_CSS_DEFAULTS
Macro for internal default values to initialize DCL_PI Example: DCL_PI pi_ctrl = { .Kp = 1.0f, .Ki = 0.0f, .Umax = 1.0f, .Umin = -1.0f, .Imax = 0.0f, .Imin = 0.0f, PI_INT_DEFAULTS };.
define DCL_initPI
#define DCL_initPI(
)
&(DCL_PI)PI_DEFAULTS
Initialize DCL_PI struct with default parameters Example: DCL_PI* pi_ctrl = DCL_initPI();.
Return: A DCL_PI* pointer
define DCL_initPIasParam
#define DCL_initPIasParam(
kp,
ki,
umax,
umin
)
&(DCL_PI) \
{ \
.Kp = kp, .Ki = ki, .Umax = umax, .Umin = umin, PI_INT_DEFAULTS \
}
Initialize DCL_PI struct with input controller parameters Example: DCL_PI* pi_ctrl = DCL_initPIasParam(1.0f,0.0f,1.0f,-1.0f);.
Return: A DCL_PI* pointer
Note: Note: input parameter needs to be in the same order as listed in PI_SPS struct
define DCL_initPIasSPS
#define DCL_initPIasSPS(
pi_ptr,
sps_ptr
)
({ \
DCL_PI *new_pi = (pi_ptr) ? pi_ptr : DCL_initPI(); \
DCL_PI_SPS *new_sps = (sps_ptr) ? sps_ptr : &(DCL_PI_SPS)PI_SPS_DEFAULTS; \
if (sps_ptr) \
{ \
*new_pi = (DCL_PI){(new_sps)->Kp, \
(new_sps)->Ki, \
(new_sps)->Umax, \
(new_sps)->Umin, \
(new_sps)->Imax, \
(new_sps)->Imin, \
1.0f, \
0.0f, \
0.0f, \
(DCL_PI_SPS *)new_sps, \
&(DCL_CSS)DCL_CSS_DEFAULTS}; \
} \
new_pi; \
})
Initialize DCL_PI struct with sps parameters Example: DCL_PI_SPS pi_sps = { .Kp = , .Ki = , …}; DCL_PI pi_ctrl; DCL_initPIasSPS(&pi_ctrl,&pi_sps);.
Parameters:
pi_ptr DCL_PI* pointer that needs to be initialized
sps_ptr DCL_PI_SPS* pointer with assigned parameters
Return: Returns DCL_PI* with set sps parameters, default parameter will be used if sps_ptr is not specified