Example project for the Rioux Chem control box
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "CHEM_BOX_INTERFACE.h" 00003 00004 Timer ControlLoopTimer; 00005 float CurrentTemperature; 00006 00007 #define VT100_RED "\033[31;40m" 00008 #define VT100_GREEN "\033[32;40m" 00009 #define VT100_YELLOW "\033[33;40m" 00010 #define VT100_BLUE "\033[34;40m" 00011 #define VT100_MAGENTA "\033[35;40m" 00012 #define VT100_CYAN "\033[36;40m" 00013 #define VT100_WHITE "\033[37;40m" 00014 #define VT100_RESET "\033c" 00015 00016 extern void WriteRAW_DAC_Value(uint8_t Channel,uint16_t Data); 00017 00018 int main() 00019 { 00020 int i; 00021 char * Color = VT100_WHITE; 00022 //This function always needs called before you do anythign wit the CHEM BOX. 00023 InitChemBox(); 00024 00025 GREEN_LED = 1; 00026 RED_LED = 0; 00027 00028 //Beep 6 times 00029 for(i=0;i<6;i++) 00030 { 00031 Buzz(.05); //Since the Buzz function immediately returns we should wait a bit before calling it again in the loop 00032 wait(.1); //I want a 50% duty cycle so I will wait twice as long as my previous Buzz() call 00033 00034 GREEN_LED = !GREEN_LED; 00035 RED_LED = !RED_LED; 00036 00037 } 00038 00039 00040 GREEN_LED = 1; 00041 RED_LED = 0; 00042 00043 //Here is the main super loop 00044 00045 //reset and start our control loop Timer 00046 ControlLoopTimer.reset(); 00047 ControlLoopTimer.start(); 00048 00049 while(1) 00050 { 00051 //Call this often if you want the USB interface/Terminal 00052 ProcessTerminal(); 00053 00054 //Call this process incoming lines from the pump 00055 ProcessRS232(); 00056 00057 00058 /* 00059 if(ControlLoopTimer.read_ms() >= 1000) 00060 { 00061 ControlLoopTimer.reset(); 00062 00063 00064 PC.printf(VT100_RESET); 00065 00066 }*/ 00067 00068 00069 /* 00070 00071 //control loop example 00072 //We will do something ever 250mS. 00073 //Use a timer and an if statement we won't hold the microprocessor from do other things in the main super loop! 00074 if(ControlLoopTimer.read_ms >= 250) 00075 { 00076 ControlLoopTimer.reset(); 00077 00078 //if 250mSec has elapsed then do our control loop 00079 00080 CurrentTemperature = ReadThermocouple(0); 00081 00082 if(CurrentTemperature < 15.5) 00083 { 00084 EnableHeater(0); 00085 } 00086 else 00087 { 00088 DisableHeater(0); 00089 } 00090 00091 FlushDigitalIO(); //Remeber, the digital outs are queued up until this is called! 00092 } 00093 */ 00094 } 00095 00096 }
Generated on Sun Jul 24 2022 04:18:19 by
1.7.2
Eli Hughes

