I had the same question a bit ago and Googled around for an answer. PC World has a pretty good description of the differences from a user's perspective. You can read it at www.pcworld.com/howto/article/0,aid,104445,00.asp
I can read a message from Eprom, store it in "char" and write ithe character to a LCD using a subroutine. However, when I identfy the digit of a number using DIG and store that digit in char the same subroutine will not write it to the LCD. It will, however, display the proper number of the screen using DEBUG. Any have any suggestions?
That's because DIG returns the numeric value of the number, not the ASCII value. ASCII values are what is actually displayed to the user and what is expected by the LCD display. For example, the numeric value of 5, is, well, 5. Where as the ASCII value that causes a '5' to be displayed on the screen is a decimal 53. So when you move the results of DIG, let's say 5, to the LCD, you are really sending an ENQ code. Decimal 05 is ASCII for Enquiry, a flow control character.
So, how do you get 05, to be 53 so that the LCD will display '5'? The easiest way is to add the digit to the literal "0". (that's a zero) So an ASCII "0", which is a decimal 48, plus a decimal 5, is a decimal 53, which is an ASCII "5". Got it? The code would look something like this:
disp_char VAR byte
results VAR nib
value VAR word
results = value DIG 2 ' Get the 2nd digit of value
disp_char = "0" + results ' generate the ASCII digit to be displayed
I'm not sure how lucid the above is. I'm fighting a head cold and not thinking to well. But hopefully you follow what I'm trying to say. If not, just post back, somebody will help.
Thanks. The answer is so obvious now that you have shown it to me. I did know that the LCD required an ASCII number. That's what I thought I was giving it. I am now a little wiser.
Comments
Jim
http://www.eio.com/lcdglos.htm
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Do you have a Stamp Tester?
http://hometown.aol.com/newzed/index.html
·
That's because DIG returns the numeric value of the number, not the ASCII value. ASCII values are what is actually displayed to the user and what is expected by the LCD display. For example, the numeric value of 5, is, well, 5. Where as the ASCII value that causes a '5' to be displayed on the screen is a decimal 53. So when you move the results of DIG, let's say 5, to the LCD, you are really sending an ENQ code. Decimal 05 is ASCII for Enquiry, a flow control character.
So, how do you get 05, to be 53 so that the LCD will display '5'? The easiest way is to add the digit to the literal "0". (that's a zero) So an ASCII "0", which is a decimal 48, plus a decimal 5, is a decimal 53, which is an ASCII "5". Got it? The code would look something like this:
I'm not sure how lucid the above is. I'm fighting a head cold and not thinking to well. But hopefully you follow what I'm trying to say. If not, just post back, somebody will help.
Jim
Thanks. The answer is so obvious now that you have shown it to me. I did know that the LCD required an ASCII number. That's what I thought I was giving it. I am now a little wiser.
Elton