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.
shared/PID_Control/PID.h
- Committer:
- e2011220
- Date:
- 2021-04-14
- Revision:
- 0:ee7e9405e1c7
File content as of revision 0:ee7e9405e1c7:
#ifndef PID_H_
#define PID_H_
#include "mbed.h"
class PID
{
public:
PID(): _pid_state()
{}
~PID()
{
_tick_i.detach();
_tick_d.detach();
}
double get_control();
void set_state(double target, double current);
void set_PID(double k, double Ti, double Td);
void reset();
protected:
typedef struct pid_con_s{
double k;
double Ti;
double Td;
double current;
double target;
}pid_con_t;
pid_con_t _pid_state;
virtual double _get_control() = 0;
virtual void _calc_p() = 0;
virtual void _calc_i() = 0;
virtual void _calc_d() = 0;
virtual void _reset() = 0;
private:
Ticker _tick_i, _tick_d;
void _on_isr_i();
void _on_isr_d();
};
#endif