Serial LCD ?


Closed Thread
Results 1 to 3 of 3

Thread: Serial LCD ?

  1. #1

    Default Serial LCD ?

    I am using a PIC16F876A. I bought a MELabs serial LCD a while ago. I connected it today to the PIC and loaded the "Hello World" program (hellox2.bas) I modified the mode from T9600 to N9600. I get characters on the LCD and probably would make sense if I spoke Russian, yet I skipped that class in high school. Is this code correct for the LCD and PIC I am using? Could I have damaged the LCD sometime long ago? When I ground out two of the pins on the back of the display to get the default values I get V1.1 N9600. Any ideas?
    Code:
    Include "modedefs.bas"	' Mode definitions for Serout
    
    
    loop:   Serout PORTC.6,N9600,["Hello",10,13]  ' Display "Hello", next line 
            Pause 500	' Wait .5 second      
            Serout PORTC.6,N9600,["World",10,13,10,13]  ' Display "World", skip a line 
            Pause 500	' Wait .5 second
            Goto loop	' Do it forever
            End

  2. #2
    Join Date
    Aug 2008
    Posts
    66


    Did you find this post helpful? Yes | No

    Default

    Have you wired the LCD correctly to your PIC?

    Check out the code below:

    Code:
    ' Program SER_LCD.BAS
    ' ***********************************************************************
    ' Simple Serial LCD Controller
    ' ***********************************************************************
    
    	Include "Modedefs.bas"
            
    	DEFINE OSC		   4		' Set the Xtal frequency to 4mHz
    
    ' ** Declare LCDOUT Defines **
    
    	DEFINE	LCD_DREG	PortB			' Set Data to PortB
    	DEFINE 	LCD_DBIT	0			' Set starting Data to Bit0
    	DEFINE 	LCD_RSREG     	PortA			' Set Register Select to PortA
    	DEFINE 	LCD_RSBIT       2			' Set RS line to PORTA.2
    	DEFINE 	LCD_EREG	PortA			' Set Enable to PortA
    	DEFINE 	LCD_EBIT  	3			' Set Enable line to PortA.3
    	DEFINE 	LCD_BITS	8			' Set for 8 bit Bus
    	DEFINE 	LCD_LINES	2			' Set number of lines to 2
    
    ' ** Define LCD Control Constants **
    
    	I		Con	254			' Control Byte
    	Clr		Con	1			' Clear the display
    	Line1		Con	128			' Point to beginning of line 1
    	Line2		Con	192			' Point to beginning of line 2
    	Line3		Con	148			' Point to beginning of line 3
    	Line4		Con	212			' Point to beginning of line 4
    	Cgram		Con	64			' Point to Cgram within LCD
    	Shift_L		Con	24			' Shift display left
    	Shift_R		Con	28			' Shift display right
    
    ' ** Declare Variables **
    
    	SO		Var	PortA.0			' Serial In Inverted
    	VDD		Var	PortA.1			' LCD VDD pin
    	SO2		Var	PortA.4			' Serial In True
    	P_Test 	Var	PortB.4				' Pin for polarity setting
    	Rcvbyte	Var	Byte				' The byte received 
    
    Main:
    	Low VDD						' Turn Off LCD
    	Pause 	500					' Wait for Pic to Initialise
    	High VDD					' Turn On LCD
    	Pause 50					' Wait for LCD to Initialize 
    
    ' ** Check for Polarity Setting **
    
    	TrisB=255					' Set PortB to Input
    	If P_Test=1 then Goto True_Pol			' PortB.4 HI then True Polarity
    	If P_Test=0 then Goto Inv_Pol			' PortB.4 LO then Inverted Polarity
    			
    	Goto Main					' Just In case it Missed the settings
    
     
    ' ** Receive characters serially with True polarity **
    
    True_Pol:
    	Gosub Clr_It					' Initialize the LCD	
    	Lcdout I,Line2," T9600 Baud OK!"		' Print message			
    
    Start_T9600:
    	Serin SO,T9600,Rcvbyte				' Get Serial Data in
    	Lcdout Rcvbyte					' Send send straight out to LCD
    	Goto Start_T9600				' Loop back forever
    
    ' ** Receive characters serially with Inverted polarity **
    
    Inv_Pol:
    	Gosub Clr_It					' Initialize the LCD	
    	Lcdout I,Line2," N9600 Baud OK!"		' Print message			
    
    Start_N9600:
    	Serin SO,N9600,Rcvbyte				' Get Serial Data in
    	Lcdout Rcvbyte					' Send straight out to LCD
    	Goto Start_N9600				' Loop back forever
    
    ' Initialize LCD ready to print
    Clr_It:
    	High	VDD				' Switch On LCD VDD
    	TrisB=0					' Set Port to Output
    	Pause 	100				' Wait for LCD to Initialise
    	Lcdout I,Clr:Pause 30			' Clear the LCD	
    	Lcdout I,Line1," LCD Serializer"
    	Return

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hello Tobias,
    most likely you are not matched as to T/N and baud rate to your serial LCD. I am not familiar with your particular serial LCD, try some different baud rates and try them true and inverted. I would just make several serout statements with a string to identify, the one you can read is the one you use, example:
    Code:
    Serout PORTC.6,N9600,["9600 inverted"]
    pause 500
    Serout PORTC.6,T9600,["9600 True"]
    pause 500
    Serout PORTC.6,N2400,["2400 inverted"]
    pause 500
    Serout PORTC.6,T2400,["2400 True"]
    pause 500
    add the rest of the available choices and you have a test program to sort out the settings of your LCD.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. LCD serial backpacks
    By Archangel in forum Serial
    Replies: 67
    Last Post: - 30th December 2010, 04:51
  2. Please help with EDE702 - Serial to LCD interface
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th October 2008, 02:48
  3. Play with LCD on PICDEM
    By The IceMan in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd August 2008, 16:56
  4. Serial LCD
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 15th November 2007, 08:31
  5. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 26th June 2007, 23:07

Members who have read this thread : 0

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