# Chinese math?

Discussion in 'Electronic Design' started by Jan Panteltje, Feb 3, 2008.

1. ### Jan PanteltjeGuest

I ordered a graphics and receiveda a 4 line text LCD.
Decided to keep the 4 line text, got it for half the price,
and now also have the graphics.
Hooked up the 4 line text LCD, could not figure out how to address line 3.
So made a slow loop that printed the RAM address while filling up RAM.

So just observed where it started:

#define LINE_1 D'128'
#define LINE_2 D'168'
#define LINE_3 D'148'
#define LINE_4 D'212'

Logic?

2. ### Spehro PefhanyGuest

Is it a 40x4 display?

Best regards,
Spehro Pefhany

3. ### John O'FlahertyGuest

Were you printing the address to the display in question?

4. ### Jan PanteltjeGuest

No, 20 x 4
You need to subtract 128 (bit 7), as that is the RAM address flag,
that leaves the 7 lower bits as the actuall RAM address:
line1 0
line2 40
line3 20
line4 84

The display is the HC200401C-VA.pdf
and the controller, of which I think there are 2, S6A0069.pdf
http://panteltje.com/panteltje/pic/swr_pic/LCD_4x20_2.jpg

I can understand they interleaved the lines from both chips,
but I cannot think of a way to come up with 84, that should have been 60?

6. ### John O'FlahertyGuest

An interesting thing is that if it were absolute sequential
addressing, the third line should overwrite half of the second. It
must be magic; that's the only logical explanation.

7. ### Spehro PefhanyGuest

Usually 0x00, 0x40, 0x20, 0x60

Probably if you looked more closely at the HD44780-based chipset and
physical constraints it would make more sense.

Best regards,
Spehro Pefhany

8. ### Jan PanteltjeGuest

No, it is 20 chars / line, so the third line starts at 20, and ends at 39.

9. ### petrus bitbyterGuest

I see no logic in this sequence. An explanation may be that some
hardware/chip designer was messing up the address lines. Or he used another
"logic" for line four. The first three ones are continous but for line four
only an extra address line is used with respect to line three. Which leaves
a hole that is not uncommon in I/O addressing, though not in RAM adressing.
BTW do you have RAM in the addresses 60-83? And beyond 104?

petrus bitbyter

10. ### Jan PanteltjeGuest

If you go beyond 104, 128+104 = 232, so 232 to 255 is the only space left that
can be used, as the MSB must always be one, as the screen was already filled
by then with 'P's I could not say if new 'P's were overwriting the old.

There is nothing going to the display IIRC between line 2 and 3 for 59 to 84,

I did set up a loop 0-127 but was only watching for line3 and line4 start.
The PIC has now been programmed with the real stuff, so I cannot check again
in a simple way.

11. ### Martin BrownGuest

There may be an option to support 6 line LCD displays of 20 char. In
which case the full set of 6 magic constants don't look quite so crazy.

0x00, 0 +00, +20, +40
0x00, 64 +00, +20, +40

3 from one bank and 1 from the other still looks odd to me though.
Maybe it shaves \$0.01 off the manufacturing cost to do it this way.

Regards,

12. ### Spehro PefhanyGuest

At some point, AFIUI, you go to two independent HD44780 controllers,
at which point all reason goes out the window.

13. ### Spehro PefhanyGuest

No. It is 0x13 chars/line so the third line starts at 0x20 and ends at
0x33

14. ### Jan PanteltjeGuest

Sorry, all values I specided ARE IN HUMAN DECIMAL FORM.
line 3 starts at 20 dec, so line 3 holds:
20 'A'
21 'r'
22 'e'
23 ' '
24 'Y'
25 'o'
26 'u'
27 ' '
28 'K'
29 'i'
30 'd'
31 'd'
32 'i'
33 'n'
34 'g'
35 ''
36 'M'
37 'e'
38 '?'
39 '?'
start line 2:
40

15. ### Martin RiddleGuest

Yes that looks correct, First and Third lines are sequential, then second and fourth.

Cheers

16. ### John O'FlahertyGuest

But the second and fourth aren't sequential.

17. ### Martin RiddleGuest

Your right, some snippets form a 4 line display commonly available:

18. ### Martin RiddleGuest

Your right, here is my old code for a 4 line jobber:

#define LINE1 0x00

#define LINE2 0X40

#define LINE3 0x14

#define LINE4 0x54

Cheers

19. ### Jan PanteltjeGuest

Thank you, confirms I do not have a bad one, they are all like that.

20. ### Spehro PefhanyGuest

All the examples I've seen so far have been symmetrical. If the 4th
line on yours started at 0x50 = 80 it would be more consistent.

Best regards,
Spehro Pefhany