[solved] LCD read/write and part numbers

Hi all,

I'm an old bloke with 20+ years in software development, first as a developer (C/C++, Java, etc.) then team lead and project management; completely new to Arduino and electronics in general - be kind :slight_smile:

I have the Arduino start kit with the project book and have been working through it, just starting on the crystal ball (project 11).

The book tells me the R/W pin (5) puts the LCD into read or write mode. My first query is what can you read from the LCD? I've done some googling and can't find anything helpful; the option is there to set the mode so why?

Valid reason or not for reading, I like to explore all possibilities. Does anyone have a simple 'hello world' type example of reading from the LCD? I only need a skeleton of how to actually do it, I can then explore further on my own.

Just one more query, the link for the LCD datasheet (LCD datasheet) tells me the model is JHD 659 M10 1.1, but there is a sticker on the back of the LCD with NDS 1602A V2; are they the same thing?

Thanks,

Mark

Your motor car might have come off the production line with tyres from a new supplier.
You need to read the spec of the particular tyres.

Your link shows a module manufacturer. It might contain a SPLC780D controller but it might also contain an Equivalence e.g. HD44780, KS0066, ...

If you want to program at the lowest hardware level, you need to consult the appropriate data sheet.

It looks as if your module sheet has copy-pasted sections of a particular controller. And it does not even look like the SPLC780D datasheet.
Hey-ho. Most LCD controllers work in a similar way. It is wise to keep to the lowest common denominator. For example, setting the controller to 4-bit mode requires less strict timing on some makes. Use the strictest sequence. Then it will work on all makes.

Yes, you can read the data from the LCD internal Display Memory RAM.
Most Arduino libraries do not.
Bill Perry's HD44780 library does.

Very few people ever want or need to read the RAM. It is easier for your program to keep its own mirror copy.

David.

The HD44780U LCD controller design goes back to before you started in software development, back when memory was expensive and rare.

The controller has enough RAM memory (80 bytes - no prefix) to handle all of the characters on 20x4 and 40x2 displays. When controlling a more common 16x2 display there are 48 unused bytes which are available for general purpose use, hence the R/W pin.

Currently the main use for reading the device is to check the 'busy flag' to see if the controller is ready to accept another character or instruction. Most programmers choose to use time delays instead which is why the R/W line is generally tied low.

For programming examples follow the LCD Programming Examples link at Don's Collected Technical Information .

Don

I have yet to see anyone read/write the non-visible RAM for general purpose use.

You can write a long message and left-shift to keep the last 16 chars in view.
Then shift back to see the previously printed chars that had gone out of view.

Just like the display in a Doctor's Waiting Room.
40 chars of RAM per line is not enough for Shakespeare.

The shifting trick works on a 16x2. But not on a 20x4. Hence my comment about being easier to keep a mirror-copy in your Arduino RAM.

David.

floresta:
Currently the main use for reading the device is to check the 'busy flag' to see if the controller is ready to accept another character or instruction.

Another use is to read the current internal memory address counter.
The address counter is what controls where characters are stored on the display.
This is useful since there is no way to move from CGRAM mode to DDRAM mode without setting the address counter. Because of this, if programming a custom character, the only way to restore the address counter to what it was prior to programming the custom character is to read the address counter before you program the custom character then restore back when done.
Currently the hd44780 library is the only library I know that does this.

Most programmers choose to use time delays instead which is why the R/W line is generally tied low.

For sure on Arduino as the time to flip the data pins around using the standard pinMode() API functions is so slow that takes longer just to program the pins as inputs and back to outputs than the LCD takes to execute the command.
(That is when using the IDE bundled AVR core. Other cores can be and often are significantly faster)

--- bill

mj010273:
Does anyone have a simple 'hello world' type example of reading from the LCD? I only need a skeleton of how to actually do it, I can then explore further on my own.

The hd44780 library comes with an example that shows how to read the LCD display RAM.
You can't do it with any other library that I know of.
i.e. you cannot do it using the IDE bundled LiquidCrystal library.

The hd44780 library includes an example, ReadWrite that demonstrates the capability.
The library has two i/o classes that support this. hd44780_pinIO and hd44780_I2Cexp
so you can do it using direct pin control or with an i2c backpack.
You can install the hd44780 library directly from the IDE library manager. (do not install it from a zip file)
You can read more about the hd44780 library on its git hub page: GitHub - duinoWitchery/hd44780: Extensible hd44780 LCD library
And the wiki: Home ยท duinoWitchery/hd44780 Wiki ยท GitHub

--- bill

Hi all,

Sorry for the late reply, busy few days.

Thanks very much for all the feedback, it answers my question so much appreciated; I'll be checking all the links you gave as well.

Thanks again,

Mark