Pages: [1] 2   Go Down
Author Topic: Delay LCD backlight turn off  (Read 3066 times)
0 Members and 1 Guest are viewing this topic.
Piemonte, Italia
Offline Offline
Jr. Member
**
Karma: 1
Posts: 65
Just a brick in the wall
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I have a project where I use a LCD. To save power, its backlight is normally off, and I have a button that, when pressed, will turn it on for a few seconds to allow reading the display.

Now, this is done on the software side, and works great, but consumes two pins of the Arduino. Is there a *simple* way to achieve the same effect in electronics, I guess using a condenser?

Thanks!
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 78
Posts: 1719
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Google "Monostable Multivibrator". I believe that is what you are looking for.

If you use one of those to drive the gate of a MOSFET which is connected between the cathode of the LCD backlight and ground ("MOSFET Switch"), then you should get the effect you are looking for.
« Last Edit: August 18, 2012, 07:41:51 am by Tom Carpenter » Logged

~Tom~

Piemonte, Italia
Offline Offline
Jr. Member
**
Karma: 1
Posts: 65
Just a brick in the wall
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks a lot, Tom, seems what I need: http://en.wikipedia.org/wiki/Multivibrator#Monostable_multivibrator_circuit.

Would you recommend some precise model of transistors I can use to implement the circuit? I've never used any, before.
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 78
Posts: 1719
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

There isn't really a specific one, any "NPN Epitaxial Silicon" Transistor will do. The BC547 is a good choice - its sort of your bog standard NPN transistor.

An alternative would be to use an NE555 timer chip. These are 8 pin IC's which are dirt cheap and can be used to make a monostable circuit.

In this circuit a 555 is setup as a monostable circuit with an output pulse time determined by the equation:
Ton = 1.1 * R1 * C1 as shown in the image. Here is a graph to help select the resistor and capacitor:



R2 is just a pullup resistor for the push button in that diagram, so a resistor of anywhere between 10k and 100k should do nicely.

The 555 is capable of sourcing 200mA of current which should be more than enough for the backlight. This means you could just connect the anode of the backlight to pin 3 of the NE555 and the cathode via a suitably sized resistor to ground.
« Last Edit: August 18, 2012, 11:15:49 am by Tom Carpenter » Logged

~Tom~

0
Offline Offline
Shannon Member
****
Karma: 200
Posts: 11730
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you use a 555 its best to avoid the original 555's and choose a CMOS version instead, the original 555's need massive decoupling capacitors (100uF electrolytic + 10uF ceramic is about right - the chip glitches upto 0.4A !!).  ICM7555 can only provide 100mA only though but doesn't crowbar the supply voltage in this way.
Logged

