Problem with programming pic16f877a

Thread Starter

Abdo_pc_dr

Joined Apr 3, 2010
13
I`ve made a simple air-conditioning system using 16f877a the system is basic and depends on Lm35 and 2 relays for Cool & Worm air conditioning

I`ve wrote my code on Proton IDE but after burning it to PIC and connecting the circuit it doesn`t work so I think that the problem is with the code


Rich (BB code):
'****************************************************************
'*  Name    : lM35.BAS                                          *
'*  Author  : [AAFHMM]                                          *
'*  Notice  : Copyright (c) 2010 [JUST TRYING]                  *
'*          : All Rights IS NOT Reserved  @ ALL                 *
'*  Date    : 4/7/2010                                          *
'*  Version : 1.0                                               *
'*  Notes   :   MAYBE   I MAYBE YUO                             *
'*          :                                                   *
'****************************************************************
 Device 16F877A               'PIC type
 XTAL 4                       ' crystal oscillator
 TRISB = 0                    ' port b as o/p port
 Declare ADIN_RES 10       ' 10-bit result required 
 Declare ADIN_TAD  2      ' RC OSC chosen 
 Declare ADIN_STIME 50     ' Allow 50us sample time 
 LOOP:
 Dim VAR1 As Word 
 TRISA = %00000001         ' Configure AN0 (PORTA.0) as an input 
 ADCON1 = %10000000        ' Set analogue input on PORTA.0 
 VAR1 = ADIn 0             ' Place the conversion into variable VAR1 
 Dim VAR2 As DWord
 VAR2 = (VAR1*10)          ' calibration of LM35 after Op-amp is used 
 Dim MAX1 As Word          ' compare the temp.
 MAX1 = 37
 Dim min1 As Word
 min1 = 18
 If VAR2 > MAX1 Then PORTB.1 = 1  
 If VAR2 < MAX1 Then PORTB.1 =0 
 If VAR2 <= min1 Then PORTB.2 = 1 
 If VAR2 > min1 Then PORTB.2 =0
 DelayMS 1000
 GoTo LOOP
 

FastEddie

Joined Jul 14, 2007
35
I'm not familiar with Proton so I'm not sure if this is correct, but I think you might need an End If statement for each If statement that you have. Hope that helps.
Rich (BB code):
 If VAR2 > MAX1 Then PORTB.1 = 1
 End If  
 If VAR2 < MAX1 Then PORTB.1 =0
 End If
 
Top