Documentation
Tools for embedded systems
Loading...
Searching...
No Matches
qpid.h
1
10#ifndef QPID_H
11#define QPID_H
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17 #include <stdlib.h>
18 #include <stdint.h>
19 #include "qnuma.h"
20
29 typedef struct {
30 float Kc;
31 float Ki;
32 float Kd;
34
44
52
53
61
67 typedef struct
68 {
70 float p00, p01, p10, p11; /*covariance values*/
71 float b1, a1; /*estimation values*/
72 float uk, yk; /*process I/O measurements*/
73 float l, il; /*memory factor [ 0.9 < l < 1 ]*/
74 float k, tao; /*process metrics*/
75 float mu, speed; /*fine adjustments [ 0 < mu < speed ] [ 0 < speed < 1 ]*/
76 uint32_t it; /*enable time*/
79
83 #define QPID_AUTOTUNING_UNDEFINED ( 0xFFFFFFFEUL )
84
90 typedef struct
91 {
93 float kc, ki, kd, b, c, dt, min, max, epsilon, kw, kt, D, u1, beta, uSat;
94 float m, mInput;
95 const float *yr;
96 float alfa, gamma; /*MRAC additive controller parameters*/
97 qNumA_state_t c_state; /*controller integral & derivative state*/
98 qNumA_state_t m_state; /*MRAC additive controller state*/
99 qNumA_state_t b_state; /*Bumples-transfer state*/
100 qPID_AutoTuning_t *adapt;
101 qNumA_IntegrationMethod_t integrate;
102 qPID_Mode_t mode;
104 qPID_Type_t type;
105 uint8_t init;
108
118 int qPID_Setup( qPID_controller_t * const c,
119 const float kc,
120 const float ki,
121 const float kd,
122 const float dt );
123
131 const qPID_Direction_t d );
132
142 int qPID_SetParams( qPID_controller_t * const c,
143 const float kc,
144 const float ti,
145 const float td );
146
155 int qPID_SetGains( qPID_controller_t * const c,
156 const float kc,
157 const float ki,
158 const float kd );
159
169 const float kw,
170 const float kt );
171
177 int qPID_Reset( qPID_controller_t * const c );
178
187 const float min,
188 const float max );
189
196 int qPID_SetSeries( qPID_controller_t * const c );
197
204 int qPID_SetEpsilon( qPID_controller_t * const c,
205 const float eps );
206
214 const float beta );
215
228 const float gb,
229 const float gc );
230
240 const float manualInput );
241
254 int qPID_SetMode( qPID_controller_t * const c,
255 const qPID_Mode_t m );
256
264 int qPID_SetMRAC( qPID_controller_t * const c,
265 const float *modelRef,
266 const float gamma );
267
279 float qPID_Control( qPID_controller_t * const c,
280 const float w,
281 const float y );
282
292 qPID_AutoTuning_t * const at );
293
306 const uint32_t tEnable );
307
314 int qPID_AutoTuningComplete( const qPID_controller_t * const c );
315
325 const float mu,
326 const float alfa,
327 const float lambda );
342 qNumA_IntegrationMethod_t im );
343
344
345 bool qPID_AutoTunningControllerType( qPID_controller_t *c,
346 const qPID_Type_t t );
347
350#ifdef __cplusplus
351}
352#endif
353
354#endif
int qPID_SetDirection(qPID_controller_t *const c, const qPID_Direction_t d)
Set the PID control action direction.
Definition qpid.c:55
qPID_Mode_t
Enumeration with the operational modes for the PID controller.
Definition qpid.h:48
qPID_Direction_t
Direction modes of the PID controller.
Definition qpid.h:57
float qPID_Control(qPID_controller_t *const c, const float w, const float y)
Computes the control action for given PID controller instance.
Definition qpid.c:265
int qPID_AutoTuningComplete(const qPID_controller_t *const c)
Verifies that the auto tuning process has finished with new gains set on the controller.
Definition qpid.c:480
int qPID_SetParams(qPID_controller_t *const c, const float kc, const float ti, const float td)
Set/Change the PID controller gains by using the [Kc, Ti Td ] triplet.
Definition qpid.c:68
int qPID_Reset(qPID_controller_t *const c)
Reset the internal PID controller calculations.
Definition qpid.c:118
int qPID_SetManualInput(qPID_controller_t *const c, const float manualInput)
Set the PID manual input mode. This value will be used as the manual input when the controller it set...
Definition qpid.c:224
int qPID_SetSeries(qPID_controller_t *const c)
Convert the controller gains to conform the series or interacting form.
Definition qpid.c:151
int qPID_AutoTuningSetParameters(qPID_controller_t *const c, const float mu, const float alfa, const float lambda)
Change parameters of the auto-tuning algorithm.
Definition qpid.c:494
int qPID_SetExtraGains(qPID_controller_t *const c, const float kw, const float kt)
Set/Change extra PID controller gains.
Definition qpid.c:103
int qPID_SetSaturation(qPID_controller_t *const c, const float min, const float max)
Setup the output saturation for the PID controller.
Definition qpid.c:136
int qPID_BindAutoTuning(qPID_controller_t *const c, qPID_AutoTuning_t *const at)
Binds the specified instance to enable the PID controller auto tuning algorithm.
Definition qpid.c:320
int qPID_EnableAutoTuning(qPID_controller_t *const c, const uint32_t tEnable)
Set the number of time steps where the auto tuner algorithm will modify the controller gains.
Definition qpid.c:358
int qPID_SetReferenceWeighting(qPID_controller_t *const c, const float gb, const float gc)
Set the PID Reference(Set-Point) Weighting. This value is used in order to avoid the increase of the ...
Definition qpid.c:209
int qPID_SetDerivativeFilter(qPID_controller_t *const c, const float beta)
Set the tuning parameter for the derivative filter.
Definition qpid.c:183
int qPID_SetMode(qPID_controller_t *const c, const qPID_Mode_t m)
Change the controller operational mode. In qPID_Automatic mode, the computed output of the PID contro...
Definition qpid.c:196
int qPID_SetMRAC(qPID_controller_t *const c, const float *modelRef, const float gamma)
Enable the additive MRAC(Model Reference Adaptive Control) feature.
Definition qpid.c:237
int qPID_SetIntegrationMethod(qPID_controller_t *const c, qNumA_IntegrationMethod_t im)
Set integration method for the PID controller.
Definition qpid.c:539
qPID_Type_t
Enumeration class with the operational modes for the PID controller.
Definition qpid.h:38
int qPID_SetGains(qPID_controller_t *const c, const float kc, const float ki, const float kd)
Set/Change the PID controller gains.
Definition qpid.c:85
int qPID_Setup(qPID_controller_t *const c, const float kc, const float ki, const float kd, const float dt)
Setup and initialize the PID controller instance.
Definition qpid.c:25
int qPID_SetEpsilon(qPID_controller_t *const c, const float eps)
Set the minimum value considered as error.
Definition qpid.c:170
@ qPID_Manual
Definition qpid.h:50
@ qPID_Automatic
Definition qpid.h:49
@ qPID_Backward
Definition qpid.h:59
@ qPID_Forward
Definition qpid.h:58
@ qPID_TYPE_PD
Definition qpid.h:40
@ qPID_TYPE_P
Definition qpid.h:39
@ qPID_TYPE_PI
Definition qpid.h:41
@ qPID_TYPE_PID
Definition qpid.h:42
Definition qnuma.h:19
A PID Auto-tuning object.
Definition qpid.h:68
PID Gains structure.
Definition qpid.h:29
float Kc
Definition qpid.h:30
float Ki
Definition qpid.h:31
float Kd
Definition qpid.h:32
A PID controller object.
Definition qpid.h:91