[ I won't respond to messages, use the forum please ]

Canada
Offline Offline
Sr. Member
****
Karma: 0
Posts: 318
Sometimes teaching, always learning,
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
but consumes two pins of the Arduino
Do you have one analog pin available? You can use one analog pin as an input and output at the same time with some clever code. Basically you read switch as an input a few times a second, then switch it to an output for the rest of the time:

Sample code: (run this a few times a second in your main loop):
Code:
    digitalWrite(analogpin, LOW);     //turn off LED
    pinMode(analogpin, INPUT);    //change the pin to input
    backlightread = analogRead(analogpin);
    backlightread = analogRead(analogpin); //take a second reading to let the ADC stabilize
    if (backlightread >400) backlight = TRUE; else backlight = FALSE;       
    pinMode(analogpin, OUTPUT);      //change pin back to output
    digitalWrite(analogpin, backlight);    //write the current backlight status to the pin

 

     


* one pin.png (6.58 KB, 402x408 - viewed 32 times.)
Logged


SF Bay area
Offline Offline
Sr. Member
****
Karma: 2
Posts: 266
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am curious, don't you control the backlight on/off already via an arduino pin? so why you need to use another pin? or is the button you refer to not connected to the arduino? It sounds like it is, since you say it is software controlled and uses 2 pins. backlight control needs only one pin. what is the second pin used for?
Logged

Piemonte, Italia
Offline Offline
Jr. Member
**
Karma: 1
Posts: 65
Just a brick in the wall
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for all your suggestions! I've just been at my local electronics store and bought both a few 555's and a few BC547's, I'll experiment with both and see what I come up with!

@MarkT: Unfortunately they had no ICM7555. I was actually given ST SA555N. Are they any better than the original NE555's? I paid € 0,50 each. I also bought a few capacitors (0,60 each, not so cheap!), where would you recommend putting them with the SA555N? Oh, and the 10 uF I got are electrolytic, can I use these instead of the ceramic ones (which I thought were only in the pF range)?

@John_S: Very clever smiley: I'll try your trick, for curiosity's sake, but unfortunately I can't use it in the actual project, as I have no pins left at all.

@doughboy: I need two pins because the backlight is normally off and only gets switched on temporarily at the press of a button. So I need one input for the button and one output for the backlight.
« Last Edit: August 20, 2012, 01:43:26 pm by SukkoPera » Logged

SF Bay area
Offline Offline
Sr. Member
****
Karma: 2
Posts: 266
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@doughboy: I need two pins because the backlight is normally off and only gets switched on temporarily at the press of a button. So I need one input for the button and one output for the backlight.

If you can use software to turn the backlight on when switch is pressed, couldn't you just use software to turn the backlight off after a certain time delay?
I have a similar setup where the backlight is turned off after 60 seconds and comes on by pressing any key.
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 78
Posts: 1719
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've never had any issue with the NE555 (or SA555, both are the same).

If you connect it up in the circuit I posted, put your 10uF capacitor between +5v and GND (the - on the electrolytic goes to ground), then you shouldn't have a problem.


Ceramic capacitors tend to be available from 10pF all the way up to 470nF. I have seen some at 1uF and 4.7uF before. Generally for anything higher than that, you use Electrolytic anyway.
« Last Edit: August 20, 2012, 12:33:52 pm by Tom Carpenter » Logged

~Tom~

Piemonte, Italia
Offline Offline
Jr. Member
**
Karma: 1
Posts: 65
Just a brick in the wall
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've built both versions with success! A couple pics:

http://db.tt/n3IRqqkJ
http://db.tt/YmDs69Xf

(Please don't mind about wire colors, I'd run out of jumpers!)

I tend to prefer the 555 version, it is much easier to choose the R/C values to achieve the desired timing.

PS: What's the difference between ceramic and electrolytic capacitors then? How should I choose?
« Last Edit: August 20, 2012, 01:56:14 pm by SukkoPera » Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, you can use a 555 or similar and a few resistors and capacitors to do the delay; but what's wrong with doing the delay in software? That's the modern way to do it. The whole point of microcontrollers is that they replace a pile of electronic components with one microcontroller and some software.

If you are short of pins, and the push button is used only to turn the backlight on, you can use a single pin both to detect the button push and control the backlight.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Piemonte, Italia
Offline Offline
Jr. Member
**
Karma: 1
Posts: 65
Just a brick in the wall
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Just to clarify: I'm perfectly fine doing the delay in software, it was my first thought and that's what I'm doing now. It was even a good excuse to use interrupts smiley.

The point is that I started testing this LCD stuff on a small side-project, where I have lots of spare pins, but the real goal is to use the LCD in another project, where unfortunately I've run out of pins. There the board is a KMtronic DINo, which drives 4 relays and an ENC26J80. It only exposes D0/D1 (Used for serial data exchange), D2 (which I use to read a digital thermometer) and A0/A1, which I'll be using to drive the LCD via a two-wire protocol through a shift register. It has no other pins. At the beginning I was planning to light the display through a button wired directly to Vcc, but it has the "inconvenience" that you have to keep the button pressed. Since I can add a delay with just € 0,50, I guess I'll go that way smiley.

« Last Edit: August 20, 2012, 01:57:31 pm by SukkoPera » Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 78
Posts: 1719
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The difference between electrolytic and ceramic is to do with the materials used.

A ceramic capacitor stores charge on two metal plates seperated by a piece of ceramic material (or in some cases an air gap) of a specific thickness. The size of the plates determines the capacitance, which is why capacitances larger than around 1uF become impractical - you would have to have a massive capacitor.

An electrolytic capacitor uses the same two plates, however it adds an electrolyte which is a material that contains a large number of free ions - essentially atoms which have had some of their outer electrons stripped away. The material is either a liquid (cheap, but eventually can leak out - which is bad), or a solid (expensive, but wont leak so used in harsh environments or high end electronics equipment). Because of the electrolyte, there is an electric feild inbuilt within the capacitor which essentially increases the amount of electrons which can be stored on the plates, leading to a much larger capacitance for a given size.
Depending on the electrolyte used, these can be polarised. Aluminum oxide is a commonly used material as it is what is called a 'dielectric' material (to do with the atomic structure). The problem with this material is that if the polarity of the electric field inside the capacitor is incorrect, the oxide will break down and thus cause the plates to short out (BOOM?!?).
Logged

~Tom~

SF Bay area
Offline Offline
Sr. Member
****
Karma: 2
Posts: 266
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just to clarify: I'm perfectly fine doing the delay in software, it was my first thought and that's what I'm doing now. It was even a good excuse to use interrupts smiley.

The point is that I started testing this LCD stuff on a small side-project, where I have lots of spare pins, but the real goal is to use the LCD in another project, where unfortunately I've run out of pins. There the board is a KMtronic DINo, which drives 4 relays and an ENC26J80. It only exposes D0/D1 (Used for serial data exchange), D2 (which I use to read a digital thermometer) and A0/A1, which I'll be using to drive the LCD via a two-wire protocol through a shift register. It has no other pins. At the beginning I was planning to light the display through a button wired directly to Vcc, but it has the "inconvenience" that you have to keep the button pressed. Since I can add a delay with just € 0,50, I guess I'll go that way smiley.




I still don't get it, you are not using any extra pins by using software. I use I2C interface to LCD+keypad (using mcp23017) and all I use is the two i2c pins. you don't need to use any more pins that what you already need just to drive the lcd. not sure why the need to do things the hard way.
Logged

Pages: [1] 2   Go Up
Jump to: