dd

Dependencies:   BufferedSerial FastAnalogIn FastPWM mbed SHT75

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 #include "BufferedSerial.h"
00004 #include "FastAnalogIn.h"
00005 #include "FastPWM.h"
00006 
00007 #include "commandt.h"
00008 #include "controlt.h"
00009 #include "peltiert.h"
00010 #include "tempsensort.h"
00011 
00012 Ticker controltick;
00013 
00014 AnalogIn temp_sensor_pin(p20);
00015 
00016 temp_sensor_t temp_sensor(&temp_sensor_pin);
00017 
00018 
00019 
00020 FastPWM PWM_pin(p23);
00021 DigitalOut PWM_dir(p22);
00022 
00023 
00024 
00025 peltier_t peltier(&PWM_pin, &PWM_dir);
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 BufferedSerial pc(USBTX, USBRX, 2048);
00035 
00036 control_t control(&temp_sensor, &peltier, &pc);
00037 
00038 command_t command(&pc, &control);
00039 
00040 
00041 
00042 void peltier_control();
00043 
00044 int main() {
00045     
00046     pc.printf("temperature start \n");
00047     
00048     controltick.attach(&peltier_control, 10);// sampling time
00049     
00050     wait(10);
00051     
00052     while(1) 
00053     {
00054         while(pc.readable())
00055         {
00056             command.get_data();   
00057         }
00058     }
00059     
00060 }
00061 
00062 void peltier_control()
00063 {
00064       command.refreshPWM();
00065 }