32 #include "physical_constants.h"
61 float diff = (err - pid->
lastErr);
87 float min_bound,
float max_bound,
float aw_bound)
96 float p =
bound_sym(err * pid->
p, aw_bound) / aw_bound;
104 float diff = (err - pid->
lastErr);
114 float ideal_output = ((err * pid->
p) + pid->
iAccumulator + dterm);
115 float saturation = 0;
116 if (ideal_output > max_bound) {
117 saturation = max_bound - ideal_output;
118 ideal_output = max_bound;
119 }
else if (ideal_output < min_bound) {
120 saturation = min_bound - ideal_output;
121 ideal_output = min_bound;
142 const float measured)
146 float err = setpoint - measured;
149 if(deadband && deadband->
width > 0)
167 float diff = (err_d - pid->
lastErr);
189 const float measured,
float min_bound,
float max_bound,
float aw_bound)
193 float err = setpoint - measured;
196 if(deadband && deadband->
width > 0)
209 float p =
bound_sym(err * pid->
p, aw_bound) / aw_bound;
219 float diff = (err_d - pid->
lastErr);
228 float ideal_output = ((err * pid->
p) + pid->
iAccumulator + dterm);
229 float saturation = 0;
230 if (ideal_output > max_bound) {
231 saturation = max_bound - ideal_output;
232 ideal_output = max_bound;
233 }
else if (ideal_output < min_bound) {
234 saturation = min_bound - ideal_output;
235 ideal_output = min_bound;
313 if(slope < 0.0
f) slope = 0.0f;
314 else if(slope > 1.0
f) slope = 1.0f;
316 deadband->
width = width;
317 deadband->
slope = slope;
float pid_apply_setpoint_antiwindup(struct pid *pid, struct pid_deadband *deadband, const float setpoint, const float measured, float min_bound, float max_bound, float aw_bound)
float cubic_deadband(float in, float w, float b, float m, float r)
static float deriv_gamma
Store the setpoint weight to apply for the derivative term.
void pid_configure(struct pid *pid, float p, float i, float d, float iLim, float dT)
void pid_configure_deadband(struct pid_deadband *deadband, float width, float slope)
float bound_sym(float val, float range)
Bound input value within range (plus or minus)
void pid_zero(struct pid *pid)
void cubic_deadband_setup(float w, float b, float *m, float *r)
float pid_apply(struct pid *pid, const float err)
Methods to use the pid structures.
Includes PiOS and core architecture components.
float integrated_response
float pid_apply_setpoint(struct pid *pid, struct pid_deadband *deadband, const float setpoint, const float measured)
float pid_apply_antiwindup(struct pid *pid, const float err, float min_bound, float max_bound, float aw_bound)
void pid_configure_derivative(float cutoff, float g)
Configure the common terms that alter ther derivative.
static float deriv_tau
Store the shared time constant for the derivative cutoff.