Go Down

Topic: Delay LCD backlight turn off (Read 3732 times) previous topic - next topic

SukkoPera

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!

Tom Carpenter

#1
Aug 18, 2012, 02:39 pm Last Edit: Aug 18, 2012, 02:41 pm by Tom Carpenter Reason: 1
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.
~Tom~

SukkoPera

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.

Tom Carpenter

#3
Aug 18, 2012, 06:12 pm Last Edit: Aug 18, 2012, 06:15 pm by Tom Carpenter Reason: 1
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.
~Tom~

MarkT

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.
[ I won't respond to messages, use the forum please ]

John_S

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: [Select]
    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




     
http://jsrintervalometers.blogspot.ca

doughboy

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?

SukkoPera

#7
Aug 20, 2012, 07:06 pm Last Edit: Aug 20, 2012, 08:43 pm by SukkoPera Reason: 1
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 :): 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.

doughboy


@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.

Tom Carpenter

#9
Aug 20, 2012, 07:30 pm Last Edit: Aug 20, 2012, 07:33 pm by Tom Carpenter Reason: 1
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.
~Tom~

SukkoPera

#10
Aug 20, 2012, 08:42 pm Last Edit: Aug 20, 2012, 08:56 pm by SukkoPera Reason: 1
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?

dc42

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.
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.

SukkoPera

#12
Aug 20, 2012, 08:54 pm Last Edit: Aug 20, 2012, 08:57 pm by SukkoPera Reason: 1
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 :).

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 :).


Tom Carpenter

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?!?).
~Tom~

doughboy


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 :).

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 :).





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.

Go Up