Pages: 1 [2]   Go Down
Author Topic: LCD Shield not behaving  (Read 5921 times)
0 Members and 1 Guest are viewing this topic.
Toronto, Canada
Offline Offline
Edison Member
*
Karma: 2
Posts: 1234
"Keep it R.E.I.L. - "Research, Experiment, Investigate and Learn"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

First. By looking at the code, the push buttons use the analog pins, not the digital pins.

Quote
my buttons when read are centered at these valies: 0, 144, 329, 504, 741

Those values are the analog value. A number between 0 = 0 V to 1023 = 5 V

The way the buttons is connected and the need a read which key is press based on the value being measured by the analog adc.

In my opinion anyway...
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've got lots of questions about this but let's start with these comments:
 // my buttons when read are centered at these valies: 0, 144, 329, 504, 741 Where do these values come from?
 // we add approx 50 to those values and check to see if we are close  Why do we add approx 50 to each value?

It's a voltage divider. So the total resistance is 2K + 330 + 620 + 1K + 3.3K which is 7250 ohms.

So if the top switch is pressed we get a voltage of 0 since we are grounding the ADC through the 2K resistor.

The next switch down will give (330 / (2000 + 330)) * 1024 = 145.

The next switch will give ((330 + 620) / (2000 + 330 + 620)) * 1024 = 329.

And so on.

I presume we add 50 to give a "fudge factor" so that the voltage doesn't have to be spot on, but within the range of this switch, compared to the next one in sequence.
Logged

Dallas, TX USA
Online Online
Edison Member
*
Karma: 48
Posts: 2349
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Also, where did you find the info that pins Arduino (RS, E, D4, D5, D6, D7) interface with LCD pins (8, 9, 4, 5, 6, 7)?

I found this schematic but I can't see that it provides this info anywhere.

Look closely at the schematic.
See the red/brown "D4", "D5", "D6", "D7" going to the 1602 DB4 to DB7?
The "D4" is Arduino digital pin 4, "D5" is Arduino digital pin 5, etc...
Also note D8 going to RS and D9 going to E.

As a bonus look over on the right at the transistor,
Arduino digital pin 10 controls the transistor so you can control the backlight with pin 10.
(Pin 10 supports PWM so you should be able to use analogWrite() and dim the display backlight)

You can also reference their document which has this information in it as well:
http://www.robotshop.com/dfrobot-lcd-keypad-shield-arduino-1.html
See the user guide then page through until you get to the LCD&Keypad shield.

--- bill
« Last Edit: March 12, 2012, 11:26:12 pm by bperrybap » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 553
Posts: 46267
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The switches on the shield are all connected to +5V and the analog in pin with a resistor in between. The resistors are different sizes, so the voltage that the analog pin sees depends on which switch is pressed.

The analogRead() function reports that voltage as an integer value in the range 0 to 1023 corresponding to 0 to the reference voltage (usually +5V).

So, the code is showing the usual value that would be read at each pin, if the reference voltage is exactly 5.000V and the resistor is exactly the nominal value and the switch is ultraclean (provides no resistance). Since none of these assumptions is true, the value actual reported will only be close to the nominal value shown.

Therefore a fudge factor is added in.
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 26
Posts: 4119
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Also, where did you find the info that pins Arduino (RS, E, D4, D5, D6, D7) interface with LCD pins (8, 9, 4, 5, 6, 7)?

I found this schematic but I can't see that it provides this info anywhere.

You've got the first part backwards - Arduino pins (8, 9, 4, 5, 6, 7) interface with LCD pins (RS, E, D4, D5, D6, D7).

Sorry I'm late, Bill already answered the second part, but here it is again.  On the schematic look at the IC in the upper right section.  If you follow the wire from the RS pin (LCD pin 4) you will see the term 'D8' which stands for Arduino digital pin 8.  The other pins have similar information.


Don
« Last Edit: March 13, 2012, 06:48:49 am by floresta » Logged

Dallas, TX USA
Online Online
Edison Member
*
Karma: 48
Posts: 2349
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Anybody else notice a backlight control problem in the DFRobot schematic?
http://www.robotshop.com/content/PDF/dfrobot-lcd-keypad-shield-schematic.pdf

D10 is hooked up straight to the 9013 base with no current limiting resistor.

When D10 is an input, the pullup will turn on backlight.
When D10 is an output and low the base goes low and the transistor turns off.
But when D10 is an output and high won't it
"short" through the transistor to the emitter?

Seems like the circuit is missing a diode to ensure that D10 only pulls the base low
and lets the resistor pull the base high.

Without the diode it seems like D10 really needs to either be an output with the pin low to turn
off the display or an input to turn on the display which precludes the use of PWM.

I have a shield that uses a similar circuit. Mine also has a switch to disconnect the ground to the
transistor emitter so you can permanently disable the backlight.

I just measured the current from D10 when D10 is high and it is 95ma!!!
I guess it is lucky that the pin output was not fried.

While the AVR doesn't get "hot", it does get warm when D10 is high
for a few minutes.

Anyway, I'm in the process of modding my shield with a diode.
It looks like an easy mod on the shield I have as the trace to D10 is on back of the shield
for a little bit up by the header before going through to the other side to the transistor which is under the LCD.
Just cut the trace and solder a diode back to the trace.

I'll post a few before/after photos after I get the mod done.

--- bill




Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 26
Posts: 4119
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

But it's on the Internet, it must be OK.

If they had taken the time to draw a proper schematic diagram they might have spotted that obvious error.  It's too bad that people think that these monstrosities (produced I think by Eagle) are true schematics. 


Don
« Last Edit: March 13, 2012, 04:20:27 pm by floresta » Logged

Dallas, TX USA
Online Online
Edison Member
*
Karma: 48
Posts: 2349
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is a thread I started about the backlight control circuit issue:
http://arduino.cc/forum/index.php/topic,96747.0.html
with some photos of the emartee shield I modified.

--- bill
Logged

Pages: 1 [2]   Go Up
Jump to: