Problem with programming pic16f877a

Discussion in 'Embedded Systems and Microcontrollers' started by Abdo_pc_dr, Apr 7, 2010.

  1. Abdo_pc_dr

    Thread Starter New Member

    Apr 3, 2010
    13
    0
    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


    Code ( (Unknown Language)):
    1. '****************************************************************
    2. '*  Name    : lM35.BAS                                          *
    3. '*  Author  : [AAFHMM]                                          *
    4. '*  Notice  : Copyright (c) 2010 [JUST TRYING]                  *
    5. '*          : All Rights IS NOT Reserved  @ ALL                 *
    6. '*  Date    : 4/7/2010                                          *
    7. '*  Version : 1.0                                               *
    8. '*  Notes   :   MAYBE   I MAYBE YUO                             *
    9. '*          :                                                   *
    10. '****************************************************************
    11.  Device 16F877A               'PIC type
    12.  XTAL 4                       ' crystal oscillator
    13.  TRISB = 0                    ' port b as o/p port
    14.  Declare ADIN_RES 10       ' 10-bit result required
    15.  Declare ADIN_TAD  2      ' RC OSC chosen
    16.  Declare ADIN_STIME 50     ' Allow 50us sample time
    17.  LOOP:
    18.  Dim VAR1 As Word
    19.  TRISA = %00000001         ' Configure AN0 (PORTA.0) as an input
    20.  ADCON1 = %10000000        ' Set analogue input on PORTA.0
    21.  VAR1 = ADIn 0             ' Place the conversion into variable VAR1
    22.  Dim VAR2 As DWord
    23.  VAR2 = (VAR1*10)          ' calibration of LM35 after Op-amp is used
    24.  Dim MAX1 As Word          ' compare the temp.
    25.  MAX1 = 37
    26.  Dim min1 As Word
    27.  min1 = 18
    28.  If VAR2 > MAX1 Then PORTB.1 = 1  
    29.  If VAR2 < MAX1 Then PORTB.1 =0
    30.  If VAR2 <= min1 Then PORTB.2 = 1
    31.  If VAR2 > min1 Then PORTB.2 =0
    32.  DelayMS 1000
    33.  GoTo LOOP
     
  2. FastEddie

    Active Member

    Jul 14, 2007
    35
    0
    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.
    Code ( (Unknown Language)):
    1.  If VAR2 > MAX1 Then PORTB.1 = 1
    2.  End If  
    3.  If VAR2 < MAX1 Then PORTB.1 =0
    4.  End If
     
  3. Abdo_pc_dr

    Thread Starter New Member

    Apr 3, 2010
    13
    0
    tried it but it didn`t work
    thnx alot 4 UR suggestion
     
Loading...