How can Line 3 and 4 Install in HD4480

Jacobsen

New Member
'BASIC converted from flowchart:
'C:\PROGRAMMER\PROGRAMMING EDITOR\MINEPROJEKTER\2X20 DISPLAY.CAD
'Converted on 27-03-2005 at 19:22:42

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

byte = $80 : GOSUB SendCmdByte ; Start of Line 1
byte = $C0 : GOSUB SendCmdByte ; Start of Line 2
byte = $A0 : GOSUB SendCmdByte ; Start of Line 3
byte = $E0 : GOSUB SendCmdByte ; Start of Line 4





PowerOnReset:

GOSUB InitialiseLcd

DisplayLine1:

EEPROM 6,("Solfanger Top:")

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

MoveCursorToStartOfSecondLine:

byte = $C0
GOSUB SendCmdByte

DisplayLine2:

EEPROM 20,("Tank Bund:")

FOR get = 20 TO 29
READ get,byte
GOSUB SendDataByte
NEXT


How can Line 3 and 4 Install ?????

DisplayLine3:

EEPROM 20,("Tank Top:")

FOR get = 20 TO 29
READ get,byte
GOSUB SendDataByte
NEXT


DisplayLine4:

EEPROM 20,("Difference Temp:")

FOR get = 20 TO 29
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

Best regards
Monie
 

hippy

Technical Support
Staff member
You can't put more than one byte in an EEPROM location ...

EEPROM 20,("Tank Bund:")
EEPROM 20,("Tank Top:")
EEPROM 20,("Difference Temp:")

Try using ...

EEPROM 20,("Tank Bund:") ; 20..29
EEPROM 30,("Tank Top:") ; 30..38
EEPROM 39,("Difference Temp:") ;39..54

And adjust the values of the FOR loops which extract the EEPROM data to display accordingly.

Also, youll need to put

byte = $xx ' $xx = $80, $C0,$A0, $E0
GOSUB SendCmdByte

Before each line you wish to display


Edited by - hippy on 4/5/2005 1:05:36 AM
 

Jacobsen

New Member
hippy

In cmd MoveCursorToStartOfSecondLine:

Compile Error:
Illegal character:('$'(0x24))

'BASIC converted from flowchart:
'C:\PROGRAMMER\PROGRAMMING EDITOR\MINEPROJEKTER\2X20 DISPLAY.CAD
'Converted on 27-03-2005 at 19:22:42

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


DisplayLine1:

EEPROM 6,("Solfanger Top:") ; 6..19

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

MoveCursorToStartOfSecondLine:

