Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Precision PI Controller

Precision PI Controller. More...

Data Structures

struct  precision_pi
 State of an independent proportional-integral controller. More...

Functions

void precision_pi_init (struct precision_pi *pi, double kp, double ki)
 Initialize a PI controller.
void precision_pi_reset (struct precision_pi *pi)
 Reset the accumulated integral term.
void precision_pi_set_limits (struct precision_pi *pi, double integral_limit, double output_limit)
 Set the limits of a PI controller.
double precision_pi_update (struct precision_pi *pi, double error)
 Update a PI controller from an error sample.
double precision_pi_update_interval (struct precision_pi *pi, double error, double interval)
 Update a PI controller from an error sample taken after an interval.

Detailed Description

Precision PI Controller.

Since
4.5
Version
0.2.0

Function Documentation

◆ precision_pi_init()

void precision_pi_init ( struct precision_pi * pi,
double kp,
double ki )

#include <zephyr/precision_timing/precision_pi.h>

Initialize a PI controller.

Parameters
piController instance.
kpProportional gain.
kiIntegral gain.

◆ precision_pi_reset()

void precision_pi_reset ( struct precision_pi * pi)

#include <zephyr/precision_timing/precision_pi.h>

Reset the accumulated integral term.

The configured gains are preserved.

Parameters
piController instance.

◆ precision_pi_set_limits()

void precision_pi_set_limits ( struct precision_pi * pi,
double integral_limit,
double output_limit )

#include <zephyr/precision_timing/precision_pi.h>

Set the limits of a PI controller.

The integral term is held within +-integral_limit, so it cannot wind up while a large error lasts. The output is held within +-output_limit, and while the output is at that limit the integral term does not move further towards it. A limit of 0 disables it, which is the state after precision_pi_init().

Parameters
piController instance.
integral_limitLargest magnitude of the integral term, 0 for no limit.
output_limitLargest magnitude of the output, 0 for no limit.

◆ precision_pi_update()

double precision_pi_update ( struct precision_pi * pi,
double error )

#include <zephyr/precision_timing/precision_pi.h>

Update a PI controller from an error sample.

Same as precision_pi_update_interval() with an interval of 1.

Parameters
piController instance.
errorCurrent control error.
Returns
Controller output.

◆ precision_pi_update_interval()

double precision_pi_update_interval ( struct precision_pi * pi,
double error,
double interval )

#include <zephyr/precision_timing/precision_pi.h>

Update a PI controller from an error sample taken after an interval.

The gains are given for an interval of 1 and are divided by interval. When the plant integrates the output over the interval, as a clock does with a rate correction, the loop gains per sample are then kp and ki for any interval, so the loop keeps its stability and damping when the sample rate changes.

Parameters
piController instance.
errorCurrent control error.
intervalTime since the previous sample, in the unit the gains are given for. Must be greater than 0.
Returns
Controller output.