1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
#ifndef PID_h_
#define PID_h_
#include <math.h>
class PID_Calc
{
public:
PID_Calc();
void Reset();
void Reset_Sum();
void Reset_D();
void Calc_Location(double PointValue, double Destination, double Epsilon);
void Set_Multipliers(double K_P, double K_I, double K_D);
void Limits(double Max_Output, double Max_Acceleration, double P_Max_Value, int I_Sum_Max, int D_Filter);
double Calc_PID();
bool Is_Done(int Min_Done_Cycles);
private:
/* Each sensor uses these variables. They need to be plugged into the functions above. Each function is used separately in the main program.*/
// All variables are explained in the Reset function.
double kp, ki, kd, P_Value, I_Value, D_Value;
double P_Full;
int I_Max, I_Sum, Filter;
double Error, P_Error, Distance;
double Point_Value, Current_PV, Prevoius_Point_Value, Velocity;
double Previous_Velocities[10];
int DP_1, DP_2, DP_3;
double DP_4;
double Average_Velocity;
double Max_O, Output, Prev_O, Max_A;
int Out_PN;
int Done_Count;
bool First_Cycle;
};
#endif
| |