Help with PIC16f877a. not doing my program

Discussion in 'Embedded Systems and Microcontrollers' started by glenn_pangfb@yahoo.com, Feb 4, 2012.

  1. glenn_pangfb@yahoo.com

    Thread Starter New Member

    Feb 3, 2012
    7
    0
    guys , i have a deadline on a project dealing with pic16f877a making it work as a motor and compressor driver. it has a easy logic and requires a basic programming but it doesnt function as i wanted when i put it on board. can someone help or assist me regarding these.. very thankful to those can help :(
     
  2. bertus

    Administrator

    Apr 5, 2008
    15,648
    2,347
    Hello,

    Without the schematic and program we can not help you.
    Please post both and we can have a look at it.

    Bertus
     
  3. glenn_pangfb@yahoo.com

    Thread Starter New Member

    Feb 3, 2012
    7
    0
    Code ( (Unknown Language)):
    1.  
    2. Device = 16F877A
    3. XTAL = 20
    4. ALL_DIGITAL 1
    5.  
    6.  
    7. Symbol F1 = PORTA.0
    8. Symbol F2 = PORTA.1
    9. Symbol R1 = PORTA.2
    10. Symbol R2 = PORTA.3
    11. Symbol P = PORTC.3
    12.  
    13. TRISD = %1111
    14. TRISA = %0000
    15. Output PORTC.3
    16.  
    17. DelayMS 1000
    18. Start:
    19. If PORTD = %1111 Then
    20. F1 = 1
    21. F2 = 1
    22. R1 = 0
    23. R2 = 0
    24. P = 1    
    25.  
    26. ElseIf PORTD = %1110 Then
    27. F1 = 0
    28. F2 = 1
    29. R1 = 0
    30. R2 = 0
    31. P = 0
    32.  
    33. ElseIf PORTD = %1101 Then
    34. F1 = 1
    35. F2 = 1
    36. R1 = 0
    37. R2 = 0
    38. P = 1
    39.  
    40. ElseIf PORTD = %1100 Then
    41. F1 = 0
    42. F2 = 1
    43. R1 = 1
    44. R2 = 0
    45. P = 0
    46.  
    47. ElseIf PORTD = %1011 Then
    48. F1 = 1
    49. F2 = 1
    50. R1 = 0
    51. R2 = 0
    52. P = 1
    53.  
    54. ElseIf PORTD = %1010 Then
    55. F1 = 0
    56. F2 = 1
    57. R1 = 0
    58. R2 = 0
    59. P = 0
    60.  
    61. ElseIf PORTD = %1001 Then
    62. F1 = 1
    63. F2 = 1
    64. R1 = 0
    65. R2 = 0
    66. P = 1
    67.  
    68. ElseIf PORTD = %1000 Then
    69. F1 = 0
    70. F2 = 1
    71. R1 = 1
    72. R2 = 0
    73. P = 0
    74.  
    75. ElseIf PORTD = %0111 Then
    76. F1 = 1
    77. F2 = 0
    78. R1 = 0
    79. R2 = 0
    80. P = 0
    81.  
    82. ElseIf PORTD = %0110 Then
    83. F1 = 1
    84. F2 = 1
    85. R1 = 0
    86. R2 = 0
    87. P = 1
    88.  
    89. ElseIf PORTD = %0101 Then
    90. F1 = 1
    91. F2 = 0
    92. R1 = 0
    93. R2 = 0
    94. P = 0
    95.  
    96. ElseIf PORTD = %0100 Then
    97. F1 = 0
    98. F2 = 1
    99. R1 = 1
    100. R2 = 0
    101. P = 0
    102.  
    103. ElseIf PORTD = %0011 Then
    104. F1 = 1
    105. F2 = 0
    106. R1 = 0
    107. R2 = 1
    108. P = 0
    109.  
    110. ElseIf PORTD = %0010 Then
    111. F1 = 1
    112. F2 = 0
    113. R1 = 0
    114. R2 = 1
    115. P = 0
    116.  
    117. ElseIf PORTD = %0001 Then
    118. F1 = 1
    119. F2 = 0
    120. R1 = 0
    121. R2 = 1
    122. P = 0
    123.  
    124. Else
    125. F1 = 0
    126. F2 = 0
    127. R1 = 0
    128. R2 = 0
    129. P = 0
    130.  
    131. EndIf
    132. GoTo Start
    133.  
    134.  
    135. End
    136.  
     
    Last edited by a moderator: Feb 5, 2012
  4. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,015
    And it might help if you tell us what "doesnt function"

    That is a really broad category.

    What have you done to troubleshoot and narrow it down to a specific area?
     
  5. glenn_pangfb@yahoo.com

    Thread Starter New Member

    Feb 3, 2012
    7
    0

    i am sorry i am new in posting here,,

    after i had my things placed on a pcb, before i made a start of the program i always have to slide a wire with 5v to pic pins back and fort before it start, after that it goes right then malfunctioning again, unless i do that method again. but when it functions it really does my program. soory:(
     
  6. glenn_pangfb@yahoo.com

    Thread Starter New Member

    Feb 3, 2012
    7
    0
    i think my program in proton is correct. i always simulate it before i load it to the pic.. maybe its on the circuitry.. help :confused:
     
  7. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,015

    What "pic pins" are you sliding this wire to 5V to get it to work? How do you know it is working when you do this?

    Just because something works in a simulator does not mean it will work in the real world.
     
  8. glenn_pangfb@yahoo.com

    Thread Starter New Member

    Feb 3, 2012
    7
    0
    i got a wire with 5v from the source and slide it on all the pins of the pic sometimes just touching the 5v wire to pin 31 then it works.. i know it works when my leds light up and do what is programmed.
     
  9. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,015
    STOP DOING THAT!!!!!! You are shorting VSS to VDD!

    You are going to have to give a lot more details if you want people to help like explain what is connected to PORTD (your input I assume).


    What have you done to troubleshoot your code? Have you stepped through the code with your debugger?
     
Loading...