Anti-Sway Capstone 1.0
Loading...
Searching...
No Matches
discrete-lib.h
Go to the documentation of this file.
1
13#ifndef DISCRETE_LIB_H_
14#define DISCRETE_LIB_H_
15
16#include <float.h>
17
18
19/* Non-saturation constants */
20
21
23#define POS_INF DBL_MAX
25#define NEG_INF (-DBL_MAX)
26
27
28/* Discrete-Time Data Structures */
29
30
36typedef struct {
38
40 double numerator[3];
42
44 double denominator[3];
46
48 double prev_input[2];
50
52 double prev_output[2];
53} Biquad;
54
60typedef float Proportional;
61
67typedef struct {
69 double prev_input;
70 double prev_output;
72
78typedef struct {
80 double prev_input;
81 double prev_output;
83
84
85/* Initialization Functions */
86
87
99void IntegratorInit(Proportional gain, double timestep, Integrator *result);
100
113 double timestep,
114 Differentiator *result);
115
116
117/* Time-Stepping Functions */
118
119
136inline double Cascade(double input,
137 Biquad sys[],
138 int size,
139 double lower_lim,
140 double upper_lim);
141
156inline double Integrate(double input,
157 Integrator *term,
158 double lower_lim,
159 double upper_lim);
160
175inline double Differentiate(double input,
176 Differentiator *term,
177 double lower_lim,
178 double upper_lim);
179
198inline double PID(double input,
199 Proportional *p,
200 Integrator *i,
202 double lower_lim,
203 double upper_lim);
204
205#endif // DISCRETE_LIB_H_
double Differentiate(double input, Differentiator *term, double lower_lim, double upper_lim)
Definition discrete-lib.c:101
void IntegratorInit(Proportional gain, double timestep, Integrator *result)
Definition discrete-lib.c:53
double Cascade(double input, Biquad sys[], int size, double lower_lim, double upper_lim)
Definition discrete-lib.c:71
float Proportional
Control Block: Proportion.
Definition discrete-lib.h:60
double Integrate(double input, Integrator *term, double lower_lim, double upper_lim)
Definition discrete-lib.c:89
double PID(double input, Proportional *p, Integrator *i, Differentiator *d, double lower_lim, double upper_lim)
Definition discrete-lib.c:114
void DifferentiatorInit(Proportional gain, double timestep, Differentiator *result)
Definition discrete-lib.c:59
Biquad.
Definition discrete-lib.h:36
Control Block: Differentiator.
Definition discrete-lib.h:78
double prev_input
Previous input.
Definition discrete-lib.h:80
double prev_output
Previous output.
Definition discrete-lib.h:81
Proportional gain
Differential Gain (with Timestep)
Definition discrete-lib.h:79
Control Block: Integrator.
Definition discrete-lib.h:67
double prev_input
Previous input.
Definition discrete-lib.h:69
double prev_output
Previous output.
Definition discrete-lib.h:70
Proportional gain
Integral Gain (with Timestep)
Definition discrete-lib.h:68