2022-04-26 23:15:13 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
//#include <stdint.h>
|
|
|
|
#include "pico/stdlib.h"
|
|
|
|
//include "common/pimoroni_common.hpp"
|
|
|
|
|
|
|
|
namespace pimoroni {
|
|
|
|
|
|
|
|
class PID {
|
|
|
|
public:
|
2022-04-28 21:23:18 +01:00
|
|
|
PID();
|
2022-04-26 23:15:13 +01: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;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|