2022-04-26 22:15:13 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
//#include <stdint.h>
|
|
|
|
#include "pico/stdlib.h"
|
|
|
|
//include "common/pimoroni_common.hpp"
|
|
|
|
|
|
|
|
namespace pimoroni {
|
|
|
|
|
|
|
|
class PID {
|
|
|
|
public:
|
2022-04-28 20:23:18 +00:00
|
|
|
PID();
|
2022-04-26 22:15:13 +00:00
|
|
|
PID(float kp, float ki, float kd, float sample_rate);
|
|
|
|
|
|
|
|
float calculate(float value);
|
|
|
|
float calculate(float value, float value_change);
|
|
|
|
|
|
|
|
public:
|
|
|
|
float kp;
|
|
|
|
float ki;
|
|
|
|
float kd;
|
|
|
|
float setpoint;
|
|
|
|
private:
|
|
|
|
float error_sum;
|
|
|
|
float last_value;
|
|
|
|
float sample_rate;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|