Go Down

Topic: How to read HD44780 LCD programmatically (Read 4 times) previous topic - next topic

Nick Gammon

Please do not cross-post. This wastes time and resources as people attempt to answer your question on multiple threads.

Threads merged.

- Moderator


Feb 22, 2013, 10:03 pm Last Edit: Feb 22, 2013, 10:06 pm by floresta Reason: 1
The only way to do this correctly is to make a "shadow" screen which buffers the content send to the screen.

You are answering this from a more modern perspective than might have originally been intended when the LCD controller was designed.  I mean that it looks like you are assuming that he wants to read back information that corresponds to that displayed on the screen.

If you are using a display with less than 80 characters then there is some unused RAM in the LCD controller.  In ancient times when RAM was scarce this RAM was a valuable resource and could be (and was) used for general purpose storage.  Perhaps the OP has an application such as this in mind.

Here is what the HD44780U data sheet has to say (just before Figure 1).

Display Data RAM (DDRAM)

Display   data   RAM   (DDRAM)   stores   display   data   represented   in   8-bit   character   codes.   Its   extended
capacity is 80 × 8 bits, or 80 characters. The area in display data RAM (DDRAM) that is not used for
display can be used as general data RAM.
See Figure 1 for the relationships between DDRAM addresses
and positions on the liquid crystal display.



The HD44780 LCD  has functions to read the display in libraries for other microcontrollers (PicBasic, for example).   So I was just searching for the same functions for the Arduino.  I really, really like the Arduino, and don't like it when there is support for other microcontrollers which is lacking for the Arduino.

For the immediate need, I will create an in-memory ("shadow") view of the LCD, send that view to the LCD, and also then be able to read fro that view.  It will be a simple 2x16 array of char.  Fortunately there is a lot of extra programming space in the Mega 2560.  Having this view in RAM serves the capability of cloning the LCD display to the PC, but doesn't help any in auto-testing the LCD, hence the need to read the LCD.

In the future I will work on providing an update to the Arduino library to make it more complete. 

Thank you for all the comments and suggestions!  I consider the question to be answered.
Phil Dorcas


Do you have access to library code of one of those other platforms?
Can you post a link?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)


In PicBasic, the support for the LCD is built into the language, and I don't have access to it's source code.
The methods to read has two parameters, the first is the address to read from the LCD, usually $80 or $C0 for the first and second lines respectively.  The second parameter is an array of characters, where the LCD characters were placed. 

Examples for reading from the LCD:
  LCDIN $80, [ InArray[20], InArray[21], InArray[22], InArray[23],_
               InArray[24], InArray[25], InArray[26], InArray[27],_
               InArray[28], InArray[29], InArray[30], InArray[31],_
               InArray[32], InArray[33], InArray[34], InArray[35] ]
  LCDIN $c0, [InArray[36], InArray[37], InArray[38], InArray[39],_
              InArray[40], InArray[41], InArray[42], InArray[43],_
              InArray[44], InArray[45], InArray[46], InArray[47],_
              InArray[48], InArray[49], InArray[50], InArray[51] ]

I'll read the Fujitsu documentation and figure it out for the Arduino.  Wish I had other source code to access as a guide.  Maybe from the mfg.  Thank you.

Go Up