View previous topic :: View next topic |
Author |
Message |
jahan
Joined: 04 Apr 2005 Posts: 63
|
Question 16F84A & LED on LCD (See Schematics) |
Posted: Thu Jul 14, 2005 8:26 am |
|
|
Simple question that I cannot figure out.
I have 16F84A connected to and LCD and Keypad. (see schematics below)
Is there a simple way to turn ON the LED on LCD after first key entry,
and turn OFF the LED on LCD 2 seconds after the last key entry?
I have the keypad and the lcd part working OK. It does echo any entry from keypad to the LCD.
It would be nice to turn OFF the LED on LCD after 2 second inactivity.
Thankx |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Jul 14, 2005 10:58 am |
|
|
Well first thing you had better do is put a resistor between the base and the pic.
Your task is quite simple. On each keypress, turn on the LED and start a timeout value. This value gets reset each time a key is pressed. If you don't press a key, the timer will eventually expire or exceed a limit and at that point, turn off the LED. |
|
|
Guest
|
|
Posted: Thu Jul 14, 2005 12:27 pm |
|
|
Possibly even more important than putting a resistor in series with the base lead of the transistor switch, is putting a current limiting resistor in series with the backlight LED line. Most panels do not include the current limit on the display. Without it the backlight will be very bright (and hot) for a short period of time. If you don't have the display data sheet try a 33 or 22 Ohm, half Watt resistor as a starting point for a 5V supply. |
|
|
jahan
Joined: 04 Apr 2005 Posts: 63
|
|
Posted: Thu Jul 14, 2005 2:26 pm |
|
|
Quote: | Possibly even more important than putting a resistor in series with the base lead of the transistor switch, is putting a current limiting resistor in series with the backlight LED line. Most panels do not include the current limit on the display. Without it the backlight will be very bright (and hot) for a short period of time. If you don't have the display data sheet try a 33 or 22 Ohm, half Watt resistor as a starting point for a 5V supply. |
Is that why my LM7805 getting to boiling point REALLY FAST if backlight is ON?
Last edited by jahan on Thu Jul 14, 2005 2:28 pm; edited 1 time in total |
|
|
jahan
Joined: 04 Apr 2005 Posts: 63
|
|
Posted: Thu Jul 14, 2005 2:27 pm |
|
|
Mark wrote: | Well first thing you had better do is put a resistor between the base and the pic.
Your task is quite simple. On each keypress, turn on the LED and start a timeout value. This value gets reset each time a key is pressed. If you don't press a key, the timer will eventually expire or exceed a limit and at that point, turn off the LED. |
1. Do I turn the LED ON in my main code?
2. Do I turn the LED OFF in my RTCC interrupte routine? |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1911
|
|
Posted: Thu Jul 14, 2005 3:22 pm |
|
|
jahan wrote: | 1. Do I turn the LED ON in my main code?
2. Do I turn the LED OFF in my RTCC interrupte routine? |
You turn the LED on in your button press routine/interrupt. At the same place, you reset the timer to time out/go off in 2 seconds.
In your RTCC routine, you turn the LED off if 2 seconds has elapsed.
It's that simple. |
|
|
MikeValencia
Joined: 04 Aug 2004 Posts: 238 Location: Chicago
|
|
Posted: Thu Jul 14, 2005 3:38 pm |
|
|
I think you're asking the same question on two parallel threads.
http://www.ccsinfo.com/forum/viewtopic.php?t=23163
Newguy is telling you to turn on the lcd in one isr, and to turn it off in another isr. As for me, i choose to set flags in an isr, and then take action out in my main loop if that flag is set.
Both methods work; there is no right or wrong place to turn the LCD on or off. |
|
|
jahan
Joined: 04 Apr 2005 Posts: 63
|
|
Posted: Thu Jul 14, 2005 3:40 pm |
|
|
Mark wrote: | Well first thing you had better do is put a resistor between the base and the pic. |
what size should I use?
Sorry for these simple questions, but I'm trying to learn this as hobby and I'm learning stuff from forums and internet by myself.
Thankx |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1911
|
|
Posted: Thu Jul 14, 2005 5:15 pm |
|
|
Most LCD backlights have a forward voltage drop of about 3.5V - 4V or so. This means that the light emitting diodes that make up the backlight have been matrixed - usually two in series, and a whole bunch of these pairs paralled.
So, when you apply 5V across the backlight, the LEDs themselves account for about 4V of the drop, leaving you to drop the remaining 1V across a resistor. The purpose of this resistor is to limit the current through the LEDs so that they don't burn out, and don't get blindingly bright.
If you're shooting for about 50 mA through your backlight when it's on, then you need a series resistor of a size R = 1V/0.05A = 20 ohms.
You can adjust the brightness of your backlight by varying this series resistor. A smaller value will mean more current and a brighter display, and a higher value will mean the opposite.
The datasheet for your LCD should say something about the maximum backlight current and its' forward voltage drop. If you can't find the datasheet or these parameters if you do have the sheet, then you're probably safe to assume a 4V forward voltage drop and about 100 - 150 mA max through the backlight.
Hope this helps. |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1911
|
|
Posted: Thu Jul 14, 2005 5:19 pm |
|
|
MikeValencia wrote: | Newguy is telling you to turn on the lcd in one isr, and to turn it off in another isr. As for me, i choose to set flags in an isr, and then take action out in my main loop if that flag is set.
Both methods work; there is no right or wrong place to turn the LCD on or off. |
Point taken.
However, turning the backlight on & off usually involves one line of code that usually compiles into one line of assembly. I haven't done anything that timing critical to need that extra instruction cycle - yet. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Jul 14, 2005 6:57 pm |
|
|
Quote: | You can adjust the brightness of your backlight by varying this series resistor. A smaller value will mean more current and a brighter display, and a higher value will mean the opposite.
|
Or PWM the drive signal for a more efficient approach. This will also allow you to keep the backlight on very dimly in case you want to use it as a locator in the dark.
As far as the base resistor goes, the Base to Emitter junction is about a 0.7V drop. By knowing the base current you use ohm's law to get the resistance. (5-0.7)/(base current) = resistance.
Most people would just stick a 1K to 10K resistor in there. Me, I'd stick a 4.7K. The idea is to give something to drop the 4.3 volts across.
If you are just starting out, Radio Shack use to sell these little hobby electronic books by Forrest M. Mims III called "Engineer's Mini-Notebook". There were several each dealing with different types of components and circuits. That's were I got my start. |
|
|
|