Stupid Newbie Question#3 LCD query
Archiver
Posts: 46,084
First, thanks to those of you who replied to my "BUTTON woes" posting.
Now, time to be a pest...
DISCLAIMER:
I have read the manual, I have more manuals on the way.
Here's the deal:
I am sucessfully writing to a 20 X 4 LCD, with a BS2. Fairly
straighforward, so long as I read characters from EEPROM, or a table.
I can display pre-defined data OK, now, for the hard (for me) part.
Say I take a measurement, and I want to display than measurement on
the LCD. ie: I convert ADC data to a decimal number, shift
characters in a loop, add a decimal point, use the "remainder" //
operator and put those (that) number to the right of the decimal.
I have done this using DEBUG, I get something like this on the screen:
VOLTS= 12.36
Just what I wanted.
I tried doing the same thing with the LCD. Shifted characters, added
48 to the number to display ASCII 0-9. Doesn't work.
Doing this with DEBUG sends beautiful output to the screen. The LCD
does display stuff, in the places I specified, only it does not
display the stuff I want it to.
Suggestions?
thanks
Rich
Now, time to be a pest...
DISCLAIMER:
I have read the manual, I have more manuals on the way.
Here's the deal:
I am sucessfully writing to a 20 X 4 LCD, with a BS2. Fairly
straighforward, so long as I read characters from EEPROM, or a table.
I can display pre-defined data OK, now, for the hard (for me) part.
Say I take a measurement, and I want to display than measurement on
the LCD. ie: I convert ADC data to a decimal number, shift
characters in a loop, add a decimal point, use the "remainder" //
operator and put those (that) number to the right of the decimal.
I have done this using DEBUG, I get something like this on the screen:
VOLTS= 12.36
Just what I wanted.
I tried doing the same thing with the LCD. Shifted characters, added
48 to the number to display ASCII 0-9. Doesn't work.
Doing this with DEBUG sends beautiful output to the screen. The LCD
does display stuff, in the places I specified, only it does not
display the stuff I want it to.
Suggestions?
thanks
Rich
Comments
Say you have:
whole=12
frac=36
char=whole dig 1 + 48
gosub lcd_out ' write char to LCD
char=whole dig 0 + 48
gosub lcd_out
char="."
gosub lcd_out
char = frac dig 1 + 48
gosub lcd_out
char = frac dig 0 + 48
gosub lcd_out
Of course, you could make these part of a loop.
Regards,
Al Williams
AWC
*NEW: PAK-IX Floating point A/D: http://www.al-williams.com/awce/pak9.htm
>
Original Message
> From: iceninevt@y... [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=SI8_oYVgSQ1_7zEuX7MEsvraEytATM6ygabTsl4N6cy_6szmgv_a4EYRSHQp42Nf3_gReMxv51L-ueoM]iceninevt@y...[/url
> Sent: Thursday, April 12, 2001 10:06 AM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] Stupid Newbie Question#3 LCD query
>
>
> First, thanks to those of you who replied to my "BUTTON woes" posting.
>
> Now, time to be a pest...
>
> DISCLAIMER:
> I have read the manual, I have more manuals on the way.
>
> Here's the deal:
>
> I am sucessfully writing to a 20 X 4 LCD, with a BS2. Fairly
> straighforward, so long as I read characters from EEPROM, or a table.
>
> I can display pre-defined data OK, now, for the hard (for me) part.
>
> Say I take a measurement, and I want to display than measurement on
> the LCD. ie: I convert ADC data to a decimal number, shift
> characters in a loop, add a decimal point, use the "remainder" //
> operator and put those (that) number to the right of the decimal.
>
> I have done this using DEBUG, I get something like this on the screen:
>
> VOLTS= 12.36
>
> Just what I wanted.
>
> I tried doing the same thing with the LCD. Shifted characters, added
> 48 to the number to display ASCII 0-9. Doesn't work.
>
> Doing this with DEBUG sends beautiful output to the screen. The LCD
> does display stuff, in the places I specified, only it does not
> display the stuff I want it to.
>
> Suggestions?
>
> thanks
>
> Rich
>
>
>
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
Original Message
> From: iceninevt@y... [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=IgumERFAC5EaXz5XXfd00-v4MED3YF5VU_vJoYks0-Ad7XWxGnPIbrAsh2tCMv6Oetoh336P8ZH2Pg]iceninevt@y...[/url
> Sent: Thursday, April 12, 2001 11:06 AM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] Stupid Newbie Question#3 LCD query
>
>
> First, thanks to those of you who replied to my "BUTTON woes" posting.
>
> Now, time to be a pest...
>
> DISCLAIMER:
> I have read the manual, I have more manuals on the way.
>
> Here's the deal:
>
> I am sucessfully writing to a 20 X 4 LCD, with a BS2. Fairly
> straighforward, so long as I read characters from EEPROM, or a table.
>
> I can display pre-defined data OK, now, for the hard (for me) part.
>
> Say I take a measurement, and I want to display than measurement on
> the LCD. ie: I convert ADC data to a decimal number, shift
> characters in a loop, add a decimal point, use the "remainder" //
> operator and put those (that) number to the right of the decimal.
>
> I have done this using DEBUG, I get something like this on the screen:
>
> VOLTS= 12.36
>
> Just what I wanted.
>
> I tried doing the same thing with the LCD. Shifted characters, added
> 48 to the number to display ASCII 0-9. Doesn't work.
>
> Doing this with DEBUG sends beautiful output to the screen. The LCD
> does display stuff, in the places I specified, only it does not
> display the stuff I want it to.
>
> Suggestions?
>
> thanks
>
> Rich
>
>
>
>
>
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
I've been watching this thread and the 'DIG' function looks interesting.
Is this the easy way to do bcd stuff ?
Chris
DCD, and NCD. The 2.0 manual might be a little better.
In my book Microcontroller Projects with Basic Stamps
(http://www.al-williams.com/awce/sbook.htm) I treat all of the operators as
commands so they have a page just like the real commands. That means you see
them when you are looking things up. Well, some of them share a page
together, but they are "in your face" every time you are looking something
up -- something the Stamp manual doesn't do.
Your mileage may vary.
Al Williams
AWC
*NEW: PAK-IX Floating Point A/D: http://www.al-williams.com/awce/pak9.htm
>
Original Message
> From: Chris Anderson [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=jKREb5EAJ8NxtmqzS4RHj5bAqXSH2fgHWdvaWBu4Y8Xr1nmH3HxMu11e8qKYZe0T90I2cxIr5GJVIPA]fes@g...[/url
> Sent: Thursday, April 12, 2001 7:35 PM
> To: basicstamps@yahoogroups.com
> Subject: Re: [noparse][[/noparse]basicstamps] Stupid Newbie Question#3 LCD query
>
>
> Hello Al,
> I've been watching this thread and the 'DIG' function looks interesting.
> Is this the easy way to do bcd stuff ?
> Chris
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>Is this the easy way to do bcd stuff ?
Hi Chris,
Here's a little tutorial.
DIG does not really have anything to do with BCD coding.
Example that might clarify it...
x=13577 ' given in decimal
' equals $3509 in hex (3509 BCD)
' or %0011010100001001 binary
y=$25 ' given in hex
' (but could represent decimal 25 in BCD code)
' equals 37 decimal, %00100101 binary
z=$A5 ' given in hex, (can't be BCD because of the "A")
' equals 165 decimal, %10100101 binary
' extracting decimal digits...
debug ? x DIG 4 ' prints 1
debug ? x DIG 0 ' prints 9
debug ? DEC x ' prints 13579
debug ? y DIG 1 ' prints 3
debug ? y DIG 0 ' prints 7
debug ? DEC y ' prints 37
debug ? z DIG 2 ' prints 1
debug ? z DIG 1 ' prints 6
debug ? z DIG 0 ' prints 5
debug ? DEC z ' prints 165
' extracting hex or BCD digits:
debug hex x ' prints 3509
' which can be either hex really,
' or the BCD representation of decimal 3509
debug hex y ' prints 25
' which could be hex really,
' or the BCD representation of decimal 25
debug hex z ' prints A5
debug dec z ' prints 165
To send individual nibbles as digits, say to an LCD screen...
x=$3509 ' BCD coded decimal number
for i=3 to 0 ' prints 3,5,0,9
debug x.nib0(i) + 48
next
debug CR
x=13577 ' same number in the computer memory
' but different interpretation
for i=4 to 0 ' prints 1,3,5,7,7
debug x DIG i + 48
next
debug CR
Adding 48 to each nibble makes it into an ascii character for a
numeral {0,1,...,9}, which the LCD screen or terminal will print
correctly.
debug ? x DIG 4 ' prints 1
debug ? x DIG 0 ' prints 7
debug ? DEC x ' prints 13577
Tracy Allen wrote:
> x=13577 ' given in decimal
> ' equals $3509 in hex (3509 BCD)
> ' or %0011010100001001 binary
> ' extracting decimal digits...
> debug ? x DIG 4 ' prints 1
> debug ? x DIG 0 ' prints 9
> debug ? DEC x ' prints 13579
=============
ACJacques
x=92
xbcd = (x DIG 1)<<4 + (x DIG 0)
Which is just another way of saying:
xbcd = x/10<<4 + (x//10) ' assuming x<=99
Or, as you point out:
xbcd.nib1=x/10
xbcd.nib0=x//10
Plenty of different ways to get from A to B.
Al Williams
AWC
* 8 channels of PWM: http://www.al-williams.com/awce/pak5.htm
x=13577 ' given in decimal
debug ? x DIG 4 ' prints 1
debug ? x DIG 0 ' prints 7
debug ? x ' prints 13577
>Just a little correction...
>
>debug ? x DIG 4 ' prints 1
>debug ? x DIG 0 ' prints 7
>debug ? DEC x ' prints 13577
>
>
>Tracy Allen wrote:
>> x=13577 ' given in decimal
>> ' equals $3509 in hex (3509 BCD)
>> ' or %0011010100001001 binary
>
>> ' extracting decimal digits...
>> debug ? x DIG 4 ' prints 1
>> debug ? x DIG 0 ' prints 9
>> debug ? DEC x ' prints 13579
>
>=============
>ACJacques
>
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
debug ? x 'prints x = 13577
ACJacques
>Tracy Allen wrote:
>And it needs another correction
> x=13577 ' given in decimal
> debug ? x DIG 4 ' prints 1
> debug ? x DIG 0 ' prints 7
> debug ? x ' prints 13577
>ACJacques wrote:
>Just a little correction...
>
>debug ? x DIG 4 ' prints 1
>debug ? x DIG 0 ' prints 7
>debug ? DEC x ' prints 13577
>
>
>Tracy Allen wrote:
>> x=13577 ' given in decimal
>> ' equals $3509 in hex (3509 BCD)
>> ' or %0011010100001001 binary
>
>> ' extracting decimal digits...
>> debug ? x DIG 4 ' prints 1
>> debug ? x DIG 0 ' prints 9
>> debug ? DEC x ' prints 13579