serial LCD display?


Closed Thread
Results 1 to 6 of 6
  1. #1
    ra68gi's Avatar
    ra68gi Guest

    Question serial LCD display?

    Hello everbody,
    Iam Interested in constructing a serial lcd display like the commercially available back pack.I tried using the serin command of Pic basic to receive the items( string of characters ) and display it on a 16*2 lcd Hitachi module in the 4 bit mode.It displayed junk.I was successful in displaying single variable but not string.can any one help me ? can any one give code example with serin2 with over flow pin,str(string variable).Preferably on pic16f84.A good explanation on its working will greatly be appreciated.
    Thanks.
    ra68gi.

  2. #2
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Default

    Hi,

    The PIC is to slow to manage the seriel communication and the LCD-work in software !
    You have to use an hardware-UART !
    Try to use also an 32-byte-ringbuffer for the received data (Interrupt-service-routine in assembler).
    I realized the same with an I2C-communication on a 16F872. The PIC is to big, but it is one of our "favorites".
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  3. #3
    Join Date
    Oct 2004
    Posts
    19


    Did you find this post helpful? Yes | No

    Default

    Look at the melabs site.
    I know they have some examples for the lab X1 board and they may have it for others.
    Victor

  4. #4


    Did you find this post helpful? Yes | No

    Default Should be easy

    I did this with a 'F88 - worked fine at 2400 baud (at 4MHz XT) so it should work fine on a 'F84/'F84A

    I had it storing stuff in a buffer until it saw a chr$(13), then sending it all out to the LCD in one go...

    Here's my code:

    'Serial Control LCD
    'for 24-char x 2 line display
    'Serial data in at 2400 baud on PA0
    'LCDout connections:
    ' PB0-PB3: DB4-DB7 ON LCD
    ' PB4: RS ON LCD
    ' PB5: E on LCD
    ' PB6: active high LCD backlight output
    ' R/W on LCD must be connected to GND
    '
    'Serial mode depends on the status of PA1 on powerup
    ' PA1=0:non-inverted mode (pic-to-pic)
    ' PA1=1:inverted mode (RS-232)
    '
    'turn the LCD backlight on/off by sending <1><13> or <0><13> respectively

    DEFINE LCD_DREG PORTB 'set LCD data port
    DEFINE LCD_DBIT 0 'Set starting Data bit (0 or 4) for 4-bit bus
    DEFINE LCD_RSREG PORTB 'set LCD register select port
    DEFINE LCD_RSBIT 4 'set LCD register select BIT
    DEFINE LCD_EREG PORTB 'set LCD enable port
    DEFINE LCD_EBIT 5 'set LCD enable bit
    DEFINE LCD_BITS 4 'LCD bus size (4 or 8)
    DEFINE LCD_LINES 2 'number of lines on LCD
    DEFINE LCD_COMMANDUS 2000 'set command delay time in microseconds
    DEFINE LCD_DATAUS 50 'set data delay time in microseconds
    '
    sermode VAR BYTE
    mybyte VAR BYTE
    pointer VAR BYTE
    sendline VAR BYTE[24]
    '
    TRISA=63 'all inputs
    TRISB=255 'all outputs
    'note: pulldown PB3 if using 16F88
    High PORTB.6

    'read PA1 on powerup to determine mode
    'jumper to ground for PIC-PIC communication (non-inverted, non-driven)
    'jumper to + for RS-232 communication (inverted, driven)

    IF PORTA.1=0 Then
    sermode=0
    Else
    sermode=4
    EndIF

    Pause 1000 'initial pause before using the LCD
    LCDOut $FE,1,"Display Initialized" 'clear display, send message
    IF sermode=0 Then
    LCDOut $FE,$C0,"PIC mode @2400 baud"
    Else
    LCDOut $FE,$C0,"RS-232 mode @2400 baud"
    EndIF

    Pause 2000 'wait 2 seconds
    LCDOut $FE,1 'clear display again

    NEWLINE:
    pointer=0

    GETMORE:
    SerIn PORTA.0,sermode,,mybyte 'get 1 byte at a time
    IF mybyte = 13 Then GoTo processme
    sendline[pointer] = mybyte
    pointer=pointer+1
    GoTo getmore

    processme:
    IF pointer=1 AND sendline[0]=0 Then
    Low PORTB.6 'turn off the LCD light if <0><13>
    GoTo newline
    EndIF

    IF pointer=1 AND sendline[0]=1 Then
    High PORTB.6 'turn on the lcd light if <1><13>
    GoTo newline
    EndIF

    IF pointer=2 AND sendline[0]=$FE Then
    IF sendline[1]=$01 Then 'clear display
    LCDOut $FE,1
    EndIF
    IF sendline[1]=$02 Then 'return home
    LCDOut $FE,2
    EndIF
    IF sendline[1]=$0C Then 'cursor off
    LCDOut $FE,$0C
    EndIF
    IF sendline[1]=$80 Then 'beginning of first line
    LCDOut $FE,$80
    EndIF
    IF sendline[1]=$C0 Then 'beginning of 2nd line
    LCDOut $FE,$C0
    EndIF
    GoTo newline
    EndIF


    LCDOut STR sendline\pointer
    GoTo newline
    End

    --------------Picster-------------

  5. #5
    ra68gi's Avatar
    ra68gi Guest


    Did you find this post helpful? Yes | No

    Question

    Picster,
    Thanks for the code.I will soon try it out.I have a few more questions with regard to the code you have sent.
    First,
    ' PA1=0:non-inverted mode (pic-to-pic)
    ' PA1=1:inverted mode (RS-232)

    is there some sort of a convention to use non-inv mode for pic to pic & inverting mode for RS-232.
    Please explain.

    Second,
    GETMORE:
    SerIn PORTA.0,sermode,,mybyte 'get 1 byte at a time

    I can see two comas after sermode.Is that right.
    ra68gi

  6. #6


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by ra68gi
    Picster,
    Thanks for the code.I will soon try it out.I have a few more questions with regard to the code you have sent.
    First,
    ' PA1=0:non-inverted mode (pic-to-pic)
    ' PA1=1:inverted mode (RS-232)

    is there some sort of a convention to use non-inv mode for pic to pic & inverting mode for RS-232.
    Please explain.
    You must use inverted mode (through a resistor) if you're using RS-232 voltage levels (i.e. - to a PC serial port). For PIC-PIC serial communication, this is not necessary, you can merely use non-inverted, TTL levels.

    Quote Originally Posted by ra68gi
    Second,
    GETMORE:
    SerIn PORTA.0,sermode,,mybyte 'get 1 byte at a time

    I can see two comas after sermode.Is that right.
    ra68gi
    Yes, because there is no "qualifier" to satisfy, you put 2 commas in as placeholders.

    ----------------------Picster----------------------

Similar Threads

  1. LCD serial backpacks
    By Archangel in forum Serial
    Replies: 67
    Last Post: - 30th December 2010, 04:51
  2. LCD Display
    By lambert in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 16th January 2010, 22:18
  3. 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
  4. Replies: 2
    Last Post: - 14th July 2008, 22:11
  5. SMART Serial 4 Digit LCD Display (SMARD4)
    By paul borgmeier in forum Adverts
    Replies: 0
    Last Post: - 5th January 2005, 05:50

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