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
29#ifndef LIBA_PID_H
30#define LIBA_PID_H
31
32#include "a.h"
33
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
143#endif /* a/pid.h */
algorithm library
#define a_float
Definition a.h:785
double a_pid_pos(a_pid *ctx, double set, double fdb)
calculate for positional PID controller
#define a_pid_init(ctx)
initialize for PID controller
Definition pid.h:50
double a_pid_run(a_pid *ctx, double set, double fdb)
calculate for PID controller
void a_pid_set_kpid(a_pid *ctx, double kp, double ki, double kd)
set proportional integral derivative constant for PID controller
void a_pid_zero(a_pid *ctx)
zeroing for PID controller
double a_pid_inc(a_pid *ctx, double set, double fdb)
calculate for incremental PID controller
instance structure for PID controller
Definition pid.h:106
double sum
controller integral output
Definition pid.h:112
double kp
proportional constant
Definition pid.h:107
double err
cache error
Definition pid.h:118
double outmax
maximum final output
Definition pid.h:113
double summin
minimum integral output
Definition pid.h:111
double ki
integral constant
Definition pid.h:108
double out
controller final output
Definition pid.h:115
double fdb
cache feedback
Definition pid.h:117
double outmin
minimum final output
Definition pid.h:114
double var
cache variable
Definition pid.h:116
double kd
derivative constant
Definition pid.h:109
double summax
maximum integral output
Definition pid.h:110