Arduino Forum

Using Arduino => Displays => Topic started by: keyzo_gakiya on Dec 07, 2019, 01:36 am

Title: LCD not working when connected to Arduino pin to control power
Post by: keyzo_gakiya on Dec 07, 2019, 01:36 am
Hi Everyone

I am working on an automatic time-based turn ON-OFF relay project and it uses an 16x2 LCD display.

I want the LCD to turn off after a while in order to save energy, to do so I connected the power VCC pin of the LCD to digital pin 6 in the Arduino, whenever a time counter in the sketch reached 0, the pin would be set to LOW and the display would turn OFF (the same was done for the backlight but in a different PIN to control each one separately).

This configuration was working as expected but last night suddenly the LCD started showing gibberish when I would upload the sketch to the ATMEGA Microcontroller.

I couldn't think of any way I could have messed something up since everything was working fine and it have do so for several days now, until last night, I even let the Arduino running for around 72 hours in a row since the Monitor's USB to which it is connected are always on.

Here is everything I have tried:


When I connect the VCC pin of the LCD to the Digital Pin of the Arduino and upload the sketch, things don't work, however, if I connect the VCC pin of the LCD to the 5V of the Arduino it does work!, it works if the VCC pin of the LCD is connected to 5V directly to the Arduino board or to the side of the breadboard (the side of the breadboard connected to the Arduino 5V output).

I read the output voltage of the Arduino pin and it read 4.8 V I know is a little low but I think it should be enough to power the display, right?

This is the code I'm using, as you can see is the most basic program for an LCD:



Code: [Select]

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);

  int lcdPow = 6;

  pinMode(lcdPow, OUTPUT);

  digitalWrite(lcdPow, HIGH);
  
  lcd.begin(16, 2);
  lcd.clear();
  lcd.print("Hi there");
}

void loop() {

}





Thanks to everyone reading this and trying to help me figure out what is going on, I wish you happy holidays, love you all!

Regards
Keyzo

Title: Re: LCD not working when connected to Arduino pin to control power
Post by: keyzo_gakiya on Dec 07, 2019, 01:46 am
I apologize, I tried uploading a couple of pictures but they were too big so I tried compressing them and now the site says that the pictures can't be uploaded since they fail security checks.

Regards
Keyzo
Title: Re: LCD not working when connected to Arduino pin to control power
Post by: ballscrewbob on Dec 07, 2019, 04:39 am
The usual cause of that is that they may be too large.

Bob.

Title: Re: LCD not working when connected to Arduino pin to control power
Post by: Paul__B on Dec 07, 2019, 07:42 am
OK now, let's first sort out the "XY Problem (http://xyproblem.info/)".

Why do you imagine you want to "save power"?

If it is connected to a USB port, then the whole concept of "saving power" is simply nonsense.  The only part of the device that requires significant power is the LED illumination - about 24 mA if this is the common sort of 1602 LCD with the value of R8 on the board being "101" - 100 Ohms.  24 mA is just within the capability of an Arduino pin to control (you will lose most of a Volt in the process) and is arguably a reasonable economy if you are using batteries.