byte = $xx ' $xx = $80, $C0,$A0, $E0 ??????????
Compile Error:
GOSUB SendCmdByte Illegal character:('$(0x24))

DisplayLine2:

EEPROM 20,("Tank Bund:") ; 20..29

FOR get = 20 TO 29
READ get,byte
GOSUB SendDataByte
NEXT


DisplayLine3:

EEPROM 30,("Tank Top:") ; 30..38

FOR get = 30 TO 38
READ get,byte
GOSUB SendDataByte
NEXT


DisplayLine4:

EEPROM 39,("Difference Temp:") ;39..54

FOR get = 39 TO 54
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

Best regards
Monie
 

hippy

Technical Support
Staff member
byte = $xx ' $xx = $80, $C0,$A0, $E0
Illegal character:('$(0x24))

Not the best error message in the world; "Hexadecimal number expected" or similar may have better pointed you in the direction of the problem - $xx is not a valid hexadecimal number.

But also my mistake for lapsing into 'shorthand' and not being totally explicit.

You need to put the correct one of these before sending the actual data to each line to the LCD ...

- byte = $80 ' Start Line 1
- GOSUB SendCmdByte

- byte = $C0 ' Start Line 2
- GOSUB SendCmdByte

- byte = $A0 ' Start Line 3
- GOSUB SendCmdByte

- byte = $E0 ' Start Line 4
- GOSUB SendCmdByte

Edited by - hippy on 4/5/2005 10:48:04 AM
 

Jacobsen

New Member
Du you mianes this on??

DisplayLine1:

EEPROM 6,("Solfanger Top:") ; 6..19

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

MoveCursorToStartOfSecondLine:

byte = $80 ' Start Line 1
GOSUB SendCmdByte

byte = $C0 ' Start Line 2
GOSUB SendCmdByte

byte = $A0 ' Start Line 3
GOSUB SendCmdByte

byte = $E0 ' Start Line 4
GOSUB SendCmdByte


DisplayLine2:

EEPROM 20,("Tank Bund:") ; 20..29

FOR get = 20 TO 29
READ get,byte
GOSUB SendDataByte
NEXT


DisplayLine3:

EEPROM 30,("Tank Top:") ; 30..38

FOR get = 30 TO 38
READ get,byte
GOSUB SendDataByte
NEXT


DisplayLine4:

EEPROM 39,("Difference Temp:") ;39..54

FOR get = 39 TO 54
READ get,byte
GOSUB SendDataByte
NEXT

END
Best regards
Monie
 

hippy

Technical Support
Staff member
Almost. The cursor positioning needs to be done immediately before writing to the display ...

DisplayLine1:

byte = $80 ' Start Line 1
GOSUB SendCmdByte

EEPROM 6,("Solfanger Top:") ; 6..19

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

DisplayLine2:

byte = $C0 ' Start Line 2
GOSUB SendCmdByte

EEPROM 20,("Tank Bund:") ; 20..29

FOR get = 20 TO 29
READ get,byte
GOSUB SendDataByte
NEXT

DisplayLine3:

byte = $A0 ' Start Line 3
GOSUB SendCmdByte

EEPROM 30,("Tank Top:") ; 30..38

FOR get = 30 TO 38
READ get,byte
GOSUB SendDataByte
NEXT

DisplayLine4:

byte = $E0 ' Start Line 4
GOSUB SendCmdByte

EEPROM 39,("Difference Temp:") ;39..54

FOR get = 39 TO 54
READ get,byte
GOSUB SendDataByte
NEXT
 

Jacobsen

New Member
hippy

From and including line 3 down it goes wrong.
The text are displaced also line 1 and 2

The display is showing:

mp:fanger Top:
:ank Bund:
Tank Top
Diff. Te

I understand the meaning of this:
byte = $80 ' Start Line 1
byte = $C0 ' Start Line 2
byte = $A0 ' Start Line 3
byte = $E0 ' Start Line 4

Best regards
Monie
 

hippy

Technical Support
Staff member
To my great surprise, it also failed on the 16x4 display I have. Lines 3 and 4 overwrote lines 1 and 2.

After some head scratching and debugging, I've found an answer, if not an entire solution for yourself ...

The Cursor Positioning Command Codes given ( $80, $A0, $C0, $E0 ) should be correct for HD44780-based devices, but not necessarily for other driver chips.

The LCD I used has an OKI driver chip which Google can't find any reference for, plus KS0065 segment drivers. By experimenting, the Command Codes I have to use are ...

Line 1 : $80
Line 2 : $90
Line 3 : $C0
Line 4 : $D0

That's okay for a 16x4, but not for a 20x4, as $90 is the 16th character of the first line ( unless it really is configured in a strange way ). If the display memory is contiguous, these Command Codes should be ...

Line 1 : $80
Line 2 : $94
Line 3 : $C0
Line 4 : $D4

That may solve the problem, but no guarantees, and you might have to switch the codes around to get the lines displayed in the right order.

If not, you'll have to find a reference manual for your particular LCD, or do some experimenting by choosing various Command Codes, seeing where characters get displayed, and determining which to use that way.

Edited by - hippy on 4/5/2005 5:44:36 PM
 

Jacobsen

New Member
Read cmd readadc on the display HD44780

How does one get a print of , for example, cmd "readadc 0,b0" b, on display line 1?

readadc 0,b0 ... Line 1 = Solfanger Top: b0 ºC
readadc 1,b1 ... Line 2 = Tank Bund: b1 ºC
readadc 2,b2 ... Line 3 = Tank Top: b2 ºC
readadc 3,b3 ... Line 4 = Diff. Temp: b3 ºC

Best regards
Monie
 

hippy

Technical Support
Staff member
Didn't we do that one already in ...

http://www.rev-ed.co.uk/picaxe/forum/topic.asp?topic_id=2506
 

Jacobsen

New Member
Im Didn't under'stand different from HD44780 and other LCDs so how
readadc 0,b0 output to the HD44780 line 1


DisplayLine1:

byte = $80; Start Line 1
GOSUB SendCmdByte
readadc 0,b0
byte=b0
EEPROM 6,("Solfanger Top: ",#b0,$B2,"C")
FOR get = 6 TO 20
READ get,byte
GOSUB SendDataByte
NEXT

Best regards
Monie
 

hippy

Technical Support
Staff member
Sorry; the previous was for a serial LCD, this is for a parallel LCD ...


- READADC 0,b0
-
- byte = $80; Start Line 1
- GOSUB SendCmdByte
-
- EEPROM 6,("Solfanger Top: ")
- FOR get = 6 TO 20
- READ get,byte
- GOSUB SendDataByte
- NEXT
-
- byte = b0 / 100 + "0"
- GOSUB SendDataByte
- byte = b0 / 10 // 10 + "0"
- GOSUB SendDataByte
- byte = b0 // 10 + "0"
- GOSUB SendDataByte
-
- byte = $BD
- GOSUB SendDataByte
- byte = "C"
- GOSUB SendDataByte
 

Jacobsen

New Member
hippy

Thanks a lot for the info you sent and it works but it only works the first time,
but I need it to work many/all time, with out the need to shut the system down for the update.
I would be glad if you could share info with me for this to work,
and again thanks for the info.

Best regards
Monie
 

hippy

Technical Support
Staff member
Rather than use an END instruction you will need to use a 'GOTO DisplayLine1' command ( or whatever is appropriate ) to make the program repeat.
 

Jacobsen

New Member
hippy

First off all I wish to thanks for the big help you you are providing to me!
It did help using CMD: goto goto DisplayLine1
I should have been able to do this my self but for some or other reason I had goon blind on the codes.

Im using this system to control a big Sun energy collecting environment ,
where I have a problen while the collection system tends to go boiling..
One question more:
Im intend to enter the following codes at the position after DisplayLine4: where if READADC 0,b0
is bigger than 90 the LED 1 shall turn on else LED1 shall be off.
As it is now the LED1 are just performing a fast flashing, how may this problem possible be fixed ?.

Best regards
Monie
 

Jacobsen

New Member
Hirs is Codes:

DisplayLine4:
......//......
GOSUB SendDataByte
byte = "C"
GOSUB SendDataByte


if b0 > 90 then Led_1_ON
low 1
goto DisplayLine1

Led_1_ON:
high 1
goto DisplayLine1

Best regards
Monie
 

Toris

New Member
I cannot see any reason why that code should not work, assuming you are reading the correct value into b0 just before the IF command.

So I would recommend that you use a debug command to look at the value of b0 on the PC, to see if it is actually fluxuating between a value above and below 90.
 
Top