liba 0.1.15
An algorithm library based on C/C++
 
Loading...
Searching...
No Matches
pid.h
Go to the documentation of this file.
1
28
29#ifndef LIBA_PID_H
30#define LIBA_PID_H
31
32#include "a.h"
33
39
40typedef struct a_pid a_pid;
41
42#if defined(__cplusplus)
43extern "C" {
44#endif /* __cplusplus */
45
50#define a_pid_init(ctx) a_pid_zero(ctx)
51
60
69
78
87
92A_EXTERN void a_pid_zero(a_pid *ctx);
93
94#if defined(__cplusplus)
95} /* extern "C" */
96namespace a
97{
98typedef struct a_pid pid;
99} /* namespace a */
100#endif /* __cplusplus */
101
105struct a_pid
106{
119#if defined(__cplusplus)
120 A_INLINE void init() { a_pid_init(this); }
121 A_INLINE void set_kpid(a_float kp_, a_float ki_, a_float kd_)
122 {
123 a_pid_set_kpid(this, kp_, ki_, kd_);
124 }
125 A_INLINE a_float run(a_float set, a_float fdb_)
126 {
127 return a_pid_run(this, set, fdb_);
128 }
129 A_INLINE a_float pos(a_float set, a_float fdb_)
130 {
131 return a_pid_pos(this, set, fdb_);
132 }
133 A_INLINE a_float inc(a_float set, a_float fdb_)
134 {
135 return a_pid_inc(this, set, fdb_);
136 }
137 A_INLINE void zero() { a_pid_zero(this); }
138#endif /* __cplusplus */
139};
140
142
143#endif /* a/pid.h */
algorithm library
double a_float
compiler built-in floating-point number type
Definition a.h:1003
void a_pid_set_kpid(a_pid *ctx, a_float kp, a_float ki, a_float kd)
set proportional integral derivative constant for PID controller
#define a_pid_init(ctx)
initialize for PID controller
Definition pid.h:50
a_float a_pid_inc(a_pid *ctx, a_float set, a_float fdb)
calculate for incremental PID controller
void a_pid_zero(a_pid *ctx)
zeroing for PID controller
a_float a_pid_pos(a_pid *ctx, a_float set, a_float fdb)
calculate for positional PID controller
a_float a_pid_run(a_pid *ctx, a_float set, a_float fdb)
calculate for PID controller
instance structure for PID controller
Definition pid.h:106
a_float var
Definition pid.h:116
a_float kd
Definition pid.h:109
a_float kp
Definition pid.h:107
a_float ki
Definition pid.h:108
a_float fdb
Definition pid.h:117
a_float sum
Definition pid.h:112
a_float err
Definition pid.h:118
a_float summin
Definition pid.h:111
a_float out
Definition pid.h:115
a_float summax
Definition pid.h:110
a_float outmax
Definition pid.h:113
a_float outmin
Definition pid.h:114