The HD44780 chip itself consumes something like 600 µA so unless you have made the necessary board modifications to the as-yet-unknown sort of Arduino board and are using its sleep functionality, that current draw is complete nonsense compared to the operating current of the Arduino.  And you have to disable the USB interface and pilot LED in order to save current in sleep mode in any case.
(https://www.buydisplay.com/media/catalog/product/cache/1/image/c577d1203d4a53d9f98182eb6081b1d6/e/r/erm1602-6_bottom_view_2.jpg)
Full Size (https://www.buydisplay.com/media/catalog/product/cache/1/image/c577d1203d4a53d9f98182eb6081b1d6/e/r/erm1602-6_bottom_view_2.jpg)

However, apart from the chip, the 11k contrast ladder on the board (resistors R1 to R5) will also draw another 450 µA and if you have not corrected the classic blunder in a long series of amateur "tutorials" and modules which show a 10k contrast potentiometer connected to VCC - 5 V - as well as ground with the wiper to pin 3, then you are wasting another 500 µA.  The contrast potentiometer should not be connected to 5 V, that end should be left open or - if using a 10k pot - connected back to the ground, which will make the contrast setting much easier and save that 500 µA.  (The correct value of the contrast potentiometer would be either 1k or 2k.)

Right, so the LCD module apart from the illumination, draws just over 1 mA.  Do not attempt to remove its power and you do not have to worry about setting all the control pins LOW before removing the power or re-initialising it when you power it up again.
Title: Re: LCD not working when connected to Arduino pin to control power
Post by: keyzo_gakiya on Dec 09, 2019, 12:31 am
Thanks a lot for your response, yes, the system is connected to USB for testing, the final implementation will be using batteries, that's why I would like the display to turn off after a couple of minutes of inactivity.

I'm not sure what's the problem with the amperage you mention, I will try to get a total amount for display, potentiometer, buttons, and the 1307 RTC but what I find odd is that it was working just fine before.

Thanks a lot!

Regards
Keyzo
Title: Re: LCD not working when connected to Arduino pin to control power
Post by: gilshultz on Dec 09, 2019, 05:30 am
Why not use the "lcd.noBacklight();" and "lcd.backlight()" commands, they work great for me. This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!
Gil
Title: Re: LCD not working when connected to Arduino pin to control power
Post by: bperrybap on Dec 09, 2019, 09:22 am
Why not use the "lcd.noBacklight();" and "lcd.backlight()" commands, they work great for me.
Those API functions are not available in the IDE supplied LiquidCrystal library as it has not support for backlight control.
These API functions are available in many 3rd party libraries.
The LiquidCrystal library does come with display() and noDisplay() to turn the pixels on/off but that doesn't save as much power as turning off the backlight.

Some 3rd party libraries also include on() and off() which turns on/off the pixels as well as the display.

The advantage of using on() / off() over turning off the actual power to the LCD, is that you don't have to reinitialize the LCD.
When you use on() the backlight will be turned on an the pixels will turn on and the display will back to where it was before turning it off.

The hd44780 library supports, on()/off(), backlight()/noBacklight(), and display() / noDisplay()

--- bill
Title: Re: LCD not working when connected to Arduino pin to control power
Post by: Paul__B on Dec 09, 2019, 11:22 am
Thanks a lot for your response, yes, the system is connected to USB for testing, the final implementation will be using batteries, that's why I would like the display to turn off after a couple of minutes of inactivity.
OK, perhaps I did not didactically answer your original questions as the information I provided was to explain why your concept of "turning off" the display was sadly misguided.

I'm not sure what's the problem with the amperage you mention, I will try to get a total amount for display, potentiometer, buttons, and the 1307 RTC but what I find odd is that it was working just fine before.
So if you are saying you changed nothing at all - including the way you were powering it - and it suddenly cased to operate normally overnight, then that would be most strange but I think you are saying you changed something but have not clarified what it was.

Changing the USB from USB 2 to USB 3 is meaningless - the power is the same,

Are you saying you read the output voltage of the Arduino pin (the one powering the LCD, not the backlight) to be 4.8 V while the display was connected and enabled?

The contrast voltage is very sensitive - a 0.2 V difference will markedly affect the contrast.  So will temperature.  But the driver chip will still function perfectly and would not on that account display gobbledegook.

Again in summary, it is a complete waste of time to connect a 1602 LCD to an Arduino and attempt to turn off the LCD driver as it draws only just more than 1 - one - milliamp.  This is something like one-fiftieth of the current drawn by the UNO, let alone any other things you connect.  It is worthwhile turning off the illumination LED and as I explained, if it is the common sort of 1602 LCD with the value of R8 on the board being "101" - 100 Ohms.  24 mA is just within the capability of an Arduino pin to control directly.
Title: Re: LCD not working when connected to Arduino pin to control power
Post by: keyzo_gakiya on Dec 09, 2019, 12:44 pm
Hi everyone, I think I solved it, it turned out that I needed a Pull Down Resistor.

I was familiar with the concept of Pull Up and Pull Down Resistors but I never used them before (this is the first circuitry I ever design by myself), mostly because the Arduino take care of a lot of those details, plus, as I mentioned earlier the system was working fine before, however it occurred to me that the VCC pin of the LCD would be floating if it didn't receive a signal from the Arduino when it would be OFF, therefore, those milliseconds before the Arduino set the Pin 6 to HIGH during SETUP the pin would be receiving interference and messing up any initialisation instructions for the LCD's MC, at least I thought that might be the case.

So I read again about the Pull Down and Pull Up Resistors and added a Pull Down to the VCC connection of the LCD and the Arduino and it worked!

I did several tests, re-uploading the sketch. and it seems it is working as expected, I believe that any interference now received is simply being discarded before it has a change to mess up the LCD while the Arduino is getting to it.

I would like to thank every one that took the time to try to help me out, I have learned several things from your suggestions and I hope I can help you out in the future, although, frankly, I think you guys know much more than me about electronics, but be sure I'll keep getting better at this :D

Thanks again and have some very happy holidays!

Regards
Keyzo
Title: Re: LCD not working when connected to Arduino pin to control power
Post by: bperrybap on Dec 09, 2019, 06:23 pm
A pull down on the power going to the LCD doesn't seem necessary
as initialization in the library should be able to restore the LCD to a sane state regardless of what state it was in prior to the initialization.

You haven't fully described how you have everything wired up, including which Arduino board is being used or if it is a custom design.
There could also be wiring / soldering issues that can cause weirdness like things working then suddenly not working and then working again.
Showing photos can be helpful to get others to look things over for any potential issues.

We also have not seen the code you are using to test things.
The code we have seen only turns on the power pin. It does not attempt to turn off the LCD and then back on again to use the LCD after it is powered back up.

As Paul pointed out, from a power perspective, there may also be things that could/need to be done that could save additional power.
Perhaps much more than the power being saved by turning the LCD power on/off.

For example of a few items:
- a typical Mega or Uno Arduino board (the ones with the headers for shields and the power barrel jack)  is not very power efficient, particularly if attempting to power it with batteries.
This extra power draw in itself could be enough to drain batteries quite quickly.

- the pull down that you just added will consume power when the LCD is on.
How much depends on the value of the pull down used.

- LCD contrast pot can waste power.
Depending on how the LCD contrast pot is wired up and its value can dramatically affect the power consumed by the pot.

- i2c pullups can waste power.
Depending on if extra/uneeded pullups are being used and what values are being used, they may consume more power than is necessary.

--- bill