20200607057 EXPERIMENT 2A Closed Loop Oven Temperature Control using a Thermocouple and a Button Conclusions:
1) How do you read analog values of the thermocouple?
İn DC voltmeter. 2) How do you set the PORTB interrupt on change and how do you increase and decrease the reference temperatures using the push buttons? I used ref++ and ref 3) How do you convert the value read from the analog input into a temperature? By ADC_read. 4) I learned how to use ADC, timer and interrupt I/O functions. 5) In which applications can you use the circuits and techniques that you have learned during this experiment? In kitchen appliances. 1) What were the problems that you have faced with during this experimental work and how did you solve them? Lack of the knowledge. I got help from my friends and previous lessons taught. sbit LCD_RS at RB2_bit; sbit LCD_EN at RB3_bit; sbit LCD_D4 at RB4_bit; sbit LCD_D5 at RB5_bit; sbit LCD_D6 at RB6_bit; sbit LCD_D7 at RB7_bit; // Give name the tris sbit LCD_RS_Direction at TRISB2_bit; sbit LCD_EN_Direction at TRISB3_bit; sbit LCD_D4_Direction at TRISB4_bit; sbit LCD_D5_Direction at TRISB4_bit; sbit LCD_D6_Direction at TRISB6_bit; sbit LCD_D7_Direction at TRISB7_bit; unsigned int act,cnt=0,ref=25; //unsigned integers to keep actual temperature and reference temperature char text_act[7],text_ref[7]; //Character arrays to print in LCD void main() { ANSEL = 0b00100000; //All pins are digital ANSELH = 0x00 ; //all pins are digital TRISB =0b00000011; //RB1, RB2 and are assigned as inputs TRISC =0b00000000; // All pins of C are assigned as outputs PORTC =0b00000000; TRISE0_bit=1; OPTION_REG.F7 = 0; WPUB = 0b00000011; // Pull-up resistor is connected to Rb1, RB2 and pins GIE_bit=RBIE_bit=1; // Global and PortB Interrupt on Change are enabled IOCB=0b00000011; //RB1, RB2 and are assigned as interrupt sources for IOCB RBIF_bit=0; //IOCB interrupt flag is reset PEIE_bit = 1; TMR1IE_bit = 1; TMR1IF_bit = 0; // LCD Initilization Lcd_Init(); //lcd display initialization Lcd_Cmd(_LCD_CURSOR_OFF);//Cursor Off Lcd_Cmd(_LCD_CLEAR);//Clear Lcd //Print text into LCD Lcd_out(1, 1, "Ref Temp="); Lcd_out(2, 1, "Act Temp="); while(1){ act=ADC_Read(5); act=act*500/1023; // Convert degrees which are intiger to string using IntToStr in order to print in LCD. IntToStr(act, text_act); IntToStr(ref, text_ref); // Print values to LCD Lcd_out(1, 10, text_ref); Lcd_out(2, 10, text_act); if( cnt<4578){ // 65535 us cnt=1 cnt++; // 300 s cnt=? } else if (cnt>4578){ RC2_bit=0; RC5_bit=0; break; } if(act<ref-1){ RC2_bit=1; RC5_bit=1; } if(act>ref+1){ RC2_bit=0; RC5_bit=0; } } } void interrupt(){ if(RB0_bit== 0)ref++; RBIF_bit=0; if(RB1_bit== 0){ref--; RBIF_bit=0; } }