Parallax Serial LCD

Questions on UARTs, and serial communication
Post Reply
Sawmiller
Posts: 4
Joined: Wed Nov 27, 2013 5:11 pm

Parallax Serial LCD

Post by Sawmiller »

I've got a SuperPro connected to a serial LCD display. I'm using UART2. I copied from example from superpro manual print command but it doesn't work. Here's what I enter in the one line editor and what I get back from it: BAUD(2)=9600
PrintUART2 ("HELLO")
ERROR 2: Expected =, found ("HELLO")

I don't understand. Please HELP



basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: Parallax Serial LCD

Post by basicchip »

You have not defined PRINTUART2.

The similar example in the help files TXD is

Code: Select all

SUB PrintUART1 (Astr(100) as STRING)
    DIM I as INTEGER
    I=0
    WHILE Astr(I)
        TXD(1) =  Astr(I)
        I=I+1
    LOOP
END SUB
'...

main:
BAUD(1)=19200  ' enable UART1


PrintUART1 ("Hello World")       ' Send a string of characters serially out UART
Most serial LCDs require some initialization code too. Which LCD are you using.

Sawmiller
Posts: 4
Joined: Wed Nov 27, 2013 5:11 pm

Re: Parallax Serial LCD

Post by Sawmiller »

I tried running the code but it only displayed the H in Hello.
The LCD I'm using is a PARALLAX Serial LCD. I'll need to do a clear display which is 12 and a CR which is 13. How do I write the code to do that. I tried writing it like PBasic but it didn't like that. Also if you don't mind another dumb question, what is '... ? PBasic is the only basic I've used. I'm almost 69 and have a terrible memory so I'm having a hard time learning ARMBasic. Any help you give I'll be thankful for.

basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: Parallax Serial LCD

Post by basicchip »

In most BASICs anything after a ' is a comment

So

Code: Select all

  '...
is a comment of ... , which indicates other code statements or comments would go here

Our dialect of BASIC is now much more like VisualBASIC or QBASIC, there don't seem to be many users of BASIC stamps anymore, so we moved away from PBASIC syntax to more widely accepted versions.

Most BASICs don't handle special characters very well, you can embed them in a string by

Code: Select all

DIM Astr(100) as string

Astr = "hello  "   ' reserve space for CR  LF
Astr(5)=12
Astr(6)=13
I took a quick look at the spec of the Parallax LCD, and while it doesn't require any dead time between characters it does require 100 ms of time at startup, which you should add after the BAUD(2)=9600 which initializes the UART2.

Sawmiller
Posts: 4
Joined: Wed Nov 27, 2013 5:11 pm

Re: Parallax Serial LCD

Post by Sawmiller »

I've spent hours trying way I can think of to write this code but no success. The code listed will display the first character of Astr but it appears that I isn't being incremented. The loop is being solved only once. I can change the I=0 to I=2 and it will display a h. The clear display doesn't work either. What am I doing wrong?
Thanks for your help. Arnold

#include <Serial.bas>
SUB PrintUART1 (Astr(100) as STRING)
DIM I as INTEGER
I=0
WHILE Astr(I)
TXD(1) = Astr(I)
I=I+1
LOOP
END SUB
main:
DIM Bstr(100) as string
Bstr = " hello" ' reserve space for clear display
Bstr(0)=12 ' clear display
BAUD(1)= 19200 ' enable UART1
wait(100)
PrintUART1 (" hello")

basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: Parallax Serial LCD

Post by basicchip »

As I don't have a Parallax LCD here I can't really duplicate it.

But I can change the TXD(1) to TXD(0) so that the characters are sent out to the PC. That displays " hello" as expected.

So there is something the LCD wants that you are not sending.

Don't you mean

Code: Select all

PrintUART1 (Bstr)
as your last statement?

basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: Parallax Serial LCD

Post by basicchip »

You can also insert control characters by

Code: Select all

DIM Bstr(100) as string
Bstr =  chr(12) + "hello"
This works for all characters except 0, which would terminate the string.

Sawmiller
Posts: 4
Joined: Wed Nov 27, 2013 5:11 pm

Re: Parallax Serial LCD

Post by Sawmiller »

No one ever accused me of being fast. Two nights later I finally got it to work. Turns out the display needed a small wait in the SUB.

#include <Serial.bas>
SUB PrintUART1 (Astr(100) as STRING)
DIM I as INTEGER
I=0
WHILE Astr(I)
TXD(1) = Astr(I)
wait(10)
I=I+1
LOOP
END SUB

main:

DIM Bstr(100) as string
BAUD(1)= 19200 ' enable UART1
HIGH (64) ' Initialize display
WAIT(100)
GOSUB main_a
END

main_a:

Bstr = chr(22) + chr(17) + chr(12) 'display on- cursor off, Backlight on, clear display
wait(5)
PrintUART1 (Bstr)
Bstr = "HELLO" + chr(13) + "WORLD"
PrintUART1 (Bstr)
WAIT(1000)
Bstr = chr(12) + "HELLO BACK" + chr(13) + "AT YOU"
wait(5)
PrintUART1 (Bstr)
RETURN

Is there a book on ARMBasic written for dummies? I try to read the manual, but it is way over my head. It uses language I don't understand.
Thanks for helping me out. I hope you don't get tired of my questions cause I'll have plenty of them. I'm using a Basic Stamp2 now to control my bandsaw saw mill that I built but it isn't a very good choice. I didn't have time to build the sawmill and to learn ARMBasic at the same time. I'm looking forward to using the SuperPro for the sawmill. Thanks again

basicchip
Posts: 1090
Joined: Fri Oct 19, 2012 2:39 am
Location: Weeki Watchee, FL
Contact:

Re: Parallax Serial LCD

Post by basicchip »

Glad you got it working, I thought to suggest adding some delay, as BASICstamps are real sllllowwwwww. But they also had a Propeller example that showed no delay. Maybe it is not required at the lower baud rates.

Yes the ARMbasic help files are meant as a reference, not as a tutorial. But ARMbasic is a subset of Visual BASIC (no object oriented stuff), so many of the tutorials for that on the web or those for MSBASIC would be good.

Post Reply