![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
dd
Dependencies: BufferedSerial FastAnalogIn FastPWM mbed SHT75
main.cpp@0:9bfc4aea91e2, 2016-02-19 (annotated)
- Committer:
- sbh9428
- Date:
- Fri Feb 19 07:07:26 2016 +0000
- Revision:
- 0:9bfc4aea91e2
- Child:
- 1:5c42ec7f1aeb
temp;
Who changed what in which revision?
User | Revision | Line number | New 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 | 0:9bfc4aea91e2 | 14 | FastAnalogIn temp_sensor_pin(p20); |
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 | 0:9bfc4aea91e2 | 20 | FastPWM PWM_pin(p21); |
sbh9428 | 0:9bfc4aea91e2 | 21 | DigitalOut PWM_dir(p22); |
sbh9428 | 0:9bfc4aea91e2 | 22 | |
sbh9428 | 0:9bfc4aea91e2 | 23 | peltier_t peltier(&PWM_pin, &PWM_dir); |
sbh9428 | 0:9bfc4aea91e2 | 24 | |
sbh9428 | 0:9bfc4aea91e2 | 25 | |
sbh9428 | 0:9bfc4aea91e2 | 26 | |
sbh9428 | 0:9bfc4aea91e2 | 27 | control_t control(&temp_sensor, &peltier); |
sbh9428 | 0:9bfc4aea91e2 | 28 | |
sbh9428 | 0:9bfc4aea91e2 | 29 | |
sbh9428 | 0:9bfc4aea91e2 | 30 | |
sbh9428 | 0:9bfc4aea91e2 | 31 | |
sbh9428 | 0:9bfc4aea91e2 | 32 | BufferedSerial pc(USBTX, USBRX); |
sbh9428 | 0:9bfc4aea91e2 | 33 | |
sbh9428 | 0:9bfc4aea91e2 | 34 | |
sbh9428 | 0:9bfc4aea91e2 | 35 | |
sbh9428 | 0:9bfc4aea91e2 | 36 | command_t command(&pc, &control); |
sbh9428 | 0:9bfc4aea91e2 | 37 | |
sbh9428 | 0:9bfc4aea91e2 | 38 | |
sbh9428 | 0:9bfc4aea91e2 | 39 | |
sbh9428 | 0:9bfc4aea91e2 | 40 | void peltier_control(); |
sbh9428 | 0:9bfc4aea91e2 | 41 | |
sbh9428 | 0:9bfc4aea91e2 | 42 | int main() { |
sbh9428 | 0:9bfc4aea91e2 | 43 | pc.printf("temperature start \n"); |
sbh9428 | 0:9bfc4aea91e2 | 44 | |
sbh9428 | 0:9bfc4aea91e2 | 45 | controltick.attach(&peltier_control, 1); |
sbh9428 | 0:9bfc4aea91e2 | 46 | |
sbh9428 | 0:9bfc4aea91e2 | 47 | |
sbh9428 | 0:9bfc4aea91e2 | 48 | |
sbh9428 | 0:9bfc4aea91e2 | 49 | while(1) |
sbh9428 | 0:9bfc4aea91e2 | 50 | { |
sbh9428 | 0:9bfc4aea91e2 | 51 | while(pc.readable()) |
sbh9428 | 0:9bfc4aea91e2 | 52 | { |
sbh9428 | 0:9bfc4aea91e2 | 53 | command.get_data(); |
sbh9428 | 0:9bfc4aea91e2 | 54 | } |
sbh9428 | 0:9bfc4aea91e2 | 55 | } |
sbh9428 | 0:9bfc4aea91e2 | 56 | |
sbh9428 | 0:9bfc4aea91e2 | 57 | } |
sbh9428 | 0:9bfc4aea91e2 | 58 | |
sbh9428 | 0:9bfc4aea91e2 | 59 | void peltier_control() |
sbh9428 | 0:9bfc4aea91e2 | 60 | { |
sbh9428 | 0:9bfc4aea91e2 | 61 | command.refreshPWM(); |
sbh9428 | 0:9bfc4aea91e2 | 62 | } |