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

The information I wish to send is directly copied herewith from the Hitachi HD44780 and is as follows: INSTRUCTION: Display on/off control:

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

PURPOSE: Sets entire display (D) on/off, cursor on/off (C), and blinking of cursor position character (B).

EXECUTION TIME: 37 µs[/table]

The above table occurs along with other instructions on Page., 24 of the data sheet.

This would answer a common question that goes unanswered in many of the forum questions that I have visited put by other members, mainly "What is the sftware instruction to shut off the complete display of the HD44780.

Chris S.

It looks like you have to set the RS and R/W pins (pins 36 and 37) to LOW then the 8 bits of the data bus (pins 39 to 46) to the values quoted. Data bits 7 to 3 have explicit values (0 0 0 1) and data bits 2 to 0 have values that you choose depending on what you want to do. Display on/off (DB2), cursor on/off (DB1) and cursor blinking on/off (DB0)

It depends how the display is wired how you set the bits. If it uses individual connections to the Arduino (unlikely) then just set each pins output to the required value. If it uses a shift register (more likely) then set the bits in a byte to the required values, or use a constant variable with the values already set, and clock the byte into the shift register.

So, how is the display wired and what is your level of knowledge programming the Arduino ?

UKHeliBob:
It looks like you have to set the RS and R/W pins (pins 36 and 37) to LOW then the 8 bits of the data bus (pins 39 to 46) to the values quoted. Data bits 7 to 3 have explicit values (0 0 0 1) and data bits 2 to 0 have values that you choose depending on what you want to do. Display on/off (DB2), cursor on/off (DB1) and cursor blinking on/off (DB0)

It depends how the display is wired how you set the bits. If it uses individual connections to the Arduino (unlikely) then just set each pins output to the required value. If it uses a shift register (more likely) then set the bits in a byte to the required values, or use a constant variable with the values already set, and clock the byte into the shift register.

So, how is the display wired and what is your level of knowledge programming the Arduino ?

Bob The wiring is fairly clearly provided herewith:-

/***** Author ChrisSpreckley *****
****** Date: 07th October 2014
****** Environment Arduino PRO MINI AT168
****** Utilises an Adafruit Class DHT.h
****** Sketch for DHT humidity/temperature sensors controlling
****** GreenHouse temperature by way of Heat Pump
****** & LCD temp & humidity readouts********************/

#include “DHT.h” // Authors Adafruit Industries
#include <LiquidCrystal.h> // Authors Arduino- Public
#define LCD_DISPLAYCONTROL 0x0F // Possible off-on for the Complete. Untested.
#define LCD_DISPLAYCONTROL 0x08 // number of LCD Display factors. Untested.
// Hexadecimal = B11011111 I believe
#include <Wire.h> // Authors Arduino- Public
#define DHTPIN1 A0 // Green House input
#define DHTPIN2 A1 // Heat Pump input
#define DHTTYPE DHT11 // DHT tpe Eleven
DHT dht1(DHTPIN1, DHTTYPE); // sensor No. 1
DHT dht2(DHTPIN2, DHTTYPE); // sensor No. 2
LiquidCrystal LCD(12, 11, 5, 4, 3, 2);// LCD to Arduino pins
boolean lastButton = LOW; // debounce variables
boolean currentButton = LOW; // ditto
const boolean switchPin = (8, LOW); // debounce switch pin origination
const char d = 0xDF; // Hex form of degree sign

Explanation of the Arduino to LCD connections are for example:Arduino 12 is connected to LCD 4 which is named RS
PIN CONNECTIONS:
12/4-RS; 11/5-R/W; 5/11-D4; 5/11-D5; 4/12-D6; 3/13-D7; 2/14-D7

I am away from my bench at the moment and I have an idea that the swithch on and off may be accomplished by defining
#define ‘LCD_DISPLAYCONTROL 0x0F’ as off and #define LCD_DISPLAYCONTROL 0x08 as on but am unsure.

Hope you can help,
Chris S

ChrisPSR:

UKHeliBob: It looks like you have to set the RS and R/W pins (pins 36 and 37) to LOW then the 8 bits of the data bus (pins 39 to 46) to the values quoted. Data bits 7 to 3 have explicit values (0 0 0 1) and data bits 2 to 0 have values that you choose depending on what you want to do. Display on/off (DB2), cursor on/off (DB1) and cursor blinking on/off (DB0)

Bob, sorry for the mistake I seem to have given you the Hex for the degree sign and not for the switch on or off for the display. Apologies here is the actual table in the data sheet:

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. These lines indicate what kind of transaction

The code is described in the first eMail of this thread and is: INSTRUCTION: Display on/off control:

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

PURPOSE: Sets entire display (D) on/off, cursor on/off (C), and blinking of cursor position character (B).

EXECUTION TIME: 37 µs[/table]

Cheers, Chris S.

#define LCD_DISPLAYCONTROL 0x0F       // Possible off-on for the Complete. Untested.
#define LCD_DISPLAYCONTROL 0x08       // number of LCD Display factors. Untested.

Which value do you want substituted where the name LCD_DISPLAYCONTROL appears in the code?

