blob: 19d5768dc06f03e5bf2c2c2637e6225d3d76efea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#ifndef PID_H
#define PID_H
// Based on the excellent Wikipedia PID control article.
// See http://en.wikipedia.org/wiki/PID_controller
#if MOTHERBOARD != 2
class PIDcontrol
{
private:
bool doingBed;
unsigned long previousTime; // ms
unsigned long time;
float previousError;
float integral;
float pGain;
float iGain;
float dGain;
byte heat_pin, temp_pin;
int currentTemperature, targetTemperature;
void internalTemperature(short table[][2]);
public:
PIDcontrol(byte hp, byte tp, bool b);
void setTarget(int t);
int getTarget();
void pidCalculation();
void shutdown();
int temperature();
};
inline int PIDcontrol::temperature()
{
return currentTemperature;
}
inline int PIDcontrol::getTarget()
{
return targetTemperature;
}
inline void PIDcontrol::shutdown()
{
analogWrite(heat_pin, 0);
}
#endif
#endif
|