Formatting Data For LCD

John West

Senior Member
I've been looking through all of my docs, but I can't seem to find the info on how to format data (binary, hex, decimal, ASCII) being sent out to an LCD.

I'm using an 08M, feeding one of Dr. Anderson's serial to parallel LCD driver chips.

I know I've read the info before. I just can't seem to find it in my docs anywhere. It's hiding for too well today.

Will someone with better eyes (or memory) than mine please point me to the info? Thank you. This seems to be one of "those" days.

John
*******
 

eclectic

Moderator
I've been looking through all of my docs, but I can't seem to find the info on how to format data (binary, hex, decimal, ASCII) being sent out to an LCD.

I'm using an 08M, feeding one of Dr. Anderson's serial to parallel LCD driver chips.

I know I've read the info before. I just can't seem to find it in my docs anywhere. It's hiding for too well today.

Will someone with better eyes (or memory) than mine please point me to the info? Thank you. This seems to be one of "those" days.

John
*******
John
Can you please supply the datasheet for Prof A's chip?
As in the 254/128 / 192/ ? / whatever syntax.

(I actually own one, but I haven't used it for ages. )

e
 

John West

Senior Member
LCD #117-2400

I've worked from the following web page info in the past. But if it's there I'm overlooking it.

http://www.phanderson.com/lcd106/lcd107.html

I'm not even certain if it's a function of the interface chip or of the PICAXE itself. Can't seem to think it through today.

Of course, it doesn't help that my web connection is running down around dial-up speeds today. It's frustrating not to be able to do a proper web search. I feel like I'm disconnected from my memory when my web link is down.
___
EDIT: O.K. I've managed to think it through and realize that it is indeed a function of the interface chip, not the PICAXE. That will narrow down the search a lot.
 
Last edited:

JoeFromOzarks

Senior Member
From Dr. Anderson's notes:

?a - set cursor to home position.
?b - destructive backspace
?f - clear LCD and leave cursor at home position
?g - beep
?h - backspace
?i - forward cursor
?j - up cursor
?k - down cursor
?l - clear current line and leave cursor at the beginning of the line
?m - carriage return. Position the cursor at the beginning of the current line.
?n - new line. Advance to the beginning of the next line and clear this line.
?t - tab. Advance the cursor one tab.
?? - display the character '?'.

Note that the line number, follows the 'y' command and the column number, consisting of two digits, follows the 'x' command.
"?y1?x10Hello?n"
positions the cursor at column 10 of line 1 and then prints "Hello", followed by a newline which also clears the next line.

If you wish, I can upload the entire PDF.

:) joe
 

Attachments

Last edited:

John West

Senior Member
Thanks, Joe. But I'm looking for the presentation format for the data as ASCII or hex or binary, etc, not the physical screen location sort of formatting. For instance, if I want to see the value of a variable such as b1 displayed as a decimal value or as a hex value, or as an ASCII character.
___
My web connection today is just about useless. Even my email is so slow it's hardly worth trying to read. I gotta get a different carrier.
 
Last edited:

JoeFromOzarks

Senior Member
Is this it John?

Code:
   Symbol N = B2
   Symbol OWord = W0
   Symbol OByte = B3


   ' These variables are used in Sub BarDemo
   Symbol NN = B8
   Symbol LeftOver = B9
   Symbol Num_5 = B10
   Symbol J = B11

   ' These variables are used in Sub SerOutByteHex
   Symbol X = B8

   ' Variables used in PWMDemo
   Symbol Duty = B9

   High 0		' Be sure Tx Pin is idle for some time
   Pause 5000		' wait for PICAXE LCD to boot

   ' next is only done once
   SerOut 0, T2400, ("?G420")			' configure LCD as 4 X 20

   'Clear the screen
   SerOut 0, T2400, ("?f")	' clear the LCD
   Pause 2000



   'Clear the screen
    SerOut 0, T2400, ("?f")	' clear the LCD