PaulS: ```

define LCD_DISPLAYCONTROL 0x0F       // Possible off-on for the Complete. Untested.

define LCD_DISPLAYCONTROL 0x08       // number of LCD Display factors. Untested.



Which value do you want substituted where the name LCD_DISPLAYCONTROL appears in the code?

Dear Paul, OK so I'm guessing with the code you ask about...................................rather badly as it seems. They do not work.

What I have done is written a small uncomplicated program for a neighbour who has built a heat pump to warm a green house. The whole of the gubins, mpu., display and sensors will be housed within the green house and will not be required but for a few seconds if and when; so as to save battery power it is fitted with a power on and off switch however I wish to fit a momentary switch that will cause the main power user, the screen, to shut down completely leaving the rest simmering in the background while necessary. The data sheets show that this is possible but I am afraid I do not know how to implement the provided code. The code is provided in the very first email thread, taken from page 24 of the Hitachi HD44780 LCD., data sheets.

Link: http://www.sparkfun.com/datasheets/LCD/HD44780.pdf

Hope the above helps, Cheers, Chris S.

I’m guessing with the code you ask about…rather badly as it seems.

A #define statement is a preprocessor directive that defines a name and a value. Wherever the name appears in the code, the value will be substituted. It does not make sense to have the same name with two different values.

PaulS:

I’m guessing with the code you ask about…rather badly as it seems.

A #define statement is a preprocessor directive that defines a name and a value. Wherever the name appears in the code, the value will be substituted. It does not make sense to have the same name with two different values.

Paul,
Sorry to mislead you so perhaps its better that I disclose the whole of the working program to date however beware of the finlal few lines as t hey are the beginnig of my normal debounced switch routine however the program does work very nicely, with it so:

/***** Author ChrisSpreckley *****
****** Date: 07th October 2014
****** Environment Arduino PRO MINI AT168
****** Utilises an Adafruit Class DHT.h
****** Sketch for DHT humidity/temperature sensors controlling
****** GreenHouse temperature by way of Heat Pump
****** & LCD temp & humidity readouts*/

#include “DHT.h” // Authors Adafruit Industries
#include <LiquidCrystal.h> // Authors Arduino- Public
#include <Wire.h> // Authors Arduino- Public
#define DHTPIN1 A0 // Green House input
#define DHTPIN2 A1 // Heat Pump input
#define DHTTYPE DHT11 // DHT tpe Eleven
DHT dht1(DHTPIN1, DHTTYPE); // sensor No. 1
DHT dht2(DHTPIN2, DHTTYPE); // sensor No. 2
LiquidCrystal LCD(12, 11, 5, 4, 3, 2);// LCD to Arduino pins
boolean lastButton = LOW; // debounce variables
boolean currentButton = LOW; // ditto
const boolean switchPin = (8, LOW); // debounce switch pin origination
const char d = 0xDF; // Hex form of degree sign

void setup() {
Serial.begin(9600);
LCD.begin(16, 4);
LCD.setCursor(1, 0);
LCD.print(" Temp And Humidity");
LCD.setCursor(0, 1);
LCD.print(“by Chris Spreckley”);
LCD.setCursor(0, 2);
LCD.print(" Hardware");
LCD.setCursor(0, 3);
LCD.print(“ArduinoPROMINI AT168”);
LCD.noCursor();
delay(5000);
dht1.begin();
dht2.begin();
}

boolean debounce(boolean last) { // debounce function
boolean current = digitalRead(switchPin);
if (last != current) {
delay(5);
current = digitalRead(switchPin);
}
return current;
} // debounce function ends

void loop() {
float h1 = dht1.readHumidity();
float t1 = dht1.readTemperature();
float h2 = dht2.readHumidity();
float t2 = dht2.readTemperature();
// below tests for correct type of info from sensors
if (isnan(t1) || isnan(t2) || isnan(h1) || isnan(h2)) {
Serial.println(“Failed to read from No.1 DHT”);
}
// generally expect sensors OK., so run print out.
else {
//LCD commmencement.
LCD.clear();
LCD.setCursor(0, 0);
LCD.print(“Green Ho Environment”); // line count 20
LCD.setCursor(1, 1);
LCD.print(“Temp:”); // Line count 6
LCD.print(t1, 0); // line count 2
LCD.print(d);
LCD.print(“C”); // line count 4
LCD.print(" Hum:"); // line count 5
LCD.print(h1,0); // line couint 2
LCD.print("%"); // line count 1 (Tot wordCount 20
LCD.setCursor(0, 2); // row 3
LCD.print(“HeatPump Temperature”);//Line count 14
LCD.setCursor(8, 3);
LCD.print(t2, 0);
LCD.print(d);
LCD.print(“C”);
delay(10000);
/*
boolean lastButton = LOW; // debounce variables
boolean currentButton = LOW; /
if (switchPin == HIGH && lastButton == LOW) {
Serial.print("
**************** BYE BYE **************");
lastButton = switchPin;
delay(1000);

Serial.print("***************** Hi-Ya **************");
}

}
}

Chris S

#define DHTPIN1 A0                    // Green House input

Or

#define GreenHousePin A0 // No useless comment needed.
const boolean switchPin = (8, LOW);   // debounce switch pin origination

WTF? The comma operator is NOT doing you any good here!

    if (switchPin == HIGH && lastButton == LOW)  {

Most people find it useful to actually read the state of the pin. YMMV.

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);

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

PaulS: ```

define DHTPIN1 A0                    // Green House input



Or 


define GreenHousePin A0 // No useless comment needed.






const boolean switchPin = (8, LOW);   // debounce switch pin origination ```

WTF? The comma operator is NOT doing you any good here!

    if (switchPin == HIGH && lastButton == LOW)  {

Most people find it useful to actually read the state of the pin. YMMV.

What on earth would that do!!!!!!!!!!!!!!!!! We know the F______G screens is on because we can't switch it off!!!!!!!!!!!!!!!!!!

I give up.

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

Sorry i must have misunderstood what you were attempting to achieve. But no worries. Go screw yourself.

Look you guys the program works beautifully. OK so I have learnt to program by learning a program using Arduin C++ for Dummies which may be true and may be untrue but is probably true

What I want, (and so do thousands others, if you read the various forums), is a simple answer to:-

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

Cheers, Chris S.

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 ?

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.