Newbie, how to send actual numbers

jmferkul

New Member
I am new to the HD44780 and using a picaxe to control it,
I am using the following code I found but have no idea how to just display an actual changing number from a register, b10 for example ??

Help would be appreciated.....

SYMBOL RS = 2 ; 0 = Command 1 = Data
SYMBOL E = 3 ; 0 = Idle 1 = Active
SYMBOL DB4 = 4 ; LCD Data Line 4
SYMBOL DB5 = 5 ; LCD Data Line 5
SYMBOL DB6 = 6 ; LCD Data Line 6
SYMBOL DB7 = 7 ; LCD Data Line 7

SYMBOL RSCMDmask = %00000000 ; Select Command register
SYMBOL RSDATmask = %00000100 ; Select Data register

SYMBOL get = b11
SYMBOL byte = b12
SYMBOL rsbit = b13

PowerOnReset:

GOSUB InitialiseLcd

DisplayTopLine:

EEPROM 6,("Hello")

FOR get = 6 TO 10
READ get,byte
GOSUB SendDataByte
NEXT

MoveCursorToStartOfSecondLine:

byte = $C0
GOSUB SendCmdByte

DisplayBottomLine:

EEPROM 11,("World!")

FOR get = 11 TO 16
READ get,byte
GOSUB SendDataByte
NEXT

END

InitialiseLcd:

FOR get = 0 TO 5
READ get,byte
GOSUB SendInitCmdByte
NEXT

' Nibble commands - To initialise 4-bit mode

EEPROM 0,( $33 ) ; %0011---- %0011---- 8-bit / 8-bit
EEPROM 1,( $32 ) ; %0011---- %0010---- 8-bit / 4-bit

' Byte commands - To configure the LCD

EEPROM 2,( $28 ) ; %00101000 %001LNF00 Display Format
EEPROM 3,( $0C ) ; %00001100 %00001DCB Display On
EEPROM 4,( $06 ) ; %00000110 %000001IS Cursor Move

; L : 0 = 4-bit Mode 1 = 8-bit Mode
; N : 0 = 1 Line 1 = 2 Lines
; F : 0 = 5x7 Pixels 1 = N/A
; D : 0 = Display Off 1 = Display On
; C : 0 = Cursor Off 1 = Cursor On
; B : 0 = Cursor Steady 1 = Cursor Flash
; I : 0 = Dec Cursor 1 = Inc Cursor
; S : 0 = Cursor Move 1 = Display Shift

EEPROM 5,( $01 ) ; Clear Screen

RETURN

SendInitCmdByte:

PAUSE 15 ; Delay 15mS

SendCmdByte:

rsbit = RSCMDmask ; Send to Command register

SendDataByte:

pins = byte & %11110000 | rsbit ; Put MSB out first
PULSOUT E,1 ; Give a 10uS pulse on E
pins = byte * %00010000 | rsbit ; Put LSB out second
PULSOUT E,1 ; Give a 10uS pulse on E

rsbit = RSDATmask ; Send to Data register next

RETURN
 

westaust55

Moderator
You are going to have to break the numbers down into digits and encode then into ASCII values.

For example if you have the number 123 then:
Value = 123

Now break it down into hundred, tens and units digits. 1_2_3 by:
Hundreds = Value / 100
Tens = Hundreds * 10
Tens = Value / 10 – Tens
Units = Value // 10

Then code each into ASCII (have a look in the back of the AXE033 manual – download if you have not got it or google for “ASCII codes”)
Hundreds = Hundreds + $30
Tens = Tens +$30
Units = Units + $30

Finally send each of these values through the parallel port to your LCD display.
 

moxhamj

New Member
Have a look at the bintoascii command in the help. It can do exactly what you want with just one line of code. Feed in a number, and out comes all the ascii characters. Then send those one at a time to the display.
 

westaust55

Moderator
Dr_A is correct.

Think of my post as an understanding of the process that occurs behind the scenes with the BINTOACSII command
 

moxhamj

New Member
LOL this forum always ends up shortening code. Hippy will probably manage to shorten my one line of code to something even less!

Bintoascii is one of the newer instructions - some of my older picaxe programs have code as westaust55 describes. I'm actually in the middle of coding some bintoascii routines in Z80 machine code. Tis good for the brain! Try doing it for floating point numbers...
 

Technical

Technical Support
Staff member
The bintoascii is a compiler 'pseudo' command, that actually does something similar to westaust55's code automatically in the background, to make life simpler for the BASIC program writer.
 

jmferkul

New Member
Have a look at the bintoascii command in the help. It can do exactly what you want with just one line of code. Feed in a number, and out comes all the ascii characters. Then send those one at a time to the display.
I can't find the BinToAscii command in my Picaxe help files ?
 

moxhamj

New Member
Yes, they slipped in some really useful commands in the new manual. I was able to shorten a lot of my code. This is why Rev Ed and picaxe is such a great system - things just keep getting better!
 
Top