Getting started
Control library has been written in c++, the library is a set of object you can instanciate.
Each Controller
is in a different file (pid.cpp, rst.cpp, pr.cpp
).
It has mainly been developped to be used with The OwnTech Power API based on Zephyr and integrated with PlatformIO.
Installation
Control library has been designed to be integrated as a PlatformIO library.
To use it, you need to add the line below in the platformio.ini
file.
Using the Pid()
Controller
.
To introduce the control library, we propose to implement a PID regulator.
The use of the Pid
is based on 3 steps.
- Object instanciation (declaration).
- Initialisation.
- Execution.
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.
new_command
is the result of the pid calculation for one step.
Note
Remind that the loop_critical_task()
is called at the sampling time you define and
must be equal to \(T_s\).