dd

Dependencies:   BufferedSerial FastAnalogIn FastPWM mbed SHT75

Committer:
sbh9428
Date:
Mon Feb 22 06:03:11 2016 +0000
Revision:
1:5c42ec7f1aeb
Parent:
0:9bfc4aea91e2
Child:
2:4c51394fb35b
PID?;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sbh9428 0:9bfc4aea91e2 1 #include "mbed.h"
sbh9428 0:9bfc4aea91e2 2
sbh9428 0:9bfc4aea91e2 3 #include "BufferedSerial.h"
sbh9428 0:9bfc4aea91e2 4 #include "FastAnalogIn.h"
sbh9428 0:9bfc4aea91e2 5 #include "FastPWM.h"
sbh9428 0:9bfc4aea91e2 6
sbh9428 0:9bfc4aea91e2 7 #include "commandt.h"
sbh9428 0:9bfc4aea91e2 8 #include "controlt.h"
sbh9428 0:9bfc4aea91e2 9 #include "peltiert.h"
sbh9428 0:9bfc4aea91e2 10 #include "tempsensort.h"
sbh9428 0:9bfc4aea91e2 11
sbh9428 0:9bfc4aea91e2 12 Ticker controltick;
sbh9428 0:9bfc4aea91e2 13
sbh9428 1:5c42ec7f1aeb 14 AnalogIn temp_sensor_pin(p19);
sbh9428 0:9bfc4aea91e2 15
sbh9428 0:9bfc4aea91e2 16 temp_sensor_t temp_sensor(&temp_sensor_pin);
sbh9428 0:9bfc4aea91e2 17
sbh9428 0:9bfc4aea91e2 18
sbh9428 0:9bfc4aea91e2 19
sbh9428 1:5c42ec7f1aeb 20 FastPWM PWM_pin(p23);
sbh9428 0:9bfc4aea91e2 21 DigitalOut PWM_dir(p22);
sbh9428 0:9bfc4aea91e2 22
sbh9428 1:5c42ec7f1aeb 23
sbh9428 1:5c42ec7f1aeb 24
sbh9428 0:9bfc4aea91e2 25 peltier_t peltier(&PWM_pin, &PWM_dir);
sbh9428 0:9bfc4aea91e2 26
sbh9428 0:9bfc4aea91e2 27
sbh9428 0:9bfc4aea91e2 28
sbh9428 0:9bfc4aea91e2 29 control_t control(&temp_sensor, &peltier);
sbh9428 0:9bfc4aea91e2 30
sbh9428 0:9bfc4aea91e2 31
sbh9428 0:9bfc4aea91e2 32
sbh9428 0:9bfc4aea91e2 33
sbh9428 0:9bfc4aea91e2 34 BufferedSerial pc(USBTX, USBRX);
sbh9428 0:9bfc4aea91e2 35
sbh9428 0:9bfc4aea91e2 36
sbh9428 0:9bfc4aea91e2 37
sbh9428 0:9bfc4aea91e2 38 command_t command(&pc, &control);
sbh9428 0:9bfc4aea91e2 39
sbh9428 0:9bfc4aea91e2 40
sbh9428 0:9bfc4aea91e2 41
sbh9428 0:9bfc4aea91e2 42 void peltier_control();
sbh9428 0:9bfc4aea91e2 43
sbh9428 0:9bfc4aea91e2 44 int main() {
sbh9428 1:5c42ec7f1aeb 45
sbh9428 0:9bfc4aea91e2 46 pc.printf("temperature start \n");
sbh9428 0:9bfc4aea91e2 47
sbh9428 1:5c42ec7f1aeb 48 controltick.attach(&peltier_control, 10);
sbh9428 0:9bfc4aea91e2 49
sbh9428 1:5c42ec7f1aeb 50 wait(10);
sbh9428 0:9bfc4aea91e2 51
sbh9428 0:9bfc4aea91e2 52 while(1)
sbh9428 0:9bfc4aea91e2 53 {
sbh9428 0:9bfc4aea91e2 54 while(pc.readable())
sbh9428 0:9bfc4aea91e2 55 {
sbh9428 0:9bfc4aea91e2 56 command.get_data();
sbh9428 0:9bfc4aea91e2 57 }
sbh9428 0:9bfc4aea91e2 58 }
sbh9428 0:9bfc4aea91e2 59
sbh9428 0:9bfc4aea91e2 60 }
sbh9428 0:9bfc4aea91e2 61
sbh9428 0:9bfc4aea91e2 62 void peltier_control()
sbh9428 0:9bfc4aea91e2 63 {
sbh9428 1:5c42ec7f1aeb 64 command.refreshPWM();
sbh9428 0:9bfc4aea91e2 65 }