PI-Controller

Toolbox for a standard PI-Controller in either parallel or ideal form. The transfer function of the parallel implementation is:

\[\frac{Y(s)}{E(s)}=K_p +\frac{K_i}{s}\]

Whilst the transfer function of the ideal implementation is:

\[\frac{Y(s)}{E(s)}=K_p (1 + \frac{K_i}{s})\]

It has a configurable output limitation with internal clamping to prevent the integrator from rising further if the output limitation is active. An input port for an external clamping signal is available as well.

Setup

Configuration

enum uz_PI_Controller_select

enum for readable configuring for the selection of PI-Controller structure

Values:

enumerator parallel
enumerator ideal
struct uz_PI_Controller_config

Configuration struct for PI-Controller. Pass to init function. Accessible by the user.

Public Members

enum uz_PI_Controller_select type

Selection for parallel or ideal PI-Controller

float Kp

Proportional gain for PI-Controller. Must be greater or equal than 0.0f

float Ki

Integral gain for PI-Controller. Must be greater or equal than 0.0f

float samplingTime_sec

SamplingTime of the PI-Controller in seconds. Must be greater than 0.0f

float upper_limit

Upper limit for the output limitation. Must be greater than lower limit

float lower_limit

Lower limit for the output limitation

Example

Listing 81 Example to initialize the configuration struct
 1#include "uz/uz_piController/uz_piController.h"
 2int main(void) {
 3   struct uz_PI_Controller_config config = {
 4      .type = parallel,
 5      .Kp = 10.0f,
 6      .Ki = 10.0f,
 7      .samplingTime_sec = 0.00005f,
 8      .upper_limit = 10.0f,
 9      .lower_limit = -10.0f
10   };
11}

Description

With this config struct one can customize the PI-Controller variables. It has to be initialized before the init-function is called.

Init function

typedef struct uz_PI_Controller uz_PI_Controller

Object definition for generating a PI-Controller.

uz_PI_Controller *uz_PI_Controller_init(struct uz_PI_Controller_config config)

Initialization of the PI-Controller object.

Parameters:
  • config – uz_PI_Controller_config configuration struct

Returns:

Pointer to uz_PI_Controller instance

Example

Listing 82 Example function call to init a PI-Controller instance. Config according to configuration section
1int main(void) {
2   uz_PI_Controller *PI_instance = uz_PI_Controller_init(config);
3}

Description

Allocates the memory for the PI-Controller instance and asserts the input values of the configuration struct.

Reset

void uz_PI_Controller_reset(uz_PI_Controller *self)

Resets the PI-Controller.

Parameters:
  • self – uz_PI_Controller instance

Example

Listing 83 Example function call to reset the PI-Controller output. PI-Instance via init-function
1int main(void) {
2   uz_PI_Controller_reset(PI_instance);
3}

Description

Resets the PI-Controller. The initial condition for the integrator after the reset is 0.0f.

Functions