abirm
Newbie level 3
hi !
I have to realize a temperature controller using pic 16f877a . normali, the microcontroller reads the temperature continuously and compares it to the desired value. when the desired value is higher than the measured value, the relay and the red LED are activated. when the desired value is equal to the measured value, the green LED is activated. but i dont find this faction (the relay and the leds do not work ). this is my code on micrc please helpe me to find the
fault :sad:
I have to realize a temperature controller using pic 16f877a . normali, the microcontroller reads the temperature continuously and compares it to the desired value. when the desired value is higher than the measured value, the relay and the red LED are activated. when the desired value is equal to the measured value, the green LED is activated. but i dont find this faction (the relay and the leds do not work ). this is my code on micrc please helpe me to find the
fault :sad:
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 // LCD module connections 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; 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 TRISB5_bit; sbit LCD_D6_Direction at TRISB6_bit; sbit LCD_D7_Direction at TRISB7_bit; // End LCD module connections char display[16]=""; void Move_Delay() { // Function used for text moving Delay_ms(2000); // You can change the moving speed here } #define HEATER PORTD.RD2 #define LED_RED PORTD.RD3 #define LED_GREEN PORTD.RC5 #define ButtonPlus PORTD.RD0 #define Buttonmoins PORTD.RD1 #define ON 1 #define OFF 0 void main() { unsigned int result; float volt,temp; float temp_ref=50; trisb=0; trisa=0xff; adcon1=0x80; lcd_init(); lcd_cmd(_lcd_clear); lcd_cmd(_LCD_CURSOR_OFF); while(1) { result=adc_read(0); volt=result*4.88; temp=volt/10; lcd_out(1,1,"Temp ="); floattostr(temp,display); lcd_out_cp(display); lcd_chr(1,15,223); //print at pos(row=1,col=13) "°" =223 =0xdf lcd_out_cp("C"); //celcius if(ButtonPlus == 1) { temp_ref +=5; if(temp_ref >100) temp_ref = 50; } if(Buttonmoins == 1) { temp_ref -=5; if(temp_ref < 10) temp_ref = 50; } lcd_out(2,1,"T. Ref ="); floattostr(temp_ref,display); lcd_out_cp(display); lcd_chr(2,15,223); //print at pos(row=1,col=13) "°" =223 =0xdf lcd_out_cp("C"); Delay_ms(500); if (temp_ref < Temp) { HEATER = 1; LED_RED = 1; LED_GREEN = 0; } if (temp_ref >= Temp) { HEATER =0; LED_RED = 0; LED_GREEN = 1; } } }