liba 0.1.15
An algorithm library based on C/C++
Loading...
Searching...
No Matches
pid_fuzzy.h
Go to the documentation of this file.
1
6#ifndef LIBA_PID_FUZZY_H
7#define LIBA_PID_FUZZY_H
8
9#include "pid.h"
10#include "fuzzy.h"
11
18typedef struct a_pid_fuzzy a_pid_fuzzy;
19
23enum
24{
32};
33
34#if defined(__cplusplus)
35extern "C" {
36#endif /* __cplusplus */
37
42#define a_pid_fuzzy_init(ctx) a_pid_fuzzy_zero(ctx)
43
49A_EXTERN a_float (*a_pid_fuzzy_opr(unsigned int opr))(a_float, a_float);
50
56A_EXTERN void a_pid_fuzzy_set_opr(a_pid_fuzzy *ctx, unsigned int opr);
57
63A_EXTERN void *a_pid_fuzzy_bfuzz(a_pid_fuzzy const *ctx);
64
71A_EXTERN void a_pid_fuzzy_set_bfuzz(a_pid_fuzzy *ctx, void *ptr, a_size num);
72
77#define A_PID_FUZZY_BFUZZ(n) (sizeof(unsigned int) * (n) * 2 + sizeof(a_float) * (n) * (2 + (n)))
78
89A_EXTERN void a_pid_fuzzy_set_rule(a_pid_fuzzy *ctx, unsigned int nrule, a_float const *me, a_float const *mec,
90 a_float const *mkp, a_float const *mki, a_float const *mkd);
91
100
109
118
127
132A_EXTERN void a_pid_fuzzy_zero(a_pid_fuzzy *ctx);
133
134#if defined(__cplusplus)
135} /* extern "C" */
136namespace a
137{
138typedef struct a_pid_fuzzy pid_fuzzy;
139} /* namespace a */
140#endif /* __cplusplus */
141
146{
148
149 a_float const *me;
150 a_float const *mec;
151 a_float const *mkp;
152 a_float const *mki;
153 a_float const *mkd;
154
155 unsigned int *idx;
157
159
163
164 unsigned int nrule;
165 unsigned int nfuzz;
166#if defined(__cplusplus)
167 A_INLINE void init() { a_pid_fuzzy_init(this); }
168 A_INLINE void set_opr(unsigned int opr_)
169 {
170 a_pid_fuzzy_set_opr(this, opr_);
171 }
172 A_INLINE void *bfuzz() const { return a_pid_fuzzy_bfuzz(this); }
173 A_INLINE void set_bfuzz(void *ptr, a_size num)
174 {
175 a_pid_fuzzy_set_bfuzz(this, ptr, num);
176 }
177 A_INLINE void set_rule(unsigned int nrule_, a_float const *me_, a_float const *mec_,
178 a_float const *mkp_, a_float const *mki_, a_float const *mkd_)
179 {
180 a_pid_fuzzy_set_rule(this, nrule_, me_, mec_, mkp_, mki_, mkd_);
181 }
182 A_INLINE void set_kpid(a_float kp_, a_float ki_, a_float kd_)
183 {
184 a_pid_fuzzy_set_kpid(this, kp_, ki_, kd_);
185 }
186 A_INLINE a_float run(a_float set, a_float fdb)
187 {
188 return a_pid_fuzzy_run(this, set, fdb);
189 }
190 A_INLINE a_float pos(a_float set, a_float fdb)
191 {
192 return a_pid_fuzzy_pos(this, set, fdb);
193 }
194 A_INLINE a_float inc(a_float set, a_float fdb)
195 {
196 return a_pid_fuzzy_inc(this, set, fdb);
197 }
198 A_INLINE void zero() { a_pid_fuzzy_zero(this); }
199#endif /* __cplusplus */
200};
201
204#endif /* a/pid_fuzzy.h */
fuzzy operator
#define a_float
Definition a.h:785
void a_pid_fuzzy_set_rule(a_pid_fuzzy *ctx, unsigned int nrule, double const *me, double const *mec, double const *mkp, double const *mki, double const *mkd)
set rule base for fuzzy PID controller
void a_pid_fuzzy_set_opr(a_pid_fuzzy *ctx, unsigned int opr)
set fuzzy relational operator for fuzzy PID controller
void a_pid_fuzzy_zero(a_pid_fuzzy *ctx)
zeroing for fuzzy PID controller
void * a_pid_fuzzy_bfuzz(a_pid_fuzzy const *ctx)
get memory block for fuzzy PID controller
void a_pid_fuzzy_set_bfuzz(a_pid_fuzzy *ctx, void *ptr, size_t num)
set memory block for fuzzy PID controller
double a_pid_fuzzy_inc(a_pid_fuzzy *ctx, double set, double fdb)
calculate for incremental fuzzy PID controller
double a_pid_fuzzy_run(a_pid_fuzzy *ctx, double set, double fdb)
calculate for fuzzy PID controller
#define a_pid_fuzzy_init(ctx)
initialize for fuzzy PID controller
Definition pid_fuzzy.h:42
double a_pid_fuzzy_pos(a_pid_fuzzy *ctx, double set, double fdb)
calculate for positional fuzzy PID controller
void a_pid_fuzzy_set_kpid(a_pid_fuzzy *ctx, double kp, double ki, double kd)
set proportional integral derivative constant for fuzzy PID controller
double(*)(double, double) a_pid_fuzzy_opr(unsigned int opr)
get fuzzy relational operator for fuzzy PID controller
Definition pid_fuzzy.h:49
@ A_PID_FUZZY_CAP
min(a,b)
Definition pid_fuzzy.h:26
@ A_PID_FUZZY_CAP_BOUNDED
max(a+b-1,0)
Definition pid_fuzzy.h:28
@ A_PID_FUZZY_CUP_ALGEBRA
a+b-a*b
Definition pid_fuzzy.h:30
@ A_PID_FUZZY_CUP
max(a,b)
Definition pid_fuzzy.h:29
@ A_PID_FUZZY_CUP_BOUNDED
min(a+b,1)
Definition pid_fuzzy.h:31
@ A_PID_FUZZY_EQU
sqrt(a,b)*sqrt(1-(1-a)*(1-b))
Definition pid_fuzzy.h:25
@ A_PID_FUZZY_CAP_ALGEBRA
a*b
Definition pid_fuzzy.h:27
#define a_size
Definition a.h:610
proportional integral derivative controller
instance structure for fuzzy PID controller
Definition pid_fuzzy.h:146
a_pid pid
instance structure for PID controller
Definition pid_fuzzy.h:147
double * val
the memory block for membership value and membership outer product of e and ec, >= (2+N)N
Definition pid_fuzzy.h:156
double(* opr)(double, double)
fuzzy relational operator
Definition pid_fuzzy.h:158
double const * mkd
points to Kd's rule base, which must be a square matrix
Definition pid_fuzzy.h:153
double const * mec
points to ec's membership function parameter table
Definition pid_fuzzy.h:150
double ki
base integral constant
Definition pid_fuzzy.h:161
double const * me
points to e's membership function parameter table
Definition pid_fuzzy.h:149
double const * mki
points to Ki's rule base, which must be a square matrix
Definition pid_fuzzy.h:152
double const * mkp
points to Kp's rule base, which must be a square matrix
Definition pid_fuzzy.h:151
unsigned int nfuzz
maximum number triggered by the rule
Definition pid_fuzzy.h:165
unsigned int nrule
number of order in the square matrix
Definition pid_fuzzy.h:164
double kp
base proportional constant
Definition pid_fuzzy.h:160
unsigned int * idx
the memory block for membership index, >= 2N
Definition pid_fuzzy.h:155
double kd
base derivative constant
Definition pid_fuzzy.h:162
instance structure for PID controller
Definition pid.h:106