2x16 lcd problem


Closed Thread
Results 1 to 12 of 12
  1. #1
    Join Date
    Oct 2008
    Posts
    11

    Default 2x16 lcd problem

    After searching the forum for 2x16 I still can't see what my problem is. I have a 2x16 lcd connected to a 16f877a and it only displays solid boxes on the first row. The code I'm using works fine on my Lab-x1 with the 2x20 lcd and I've wired the 2x16 to the 16f877a the same way it is on the Lab-x1. This is the datasheet for the 2x16 i'm using http://www.lcdmk.com/product/zfx/RT162-7.PDF . I think there is something in the DEFINE's that I need to change for this particular display just not sure what. Also pretty sure I've got the BL and the contrast set to readable levels using a couple resistors.

    here's my code

    Code:
    CLEAR				;Define LCD registers and control bits
    DEFINE OSC  4			;System speed
    DEFINE LCD_DREG PORTD 	;data register
    DEFINE LCD_BITS 4 		;width of data path
    DEFINE LCD_DBIT 4		;data starts on bit 4
    DEFINE LCD_RSREG PORTE 	;select register 
    DEFINE LCD_RSBIT 0 		;select bit
    DEFINE LCD_EREG PORTE 	;enable register
    DEFINE LCD_EBIT 1 		;enable bit
    DEFINE LCD_RWREG PORTE 	;read/write register
    DEFINE LCD_RWBIT 2 		;read/write bit
    LOW PORTE.2 			;LCD R/W low (write) We will do no reading
    DEFINE LCD_LINES 2 		;lines in display
    DEFINE LCD_COMMANDUS 2000 	;delay in micro seconds
    DEFINE LCD_DATAUS 20 		;delay in micro seconds
    				; 
    ;Set the port directions. We are setting (must set) all of PORTD and all of PORTE as outputs
    ;even though PORTE has only 3 lines. The other 5 lines will be ignored by the system.
    				; 
    TRISD = %00000000 		; set all PORTD lines to output
    TRISE = %00000000 		; set all PORTE lines to output 
    				; Set the Analog to Digital control register
    ADCON1=%00000111 		; needed for the 16F877A see note above and below
    				; 
    LOOP:				; The main loop of the program
    LCDOUT $FE, 1 			; clear screen
    PAUSE 500			; pause 0.25 seconds
    LCDOUT "HELLO" 			; print
    LCDOUT $FE, $C0 		; goto second line, first position
    LCDOUT "WORLD" 		; print
    PAUSE 250 			; pause 0.25 seconds
    GOTO LOOP 			; repeat
    END				; always end all programs with an END statement
    The attached file is basically how I have it wired. Does not show the resistors on the bl and contrast.
    Suggestions anyone?
    Attached Images Attached Images  

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Code:
    DEFINE LCD_DATAUS 20 		;delay in micro seconds
    Turn that up to about 200 for starters, then after it's working dial it down until it fails again, then dial it back up and add a bit of a fudge factor to keep it working. The LCD needs time to work. Also, add about a one second pause before your first initial LCDOUT command. The LCDOUT needs time to start up.

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    And...

    You may want to use a pot on pin #3 of the LCD so it can be adjusted.
    I have a 2x16 lcd connected to a 16f877a and it only displays solid boxes on the first row.
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Oct 2008
    Posts
    11


    Did you find this post helpful? Yes | No

    Default tried it

    Still the same went as high as 500. Also put in a PAUSE of 900 before first lcd out. I don't think it can be a busted lcd cause i have 4 and they all do the same thing. Unless this model is just junk.

  5. #5
    Join Date
    Oct 2008
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    Also I can replace the lcd with 8 led's and make them flash, so pretty sure the rest of my circuit is working ok.

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    On your schematic, your pinout seems to be wrong... at least the way you connect your Data lines to your PIC.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Oct 2008
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    And...

    You may want to use a pot on pin #3 of the LCD so it can be adjusted.
    Just put in a 10k pot and I can adjust the crap out of it ... still not displaying any text #$%#!#@$%^

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by k3v1nP View Post
    Still the same went as high as 500. Also put in a PAUSE of 900 before first lcd out. I don't think it can be a busted lcd cause i have 4 and they all do the same thing. Unless this model is just junk.
    DATAUS is a byte value. Go to 500, and you may as well go to 244 (figured this out the hard way awhile back, not mentioned in the book, but good to know).
    Try the pause value up to a couple of seconds...some really are that slow...
    Also, double, nay, triple check your wiring...Make sure you've got the connector on the 'right way'.
    And put a 'heartbeat LED' in there...
    Code:
    CLEAR				;Define LCD registers and control bits
    DEFINE OSC  4			;System speed
    DEFINE LCD_DREG PORTD 	;data register
    DEFINE LCD_BITS 4 		;width of data path
    DEFINE LCD_DBIT 0		;data starts on bit 0
    DEFINE LCD_RSREG PORTE 	;select register 
    DEFINE LCD_RSBIT 0 		;select bit
    DEFINE LCD_EREG PORTE 	;enable register
    DEFINE LCD_EBIT 1 		;enable bit
    DEFINE LCD_RWREG PORTE 	;read/write register
    DEFINE LCD_RWBIT 2 		;read/write bit
    LOW PORTE.2 			;LCD R/W low (write) We will do no reading
    DEFINE LCD_LINES 2 		;lines in display
    DEFINE LCD_COMMANDUS 4000 	;delay in micro seconds
    DEFINE LCD_DATAUS 200 		;delay in micro seconds				; 
    ;Set the port directions. We are setting (must set) all of PORTD and all of PORTE as outputs
    ;even though PORTE has only 3 lines. The other 5 lines will be ignored by the system.
    				; 
    TRISD = %00000000 		; set all PORTD lines to output
    LED VAR PORTD.7
    OUTPUT LED
    TEMP VAR BYTE
    TRISE = %00000000 		; set all PORTE lines to output 
    				; Set the Analog to Digital control register
    ADCON1=%00000111 		; needed for the 16F877A see note above and below
    				; 
    PAUSE 2000
    LOOP:				; The main loop of the program
    TEMP = TEMP + 1
    LED = TEMP.0
    LCDOUT $FE, 1 			; clear screen
    PAUSE 500			; pause 0.25 seconds
    LCDOUT "HELLO" 			; print
    LCDOUT $FE, $C0 		; goto second line, first position
    LCDOUT "WORLD" 		; print
    PAUSE 250 			; pause 0.25 seconds
    GOTO LOOP 			; repeat
    END				; always end all programs with an END statement

    EDIT: Oh yeah, that schematic is jacked up...
    Example schematic and/or program is in the PBP manual...
    Last edited by skimask; - 28th October 2008 at 18:17. Reason: EDIT: Added Mr_E's FIX as noted below :D

  9. #9
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    As it is connected right now i would try
    Code:
    DEFINE LCD_DREG PORTD 	;data register
    DEFINE LCD_BITS 4 		;width of data path
    DEFINE LCD_DBIT 0
    AND change the DATAUS as Skimask said.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  10. #10
    Join Date
    Oct 2008
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    So i ripped my circuit down and simplified it with a 16f84a and that worked with all my lcd's. Rebuilt it with the 16f877a and it now works as well. I must have had something messed up in the first build. Sometimes I guess it just pays to start from scratch.

    Thanks to everyones for there help. One thing for sure I am certainly learning alot.

  11. #11
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by k3v1nP View Post
    So i ripped my circuit down and simplified it with a 16f84a and that worked with all my lcd's. Rebuilt it with the 16f877a and it now works as well. I must have had something messed up in the first build. Sometimes I guess it just pays to start from scratch.
    Thanks to everyones for there help. One thing for sure I am certainly learning alot.
    Good game... Any idea what the real problem was? Miswired? One wire off?
    Keep in mind, the PBP manual, while not a 'do-all end-all of manuals', has a lot of good information in it, a lot of it 'in between the lines', and a lot of it applies to this PIC and that PIC since they're all pretty much built on the same architecture. Use it and use it often! It'll save you a lot of time and trouble. Same goes for the PIC datasheets. A load of the problems that show up here could have been avoided by those two items.

  12. #12
    Join Date
    Oct 2008
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    Not a hundred % sure but it was probably just a wrong wire or 2. Wiring diagrams are usually pretty much straight forward so I usually just slap them together and they work ... if I get lucky. When they don't work I can look at it a hundred times and it looks absolutely right. Howerver it only takes one mistake to F it all up. So when things don't work I usually make the call that its one or the other (software or hardware)... this time I think I made the wrong choice. When I rebuilt the circuit this last time I was absolutely maticulous and took my time ... and it works.
    Thanks again for the help next time I should just post photographs cause probably all I needed was a second pair of eyes to have a look at it. Now that I got my lcd's all working on to the next challenge. ( I totally understand mister_e's avatar now).

Similar Threads

  1. LCD problem with 16F628
    By ngeronikolos in forum mel PIC BASIC Pro
    Replies: 25
    Last Post: - 19th September 2016, 09:28
  2. 2x16 lcd not working with pic16f72
    By vu2iia in forum Schematics
    Replies: 4
    Last Post: - 16th February 2011, 15:59
  3. Newbie? Problem with LCD
    By lew247 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 7th December 2009, 20:48
  4. LCD Problem
    By karenhornby in forum General
    Replies: 3
    Last Post: - 19th June 2008, 12:43
  5. Problem with 2x16 LCD on 16F630
    By Falcon in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th June 2005, 04:25

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts