PID Controller
.
Introduction.
The PID
Controller
is implemented here in a Standard form.
Parameters:
Here the continuous transfer function representation of the PID.
where:
- \(K_p\) is the proportionnal gain
- \(T_i\) is the integration time
- \(T_d\) is derivative time
- \(N\) help to filter the derivative (typical values \(\in [2, 20]\)).
controller are sampled
We show here the continuous form of the function we want to implement. But calculation are sampled. Relationship to Laplace transform
Discretization:
This Pid()
object is implemented using a backward euler integration method.
We have the following discrete equation implemented:
Use of the PID Controller
.
The use of the Pid
is based on 3 steps.
- Object instanciation (declaration).
- Initialisation.
- Execution.
Example
For each Controller
like (Pid
, Rst
, Pr
) we have to define a parameter structure.
We define constants used to initialize the parameter structure.
#include "pid.h"
static float32_t Ti = 7.5175e-5F;
static float32_t Td = 0.0F;
static float32_t N = 0.0F;
static float32_t upper_bound = 1.0F;
static float32_t lower_bound = 0.0F;
static float32_t Ts = 100.0e-6F;
We define the parameter structure. Each parameter is defined here.
We define the variable pid
which is a Pid
object.
In the setup_routine()
of the OwnTech Power API,
you must initialize the Pid
with its parameters.
In the loop_critical_task()
you can call the method calculateWithReturn()
which have two arguments:
- the reference
- the measure.
Note
Remind that the loop_critical_task()
is called at the sampling time you define and
must be equal to \(T_s\).
new_command
is the result of the pid calculation for one step.
Example
You can find a pid use with the buck voltage mode example which regulates a DC voltage.