1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*!
@file pid_neuro.h
@brief single neuron proportional integral derivative controller
@details
\f{cases}{
x_i=e(k)\\
x_p=e(k)-e(k-1)\\
x_d=e(k)-2e(k-1)+e(k-2)
\f}
\f{cases}{
\omega_{p}(k)=\omega_{p}(k-1)+\eta_{p}e(k)u(k)x_{p}(k)\\
\omega_{i}(k)=\omega_{i}(k-1)+\eta_{i}e(k)u(k)x_{i}(k)\\
\omega_{d}(k)=\omega_{d}(k-1)+\eta_{d}e(k)u(k)x_{d}(k)
\f}
\f[
u(k)=u(k-1)+K\frac{w_{p}(k)x_{p}(k)+w_{i}(k)x_{i}(k)+w_{d}(k)x_{d}(k)}
{|\omega_{p}(k)|+|\omega_{i}(k)|+|\omega_{d}(k)|}
\f]
*/
#ifndef LIBA_PID_NEURO_H
#define LIBA_PID_NEURO_H
#include "pid.h"
/*!
@ingroup liba
@addtogroup a_pid_neuro single neuron proportional integral derivative controller
@{
*/
typedef struct a_pid_neuro a_pid_neuro;
#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus */
/*!
@brief initialize for single neuron PID controller
@param[in,out] ctx points to an instance of single neuron PID controller
*/
#define a_pid_neuro_init(ctx) a_pid_neuro_zero(ctx)
/*!
@brief set proportional integral derivative constant for single neuron PID controller
@param[in,out] ctx points to an instance of single neuron PID controller
@param[in] k proportional output coefficient
@param[in] kp proportional learning constant
@param[in] ki integral learning constant
@param[in] kd derivative learning constant
*/
A_EXTERN void a_pid_neuro_set_kpid(a_pid_neuro *ctx, a_float k, a_float kp, a_float ki, a_float kd);
/*!
@brief set proportional integral derivative weight for single neuron PID controller
@param[in,out] ctx points to an instance of single neuron PID controller
@param[in] wp proportional weight
@param[in] wi integral weight
@param[in] wd derivative lweight
*/
A_EXTERN void a_pid_neuro_set_wpid(a_pid_neuro *ctx, a_float wp, a_float wi, a_float wd);
/*!
@brief calculate for single neuron PID controller
@param[in,out] ctx points to an instance of single neuron PID controller
@param[in] set setpoint value
@param[in] fdb feedback value
@return setpoint value
*/
A_EXTERN a_float a_pid_neuro_run(a_pid_neuro *ctx, a_float set, a_float fdb);
/*!
@brief calculate for incremental single neuron PID controller
@param[in,out] ctx points to an instance of single neuron PID controller
@param[in] set setpoint value
@param[in] fdb feedback value
@return output value
*/
A_EXTERN a_float a_pid_neuro_inc(a_pid_neuro *ctx, a_float set, a_float fdb);
/*!
@brief zeroing for single neuron PID controller
@param[in,out] ctx points to an instance of single neuron PID controller
*/
A_EXTERN void a_pid_neuro_zero(a_pid_neuro *ctx);
#if defined(__cplusplus)
} /* extern "C" */
namespace a
{
typedef struct a_pid_neuro pid_neuro;
} /* namespace a */
#endif /* __cplusplus */
/*!
@brief instance structure for single neuron PID controller
*/
struct a_pid_neuro
{
a_pid pid; //!< instance structure for PID controller
a_float k; //!< proportional output coefficient
a_float wp; //!< proportional weight
a_float wi; //!< integral weight
a_float wd; //!< derivative weight
a_float ec; //!< error change
#if defined(__cplusplus)
A_INLINE void init() { a_pid_neuro_init(this); }
A_INLINE void set_kpid(a_float k_, a_float kp, a_float ki, a_float kd)
{
a_pid_neuro_set_kpid(this, k_, kp, ki, kd);
}
A_INLINE void set_wpid(a_float wp_, a_float wi_, a_float wd_)
{
a_pid_neuro_set_wpid(this, wp_, wi_, wd_);
}
A_INLINE a_float run(a_float set, a_float fdb)
{
return a_pid_neuro_run(this, set, fdb);
}
A_INLINE a_float inc(a_float set, a_float fdb)
{
return a_pid_neuro_inc(this, set, fdb);
}
A_INLINE void zero() { a_pid_neuro_zero(this); }
#endif /* __cplusplus */
};
/*! @} a_pid_neuro */
#endif /* a/pid_neuro.h */