xyControl
0.1
Quadrotor Flight Controller on AVR Basis
|
Simple implementation for multiple floating-point PID Controllers. More...
Files | |
file | pid.h |
PID Library Header. | |
file | pid.c |
PID Library Implementation. | |
Data Structures | |
struct | PIDState |
Data Structure for a single PID Controller. More... | |
Macros | |
#define | ROLL 0 |
Roll index for pidTarget, pidOutput and pidStates. More... | |
#define | PITCH 1 |
Pitch index for pidTarget, pidOutput and pidStates. More... | |
Functions | |
void | pidInit (void) |
Initialize Roll and Pitch PID. More... | |
void | pidTask (void) |
Step the Roll and Pitch PID Controllers. More... | |
void | pidSet (PIDState *pid, double kp, double ki, double kd, double min, double max, double iMin, double iMax) |
Set the parameters of a PID controller. More... | |
double | pidExecute (double should, double is, PIDState *state) |
Execute a single PID Control Step. More... | |
Variables | |
double | pidTarget [2] |
Roll and Pitch target angles. More... | |
double | pidOutput [2] |
Roll and Pitch PID Output. More... | |
PIDState | pidStates [2] |
Roll and Pitch PID States. More... | |
PIDState | pidStates [2] |
Roll and Pitch PID States. More... | |
double | pidTarget [2] |
Roll and Pitch target angles. More... | |
double | pidOutput [2] |
Roll and Pitch PID Output. More... | |
Simple implementation for multiple floating-point PID Controllers.
#define PITCH 1 |
Pitch index for pidTarget, pidOutput and pidStates.
Definition at line 61 of file pid.h.
Referenced by pidTask(), and setMotorSpeeds().
#define ROLL 0 |
Roll index for pidTarget, pidOutput and pidStates.
Definition at line 60 of file pid.h.
Referenced by pidTask(), and setMotorSpeeds().
double pidExecute | ( | double | should, |
double | is, | ||
PIDState * | state | ||
) |
Execute a single PID Control Step.
should | Target value |
is | Measured value |
state | PID State |
Definition at line 54 of file pid.c.
References getSystemTime(), PIDState::intMax, PIDState::intMin, PIDState::kd, PIDState::ki, PIDState::kp, PIDState::last, PIDState::lastError, PIDState::outMax, PIDState::outMin, and PIDState::sumError.
Referenced by pidTask().
void pidInit | ( | void | ) |
Initialize Roll and Pitch PID.
Stores the PID States in pidStates. Also resets pidTarget to zero.
Definition at line 74 of file pid.c.
References PID_D, PID_I, PID_INTMAX, PID_INTMIN, PID_OUTMAX, PID_OUTMIN, PID_P, pidSet(), and pidTarget.
void pidSet | ( | PIDState * | pid, |
double | kp, | ||
double | ki, | ||
double | kd, | ||
double | min, | ||
double | max, | ||
double | iMin, | ||
double | iMax | ||
) |
Set the parameters of a PID controller.
The state variables will be reset to zero.
pid | PIDState to be changed. |
kp | New Proportional constant. |
ki | New Integral constant. |
kd | New Derivative constant. |
min | New minimum Output. |
max | New maximum Output. |
iMin | New minimal Integral Sum. |
iMax | New maximal Integral Sum. |
Definition at line 81 of file pid.c.
References PIDState::intMax, PIDState::intMin, PIDState::kd, PIDState::ki, PIDState::kp, PIDState::last, PIDState::lastError, PIDState::outMax, PIDState::outMin, and PIDState::sumError.
Referenced by pidInit().
void pidTask | ( | void | ) |
Step the Roll and Pitch PID Controllers.
Placing their output in pidOutput and reading the input from pidTarget and the global orientation Angles.
Definition at line 94 of file pid.c.
References orientation, pidExecute(), pidOutput, pidTarget, Angles::pitch, PITCH, Angles::roll, and ROLL.
double pidOutput[2] |
double pidOutput[2] |
PIDState pidStates[2] |
double pidTarget[2] |
double pidTarget[2] |