How do I send a register program instruction to a Hitachi HD44780 LCD

UKHeliBob:

How do we write the code to switch off a standard Hitachi LCD screen while the processor is still running, (switched on)?

Have you tried what I suggested in reply #1 ?

Bob: I haven’t directly tried to use your information because I don’t know how to instigate the necessary binary into the LCD., ports; I have however disconnected the RS., & R/W., connections as I have too the power connections on pins 15 & 16. I have also disconnected the 'E’nable pin but none of these disconnections nor the sum of these disconnections extinguish the background light. So coupled with my ignorance and the aforementioned acts I have failed to reach my goal of extinguishing all actions that occur on the display and namely a] the cursor; b] the text (known as the display); c] the blinking and d]the backlight.

The actual binary for performing the act of complete display shutdown is given by the manufacturers as:
…CODE…
RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
0 0 0 0 0 0 1 D C B

The Binary for the letters is given as: Display on/off control:
D = 0; Display off
C = 0; Cursor off
B = 0; Blinking off

Now the first thing that i do not understand here is that the above code consists of 10 bits in an 8 bit coding and then I also do not know how to write the relevant code to the Hitachi HD44780 LCD driver ports.
Although it seems to me that you Bob, do not need it, a good straightforward link to the HD44780 data sheet is:
Link: http://www.sparkfun.com/datasheets/LCD/HD44780.pdf

So that’s where I am up to, hope all I have written makes sense,
Thanks, Chris S.

The pinout details in reply #3 are as follows

Table 1:  Character LCD Pinout 
Pin# Name  In/Out/Pwr 
1 GND Ground Power 
2 VCC LCD Controller Power (+3 to +5V) Power 
3 VLCD LCD Display Bias (+5 to -5V *see text) Analog 
4 RS Register Select:  H: Data  L: Command Input 
5 R/W H: Read  L: Write Input 
6 E Enable (Data strobe, active high) Input 
7 DB0 Data LSB I/O 
8 DB1 Data I/O 
9 DB2 Data I/O 
10 DB3 Data I/O 
11 DB4 Data I/O 
12 DB5 Data I/O 
13 DB6 Data I/O 
14 DB7 Data MSB I/O 
15 A LED Backlight Anode (optional) Power  
16 K LED Backlight Cathode (optional) Power Pins 4,5, and 6 are the control lines for the LCD.

I assume that the pin numbers are those of the board the LCD is connected to rather than those of the LCD itself.

So you should be able to connect an Arduino pin to pins 7 to 14 to provide the 8 data inputs and pins 4, 5 and 6 to provide the control signals. If that is the case you can output the 8 data bits and the 3 control bits using digitalWrite() on the Arduino.

UKHeliBob: The pinout details in reply #3 are as follows

Table 1:  Character LCD Pinout 
Pin# Name  In/Out/Pwr 
I assume that the pin numbers are those of the board the LCD is connected to rather than those of the LCD itself.

So you should be able to connect an Arduino pin to pins 7 to 14 to provide the 8 data inputs and pins 4, 5 and 6 to provide the control signals.  If that is the case you can output the 8 data bits and the 3 control bits using digitalWrite() on the Arduino.

[/quote]

Crickie Bob, If only I had brains. Can't  try it for a while I don't think but as soon as I can I will and get back to you. I have I fear been playing with PIC's for a time without thorough understanding but I got used to writing an amalgamation of bits and was looking to do something like that here, but I can see exactly what your getting at and the logics therein. Cheers, I will be back to you.

Bob,

This is what I wrote into the end of the program for a loop test but it did not work:

LCD.print("***************** BYE BYE **************"); delay(2000); digitalWrite(5, 1); digitalWrite(4, 0); digitalWrite(3, 0); digitalWrite(2, 0);

I followed it after a delay of 5" with a reverse procedure.

Did I miss understand something?

Cheers

You don’t say which Arduino pins are connected to which LCD pins but you don’t have enough outputs in that code to do what you want. There are 8 data inputs to the LCD and 3 control inputs so you need to use 11 Arduino pins or a shift register (or 2) to provide the outputs. It may be possible to hard wire some of the LCD inputs because they need to be permanently HIGH or LOW but that depends on how you use the LCD.

