こて先温度計 Sodering Iron Tips Thermometer
Dependencies: AQM0802 MAX31855 mbed
main.cpp
00001 //********************** 00002 // こて先温度計:Soldering Iron Tips Thermometer with MAX31855K 00003 // 00004 // こて先温度計シールド:Thermocouple Shield for Soldering Iron 00005 // https://www.switch-science.com/catalog/2322/ 00006 // 3.3V用にSJ1, SJ2をショートして使用しています 00007 // It is the shield with MAX31855K and K-type thermocouple. 00008 // 00009 // Universal Embedded Board for LPC11U68 by HAPI-TechSolution 00010 // https://www.switch-science.com/catalog/2316/ 00011 // 00012 // I2C接続の小型LCD搭載ボード(3.3V版): 8x2 LCD display 00013 // https://www.switch-science.com/catalog/1405/ 00014 // 8x2 LCD with AQM0802 controller 00015 // 00016 //********************** 00017 #include "mbed.h" 00018 #include "AQM0802.h" 00019 #include "max31855.h" 00020 00021 #define NEED_CONSOLE_OUTPUT 0 00022 #define NEED_LCD_OUTPUT 1 00023 00024 #if NEED_CONSOLE_OUTPUT 00025 Serial pc(USBTX, USBRX); 00026 #define PC(...) { pc.printf(__VA_ARGS__); } 00027 #else 00028 #define PC(...) /* nothing */ 00029 #endif /* #if NEED_CONSOLE_OUTPUT */ 00030 00031 I2C i2c(SDA, SCL); 00032 SPI spi(P0_9, P0_8, P1_29); 00033 max31855 max1(spi, P0_2); 00034 00035 #if NEED_LCD_OUTPUT 00036 AQM0802 lcd(i2c); 00037 #endif 00038 00039 int main() 00040 { 00041 char msg1[10],msg2[10]; 00042 float fvalue; 00043 float chiptemp; 00044 int faultCode; 00045 00046 //Initialise chip (starts internal timer) 00047 max1.initialise(); 00048 wait(2); 00049 00050 sprintf(msg1,"Temp"); 00051 fvalue = max1.read_temp(); 00052 wait_ms(500); 00053 00054 while(1){ 00055 fvalue = max1.read_temp(); 00056 PC("%d\n",fvalue); 00057 00058 if (fvalue > 2000.){ 00059 faultCode = fvalue - 2000; 00060 if((faultCode & 4 ) != 0){ 00061 sprintf(msg2,"Short Vc"); 00062 PC("ERROR: Short to VCC"); 00063 }else if((faultCode & 2 ) != 0){ 00064 sprintf(msg2,"Short G "); 00065 PC("ERROR: Short to GND"); 00066 }else if((faultCode & 1 ) != 0){ 00067 PC("ERROR: Open Circuit"); 00068 sprintf(msg2,"Open "); 00069 } 00070 } else { 00071 sprintf(msg2,"%6.2f%cC",fvalue,0xf2); 00072 } 00073 00074 chiptemp = max1.chipTemp * 0.25; 00075 // sprintf(msg1,"%6.2f%cC",chiptemp,0xf2); 00076 00077 PC("%7.2f : %7.2f\n",fvalue, chiptemp); 00078 00079 #if NEED_LCD_OUTPUT 00080 lcd.locate(0,0); 00081 lcd.print(msg1); 00082 lcd.locate(0,1); 00083 lcd.print(msg2); 00084 00085 #endif 00086 wait_ms(500); 00087 } 00088 00089 }
Generated on Sat Jul 16 2022 15:21:15 by 1.7.2