dd

Dependencies:   BufferedSerial FastAnalogIn FastPWM mbed SHT75

Committer:
sbh9428
Date:
Fri Mar 25 00:10:39 2016 +0000
Revision:
3:72644690e2e6
Parent:
2:4c51394fb35b
Child:
4:7ca449fca19b
00;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sbh9428 0:9bfc4aea91e2 1 /*
sbh9428 0:9bfc4aea91e2 2 * controlt.h
sbh9428 0:9bfc4aea91e2 3 *
sbh9428 0:9bfc4aea91e2 4 * Created on: 2016. 2. 19.
sbh9428 0:9bfc4aea91e2 5 * Author: sbh9428
sbh9428 0:9bfc4aea91e2 6 */
sbh9428 0:9bfc4aea91e2 7
sbh9428 0:9bfc4aea91e2 8 #ifndef CONTROLT_H_
sbh9428 0:9bfc4aea91e2 9 #define CONTROLT_H_
sbh9428 0:9bfc4aea91e2 10
sbh9428 2:4c51394fb35b 11 #include "BufferedSerial.h"
sbh9428 0:9bfc4aea91e2 12 #include "tempsensort.h"
sbh9428 0:9bfc4aea91e2 13 #include "peltiert.h"
sbh9428 0:9bfc4aea91e2 14
sbh9428 0:9bfc4aea91e2 15 class control_t {
sbh9428 0:9bfc4aea91e2 16 public:
sbh9428 0:9bfc4aea91e2 17 float get_temp();
sbh9428 1:5c42ec7f1aeb 18 void control_PWM(float _PWM);
sbh9428 0:9bfc4aea91e2 19 void control_temp();
sbh9428 1:5c42ec7f1aeb 20
sbh9428 0:9bfc4aea91e2 21 void set_mode(int _mode);
sbh9428 1:5c42ec7f1aeb 22 void set_target_temp(float _target_temp);
sbh9428 1:5c42ec7f1aeb 23 void set_PWM_value(float _PWM_value);
sbh9428 1:5c42ec7f1aeb 24 void set_P_value(float _P_value);
sbh9428 1:5c42ec7f1aeb 25 void set_I_value(float _I_value);
sbh9428 1:5c42ec7f1aeb 26 void set_D_value(float _D_value);
sbh9428 3:72644690e2e6 27 void set_period(int _period);
sbh9428 1:5c42ec7f1aeb 28
sbh9428 1:5c42ec7f1aeb 29 void refresh_PWM();
sbh9428 1:5c42ec7f1aeb 30
sbh9428 1:5c42ec7f1aeb 31 int get_mode();
sbh9428 1:5c42ec7f1aeb 32 float get_target_temp();
sbh9428 1:5c42ec7f1aeb 33 float get_P_value();
sbh9428 1:5c42ec7f1aeb 34 float get_I_value();
sbh9428 1:5c42ec7f1aeb 35 float get_D_value();
sbh9428 1:5c42ec7f1aeb 36 float get_PWM_value();
sbh9428 3:72644690e2e6 37 int get_period();
sbh9428 3:72644690e2e6 38 int get_table_check();
sbh9428 2:4c51394fb35b 39 int get_table_count();
sbh9428 1:5c42ec7f1aeb 40
sbh9428 1:5c42ec7f1aeb 41 float calc_P();
sbh9428 1:5c42ec7f1aeb 42 float calc_I();
sbh9428 1:5c42ec7f1aeb 43 float calc_D();
sbh9428 1:5c42ec7f1aeb 44
sbh9428 1:5c42ec7f1aeb 45 void write_log();
sbh9428 1:5c42ec7f1aeb 46
sbh9428 2:4c51394fb35b 47 void print_table();
sbh9428 3:72644690e2e6 48 void follow_table();
sbh9428 2:4c51394fb35b 49
sbh9428 0:9bfc4aea91e2 50 control_t();
sbh9428 2:4c51394fb35b 51 control_t(temp_sensor_t* _temp_sensor, peltier_t* _peltier,BufferedSerial* _pc);
sbh9428 0:9bfc4aea91e2 52 virtual ~control_t();
sbh9428 0:9bfc4aea91e2 53 private:
sbh9428 1:5c42ec7f1aeb 54 float P_value;
sbh9428 1:5c42ec7f1aeb 55 float I_value;
sbh9428 1:5c42ec7f1aeb 56 float D_value;
sbh9428 1:5c42ec7f1aeb 57
sbh9428 1:5c42ec7f1aeb 58 float PWM_value;
sbh9428 1:5c42ec7f1aeb 59
sbh9428 1:5c42ec7f1aeb 60 float target_temp;
sbh9428 1:5c42ec7f1aeb 61
sbh9428 1:5c42ec7f1aeb 62 float dif;
sbh9428 1:5c42ec7f1aeb 63
sbh9428 1:5c42ec7f1aeb 64 float temp_log[10];
sbh9428 2:4c51394fb35b 65 float PWM_log[10];
sbh9428 1:5c42ec7f1aeb 66 int log_count;
sbh9428 1:5c42ec7f1aeb 67
sbh9428 1:5c42ec7f1aeb 68 float table[201];
sbh9428 1:5c42ec7f1aeb 69 int table_count;
sbh9428 2:4c51394fb35b 70 int table_mode;
sbh9428 3:72644690e2e6 71 int table_check;
sbh9428 3:72644690e2e6 72 float table_min;
sbh9428 3:72644690e2e6 73 float table_max;
sbh9428 3:72644690e2e6 74
sbh9428 3:72644690e2e6 75 int period;
sbh9428 3:72644690e2e6 76 int step;
sbh9428 2:4c51394fb35b 77
sbh9428 2:4c51394fb35b 78 void build_table();
sbh9428 3:72644690e2e6 79 float find_table(float _temp);
sbh9428 2:4c51394fb35b 80
sbh9428 0:9bfc4aea91e2 81 temp_sensor_t* temp_sensor;
sbh9428 0:9bfc4aea91e2 82 peltier_t* peltier;
sbh9428 2:4c51394fb35b 83 BufferedSerial *pc;
sbh9428 0:9bfc4aea91e2 84
sbh9428 0:9bfc4aea91e2 85 int mode;//0: stop 1: set pwm 2: set temp
sbh9428 0:9bfc4aea91e2 86 };
sbh9428 0:9bfc4aea91e2 87
sbh9428 0:9bfc4aea91e2 88 #endif /* CONTROLT_H_ */
sbh9428 0:9bfc4aea91e2 89