write to LCD on the fly ?
Barney-
Let your Stamp work for you! It knows the ASCII code for 'M' and 'o'
etc., you don't have to define the bit patterns yourself.
Try this:
OUT4 = 1 ' data vice command
OUTA = "M" >> 4 ' high order nibble on OUTA
PULSOUT 6,1
OUTA = "M" ' low order nibble on OUTA
PULSOUT 6,1
To generate an ASCII character for a single (decimal) digit, simply
OR in $30. Or add "0" which has the same effect--whichever feels
best. Look at the ASCII codes for numeric characters to convince
yourself. For example, if a variable x holds the value 8:
OUT4 = 1 ' data vice command
OUTA = x | $30 >> 4 ' high order nibble on OUTA
'OUTA = x + "0" >> 4 ' high order nibble on OUTA (alternate form)
PULSOUT 6,1
OUTA = x ' low order nibble on OUTA
PULSOUT 6,1
Now a more generic form of the above:
byte_to_lcd = "M": GOSUB charToLCD ' ASCII data
byte_to_lcd = x + "0": GOSUB charToLCD ' numeric data
STOP
charToLCD:
OUT4 = 1 ' data vice command
OUTA = byte_to_lcd >> 4 ' high order nibble on OUTA
PULSOUT 6,1
OUTA = byte_to_lcd ' low order nibble on OUTA
PULSOUT 6,1
RETURN
By changing the OUT4 = 1 to OUT4 = 0, the same routine works to send
commands to your LCD. Now add some data storage and retrieval:
mode_msg DATA "Mode",0
rom_addr = mode_msg
GOSUB displayLoop
quit:
STOP
displayLoop:
READ rom_addr,byte_to_LCD
IF n = 0 THEN quit
GOSUB charToLCD
GOTO displayLoop
Good on you for your evident effort to date. Regards,
Steve
Let your Stamp work for you! It knows the ASCII code for 'M' and 'o'
etc., you don't have to define the bit patterns yourself.
Try this:
OUT4 = 1 ' data vice command
OUTA = "M" >> 4 ' high order nibble on OUTA
PULSOUT 6,1
OUTA = "M" ' low order nibble on OUTA
PULSOUT 6,1
To generate an ASCII character for a single (decimal) digit, simply
OR in $30. Or add "0" which has the same effect--whichever feels
best. Look at the ASCII codes for numeric characters to convince
yourself. For example, if a variable x holds the value 8:
OUT4 = 1 ' data vice command
OUTA = x | $30 >> 4 ' high order nibble on OUTA
'OUTA = x + "0" >> 4 ' high order nibble on OUTA (alternate form)
PULSOUT 6,1
OUTA = x ' low order nibble on OUTA
PULSOUT 6,1
Now a more generic form of the above:
byte_to_lcd = "M": GOSUB charToLCD ' ASCII data
byte_to_lcd = x + "0": GOSUB charToLCD ' numeric data
STOP
charToLCD:
OUT4 = 1 ' data vice command
OUTA = byte_to_lcd >> 4 ' high order nibble on OUTA
PULSOUT 6,1
OUTA = byte_to_lcd ' low order nibble on OUTA
PULSOUT 6,1
RETURN
By changing the OUT4 = 1 to OUT4 = 0, the same routine works to send
commands to your LCD. Now add some data storage and retrieval:
mode_msg DATA "Mode",0
rom_addr = mode_msg
GOSUB displayLoop
quit:
STOP
displayLoop:
READ rom_addr,byte_to_LCD
IF n = 0 THEN quit
GOSUB charToLCD
GOTO displayLoop
Good on you for your evident effort to date. Regards,
Steve
Comments
Am a bit stuck here and would appreciate any help with this.
How do I write data to my LCD on the fly ?
I've built a 4 bit data bus.
I have predetermined constant values which spell the static words
to be displayed throughout the program.
ie.
PINS 0=DB7 1=DB6 2=DB5 3=DB4 4=RS 5=R/W 6=Enable
'MODE
muh con %10100 'high upper M
mul con %11101 'low upper M
oh con %10110 'high
ol con %11111 'low
dh con %10110 'high
dl con %10100 'low
eh con %10110 'high
el con %10101 'low
high byte first of the ASC11 code for the character followed by low byte
this is then printed to LCD via two subroutines as below.
The 1 at the front of every binary byte eg. oh con %10110 is the
Register select "1" which tells the LCD that the bus
is data as opposed to instruction.
'MODE
MODE:
FOR reps = 0 to 7 'reps is a var
lookup reps,[noparse][[/noparse]muh,mul,oh,ol,dh,dl,eh,el],set 'looks up "mode" and
prints to LCD, set is a var
gosub print
NEXT
return
PRINT:
outs = set 'outs is set to the var "set"
which is determined in the For
pulsout 6,20 'Next lookups
pause 20
return
This is all working fine although I'm chewing up a lot of EEPROM , but I
would like to
write data on the fly like maybe a number in a variable that will change
constantly. as opposed to predetermined
and specified words.
Trouble is :
For example we have a var = 8 %1000
I cant figure out how to access the binary low or high byte of a variable ?
in this case high "0000" low "1000"
Even if I could and then set "OUTS" to the correct combination of 0's and
1's to print that character
I still cant get the all important (register select) "1" on the bus to
specify that the bus is data ? the
OUTS should actually look like :
OUTS = %10000 high
OUTS = %11000 low
in order to print to the LCD.
But even if I could do all of that it still wouldn't work because the LCD
uses ASC11
to print with and so the "8" in my variable and the above OUTS configuration
wouldn't end up being anything
because "8" in ASC11 = backspace.
If I wanted to print 8 to the LCD I would have to configure the outs to %56
OUTS = %10011 high
OUTS = %11000 low
Would be great to be able to print on the fly as the LCD is going to be the
only form of
user interface.
Thanks for your help.
Regards
Barney
This could perhaps help:
To enter and display one byte (<256) on LCD
value var byte
digit var byte
index var nib
loop:
value = 0
for index = 0 to 2
serin 16,240,[noparse][[/noparse]DEC digit] 'get a digit from PC
value = (value * 10) + digit 'add it to value * 10
debug dec digit,CR 'for testing only
digit = digit + 48 'convert it to ASCII
gosub displ
next
debug dec value,CR 'for testing only
goto loop
displ:
'put your LCD display subroutine for one ASCII character
return
Regards
ECO
Original Message
From: Barney <cafe@e...>
To: basic stamp <basicstamps@yahoogroups.com>
Sent: Thursday, July 19, 2001 8:45 AM
Subject: [noparse][[/noparse]basicstamps] write to LCD on the fly ?
> Hi,
>
> Am a bit stuck here and would appreciate any help with this.
>
> How do I write data to my LCD on the fly ?
>
> I've built a 4 bit data bus.
>
> I have predetermined constant values which spell the static words
> to be displayed throughout the program.
>
> ie.
>
> PINS 0=DB7 1=DB6 2=DB5 3=DB4 4=RS 5=R/W 6=Enable
>
>
> 'MODE
>
> muh con %10100 'high upper M
> mul con %11101 'low upper M
> oh con %10110 'high
> ol con %11111 'low
> dh con %10110 'high
> dl con %10100 'low
> eh con %10110 'high
> el con %10101 'low
>
> high byte first of the ASC11 code for the character followed by low byte
>
> this is then printed to LCD via two subroutines as below.
>
> The 1 at the front of every binary byte eg. oh con %10110 is the
> Register select "1" which tells the LCD that the bus
> is data as opposed to instruction.
>
> 'MODE
> MODE:
> FOR reps = 0 to 7 'reps is a var
> lookup reps,[noparse][[/noparse]muh,mul,oh,ol,dh,dl,eh,el],set 'looks up "mode" and
> prints to LCD, set is a var
> gosub print
> NEXT
> return
>
>
> PRINT:
> outs = set 'outs is set to the var "set"
> which is determined in the For
> pulsout 6,20 'Next lookups
> pause 20
> return
>
>
> This is all working fine although I'm chewing up a lot of EEPROM , but I
> would like to
> write data on the fly like maybe a number in a variable that will change
> constantly. as opposed to predetermined
> and specified words.
>
> Trouble is :
>
> For example we have a var = 8 %1000
>
> I cant figure out how to access the binary low or high byte of a variable ?
> in this case high "0000" low "1000"
>
> Even if I could and then set "OUTS" to the correct combination of 0's and
> 1's to print that character
> I still cant get the all important (register select) "1" on the bus to
> specify that the bus is data ? the
> OUTS should actually look like :
>
> OUTS = %10000 high
> OUTS = %11000 low
>
> in order to print to the LCD.
>
> But even if I could do all of that it still wouldn't work because the LCD
> uses ASC11
> to print with and so the "8" in my variable and the above OUTS configuration
> wouldn't end up being anything
> because "8" in ASC11 = backspace.
>
> If I wanted to print 8 to the LCD I would have to configure the outs to %56
>
> OUTS = %10011 high
> OUTS = %11000 low
>
> Would be great to be able to print on the fly as the LCD is going to be the
> only form of
> user interface.
>
> Thanks for your help.
>
> Regards
>
> Barney
>
>
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and Body
of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>