dd

Dependencies:   BufferedSerial FastAnalogIn FastPWM mbed SHT75

Committer:
sbh9428
Date:
Fri Mar 25 05:55:07 2016 +0000
Revision:
4:7ca449fca19b
Parent:
3:72644690e2e6
Child:
6:c2fb5c188e8a
r

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 4:7ca449fca19b 28 void set_start_temp(float _start_temp);
sbh9428 1:5c42ec7f1aeb 29
sbh9428 1:5c42ec7f1aeb 30 void refresh_PWM();
sbh9428 1:5c42ec7f1aeb 31
sbh9428 1:5c42ec7f1aeb 32 int get_mode();
sbh9428 1:5c42ec7f1aeb 33 float get_target_temp();
sbh9428 1:5c42ec7f1aeb 34 float get_P_value();
sbh9428 1:5c42ec7f1aeb 35 float get_I_value();
sbh9428 1:5c42ec7f1aeb 36 float get_D_value();
sbh9428 1:5c42ec7f1aeb 37 float get_PWM_value();
sbh9428 3:72644690e2e6 38 int get_period();
sbh9428 3:72644690e2e6 39 int get_table_check();
sbh9428 2:4c51394fb35b 40 int get_table_count();
sbh9428 1:5c42ec7f1aeb 41
sbh9428 1:5c42ec7f1aeb 42 float calc_P();
sbh9428 1:5c42ec7f1aeb 43 float calc_I();
sbh9428 1:5c42ec7f1aeb 44 float calc_D();
sbh9428 1:5c42ec7f1aeb 45
sbh9428 1:5c42ec7f1aeb 46 void write_log();
sbh9428 1:5c42ec7f1aeb 47
sbh9428 2:4c51394fb35b 48 void print_table();
sbh9428 3:72644690e2e6 49 void follow_table();
sbh9428 2:4c51394fb35b 50
sbh9428 0:9bfc4aea91e2 51 control_t();
sbh9428 2:4c51394fb35b 52 control_t(temp_sensor_t* _temp_sensor, peltier_t* _peltier,BufferedSerial* _pc);
sbh9428 0:9bfc4aea91e2 53 virtual ~control_t();
sbh9428 0:9bfc4aea91e2 54 private:
sbh9428 1:5c42ec7f1aeb 55 float P_value;
sbh9428 1:5c42ec7f1aeb 56 float I_value;
sbh9428 1:5c42ec7f1aeb 57 float D_value;
sbh9428 1:5c42ec7f1aeb 58
sbh9428 1:5c42ec7f1aeb 59 float PWM_value;
sbh9428 1:5c42ec7f1aeb 60
sbh9428 1:5c42ec7f1aeb 61 float target_temp;
sbh9428 1:5c42ec7f1aeb 62
sbh9428 1:5c42ec7f1aeb 63 float dif;
sbh9428 1:5c42ec7f1aeb 64
sbh9428 1:5c42ec7f1aeb 65 float temp_log[10];
sbh9428 2:4c51394fb35b 66 float PWM_log[10];
sbh9428 1:5c42ec7f1aeb 67 int log_count;
sbh9428 1:5c42ec7f1aeb 68
sbh9428 1:5c42ec7f1aeb 69 float table[201];
sbh9428 1:5c42ec7f1aeb 70 int table_count;
sbh9428 2:4c51394fb35b 71 int table_mode;
sbh9428 3:72644690e2e6 72 int table_check;
sbh9428 3:72644690e2e6 73 float table_min;
sbh9428 3:72644690e2e6 74 float table_max;
sbh9428 4:7ca449fca19b 75 float start_temp;
sbh9428 3:72644690e2e6 76
sbh9428 3:72644690e2e6 77 int period;
sbh9428 3:72644690e2e6 78 int step;
sbh9428 2:4c51394fb35b 79
sbh9428 2:4c51394fb35b 80 void build_table();
sbh9428 3:72644690e2e6 81 float find_table(float _temp);
sbh9428 2:4c51394fb35b 82
sbh9428 0:9bfc4aea91e2 83 temp_sensor_t* temp_sensor;
sbh9428 0:9bfc4aea91e2 84 peltier_t* peltier;
sbh9428 2:4c51394fb35b 85 BufferedSerial *pc;
sbh9428 0:9bfc4aea91e2 86
sbh9428 0:9bfc4aea91e2 87 int mode;//0: stop 1: set pwm 2: set temp
sbh9428 0:9bfc4aea91e2 88 };
sbh9428 0:9bfc4aea91e2 89
sbh9428 0:9bfc4aea91e2 90 #endif /* CONTROLT_H_ */
sbh9428 0:9bfc4aea91e2 91