+ Post New Thread
Results 1 to 20 of 20
  1. #1
    Full Member level 2
    Points: 1,563, Level: 9

    Join Date
    Sep 2011
    Posts
    146
    Helped
    1 / 1
    Points
    1,563
    Level
    9

    pic16F877a basic circuit problem

    I am using PIC 16F877a micro controller initially i just want to on/off an led by giving high/low to RD0and portA is constantly high , the circuit is working fine in proteus simulation but not in hardware no any port is giving any output. I am using 4MHz oscillator with 15pf capacitors ....

    Thanks in Advance

    LIST P=16F877a,r=hex,n=80,x=off,st=off


    #include <P16F877.INC>

    __CONFIG _CP_OFF & _WDT_OFF & _HS_OSC & _PWRTE_ON & _LVP_OFF

    ORG 0010H

    BSF STATUS, RP0
    BCF STATUS, RP1
    MOVLW 00H
    MOVWF TRISB
    MOVLW 00H
    MOVWF TRISA
    MOVLW 0FFH
    MOVWF TRISD
    BCF STATUS, RP0
    BCF STATUS, RP1
    CLRF 21H
    CLRF 22H
    CLRF 23H
    MOVLW 0FFH
    MOVWF PORTA

    A CALL DELAY
    BTFSS PORTD,0
    GOTO A1
    MOVLW 0FFH
    MOVWF PORTB
    GOTO A2
    A1 CLRF PORTB
    A2 CALL DELAY
    GOTO A


    DELAY:
    MOVLW 0FFH
    MOVWF 22H
    AAA MOVLW 0FFH
    MOVWF 21H
    AA DECFSZ 21H,F
    GOTO AA
    DECFSZ 22H,F
    GOTO AAA
    RETURN


    END

  2. #2
    Banned
    Points: 23,048, Level: 36

    Join Date
    Dec 2012
    Location
    Bangalore, India
    Posts
    4,294
    Helped
    826 / 826
    Points
    23,048
    Level
    36

    Re: pic16F877a basic circuit problem

    Capacitors should be 22pf to 33pf. Where is ADCON1 and CMCON settings?



  3. #3
    Full Member level 2
    Points: 1,563, Level: 9

    Join Date
    Sep 2011
    Posts
    146
    Helped
    1 / 1
    Points
    1,563
    Level
    9

    Re: pic16F877a basic circuit problem

    for 4MHz crytal capacitors can be used are from 15-68 pF
    and
    why ADCON1 and CMCON settings needed

    plz help



  4. #4
    Advanced Member level 5
    Points: 20,490, Level: 34
    Achievements:
    7 years registered

    Join Date
    May 2009
    Location
    Prime Meridian
    Posts
    3,056
    Helped
    892 / 892
    Points
    20,490
    Level
    34

    Re: pic16F877a basic circuit problem

    Hi,

    Thats a terrible example of assembler coding you have used, will post a more sensible example shortly.

    As Jay said, 22-33pf is a much more typical value for the crystal caps though 15pf may work; proteus does not actually use them.
    Have you got Pin1 Mlcre tied up to +5v ?

    - - - Updated - - -

    Hi,

    Try this code, a bit easier to follow.

    Code:
    ;       progam to flash all of PortB pins on and off every 4 seconds
    
    
    		list p=16f877a
    		include p16f877a.inc
    		__CONFIG _CP_OFF & _WDT_OFF & _XT_OSC & _PWRTE_ON & _LVP_OFF
    	
    		cblock 0x20			; specify user regiaters
    		d1
    		d2
    		d3
    		COUNT
    		endc
    
    
    
    		org 	0x000
    		GOTO	Main
    
    
    
    Main	CLRF	PORTB		; Set portb,c,d to digital outputs
    		CLRF   	PORTC
    		CLRF 	PORTD
    		BANKSEL TRISA
    		CLRF	TRISB
    		CLRF 	TRISC
    		CLRF 	TRISD
    		BANKSEL 0
    
    		
    
    LOOP						; main program loo[
    		CALL	DELAY4s
    		MOVLW   0xFF
    		MOVWF	PORTB		; Set  port HIGH
    
    		CALL	DELAY4s
    
    		MOVLW   0x00
    		MOVWF	PORTB		; Set  port LOW
    		GOTO	LOOP		
    
    	
    DELAY4s						; 4 SECOND DELAY
    		movlw	0x23
    		movwf	d1
    		movlw	0xB9
    		movwf	d2
    		movlw	0x09
    		movwf	d3
    Delay_0
    		decfsz	d1, f
    		goto	dly1
    		decfsz	d2, f
    dly1	goto	dly2
    		decfsz	d3, f
    dly2	goto	Delay_0
    	
    
    		return
    
    		END



    •   Alt10th May 2013, 17:35

      advertising

        
       

  5. #5
    Banned
    Points: 23,048, Level: 36

    Join Date
    Dec 2012
    Location
    Bangalore, India
    Posts
    4,294
    Helped
    826 / 826
    Points
    23,048
    Level
    36

    Re: pic16F877a basic circuit problem

    PORTA has ADC and Comparator. So to disable ADC and Comparators you have to set ADCON1 and CMCON.



    •   Alt10th May 2013, 18:07

      advertising

        
       

  6. #6
    Full Member level 2
    Points: 1,563, Level: 9

    Join Date
    Sep 2011
    Posts
    146
    Helped
    1 / 1
    Points
    1,563
    Level
    9

    Re: pic16F877a basic circuit problem

    thanks alot
    i have 13V DC supply i am using LM7805 for 5V output but the output i am getting is 4.2V even when controller is connected or disconnected i have also used a transformer to convert 220V to 12V AC then i used bridge rectifier and then capacitor in then i used LM7805 even then the output is not excedding 4.2V even i have replaced 3 7805 ICs but results are same
    what could be the possible reason for this
    plz help



  7. #7
    Advanced Member level 5
    Points: 20,490, Level: 34
    Achievements:
    7 years registered

    Join Date
    May 2009
    Location
    Prime Meridian
    Posts
    3,056
    Helped
    892 / 892
    Points
    20,490
    Level
    34

    Re: pic16F877a basic circuit problem

    Hi,

    Unless you have the unlikely event of a faulty batch of 7805 regulators, then you must have wired them up incorrectly or have a faulty multimeter.

    Can you post your actual diagram and photo of how you have done it.

    Do you have a battery that you can test you meter against on that low voltage DC range ?

    Your pic chip will probably just work ok at 4.2v



  8. #8
    Banned
    Points: 23,048, Level: 36

    Join Date
    Dec 2012
    Location
    Bangalore, India
    Posts
    4,294
    Helped
    826 / 826
    Points
    23,048
    Level
    36

    Re: pic16F877a basic circuit problem

    Measure the voltage of a 9V battery using Multimeter. If you get 9V then your meter is ok.



  9. #9
    Full Member level 2
    Points: 1,563, Level: 9

    Join Date
    Sep 2011
    Posts
    146
    Helped
    1 / 1
    Points
    1,563
    Level
    9

    Re: pic16F877a basic circuit problem

    thanks again
    when i programmed the controller with pickit2 the error message displayed was
    device requires a minimum VDD of 4.5V for bulk erase operation ...
    I continued to program but when given 4.2V of supply from 7805 the pins of all ports have 1.3V and when connected led or resistor to any pin of port B the output falls to 0.5V
    I also tried to program it with genius 540 the error msg was
    configuration bits not set in the code ....
    I also continued to program but same results
    Plz help



    •   Alt12th May 2013, 09:16

      advertising

        
       

  10. #10
    Advanced Member level 5
    Points: 20,490, Level: 34
    Achievements:
    7 years registered

    Join Date
    May 2009
    Location
    Prime Meridian
    Posts
    3,056
    Helped
    892 / 892
    Points
    20,490
    Level
    34

    Re: pic16F877a basic circuit problem

    Hi,

    That program code I posted runs on my hardware without any problem, its .hex file attached.

    I program with a Microchip Pickit2 without problems, are you using a Microchip or a clone ?

    Have you programmed any chip with the Pk2 before ?

    Are you programming in circuit with your 4.2v power or are you placing the 877a in a separate programming socket ?

    You have not said anything about checking your 7805 regulator circuit or multimeter, does anything get warm or hot, have you measured the current going in to the 7805 ?

    You can also use the PK2 VDD TARGET CHECK to read out your 4.2V



  11. #11
    Full Member level 2
    Points: 1,563, Level: 9

    Join Date
    Sep 2011
    Posts
    146
    Helped
    1 / 1
    Points
    1,563
    Level
    9

    Re: pic16F877a basic circuit problem

    the programmer is local made pickit2 programmer using PIC18f2550 controller I don’t know much about it but when I connect to PC it shows pickit2 connected and ….
    I have not programmed any ic before with it ….
    I am separately programming the IC by placing it in programming socket…..
    I am unable to tick the box of CHECK option nor to change the voltages which are shown as 3.4V.....
    For 7805 nothing is getting hot I have also used analog DC voltage meter and same 4V is shown where as multimeter is displaying 4.2V and these voltages are open circuit voltages and when controller is connected voltages remains constant, further the input voltages are dropping from 13V to 10V
    plz help



  12. #12
    Advanced Member level 5
    Points: 20,490, Level: 34
    Achievements:
    7 years registered

    Join Date
    May 2009
    Location
    Prime Meridian
    Posts
    3,056
    Helped
    892 / 892
    Points
    20,490
    Level
    34

    Re: pic16F877a basic circuit problem

    Hi,

    The PK2, how are you controlling it, from MPLAB or from the PK2 Stand Alone Program V2.61 ?

    If you are not using V2.61 download and install it from the Microchip Pk2 page.

    In V2.61 under the HELP menu there is the User Guide which shows the 5 pins which need to be connected to the 877a
    Its important that you connect both sets of power rails pins 11,32 to VDD +5v and 12,31 to VSS 0v
    The wires between the PK2 and the 877a should be no longer 150mm.

    With the 877a in the socket and your Pk2 connected, start the V2.61 and it should open with a message like my pic shows - do you get that ?

    As for your 7805 problem again you have not provided any digram of how you have wired it all up or a photo so its difficult to say where things have gone wrong, particularly as you say two different meters give 4.2v

    Have you tried powering the 7805 with a 6v or 9v or 12v battery to see if it delivers 5v ?



  13. #13
    Full Member level 2
    Points: 1,563, Level: 9

    Join Date
    Sep 2011
    Posts
    146
    Helped
    1 / 1
    Points
    1,563
    Level
    9

    Re: pic16F877a basic circuit problem

    i really dont know the connections on the board ......iam using V2.6 downloaded from microchip website
    the warning message is still appearing....but the board is programming the IC.

    for 7805 the connections are simple as the left most pin is input pin and middle pin is ground and right most pin is 5v output ...i connected 100uf capacitor at the input to ground and output to ground this caused the output voltage to rise to 4.88 to 4.9V and at this voltage the controller started working though it has to work at 4.2V....



  14. #14
    Super Moderator
    Points: 68,098, Level: 63
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    11,139
    Helped
    3675 / 3675
    Points
    68,098
    Level
    63

    Re: pic16F877a basic circuit problem

    Something is very wrong with your power supply, you need to sort it out before worrying about software although Jayanth has done an excellent job of writing your code properly.

    Lets go back to basics - your voltmeter and the Pickit seem to agree that the supply voltage is wrong. The only thing other than faulty regulators that can cause low supply is a current overload in which the regulator should be very hot, or, the voltage at the input of the regulator is too low. I am suspicious that adding those capacitors made a difference to the voltage. They should be there but should not make the voltage increase. Can you use your meter to measure the voltage at the input pin of the regulator and tell us what it is please.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



  15. #15
    Full Member level 2
    Points: 1,563, Level: 9

    Join Date
    Sep 2011
    Posts
    146
    Helped
    1 / 1
    Points
    1,563
    Level
    9

    Re: pic16F877a basic circuit problem

    thanks for cooperation
    7805 is normal and input voltage is 10V...both open circuit and with controller the o/p voltage remain at 4.9V
    thanks



  16. #16
    Super Moderator
    Points: 68,098, Level: 63
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    11,139
    Helped
    3675 / 3675
    Points
    68,098
    Level
    63

    Re: pic16F877a basic circuit problem

    Then there is something wrong. If you are using a 13V DC supply the input pin should be at 13V and if you are using the 12V transformer and bridge rectifier it should be about 16V. Check your input circuitry and in particular the capacitor value after the bridge rectifier. I suggest it should be 1000uF or more.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



  17. #17
    Full Member level 3
    Points: 1,619, Level: 9

    Join Date
    Nov 2012
    Location
    India
    Posts
    159
    Helped
    13 / 13
    Points
    1,619
    Level
    9

    Re: pic16F877a basic circuit problem

    Attach your circuit diagram...
    aghilwtsn



  18. #18
    Full Member level 2
    Points: 1,563, Level: 9

    Join Date
    Sep 2011
    Posts
    146
    Helped
    1 / 1
    Points
    1,563
    Level
    9

    Re: pic16F877a basic circuit problem

    thanks alot
    the circuit is working well in simulation (ofcourse) ...............but the problem is in real hardware .........the connection are simple left pin i/p higher voltages....mid one ground...and right one must give 5V ...



  19. #19
    Full Member level 4
    Points: 1,538, Level: 8
    rparthiban69's Avatar
    Join Date
    Aug 2012
    Posts
    225
    Helped
    19 / 19
    Points
    1,538
    Level
    8

    Re: pic16F877a basic circuit problem

    check the Hardware

    Click image for larger version. 

Name:	Capture.PNG 
Views:	19 
Size:	34.8 KB 
ID:	91835
    Thanks,
    Parthi


    1 members found this post helpful.

    •   Alt1st June 2013, 04:17

      advertising

        
       

  20. #20
    Full Member level 2
    Points: 1,563, Level: 9

    Join Date
    Sep 2011
    Posts
    146
    Helped
    1 / 1
    Points
    1,563
    Level
    9

    Re: pic16F877a basic circuit problem

    thanks alot the circuit worked well with little modification...... i.e. the resistor R11 is replaced by variable resistor to get 5V at output.



--[[ ]]--