OK. Sorry for my misambiguance so there are pins in total and pins in use and all as follows:

1] Vss 2] Vdd 3] Screen contrast adjust via 10K pot 4] Ground by way of Arduino pin 14 5] Connection to Arduino 12 6] Connection to Arduino 11 7] Not in use {Commonly in all arduino LCD programs that I have seen - however I do not preclude their use} 8] Not in use ditto if deemed necessary) 9] Not in use ditto 10] Not in use ditto 11] connection to Arduino 5 digital 12] connection to Arduino 4 " 13] connection to Arduino 3 " 14] connection toi Arduino 2 " 15] Vcc via a 840R to protect the led at 6mA 16] Vss

Any other Arduino pins are not in use with respect to the LCD., unit. my temperature sensors use A0 & A1

Cheers, Chris S

Why do you want to turn the display off? The coltroller eats 1-2mA, regardless of what's displayed on the LCD glass.

If power saving is important, then put all your pins from your Arduino into high-Z-state, and cut the power on VCC-pin with a MOSFET.

// Per.

A suggestion. Try connecting the 11 pins directly to 5v or GND in the required pattern instead of to the Arduino to see whether the display turns on/off as required. Try turning the cursor on/off in the same way so that you can be sue that you understand how to control the display.

When/if that works wire the LCD pins to the Arduino and control it from there.

Zapro: Why do you want to turn the display off? // Per.

If this was a professional script then one could say " Clients request" however this is my neighbour whom I would like to please.

Can you help?

UKHeliBob: A suggestion. Try connecting the 11 pins directly to 5v or GND in the required pattern instead of to the Arduino to see whether the display turns on/off as required. Try turning the cursor on/off in the same way so that you can be sue that you understand how to control the display.

When/if that works wire the LCD pins to the Arduino and control it from there.

Hi Bob; I do in fact turn off the cursor (& display

ChrisPSR:

KenF: Are you really sure you need to. I'd have thought that the LiquidChrystal Library would work straight out of the box. Doesn't lcd.noDisplay() do the job? If you're just trying to turn off the backlight, you just have to find out which pin it's connected to and DigitalWrite(pin,low);

Quite obviously you have never looked at the programming of this chip so why do you bother to comment. What I want is an honest appraisal followed by a workable code,

"LCD.noDisplay;" MERELY SHUTS DOWN THE CHARACTER PRODUCTION ON THE SCREEN and all the other rubbish you accumulated has nothing to do with shutting down the display. You annoy me intensely.

Please don't try to make and Ar__le of me, even when doing the same to your self. I am looking for an answer not a guess or even some one trying it on with me by guessing.

ChrisS.

Chris S

Chris, No need to thrash out at people. What I'm seeing is frustration over asking for help based on trying to implement an assumed very specific solution to a given problem along with a lack of understanding of how certain components work.

The thread started out asking for help with the solution without stating the problem.

And then there are some terminology issues like: The "LCD display" is not the same as the "LCD backlight".

I believe that the combination of all these factors is the reason you are seeing some questions about what you are wanting to do.

Assuming that I understand what you are trying solve (which I admit at this point is still a bit vague to me), I believe that in the bigger picture, that the specific solution that you are trying to implement is not going to fully solve your real issue of power management as I think there is some misunderstanding as to where the power issues are and how to control/manage them. (back to that a bit later)


If you look even closer at the HD44780 specification and programming of the chip, you will notice that there is nothing related to the backlight. That is because the backlight is not part of the hd44780 spec so there will be no hd44780 command that can be used to control the backlight. The hd44780 electrical interface is only 14 pins. The 2 LED pins (pins 15 and 16) are separate power pins that directly control the backlight. The hd44780 Display control on/off command bit D will not control the backlight.


Controlling the D,C,B bits of the Display control on/off command:

Have you looked at the LiquidCrystal library code to see if there are API functions to control the hd44780 D, C, B bits of the display on/off command? There are existing API functions in the LiquidCrystal library to control those bits so there is no need to have to write any of your own code to control them as you can simply use the existing API functions: display()/noDisplay() controls the D bit cursor()/noCursor() controls the C bit blink()/noBlink() controls the B bit (All other bits are remembered and resent during each API function call for each individual bit) Normally, as is the case in your example code, the C and B bits are not used so if you want to disable the display circuitry (which is not the same as the backlight) you can use display()/noDisplay() to manipulate the D bit.


Backlight control:

If I look at the wiring that you indicated, in response #20: http://forum.arduino.cc/index.php?topic=272241.msg1920968#msg1920968 You have said that the pins 15 and 16 are hard wired as follows:

15]      Vcc       via     a   840R to protect the led at 6mA
16]      Vss

