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.
Dependencies: mbed BNO055_fusion_AUV
Diff: PIDusna/PID.h
- Revision:
- 0:37123f30e8b2
- Child:
- 4:e89234ca9d4e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PIDusna/PID.h Tue Jan 14 19:52:12 2020 +0000 @@ -0,0 +1,49 @@ +/* + * PID class for mbed + * US Naval Academy + * Robotics and Control TSD + * Patrick McCorkell + * + * Created: 2019 Dec 11 + * + */ + +#include "mbed.h" + +typedef struct { + float Kp; + float Ki; + float Kd; +} PID_GAINS_TypeDef; + +class PID +{ +public: + PID (float Kp, float Ki, float Kd, int dt, float deadzone=0); + void calculate_K(float Tu); + void set_dt(int dt); + void clear_integral(); + void clear_error(); + void clear_error_previous(); + void clear(); + void set_K(float Kp, float Ki=0, float Kd=0); + void set_deadzone(float deadzone); + float process(float setpoint, float measured); + float process(float error); + void get_gain_values(PID_GAINS_TypeDef *gains); + +protected: + float _Kp; + float _Ki; + float _Kd; + float _floor; + float _deadzone; + int _dt; + float _error_previous; + float _integral; + +//private: + +}; + +