Problem in PIC16F877A's PCB

Discussion in 'Embedded Systems and Microcontrollers' started by lloydi12345, Nov 16, 2010.

  1. lloydi12345

    Thread Starter Member

    Aug 15, 2010
    103
    0
    Hi, I would like to ask help again because this site helped me solve some problems I can't solve myself.

    I have two PCBs. PCB1 contains PIC, Comparator and hbridge. PCB2 contains the IR LEDs and IR receiver modules. The first sensor is located at front, 2nd at left side of the mobile car and 3rd at the right side. I would like first to try it on flashing LEDs on the PIC before giving it a try on the motors. When an obstacle is detected in front, the 2nd LED will light. If an obstacle is detected on left, the 1st LED will light. If an obstacle is detected on right, the 3rd LED will light. I am having problems in using in the sensor part. The 1st sensor doesn't make the 2nd LED light even if I place an obstacle. Left sensor and right sensor works very well without any problems. The 3 IR receiver modules are different from each other that's why the schematic for each IR receiver module is different.

    When I try PCB2 disconnecting from PCB1 and try PCB2 on a breadboard with only LM324 and variable resistor. The output of LM324 is connected to a visible LED to show that there is an obstacle detected. On if there's no obstacle and Off if there's an obstacle. The sensors are not having any problems at all. The 3 sensors function well. Anything you find wrong on my PCB1?

    I tried using other pins like RB0 to RB3 as input but still they are the same. The front IR receiver module isn't detected by the PIC. Can you kindly help me out here?

    I believe there's no problem on the software. Here's my source code:

    Code ( (Unknown Language)):
    1.     list        p=16f877A    ; list directive to define processor
    2.     #include    <p16f877A.inc>    ; processor specific variable definitions
    3.    
    4.     __CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _XT_OSC & _WRT_OFF & _LVP_OFF & _CPD_OFF
    5.  
    6.  
    7.  
    8.  
    9. CBLOCK 0x21
    10.     FIRST
    11.     SECOND
    12.     THIRD
    13. ENDC
    14.  
    15.  
    16.     ORG     0x000            
    17.       goto    main              ; go to beginning of program
    18.  
    19.     ORG     0x004
    20. ; isr code can go here
    21.  
    22.  
    23. main
    24.  
    25. BANKSEL TRISC
    26. MOVLW 0x00
    27. MOVWF TRISC
    28. MOVLW 0XFF
    29. MOVWF TRISB
    30. BANKSEL PORTC
    31.  
    32. FORWARD:
    33.     MOVLW B'00000001'
    34.     MOVWF PORTC
    35.     CALL DELAYY
    36.     MOVLW B'00000010'
    37.     MOVWF PORTC
    38.     CALL DELAYY
    39.     MOVLW B'00000100'
    40.     MOVWF PORTC
    41.     CALL DELAYY
    42.     MOVLW B'00000101'
    43.     MOVWF PORTC
    44.     CALL DELAYY
    45.     MOVLW B'00000110'
    46.     MOVWF PORTC
    47.     CALL DELAYY
    48.     MOVLW B'00000111'
    49.     MOVWF PORTC
    50.     CALL DELAYY
    51.     MOVLW B'00000000'
    52.     MOVWF PORTC
    53.     CALL DELAYY
    54.     MOVLW B'00000111'
    55.     MOVWF PORTC
    56.     CALL DELAYY
    57.  
    58. MOVE:    
    59.     BTFSS PORTB, 4
    60.     GOTO SENSOR0
    61.     GOTO SENSOR1
    62.    
    63. SENSOR0:
    64.     BTFSS PORTB, 5
    65.     GOTO SENSOR00
    66.     GOTO SENSOR01
    67.    
    68. SENSOR00:
    69.     BTFSS PORTB, 6
    70.     GOTO SENSOR000
    71.     GOTO SENSOR001
    72.    
    73. SENSOR01:
    74.     BTFSS PORTB, 6
    75.     GOTO SENSOR010
    76.     GOTO SENSOR011
    77.    
    78. SENSOR1:
    79.     BTFSS PORTB, 5
    80.     GOTO SENSOR10
    81.     GOTO SENSOR11
    82.    
    83. SENSOR10:
    84.     BTFSS PORTB, 6
    85.     GOTO SENSOR100
    86.     GOTO SENSOR101
    87.    
    88. SENSOR11:
    89.     BTFSS PORTB, 6
    90.     GOTO SENSOR110
    91.     GOTO SENSOR111
    92.  
    93. SENSOR000:
    94.     MOVLW B'00000111'
    95.     MOVWF PORTC
    96.     CALL DELAYY
    97.     GOTO MOVE
    98.    
    99. SENSOR001:
    100.     MOVLW B'00000011'
    101.     MOVWF PORTC
    102.     CALL DELAYY
    103.     GOTO MOVE
    104.    
    105. SENSOR010:
    106.     MOVLW B'00000110'
    107.     MOVWF PORTC
    108.     CALL DELAYY
    109.     GOTO MOVE
    110.    
    111. SENSOR011:
    112.     MOVLW B'00000010'
    113.     MOVWF PORTC
    114.     CALL DELAYY
    115.     GOTO MOVE
    116.    
    117. SENSOR100:
    118.     MOVLW B'00000101'
    119.     MOVWF PORTC
    120.     CALL DELAYY
    121.     GOTO MOVE
    122.    
    123. SENSOR101:
    124.     MOVLW B'00000001'
    125.     MOVWF PORTC
    126.     CALL DELAYY
    127.     GOTO MOVE
    128.    
    129. SENSOR110:
    130.     MOVLW B'00000100'
    131.     MOVWF PORTC
    132.     CALL DELAYY
    133.     GOTO MOVE
    134.    
    135. SENSOR111:
    136.     MOVLW B'00000000'
    137.     MOVWF PORTC
    138.     CALL DELAYY
    139.     GOTO MOVE
    140.  
    141.    
    142.    
    143.  
    144. DELAY:                        ;    1 second delay
    145.         MOVLW .2
    146.         MOVWF THIRD
    147. LOOP_1_SEC:
    148.         MOVLW .250
    149.         MOVWF SECOND
    150. LOOP_125_MS:
    151.         MOVLW .250
    152.         MOVWF FIRST
    153. LOOP_.5_MS:
    154.         NOP
    155.         DECFSZ    FIRST,F
    156.         GOTO    LOOP_.5_MS
    157.        
    158.         DECFSZ     SECOND,F
    159.         GOTO    LOOP_125_MS
    160.        
    161.         DECFSZ    THIRD,F
    162.         GOTO    LOOP_1_SEC
    163.         return
    164.  
    165. DELAYY:
    166.  
    167.         MOVLW .2
    168.         MOVWF THIRD
    169. LOOP_1_SECC:
    170.         MOVLW .200
    171.         MOVWF SECOND
    172. LOOP_125_MSS:
    173.         MOVLW .200
    174.         MOVWF FIRST
    175. LOOP_.5_MSS:
    176.         NOP
    177.         DECFSZ    FIRST,F
    178.         GOTO    LOOP_.5_MSS
    179.        
    180.         DECFSZ     SECOND,F
    181.         GOTO    LOOP_125_MSS
    182.        
    183.         DECFSZ    THIRD,F
    184.         GOTO    LOOP_1_SECC
    185.         return
    186.  
    187.  
    188. END
     
  2. lloydi12345

    Thread Starter Member

    Aug 15, 2010
    103
    0
    What if I'll change the power source of the Sensor's PCB? Will it help?
     
  3. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Have you tried to debug the code. Like using MPLAB SIM to step through the code
     
  4. lloydi12345

    Thread Starter Member

    Aug 15, 2010
    103
    0
    Yes and there's no problem on the program.
     
Loading...