With this wiring, the backlight will be permanently on and there will be no way to turn it off in software since there is not even any h/w for controlling it.


Stepping back, way back for a moment. We need to understand what the real problem is in order to provide reasonable suggestions for how to solve it. If the problem is that the full h/w needs to run on batteries, then the solution is definitely not as simple as being able to send a hd44780 command like controlling the D,C,B bits in the display on/off command. For example, the D bit will not control the backlight and there are other sources of power consumption. In order to help with suggesting power management solutions, we would also need to fully understand all the hardware you are using.

The backlight is a moderate power draw, not nearly as large as the draw of a typical Arduino board, particularly when using an external power supply vs the USB to power the board since the on board Arduino voltage regulators are very inefficient.

When trying to get things to run efficiently on batteries, it is often not a simple solution since the entire system has to optimized for lower power. You must know where all the sources of power draw are coming from and then how to manage/control them and it often means using special s/w to put the MCU to sleep. In most cases, if you want extended battery life, it cannot be done with an off the shelf Arduino board.

If you could tell us what your real goals/needs are along with the hardware you are currently using, then we could provide you with information on reasonable solutions on how to get there - or if it is even possible to get there with the hardware you have.

Stumbling down this path of trying to come up with a way send raw hd44780 commands to the display is not a good approach.

--- bill

The manufacturer provides the following to switch off everything concerned with the LCD., Display

.......................................CODE.............................................. RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 0 0 0 0 0 0 1 D C B

however if I write the following code using digitalWrite(x, y) at my pertinent point, it doesn't work.

The Binary for the letters is given as: Display on/off control: D = 0; Display off (DB2) C = 0; Cursor off (DB1) B = 0; Blinking off(DB0)

Which equates to:

digitalWrite(5, 1); digitalWrite(4, 0); digitalWrite(3, 0); digitalWrite(2, 0);

Cheers, Chris S

bperrybap:

ChrisPSR:

KenF: --- bill

Dear Bill,

I have cut all the previous quotes as they amount to absolutely nothing following your terrific dissertation which I intend to study.....................................................during my sleep.

Currently friends have visited in the real world and I must shut down. I will respond during tomorrow if I may, very many thanks, Chris S

ChrisPSR: Bob,

This is what I wrote into the end of the program for a loop test but it did not work:

LCD.print("***************** BYE BYE **************"); delay(2000); digitalWrite(5, 1); digitalWrite(4, 0); digitalWrite(3, 0); digitalWrite(2, 0);

I followed it after a delay of 5" with a reverse procedure.

Did I miss understand something?

Cheers

Yes, you missed a LOT of stuff. There seems to be a big misunderstanding how the hd44780 electrical interface works. Have a look at the interface timing diagram in the hd44780 spec figure 25 page 58.

That code is merely setting the output level of the 4 data bits. You have not properly wiggled the control signals for sending the data bits to the display module. In particular you must ensure that RS is low and that E is clocked with the proper timing. And since you are using 4 bit mode, you will have to send both nibbles of the 8 bit value. (The upper nibble is all zeros)

The library handles all this low level i/o and timing down in the write4bits() function which is called by the send() function which is called by the command() function.

It should not be necessary to send raw commands to turn on/off the LCD display, but if If you still really want to jack around at that low level and send raw commands to the display module, then why not use the use the LiquidCrystal library API function to do it rather than try to write your own low level i/o routines? You can call command() with the 8 bit value to send to the display and the library will do it for you.

--- bill