'    SerOut 0, T2400, ("?B00")	' set PWM to 0
    
   SEROUT 0, T2400, ("?B40") ' set backlight to 40 hex
   PAUSE 200    ' pause to allow LCD EEPROM to program
  
   SerOut 0, T2400, ("?f")			' clear the LCD and home the cursor

   Pause 100
   SerOut 0, T2400, ( "    PICAXE LCD?n")	' note new line
   
   Pause 2000

   SerOut 0, T2400, ("?0?1?2?3?4?5?6?7?n")		' display special characters

   Pause 2000			' pause to admire

   SerOut 0, T2400, ("?y1?x00")						' position cursor at beginning of row 1

   SerOut 0, T2400, ("?l?j?l?j?l?y1") ' clear lines 1, 2 and 3 and start at line 1
   ' note the use of down cursor command

   OWord = 12345

   For N = 0 to 25
      SerOut 0, T2400, ("?x00?y1")	' locate cursor to beginning of line 1

      SerOut 0, T2400, (#N)		'  display in decimal
      SerOut 0, T2400, ("?t")

      OByte = N
      GoSub SerOutByteHex     		' display in hex
      SerOut 0, T2400, ("?t")


      SerOut 0, T2400, (#OWord, "?t")	' display a word in decimal

      GoSub SerOutWordHex			' and in hex
      SerOut 0, T2400, ("?n")

      OWord = OWord + 1

      ' cj SerOut 0, T2400, ("?g")		' beep
      Pause 1000
   Next

'cj
   SEROUT 0, T2400, ("?B40") ' set backlight to 40 hex
   PAUSE 200    ' pause to allow LCD EEPROM to program
   pause 2000


   SerOut 0, T2400, ("?D00000000000000000")		' define special characters
   Pause 200					' delay to allow EEPROM to program

   SerOut 0, T2400, ("?D11010101010101010")
   Pause 200

   SerOut 0, T2400, ("?D21818181818181818")
   Pause 200

   SerOut 0, T2400, ("?D31c1c1c1c1c1c1c1c")
   Pause 200

   SerOut 0, T2400, ("?D41e1e1e1e1e1e1e1e")
   Pause 200

   SerOut 0, T2400, ("?D51f1f1f1f1f1f1f1f")
   Pause 200


   SerOut 0, T2400, ("?c0")		' no cursor


   SerOut 0, T2400, ("?y3?x00?l")	' cursor to beginning of line 3 and clear line

   GoSub BarDemo

   Pause 200

   GoSub PWMDemo

   Pause 200

' cj
    SerOut 0, T2400, ("?f")	' clear the LCD
   
    SEROUT 0, T2400, ("?B40") ' set backlight to 40 hex
    PAUSE 200    ' pause to allow LCD EEPROM to program    

pause 2000



AGAIN:   
for n = 1 to 20					' continually bring outputs 5 and 4 high and low
   SerOut 0, T2400, ("?H5?L4")
   SerOut 0, T2400, (".")
   Pause 500
   SerOut 0, T2400, ("?L5?H4")
   SerOut 0, T2400, ("!")
   Pause 500
   ' GoTo AGAIN   ' cj took out
next  
    SerOut 0, T2400, ("?f")	' clear the LCD
   
    SEROUT 0, T2400, ("?B40") ' set backlight to 40 hex
    PAUSE 200    ' pause to allow LCD EEPROM to program     

' =====================================================================

BarDemo:
'cj
    SEROUT 0, T2400, ("?B40") ' set backlight to 40 hex
    PAUSE 200    ' pause to allow LCD EEPROM to program    

   For N = 0 to 25				' increasing bar
      SerOut 0, T2400, ("?y3?x00")
      NN = 4 * N
      Num_5 = NN / 5
      LeftOver = NN % 5
      For J = 1 to Num_5
         SerOut 0, T2400, ("?5")
      Next
      LeftOver = LeftOver + 48		' convert to a character
      SerOut 0, T2400, ("?", LeftOver)
   Next

   For N = 0 to 25			' decreasing bar
      SerOut 0, T2400, ("?y3?x00?l")
      NN = 4 * N
      NN = 100 - NN
      Num_5 = NN / 5
      LeftOver = NN % 5
      For J = 1 to Num_5
         SerOut 0, T2400, ("?5")
      Next

      LeftOver = LeftOver + 48		' convert to a character
      SerOut 0, T2400, ("?", LeftOver)
   Next

pause 2000


   Return

PWMDemo:

   SEROUT 0, T2400, ("?B40") ' set backlight to 40 hex
   PAUSE 200    ' pause to allow LCD EEPROM to program

    SerOut 0, T2400, ("?f")	' clear the LCD
    SerOut 0, T2400, ("  PWM Duty Demo?n")
    For N = 0 to 25
       Duty = 10 * N
       SerOut 0, T2400, ("?l")
       OByte = Duty
       GoSub SerOutByteHex	' display the PWM in hex

       SerOut 0, T2400, ("?B")	' backlight control
       GoSub SeroutByteHex
       Pause 500
    Next

    SerOut 0, T2400, ("?f")	' clear the LCD

    SEROUT 0, T2400, ("?B40") ' set backlight to 40 hex
    PAUSE 200    ' pause to allow LCD EEPROM to program    

    Return


SerOutByteHex:
    X = OByte / 16	' high nibble
    X = X + 48		' add the character '0'

    If X <= 57 Then SerOutByteHex_1
       X = X + 7	' it is alphabetic; A, B, C, D, E, F

SerOutByteHex_1:
    SerOut 0, T2400, (X)

    X = Obyte % 16	' low nibble
    X = X + 48		' add the character '0'

    If X <= 57 Then SerOutByteHex_2
       X = X + 7	' it is alphabetic; A, B, C, D, E, F

SerOutByteHex_2:
    SerOut 0, T2400, (X)

    Return

SerOutWordHex:

    OByte = OWord / 256
    GoSub SerOutByteHex
    OByte = OWord % 256
    GoSub SerOutByteHex

    Return
 
Last edited:

BillyGreen1973

Senior Member
I may be missing something, but the page you gave the link for, has a couple of extensive picaxe examples at the bottom of the page.
Are these not of any use?
 

John West

Senior Member
Thanks, Joe. Yep, it's right there. I see it now. I was scanning right past it. Sigh.

Yes, BG. It's there, allright. Second sigh.
 

JoeFromOzarks

Senior Member
John,

I rewrote the code I posted in #6 above, but I don't have a clue where it is. I'll keep looking - after supper!

If that code will do you, let me know and I'll quit hunting. (For code, not food!)

:) joe
 

John West

Senior Member
Its fine as is, Joe. I was just having a senior moment and being frustrated by my connection speed problems. Thanks again.
 
Top