Serial LCD is Killing Me! Just garbage


Closed Thread
Results 1 to 8 of 8
  1. #1
    mslaney's Avatar
    mslaney Guest

    Default Serial LCD is Killing Me! Just garbage

    Hi there,
    I have a 4x20 LCD Seetron BPP420 with a 628A. It won't work for me. I am sure it's a code problem.

    I don't just want to cut and paste code but I really need a working example of the classic hello world on a 4x20 and/or a 2x20.
    Where is all this basic information? The PBP manual is terse and cryptic.

    Here are all the things I tried:

    DEFINE OSC 20
    include "modedefs.bas"

    cmcon = 7
    trisa = %00000000
    trisb = %00000000
    porta = $00
    portb = $00

    main:

    pause 1000 ' wait for the LCD to startup

    serout PortB.2,4,[$FE,$01] ' clear the screen

    serout PortB.2,4,["Hello World"] ' send string

    pause 1000 ' pause for a second

    SEROUT2 PORTB.2,84,["the world frustrates me"]

    serout portb.0, n9600, ["Mike, Just ask for help!"]

    'Just make sure the chip is running:
    high portb.3
    pause 100
    low portb.3
    pause 100


    goto main ' loop

  2. #2
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello MSLaney,

    MSLKaney>>pause 1000 ' wait for the LCD to startup

    serout PortB.2,4,[$FE,$01] ' clear the screen<<

    I notice you are using SEROUT, instead of LCDout.... I am assuming that you are using some kind of Serial LCD....

    Many LCD's have to be initialized before they will work...

    LCDout does this automatically for you....
    SEROUT does NOT!!!


    Thus, make up your mind... either use LCDout, and let PBP do all the work for you (but this also means you must use at least 4 pins for data, and a few others for Command/Data, Clock, etc.

    Or using a serial backpack type LCD... you may need to initalize manually and do the overhead yourself.



    Try sending a Dec 13 to your LCD to "Initialize" it ok??? Then try writing to it...

    serout PortB.2,4,[13] ' Initialize LCD

    or

    serout PortB.2,4,[$0D] ' Initialize LCD

    Dwayne
    Last edited by Dwayne; - 21st June 2005 at 17:55.
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  3. #3
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Hi,

    This is the Basic Stamp 2 sample you can find in your LCD manual.

    Changes for PBP:

    - SEROUT Pin,Mode,[Item{,Item...}]
    Mode is 6 (9600 Driven Inverted)

    - Declare variable b2
    b2 VAR byte

    Serial LCD manual:
    http://www.seetron.com/pdf/bpp423.pdf

    In order to run the sample code below you will have to set the
    DIP Switch of the LCD module as following:

    1=OFF (Normal mode)
    2=ON (9600 baud)

    Regards,

    Luciano

    Code:
    ' Program: 420DEMO.BS2 (Demonstrate 4x20 Serial LCD with Stamp II)
    ' This program demonstrates many of the features of the 4x20 Serial
    ' LCD Module from Scott Edwards Electronics. Set the module to
    ' 9600 bps (S1: switch 1 down; 2 up). Connect the serial input
    ' of the module to BS2 pin P0, GND to GND and +5V to +5V.
    ' Run this program.
    ' =========Define names for LCD instructions, bps=======
    noCurs con 4 ' Make cursor invisible.
    ulCurs con 5 ' Show underline cursor.
    clrLCD con 12 ' Clear entire LCD screen.
    posCmd con 16 ' Position cursor.
    clrCol con 17 ' Clear column.
    wedge con 128 ' Wedge-shaped symbol.
    bigNums con 2 ' Begin big numbers.
    N9600 con $4054 ' Baudmode for inverted, 9600-bps output.
    ' The constants "bell" and "bksp" are predefined in PBASIC2.
    ' =================Begin demonstration=================
    pause 1000
    
    serout 0,N9600,[clrLCD] ' Clear the screen.
    
    for b2 = 0 to 79
      serout 0,N9600,[wedge] ' Fill screen with wedges.
    next
    
    pause 1000 ' Wait 1 second.
    
    serout 0,N9600,[posCmd,68] ' Move to position 4 (64+4= 68).
    
    for b2 = 1 to 12 ' Clear a 12-character swath with
      pause 350 ' ...the clear-column feature.
      serout 0,N9600,[clrCol,bell] ' Ring bell (if available) each loop.
    next
    
    ' Turn on the underline cursor, move to pos. 26, and show message.
    serout 0,N9600,[ulCurs,posCmd,90,"4x20 LCD"]
    
    pause 1000 ' Wait 1 second.
    
    for b2 = 1 to 8
      pause 100 ' Backspace to erase message.
      serout 0,N9600,[bksp,bell] ' Ring bell (if available) each loop.
    next
    
    pause 1000 ' Wait 1 second.
    
    serout 0,N9600,[noCurs] ' Turn cursor off.
    
    ' Print the numbers 0 to 99 in big numbers in the middle of
    ' the screen. Pause a half second between numbers.
    
    for b2 = 0 to 99
      serout 0,N9600,[posCmd,70,bigNums,dec b2]
      pause 500
    next
    
    END ' Finished.

  4. #4
    mslaney's Avatar
    mslaney Guest


    Did you find this post helpful? Yes | No

    Default

    Thank you guys!
    In the meantime, i took a long fast ride on my motorcycle and came back with a clear head. I got it working...
    All this time I was looking in the manual when I should have been looking at the datasheet.
    When I get to trying to make the code more elegant, I'll be back!
    Thanks.

  5. #5
    mslaney's Avatar
    mslaney Guest


    Did you find this post helpful? Yes | No

    Default

    OK, this is what I came up with to write the line number on their repective lines. How do I make this more elegant/neater? A counter loop for the line number maybe?


    'Chip registers and inits
    cmcon = 7
    trisa = %00000000
    trisb = %00000000
    porta = $00
    portb = $00

    'Vars and Cons
    screen var portb.0


    main:

    pause 500 'wait for the LCD to startup

    serout screen,n9600,[$FE,12,4,1] 'clear the screen position and hide cursor
    serout screen,n9600,["Line 1"] 'Print on line 1
    pause 500
    serout screen,n9600,[$FE,12,4,1,10] 'Clear screen and position to line 1
    serout screen,n9600,["Line 2"] 'print on line 2
    pause 500
    serout screen,n9600,[$FE,12,4,1,10,10] 'Clear screen and position cursor to line3
    serout screen,n9600,["Line 3"] 'Print on line 3
    pause 500
    serout screen,n9600,[$FE,12,4,1,10,10,10] 'Go to line 4
    serout screen,n9600,["Line 4"] 'Print on line 4


    ''Just make sure the chip is running:
    'high portb.3
    'pause 100
    'low portb.3
    'pause 100

    goto main ' loop

  6. #6
    Join Date
    Jun 2005
    Location
    Up the bush, Western Plains, NSW Au
    Posts
    216


    Did you find this post helpful? Yes | No

    Default

    I also have had problems with serial LCD coms. I have tried serial modules form 4 different manufacturers and have spent hours trying to make the buggers work. Well, NO MORE!!!
    In utter frustration, I tried the setup exactly as listed in the MEL manual for connecting to an LCD direct. First time success. I know there is a lot of talk about the extra lines required, but, is it cheaper to move up 1 size in PIC for a cuppla bucks, or add a serial adaptor for a cuppla bucke. No arguement. I will be using the book's example from here on in. It really is so simple.

  7. #7
    mslaney's Avatar
    mslaney Guest


    Did you find this post helpful? Yes | No

    Default

    Well, it certainly was not a cuppla bucks for the display and backpack!! Seetron.com ~$50.

    However, the reason I got it was to learn how to use it. Now that I figured it out, I can use smaller packages even if it doesn't matter. I think of it as tuition!

    I was using a parallel display and the LCD out commands and it *was* much easier after adjusting the defines. Oh, and the display was as cheap as the pic!!

  8. #8
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Mike Slaney,

    MS>>Well, it certainly was not a cuppla bucks for the display and backpack!! Seetron.com ~$50. <<

    Yeah... I couldn't see myself paying that much for a backpack...For less than 15 dollars. Used a cheapo LCD and a 648A for the driver.

    MS>>However, the reason I got it was to learn how to use it.<<

    Thats the fun part.... I have a very good friend...He has a quote...that goes something like this:

    "We purchase and put together 5 and 10 dollar PIC projects to learn to use our 1000s of dollars equipment."

    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

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