Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: PID.h
- Revision:
- 2:c8ab3e8d4c51
- Parent:
- 1:4705d8930670
- Child:
- 3:c690a8974246
--- a/PID.h Sun Apr 07 13:52:44 2019 +0000
+++ b/PID.h Sun Apr 14 14:03:46 2019 +0000
@@ -3,33 +3,49 @@
#include "mbed.h"
+typedef enum{
+ pos_PID,
+ vel_PID,
+ P_D,
+ PI_D,
+ I_PD
+} PID_Mode;
class PID {
public:
- PID(Timer *_timer);
- float control(float target, float nowrpm);
- float PI_lateD(float target, float nowrpm);
- float control_P(float target, float nowrpm, float new_Kp);
- float control_PI(float target, float nowrpm);
- void setParameter_pid(float new_Kp, float new_Ki, float new_Kd);
- void setParameter_KuPu(float new_Ku, float new_Pu);
- void reset(float target);
-
- float Ku;
- float Pu;
- float Kp;
- float Ti;
- float Td;
- float Ki;
- float Kd;
+ PID(double* _Input, double* _Output, double* _Setpoint, double _Kp, double _Ki, double _Kd, PID_Mode _mode, Timer *_timer);
+ void control();
+ void setParameter_pid(double new_Kp, double new_Ki, double new_Kd);
+ void setParameter_KuPu(double new_Ku, double new_Pu);
+ void setPIDMode(PID_Mode);
+ void setOutputLimits(double, double);
+ void reset(double target);
private:
+ void Initialize();
+
+ double Ku;
+ double Pu;
+ double Kp;
+ double Ti;
+ double Td;
+ double Ki;
+ double Kd;
+
Timer *timer;
- float integral;
- float prev_hensa;
- float nowtime;
- float prev_time;
- float lateD;
+
+ double *Input;
+ double *Output;
+ double *Setpoint;
+
+ double lastTime;
+ double outMin, outMax;
+ double lastInput;
+ double lastError;
+ double outputSum;
+ double SampleTime;
+
+ PID_Mode mode;
};
#endif