1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

in trouble with LCD (JHD162A)

Discussion in 'Microcontrollers' started by smileguitar, Dec 18, 2007.

  1. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,239
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi,
    Its the one I posted a few days ago,, IIRC.... 'lcd2line'

    To determine the cause of a problem, sometimes you have to use a known 'good' program or component.
    For example: say you had a spare LCD on the shelf, you would try it in the place of the suspect one. If it worked with the new one that would most likely mean the first one is faulty.
    If it still didnt work with a new LCD that would mean the problem is most likely something else other than the LCD.

    The same applies to a program,, the program i posted works with a HD44870 LCD controller and the same type of PIC that you are using.
    If my program drives the LCD OK, this means the fault is most likely your program,,, if the LCD dosnt work with my program then either the LCD is faulty or the LCD wiring is faulty.

    Its necessary when fault finding to go thru a process of elimination, using devices or programs of known quality...

    Do You follow this???

    Its this one.
     
    Last edited: Jul 7, 2008
  2. smileguitar

    smileguitar New Member

    Joined:
    Dec 17, 2007
    Messages:
    39
    Likes:
    0
    I did test the LCD with the programme that you provided, it not work; means that the possibility for LCD faulty and LCD wiring is faulty. So, I have to use your programme to test in the new LCD. If work in new LCD, I'll know the result, am I right?

    Erm... could you help me to double check again my connection of LCD? I've attached it above.

    Thanks!!
     

    Attached Files:

  3. blueroomelectronics

    blueroomelectronics Well-Known Member

    Joined:
    Jan 21, 2007
    Messages:
    12,536
    Likes:
    170
    Location:
    Toronto, Canada
    You can't just connect VEE to gnd, it generally need to be adjustable and some LCDs require a small negative voltage.
    Put a 10K pot bettween pins 1 & 2 with the wiper going to pin 3.
    [​IMG]
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. smileguitar

    smileguitar New Member

    Joined:
    Dec 17, 2007
    Messages:
    39
    Likes:
    0

    Ok, thanks!
     
  6. futz

    futz Active Member

    Joined:
    Sep 15, 2007
    Messages:
    2,043
    Likes:
    24
    Location:
    Vancouver, B.C.
    Hey smileguitar. I just wired an LCD up to a 16F877A I had kickin around, using pretty much your original post schematic, but with some minor changes.

    I programmed the chip with your original posted code (fixed the BANK0 macro error).

    It works fine. Prints "YES" on line 1 and "123" on line 2.

    I'll draw up a quicky schematic of how I wired it and post tonight. Meanwhile, here's the code with that one tiny error fixed:
    Code (text):
        LIST P=16F877
        #INCLUDE <P16F877.INC>
        __CONFIG 0X3F32

    ; MACRO
    BANK0   MACRO
        BCF STATUS,RP0
        BCF STATUS,RP1
        ENDM

    BANK1   MACRO
        BSF STATUS,RP0
        BCF STATUS,RP1
        ENDM


    CLOCK_E MACRO
        BSF PORTD,3
        CALL    DELAY2
        BCF PORTD,3
        ENDM

    ; VARIABLE
    D1  EQU 0X20
    D2  EQU 0X21
    D3  EQU 0X22
    D4  EQU 0X23
    D5  EQU 0X24
    D6  EQU 0X25

    ; MAIN PROGRAM
        ORG 0X0000
        GOTO    START

    STOP    ORG 0X0004
        GOTO    STOP

    START   BANK0
        CLRF    PORTA
        CLRF    PORTB
        CLRF    PORTC
        CLRF    PORTD
        CLRF    PORTE

        BANK1
        MOVLW   0x06
        MOVWF   ADCON1
        CLRF    TRISA
        CLRF    TRISB
        CLRF    TRISC
        CLRF    TRISD
        CLRF    TRISE

        BANK0
        CLRF    PORTB

    ; LCD INITIALIZED
        CALL    DELAY1
        BCF PORTD,2
        MOVLW   B'00110000'
        MOVWF   PORTB
        CLOCK_E

        CALL    DELAY2
        MOVLW   B'00001101'
        MOVWF   PORTB
        CLOCK_E

        CALL    DELAY3
        MOVLW   B'00111000'
        MOVWF   PORTB
        CLOCK_E
        MOVLW   B'00000001'
        MOVWF   PORTB
        CLOCK_E
        MOVLW   B'00000110'
        MOVWF   PORTB
        CLOCK_E

    ; MESSAGES DISPLAY IN LINE 1
        BSF PORTD,2
        MOVLW   H'59'
        MOVWF   PORTB   ;DISPLAY "YES"
        CLOCK_E
        MOVLW   H'45'
        MOVWF   PORTB
        CLOCK_E
        MOVLW   H'53'
        MOVWF   PORTB
        CLOCK_E

    ; SET LCD TO SECOND LINE
        BCF PORTD,2
        MOVLW   B'11000000'
        MOVWF   PORTB
        CLOCK_E

    ; MESSAGES DISPLAY IN LINE 2
        BSF PORTD,2
        MOVLW   H'31'
        MOVWF   PORTB   ;DISPLAY123
        CLOCK_E
        MOVLW   H'32'
        MOVWF   PORTB
        CLOCK_E
        MOVLW   H'33'
        MOVWF   PORTB
        CLOCK_E

        GOTO    $-1

    ; SUBROUTINE FOR DELAY
    DELAY1 MOVLW D'65' ;DELAY 50ms
        MOVWF   D2
        MOVLW   D'238'
        MOVWF   D1
    LOOP1   DECFSZ  D1,1
        GOTO    LOOP1
        DECFSZ  D2,1
        GOTO    LOOP1
        RETURN

    DELAY2  MOVLW   D'13'   ;DELAY 10ms
        MOVWF   D4
        MOVLW   D'251'
        MOVWF   D3
    LOOP2   DECFSZ  D3,1
        GOTO    LOOP2
        DECFSZ  D4,1
        GOTO    LOOP2
        RETURN

    DELAY3  MOVLW   D'1'    ;DELAY 100us
        MOVWF   D6
        MOVLW   D'31'
        MOVWF   D5
    LOOP3   DECFSZ  D5,1
        GOTO    LOOP3
        DECFSZ  D6,1
        GOTO    LOOP3
        RETURN

        END
     
    Couple pics:
    Photo 1
    Photo 2
     
    Last edited: Jan 4, 2008
  7. futz

    futz Active Member

    Joined:
    Sep 15, 2007
    Messages:
    2,043
    Likes:
    24
    Location:
    Vancouver, B.C.
    Bah! Too much work. Here's the LCD connections.

    LCD Pins:
    Pin 1. Ground (VSS)
    Pin 2. 5V (VDD)
    Pin 3. 1K resistor to ground (VSS).
    Pin 4. RD2 and also a 10K pullup resistor
    Pin 5. Ground (VSS)
    Pin 6. RD3
    Pin 7. RB0
    Pin 8. RB1
    Pin 9. RB2
    Pin 10. RB3
    Pin 11. RB4
    Pin 12. RB5
    Pin 13. RB6
    Pin 14. RB7
    Pin 15. 5V (VDD) (Backlight)
    Pin 16. Ground (VSS) (Backlight)

    I determined the resistor value for Pin 3 by first putting a 10K potentiometer in using one leg and the wiper from pin 3 to ground, adjusting it till the display looked good, removing it and measuring the resistance and putting that value of resistor back in place of the pot. LCDs vary from model to model. If you just put in the resistor there's a good chance you'll end up with maladjusted contrast and have a "blank display".

    Silly questions:
    You ARE using a 4MHz crystal as the schematic shows, right? If you aren't, that would explain the the blinking LED program working but the LCD not working. The LCD delay durations depend on the PIC running at that 4MHz clock speed (or lower, but not higher). If you put (for instance) a 20MHz crystal on the PIC the LCD is not gonna work until you change either the code or the crystal.

    Is your MCLR pulled up properly? If not the chip could possibly be doing something weird like restarting over and over, giving the illusion that the blinky program is actually running when it's really not. Try making some changes to the blinky prog and see if it responds correctly.

    Got enough juice? Not enough power can cause LCDs to not work properly. I found this one out the hard way a couple times. Backlight seemed to be working, but couldn't get the display to work right. Got better power to it and it took right off. It had been working all along but I couldn't see it.
     
    Last edited: Jan 4, 2008
  8. smileguitar

    smileguitar New Member

    Joined:
    Dec 17, 2007
    Messages:
    39
    Likes:
    0
    Today I tested the new LCD with my programme, it works. I'm so happy, testing for a long time, today success. Now I know the big problem is caused by the LCD failure. Thanks to all who give suggestion, advise and encouragement. Eric, Eng1, mvs sarma, Pommie, blueroomelectronics and futz, THANK YOU VERY MUCH!! :) :D

    Erm... Now I've one more question to ask.... If the LCD feel a bit warm is consider burnt?

    Today I tested the new LCD can work properly, but I think through my careless, I connected wrongly that caused the cicuit short. After that the LCD cannot function anymore and feel slightly warm. Is LCD burnt?? (I'm so stupid :( )
     
  9. mvs sarma

    mvs sarma Well-Known Member

    Joined:
    Oct 29, 2006
    Messages:
    3,512
    Likes:
    76
    Location:
    Hyderabad, India.
    Hey Smileguitar,

    Are you telling about the old display that went faulty or,god forbid, is it second time failure?

    Generally the voltage pattern at pins 1,2 and 16,15, they are symmetrical. even if pin3 goes to pin 14, it could be imagined as high or low input on D7-this also should not matter. So reverse connection may not cause failure of display and when normalcy restored,it should start working. But, on the other hand if connection pulled out while the supply is ON and display working, this type of failure is anticipated , as far as i could analyze.
     
  10. blueroomelectronics

    blueroomelectronics Well-Known Member

    Joined:
    Jan 21, 2007
    Messages:
    12,536
    Likes:
    170
    Location:
    Toronto, Canada
    LCDs are really easy to kill, if you ever reverse power & gnd it's ususually bye bye.
     
  11. smileguitar

    smileguitar New Member

    Joined:
    Dec 17, 2007
    Messages:
    39
    Likes:
    0
    I'm telling about the new display. I'm not connect wrongly at LCD pins, but in MCLR pin of PIC. I connect a push button in pin1 of PIC with a diode, resistor and capacitor. Unfortunately, I made it short circuit. After this, my new LCD is not function stable. Is LCD burnt again? or.....???
     
  12. mvs sarma

    mvs sarma Well-Known Member

    Joined:
    Oct 29, 2006
    Messages:
    3,512
    Likes:
    76
    Location:
    Hyderabad, India.
    i was talking about the reversal of the entire 16 pin connector of LCD display with spl ref to JHD162A model. Generally voltage reversal in solidstate circuits and digital circuits,kills many ICs. memories more instantaneously.

    however Smileguitar confirms that it is case of mishandling pin1 of the 16F877 (MCLR), i suppose. That might not cause such serious damage to LCD display, i hope, as there is no Vpp at a working board.
     
  13. smileguitar

    smileguitar New Member

    Joined:
    Dec 17, 2007
    Messages:
    39
    Likes:
    0

    Hopefully. Thanks in advance. I'll double check it....
     
  14. smileguitar

    smileguitar New Member

    Joined:
    Dec 17, 2007
    Messages:
    39
    Likes:
    0
    I've successfully displayed character in LCD, now going to do my next step of my project. Thanks all guys !!! :) :) :)
     
  15. nageshbabu

    nageshbabu New Member

    Joined:
    Apr 13, 2008
    Messages:
    3
    Likes:
    0
    datasheet

     
  16. mvs sarma

    mvs sarma Well-Known Member

    Joined:
    Oct 29, 2006
    Messages:
    3,512
    Likes:
    76
    Location:
    Hyderabad, India.
    the JHD162A is compatible. Nothing to worry. i use it
     
  17. iloveyou321

    iloveyou321 New Member

    Joined:
    Feb 27, 2009
    Messages:
    2
    Likes:
    0
    Hi eric, could u give the lcd2line.asm file because i couldn't get the attached file. because i'm also having the same problem like smileguitar
     
  18. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,239
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi,:)
    For some reason the original posted file has gone.!

    This is a copy from my PC.

    EDIT: which pins of the 628A are connected to the LCD.??
     

    Attached Files:

    Last edited: Feb 28, 2009
  19. iloveyou321

    iloveyou321 New Member

    Joined:
    Feb 27, 2009
    Messages:
    2
    Likes:
    0

    The assembly code is quite hard to understand but i will try to explore it...ya, it is nice of you to give me the code.Thank you very much.
     
  20. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,239
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi,
    If you post which pins you are using, I could change the asm to suit.:)
     
  21. Jent Ching

    Jent Ching New Member

    Joined:
    Apr 4, 2011
    Messages:
    5
    Likes:
    0
    My LCD JHD162A cannot display any characters

    I have checked many times of my circuit connection of LCD with my Microcontroller MC68HC11E, even the programming code I have edited many times, but the LCD still can't display any characters. I have to summit my project by next week. Anyone can help me please!!! Pin E I connected to PA3, Pin RS connected to PA4, Pin R/W connected to PA7 and DB0-DB7 connected to PC0-PC7. The following is my programming code:

    LCD to MC68HC11.jpg

    ORG $B600
    PORTA EQU $1000
    PORTC EQU $03
    DDRC EQU $07

    LDX #PORTA
    LDAA #$FF
    STAA DDRC,X
    BCLR PORTC,X,$FF
    LDS #$FF

    LDY #INITIAL
    LOOP LDAA 0,Y
    BEQ START
    BSR INS
    INY
    BRA LOOP

    START LDY #DATA
    LDAA #$80
    AGAIN BSR INS
    LDAB 0,Y
    BSR CHAR
    INY
    INCA
    CMPA #$87
    BNE AGAIN
    NOP

    ENABLE BSET 0,X,$08
    BSR DELAY
    RTS

    INS BCLR 0,X,$90
    STAA PORTC,X
    BSR ENABLE
    RTS

    CHAR BSET 0,X,$90
    STAB PORTC,X
    BSR ENABLE
    RTS

    DELAY PSHB
    PSHX
    LDAB #1
    LOOP3 LDX #$7FFF
    LOOP2 DEX
    BNE LOOP2
    DECB
    BNE LOOP3
    PULX
    PULB
    RTS

    INITIAL FCB $01,$02,$06,$0C,$14,$38,0
    DATA FCC "WELCOME"
    END
     

Share This Page