PDA

View Full Version : Serial LCD is Killing Me! Just garbage



mslaney
- 21st June 2005, 16:17
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

Dwayne
- 21st June 2005, 17:47
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

Luciano
- 21st June 2005, 21:16
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



' 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.

mslaney
- 21st June 2005, 21:35
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.

mslaney
- 21st June 2005, 22:19
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

muddy0409
- 22nd June 2005, 04:08
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.

mslaney
- 22nd June 2005, 13:19
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!!

Dwayne
- 22nd June 2005, 14:55
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