UKHeliBob:
A suggestion. Try connecting the 11 pins directly to 5v or GND in the required pattern instead of to the Arduino to see whether the display turns on/off as required. Try turning the cursor on/off in the same way so that you can be sue that you understand how to control the display.

When/if that works wire the LCD pins to the Arduino and control it from there.

Bob, I’ve tried these things but the display (whole screen) still stays on. I use LCD.clear() and or LCD.noDisplay(); to clear all text from the display as I swope screen information. one thing that I have found is that having used LCD.noDisplay I can then disable the screen by pulling off the two leads that power the screen, so may be I can switch the 5V supply through say pin 7 which is unused and setting it LOW there should be enough current through a pin to light the LED., don’t you think and LOW should be low enough to cause the screen to be off.
I’ll try it anyway.

Cheers, I’m waiting for the home truths.
Chris

Hi once more Bob,

As I self predicted there was a problem or series of problems namely that the prescribed action merely degraded the illumination level of the screen, the actual function only deleted the text as in clrearDisplay() or noDisplay() and left you looking at a low level illumination of the backlight no matter what you elected to do.

I'm beginning to think tat the on/off switch already instigated in the project box is the absolute answer and be-hanged to my neighbour seeing my originator text at the beginning and awaiting for the sensors to settle.

Might just see if I can ask someone at Adafruit just what these items are in place for in their header file:

define LCD_DISPLAYON 0x04

define LCD_DISPLAYOFF 0x00

define LCD_CLEARDISPLAY 0x01

and as to whether they have a method of closing down the screen.

Cheers, Chris S.

OK., Bob,

I did my mooch about Adafruit Industries and found that they were not keen to talk to none customers so on the basis of being persona non grata I rummaged about and found an article by a guy called Peter Ouwehand who was said to know all about the Hitachi HD44780's but they would not let me read his article. Howsoever; on further rummaging I found on google the chap and the article that he had written and very thorough it seems to be. You may know the article alredy butr if you do not then the link is:

http://irtfweb.ifa.hawaii.edu/~tcs3/tcs3/vendor_info/Technologic_systems/embeddedx86/HD44780_LCD/lcd0.shtml.htm

Seems to me that this particular LCD., is incabable of having the backlight switch ed off as a singular happening and I feel therefore that I should close the book. Interestingly in my rummaging I found that there is Tri colour LCD which has the three colours adjustable by pwm., and of course if you provide them all with 'nowt' then what you get is 'nowt', please forgive my Mancunian and I'm sure that you get my gist of things. Please get back to me if you consider me wrong as I would be delighted to know.

Thanks for all your help and proposals. Cheers, Chris

ChrisPSR: Seems to me that this particular LCD., is incabable of having the backlight switch ed off as a singular happening ...

This should not be a surprise. And it is not specific to your particular LCD, it is the way hd44780 interface works so backlight control can't be done through hd44780 commands on any hd44780 LCD. (This is documented in the hd44780 spec) Actually, power management, including turning of the backlight can be done just not the way you were trying to go about it. I tried to explain this to you in my previous posts, and even offered to help you come up with a working solution, but you seemed to be fixated on going down your own set path.

--- bill

Actually, power management, including turning of the backlight can be done just not the way you were trying to go about it. I tried to explain this to you in my previous posts, and even offered to help you come up with a working solution, but you seemed to be fixated on going down your own set path.

--- bill [/quote] Dear Bill, I copied your eMail to hard copy and read and re-read it, all two foolscap pages, I digested what I could but really couldn't see an answer to the problem therein. It was probably there to some one who understood all that was written but I did not. There was also some remarks about a possible misunderstanding of the action of display() actions but if you look back in the thread you will see that my coding actually uses the noDisplay() and display() to accomplish clean reading of the two pages post to the LCD.

However I would be pleased to learn what ever I can to close the screen completely and satisfy the aspiration of the eventual user and I thank you for the help and instruction that you have provided. The back box has been made by the eventual user who has already cut out the aperture for the display screen, incorporated a momentary switch and a power on/off slidding switch which compounds my reason for attempting to find a solution to partial quiesence of the whole.

Cheers and very many thanks, Chris S