Warning to users of some vendors LCD keypad shields

The value of arduino rests on the community. Those that exploits profits without supporting the community will not get your money a second time, will they? (they are so cheap thou, for a reason).

Heads up to anyone else!!
First- THANK YOU Bill!!
Just bought a Button-LCD shield by SainSmart- was looking for example code and found this thread- LUCKY ME!!
April 2013 and STILL the same problem- except on this board there is a 1K resistor where there is a 4.7k on the schematic!!
(took the LCD off the shield to look)
Trying your test caused the Arduino to disconnect from usb so it definitely shorted!!

Hey

I'm really new to all this.

Please could you help me with the display. I've tried to enter the code as is displayed, when I press "right" right is displayed. Pressing "left" displays select. "up" displays down. "down" displays left. And "select" displays nothing at all. I have tried adjusting the numerical values and have got it working except for the "select" button which I cant get to show anything at all. Any ideas why or how to rectify this?

Thanks

Dan

I am happy I came across this post. I have a Robot LCD keypad shield that the backlight flashes when I tryto use it I thought it was ready for the bin. Will try the mod and see what happens:)

Adrian

Hy DanBeno! Have you tried the following configurations?

#define btnRIGHT  0
#define btnUP     1
#define btnDOWN   2
#define btnLEFT   3
#define btnSELECT 4
#define btnNONE   5

int read_LCD_buttons()
{
  x = analogRead(0);      // read the value from the sensor 
  delay(5); //switch debounce delay. Increase this delay if incorrect switch selections are returned.
  int k = (analogRead(0) - x); //gives the button a slight range to allow for a little contact resistance noise
  if (5 < abs(k)) return btnNONE;  // double checks the keypress. If the two readings are not equal +/-k value after debounce delay, it tries again.
  // my buttons when read are centered at these values: 0, 144, 329, 504, 741
  // we add approx 50 to those values and check to see if we are close
  if (x > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result
  if (x < 50)   return btnRIGHT;  
  if (x < 195)  return btnUP; 
  if (x < 380)  return btnDOWN; 
  if (x < 555)  return btnLEFT; 
  if (x < 790)  return btnSELECT;   
  return btnNONE;  // when all others fail, return this…
}

lcd_key = read_LCD_buttons();
    checkBtns = false;
    switch(lcd_key){
    case btnRIGHT:
        Serial.println("btnRight");
        break;
      case btnLEFT:
        Serial.println("btnLeft");
        break;
    case btnUP:
        Serial.println("btnUp");
        increment = 1;
        break;
    case btnDOWN:
        Serial.println("btnDown");
        increment = -1;
        break;
    case btnSELECT:
        Serial.println("btnSelect");
        data_item++;
        break;
    default:
        break;
    }

I Made the Diode Repair proposed by dweston and the keypad is perfect now!
The background led is dimming perfectly! I was lucky finding the diode 1N5817 in an old ethernet pci board!
Later I could measure the consumption through pins Vin and ground and the multimeter in amperes in series and 9v power source.
It can be measured also from the keypad itself. Then I uploaded the thest sketch on page 1, to test the dimming of backlight.

Only the arduino consumes 46 mA, with the Lcd Shield modified by the diode around 67mA and adding a jumper to it (original circuit) it consumes 150mA! I wonder all the lcd shields being sold will end up burning port 10 on the arduinos!
I received my arduino for less than a week and I´m loving it! I assume it is safe to let it plugged directly on the usb port since it is consuming far less than 500mA.

I Installed the IDE interface on Mageia Linux 3 and it worked without effort, Arduino RPM (Mageia, Mandriva, Fedora, SuSe, etc.) - IDE 1.x - Arduino Forum

Celso Ferrarini

cferrarini:
Only the arduino consumes 46 mA, with the Lcd Shield modified by the diode around 67mA and adding a jumper to it (original circuit) it consumes 150mA! I wonder all the lcd shields being sold will end up burning port 10 on the arduinos!

Probably not, since I'm guessing that most users are not even aware that their shield "supports dimming"
and even then they are using the stock LiquidCrystal library which does not support dimming.
And as long as they don't mess with the pin that is connected to the transistor, not bad happens and the backlight
is on

I received my arduino for less than a week and I´m loving it! I assume it is safe to let it plugged directly on the usb port since it is consuming far less than 500mA.

I use the USB port directly. Excess USB power shouldn't be an issue, but not everyone does things properly.
However, the small little USB extern USB passport type drives pull up to 1 amp as they start up and most
USB ports can run them, so under 500ma will be fine.

I Installed the IDE interface on Mageia Linux 3 and it worked without effort, Arduino RPM (Mageia, Mandriva, Fedora, SuSe, etc.) - IDE 1.x - Arduino Forum

Celso Ferrarini

BTW, if you switch to fm's LiquidCrystal library, it is faster and has backlight support
including dimming:
https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home

This problem is real and my LCD branded Deekbot off eBay has same issue.

I think replacing bipolar transistor with FET is the cleanest solution, but I don't have suitable FET around and I'm not looking to procure it.

I hate to take LCD out of the shield to reach transistor or resistor and my hands too shaky to cut trace and solder diode, and I hate to look for additional parts like shottky ot germanium diode, but I can do two other things that do not require additional parts:

  1. Pluck pull-up resistor from underneath LCD and run backlight control D10 as INPUT only. If you really up to it you may put 100K resistor from D10 to ground to prevent base from floating, but I don't think it's necessary.

  2. Pluck transistor out from underneath LCD and connect D10 directly to LCDs pin 16. Resistor is irrelevant. D10must be an output, but control will be inverted - full bright will be 0 and dim 255. Outputs are plenty strong to drive LED directly.

These are two separate options, not two steps for same one!

Use something like small watch screwdriver to pluck part of your choice. If trace start delaminating - just cut it with same screwdriver.

I think these fixes are easier than others.

I just did second option - works as expected. Took 20 seconds + iron heating time. See attached pictures. Second picture is half -plucked transistor standing on it's hind (BE) legs before final termination.

Cheers y'all!

DSC03292.JPG

DSC03290.JPG

SuperLAVA:
This problem is real and my LCD branded Deekbot off eBay has same issue.
Sure it is, which is why I created the thread.

I think replacing bipolar transistor with FET is the cleanest solution, but I don't have suitable FET around and I'm not looking to procure it.

I hate to take LCD out of the shield to reach transistor or resistor and my hands too shaky to cut trace and solder diode, and I hate to look for additional parts like shottky ot germanium diode, but I can do two other things that do not require additional parts:
Removing the LCD is quite difficult. I tried it. Getting all the pins cleanly de-soldered is a real pain
even with a de-soldering tool. The mod for the diode was actually much less work.

  1. Pluck pull-up resistor from underneath LCD and run backlight control D10 as INPUT only. If you really up to it you may put 100K resistor from D10 to ground to prevent base from floating, but I don't think it's necessary.
    Are you saying leave D10 connected to the transistor base? And then set D10 to INPUT to
    turn on the backlight?
    If so, that doesn't solve the problem since if you set D10 to HIGH you still have the "short".
    The problem isn't the resistor between d10 and VCC it is that there is no resistor
    between D10 and the base.
    If using this "INPUT only" option, there is no need to remove the resistor.
    since if you don't mess with D10, D10 will default to input and the resistor
    will turn on the transistor so the backlight is on.
    The problem is only if D10 is ever set to HIGH which also happens during PWM.
    With the resistor removed, there may also be an issue with the transistor
    turning on enough to fully light the backlight since the internal pullup on the AVR
    (assuming it is enabled) won't provide much current to feed into the base.
    There is a s/w approach mentioned at the bottom of response #3:
    Warning to users of some vendors LCD keypad shields - #4 by bperrybap - Displays - Arduino Forum
    which didn't remove the resistor.
    The limitation is that you can't do PWM to dim the backlight
    and this method doesn't work with libraries like fm's library that assume
    you set the output to HIGH or LOW or can use PWM to control the backlight.

  2. Pluck transistor out from underneath LCD and connect D10 directly to LCDs pin 16. Resistor is irrelevant. D10must be an output, but control will be inverted - full bright will be 0 and dim 255. Outputs are plenty strong to drive LED directly.
    Disconnecting D10 from the transistor and driving the backlight directly might work.
    I haven't measured the current on these backlights but many of the 16x2 backlights only
    use a few milliamps.
    Libraries like fm's allow configuring the polarity of the backlight control and will take care
    of inverting the signals including with PWM.

These are two separate options, not two steps for same one!
Use something like small watch screwdriver to pluck part of your choice. If trace start delaminating - just cut it with same screwdriver.

I think these fixes are easier than others.

Cheers y'all!

bperrybap:

SuperLAVA:
This problem is real and my LCD branded Deekbot off eBay has same issue.
Sure it is, which is why I created the thread.

I think replacing bipolar transistor with FET is the cleanest solution, but I don't have suitable FET around and I'm not looking to procure it.

I hate to take LCD out of the shield to reach transistor or resistor and my hands too shaky to cut trace and solder diode, and I hate to look for additional parts like shottky ot germanium diode, but I can do two other things that do not require additional parts:
Removing the LCD is quite difficult. I tried it. Getting all the pins cleanly de-soldered is a real pain
even with a de-soldering tool. The mod for the diode was actually much less work.

  1. Pluck pull-up resistor from underneath LCD and run backlight control D10 as INPUT only. If you really up to it you may put 100K resistor from D10 to ground to prevent base from floating, but I don't think it's necessary.
    Are you saying leave D10 connected to the transistor base? And then set D10 to INPUT to
    turn on the backlight?
    If so, that doesn't solve the problem since if you set D10 to HIGH you still have the "short".
    No, you don't. If set as INPUT then High will be driven with 20K to VCC. See digitalWrite() - Arduino Reference
    When writing Low to input it will be left floating. Leaving original transistor pull-up will prevent it from going low, this is why it have to be removed
    The problem isn't the resistor between d10 and VCC it is that there is no resistor
    between D10 and the base.Only if driven with high current. Setting D10 as Input will drive base through 20K internal pullup only, not through output mode PUSH wich can blow transistor or micro's output.
    If using this "INPUT only" option, there is no need to remove the resistor.Wrong. With resistor present it would never go LOW. Removing it or even adding weak pull down will assure low potential on base and closing of transistor.
    since if you don't mess with D10, D10 will default to input and the resistor
    will turn on the transistor so the backlight is on.Correct, but you can't drive it low without setting as output. Unless, once again, you remove resistor.
    The problem is only if D10 is ever set to HIGH which also happens during PWM.
    With the resistor removed, there may also be an issue with the transistor
    turning on enough to fully light the backlight since the internal pullup on the AVR
    (assuming it is enabled) won't provide much current to feed into the base.20K pullup is plenty to drive this transistor.
    There is a s/w approach mentioned at the bottom of response #3:
    Warning to users of some vendors LCD keypad shields - #4 by bperrybap - Displays - Arduino Forum
    which didn't remove the resistor.
    The limitation is that you can't do PWM to dim the backlightYep, same as here, but for different reason.
    and this method doesn't work with libraries like fm's library that assume
    **you set the output to HIGH or LOW or can use PWM to control the backlight.**Analog write will automatically make pin output (I think so), so yes, you can't do dimming with it, but you still can control on/off. Depending on your application (library reuse?) some might prefer it. Just another available option.

  2. Pluck transistor out from underneath LCD and connect D10 directly to LCDs pin 16. Resistor is irrelevant. D10must be an output, but control will be inverted - full bright will be 0 and dim 255. Outputs are plenty strong to drive LED directly.
    Disconnecting D10 from the transistor and driving the backlight directly might work.
    I haven't measured the current on these backlights but many of the 16x2 backlights only
    use a few milliamps.Correct. As I.ve mentioned I already did it and it works. Definitely less stress for chip than driving straight base-emitter junction.
    Libraries like fm's allow configuring the polarity of the backlight control and will take care
    of inverting the signals including with PWM. I just did conversion in my code : 255-backlight

These are two separate options, not two steps for same one!
Use something like small watch screwdriver to pluck part of your choice. If trace start delaminating - just cut it with same screwdriver.

I think these fixes are easier than others.

Cheers y'all!

GOOD TALK!

We are in general agreement and I think both of us
misunderstood each other.
We have two different approaches for avoiding the D10 output HIGH
issue when offering backlight on/off control.
One method involves a hardware mod and s/w while the other is s/w only.

Your first explanation was not clear enough to me to be able to tell how you were intending
to use the output pin since you didn't fully describe it.
From your first description it appeared that you were just setting the pin to INPUT
and nothing else.
I now see that you intended to control the backlight on/off.

However, this approach and the s/w only approach from response #3 both
have the same issue of a "short" when D10 is an output and driven HIGH.
The reason is exactly the same whether the resistor is present or not.
(No current limiting from D10 into the base).

i.e. if s/w is loaded into the board that programs D10 as output and drives it high
BOOM... There is a problem - regardless of whether the resistor is removed.

So while either method can offer on/off backlight control,
neither protects the hardware from damage and
neither can support PWM because the first thing analogWrite() does is
make the pin an output as it turns on PWM which will
be driving the pin high.

The difference between the two
is that one requires a hardware mod AND special/odd s/w
and the other is only special/odd s/w.


The h/w and s/w method:

  • cut/remove resistor under LCD

  • possibly add weak pulldown resistor to D10

  • set D10 to INPUT

  • turn on pullup to turn on backlight
    (AVR m328 spec says 20k to 50k, worst case of 50k is that enough to turn on the transistor for backlight? .1ma ?)

  • turn off pullup to turn off backlight.

Alternatively with IDE 1.0.1 and beyond the s/w part reduces to be:
(with no initial setting of D10 to any state or level)

pinMode(D10, INPUT); // turn off backlight
pinMode(D10, INPUT_PULLUP); //turn on backlight

The s/w only method:

  • set D10 to LOW (only once)
  • set D10 to OUTPUT for backlight off
  • set D10 to INPUT for backlight on

Alternatively, with any version of IDE this reduces to:
(with no initial setting of D10 to any state or level)

pinMode(D10, OUTPUT); // turn off backlight
pinMode(D10, INPUT); // turn on backlight

This works because OUTPUT sets the output of the pin to LOW as well
which will pull the transistor base down which will turn off the backlight.
Since the pullup still in place on the LCD shield, there is no need
to turn on the D10 pullup, just setting it to INPUT mode will allow the shield pullup to drive
the transistor to turn on the backlight.


Given both methods have the same limitations
and they both reduce down to very similar s/w operations to control the backlight,
my preference would be for a s/w only solution.

I had talked to fm just after I started this thread
about adding support for this s/w only method to the lcd library
as an option but we came the conclusion that there is no guarantee that the user will
provide the correct information to the constructor.
And since you really can't tell things are broken, because it seems to work,
when you are shorting out the D10 pin by driving it HIGH, we opted not to provide it.
(Its also a strange and very narrow usage case as well)

--- bill

bperrybap:
We are in general agreement and I think both of us
misunderstood each other.
We have two different approaches for avoiding the D10 output HIGH
issue when offering backlight on/off control.
One method involves a hardware mod and s/w while the other is s/w only.

Your first explanation was not clear enough to me to be able to tell how you were intending
to use the output pin since you didn't fully describe it.
From your first description it appeared that you were just setting the pin to INPUT
and nothing else.
I now see that you intended to control the backlight on/off.

However, this approach and the s/w only approach from response #3 both
have the same issue of a "short" when D10 is an output and driven HIGH.
The reason is exactly the same whether the resistor is present or not.
(No current limiting from D10 into the base).

i.e. if s/w is loaded into the board that programs D10 as output and drives it high
BOOM... There is a problem - regardless of whether the resistor is removed.

So while either method can offer on/off backlight control,
neither protects the hardware from damage and
neither can support PWM because the first thing analogWrite() does is
make the pin an output as it turns on PWM which will
be driving the pin high.

The difference between the two
is that one requires a hardware mod AND special/odd s/w
and the other is only special/odd s/w.


The h/w and s/w method:

  • cut/remove resistor under LCD

  • possibly add weak pulldown resistor to D10

  • set D10 to INPUT

  • turn on pullup to turn on backlight
    (AVR m328 spec says 20k to 50k, worst case of 50k is that enough to turn on the transistor for backlight? .1ma ?)So average LED run at 20mA, 10 typical. You need gain of 200+. Most of these small transistors have current gain of 200-500 on average. I think it is sufficient.

  • turn off pullup to turn off backlight.

Alternatively with IDE 1.0.1 and beyond the s/w part reduces to be:
(with no initial setting of D10 to any state or level)

pinMode(D10, INPUT); // turn off backlight

pinMode(D10, INPUT_PULLUP); //turn on backlight




**Correct. Or after initial setup as input just do regular digital write (but not PWM!).**




---



**The s/w only method:**
- set D10 to LOW (only once)
- set D10 to OUTPUT for backlight off
- set D10 to INPUT for backlight on

Alternatively, with any version of IDE this reduces to:
(with no initial setting of D10 to any state or level)


pinMode(D10, OUTPUT); // turn off backlight
pinMode(D10, INPUT); // turn on backlight



**Correct. But you have to be careful and assure not to set output High.**

This works because OUTPUT sets the output of the pin to LOW as well
which will pull the transistor base down which will turn off the backlight.
Since the pullup still in place on the LCD shield, there is no need
to turn on the D10 pullup, just setting it to INPUT mode will allow the shield pullup to drive
the transistor to turn on the backlight.



---


Given both methods have the same limitations 
and they both reduce down to very similar s/w operations to control the backlight,
my preference would be for a s/w only solution.

I had talked to fm just after I started this thread
about adding support for this s/w only method to the lcd library
as an option but we came the conclusion that there is no guarantee that the user will
provide the correct information to the constructor.
And since you really can't tell things are broken, because it seems to work,
when you are shorting out the D10 pin by driving it HIGH, we opted not to provide it.
(Its also a strange and very narrow usage case as well)


--- bill

Bill,

Good points, no other arguments. It is good drill for crowd to understand all options. And yes, software only fix is better, or rather more convenient but it is still short of full functionality and compatibility. I believe, and this is why I did implement my option 2 - removing transistor. It is safe, no additional parts required, full functionality preserved, tho some software adaptations of existing code might be necessary.

Best regards!

Sal

As I came to this thread, I was most concerned because I had been running a shield for some weeks, just to see how high the seconds counter would go. In the event, the thunderstorm came first (and we had more today).

I was not quite sure how to determine whether this was a faulty or "fixed" board, so to test it I used the "Diode Test" range on the meter to test between D10 and ground on the shield - sure enough, it read 0.7V.

OK, I'm not happy. My solution? Well, I note that the holes on the LCD panel itself are unusually big, and it is relatively easy to suck out the solder on the top side (partially as it turns out that there is only solder on the top side anyway, it has not fully filled the holes). Where pins were still "tacked" to the sides of the holes after a second suck (it is often useful to put more solder on the connection for a second suck, so that it is all liquefied by adequate contact with the iron), they could generally be released by warping or twisting the pin with tweezers (that is a pair of epilation tweezers in the photo!).

Now revealed is R7 and the transistor. I don't know about the original, but R7 on this specimen (note all the spelling mistakes) is not 10k, it is actually 1k! What I did was to shave out the track between R7 and the transistor and move it over this gap - the pads already suited the purpose.

Many other alterations are possible but I did not fancy finding my SMD stocks, so now D10 connects to the transistor via 1k and nothing else.

Next I mounted the shield and plugged in power. Nothing appeared. Until at least, I looked closer. In fact, the test sketch was running as before, but no light. No voltage (at all!) on D10 either, unless I put the multimeter on low volts between D10 and Vcc, when I saw some light.

Had I fried a pin on a Mega2560? Well, no. The sketch is Mark Bramwell's July 2010 LCD panel test which uses the six-argument LiquidCrystal lcd constructor which makes no reference to port 10, thus it remains an input. Adding the lines

pinMode(10, OUTPUT);
digitalWrite(10, HIGH); // set the LED on

brings up the LED illumination and in fact, commenting out the first so that port 10 remains an input, makes virtually no difference though the voltage on D10 is only about 0.8V rather than near Vcc.

So I have a shield which is (now) safe, but expects D10 to be activated, if only using the internal pull-up.

A thought - if the digitalRead() call actually reads the pin state, then it would be possible to set it high as an output, then immediately test it to see if it is actually high, and if not, deem it to be shorted and alter the sketch behaviour accordingly.

RIMG1701a.jpg

RIMG1701b.jpg

Paul_B,
I really like the idea of testing/reading the D10 pin state after setting the pin HIGH.
Luckily the digitalRead() code reads the PINx register vs the PORTx register so this is possible.
What I'm not sure of is how much the output pin droops. If it droops enough
to be read as a LOW (which I'm assuming that it does given the "short"), then it
could be used to make a great little test sketch to tell people if their
shield has this issue.


On an actual "fix"
A better alternative to moving the resistor would be to replace the transistor
with an FET like a 2n7000.
That way you can still leve the pullup resistor in place to ensure the backlight
is on by default and there is no issue of shorting out D10 like with a NPN transistor
since the FET gate doesn't draw/sink current like the NPN base does.

--- bill

bperrybap:
What I'm not sure of is how much the output pin droops. If it droops enough to be read as a LOW (which I'm assuming that it does given the "short")

With the base-emitter junction of a transistor pulling it down, it will droop, make no mistake! The technique would not be so useful to detect for example, being connected to the backlight LED with no series resistor.

bperrybap:
A better alternative to moving the resistor would be to replace the transistor with a FET like a 2n7000.

Presupposing you have a drawer full of surface-mount FETs. I do not, and being late at night, I did not feel like exhuming my SMD resistor stock from the garage either. XD


I asked Nick to make this a "sticky" as the matter is to my mind, just so important (with the clear risk of damage to MCU boards).

The backlight pin output does seem to droop low enough on an unmodified shield
when attempting to turn on the backlight.
I created a sketch that will automatically detect if the shield
has a backlight circuit issue.
It will display results on the LCD.
See the sketch for full details.
It is attached.

--- bill

LCDKeypadCheck.pde.zip (2.22 KB)

I decided to bite the bullet and separate the LCD module from the LCD/keypad shield I have. Unsoldering 16 pins simultaneously is a challenge but it can be done if most of the solder is sucked out of the holes and then you wiggle the two boards relative to each other and also wiggle each pin in each hole for a while to break loose any solder that does remain. I found an SOT-23-3 transistor labeled AM1 (like this one http://www.digikey.com/product-detail/en/SMMBT3904LT1G/SMMBT3904LT1GOSTR-ND/3062754 ) installed on the lower board. I got this 2N7002 FET as a replacement for the transistor: http://www.digikey.com/product-detail/en/2N7002,215/568-1369-1-ND/763366. Soldering something that is as tiny as one of these is also a challenge and you need to have a good soldering iron with a needle tip to attempt it. After connecting everything back together it works.

I found that the following code could be used to turn the backlight on or off or any value in between.

pinMode ( BACKLIGHT_PIN, OUTPUT );
analogWrite ( BACKLIGHT_PIN, 64); // a value of 000 (off) to 255 (on) controls PWM%
//digitalWrite ( BACKLIGHT_PIN, HIGH ); // turn on backlight
//digitalWrite ( BACKLIGHT_PIN, LOW ); // turn off backlight

lcd.begin(16, 2); // start the lcd object

Hi All,

Just discovered this issue in my LCD shield.

[edit: I just replaced the transistor with a 2n7002 (marked 702 3d salvaged from a random PCB), since I shorted the transistor that was in there trying one of the earlier suggestions. Whew!]

[edit2: that lasted a few minutes. I had a simple timer to turn off the backlight after 60 seconds. After a few cycles, instead of going off, the backlight flickered and then went off permanently. I've now cut the trace to D10, the gate voltage is 0.34V, 2.4V on LCD pin 15. I can jump the gate voltage to 5V and measure about 40mA, and the backlight will then go on. So the mosfet seems to be working. Seems like the 4.7K resistor is open or maybe there is not enough to drive the mosfet?]

I have these small signal diodes: PMBD914
datasheet: http://www.nxp.com/documents/data_sheet/PMBD914.pdf

Will that diode work here?

If so, I can cut the trace from arduino pin 10 on the shield. Do I solder pin 3 of the diode to arduino side pin 10?

Thanks!

Is there any supplier in INDIA

I bought an OSEPP 16x2 LCD display shield today (16X2SHD-01) and found it has the same issue. The test sketch posted here reports it as "BAD". There is a 1K pullup resistor and no base resistor (schematic from OSEPP). Intriguingly, I can just barely see an empty SMD outline next to the 1K resistor. I tried removing the display to see how easy it would be to add a base resistor, but failed: my only desoldering tool is a solder sucker and some pads were starting to lift. So I'll live with it for now: I don't really need to control the brightness for the simple projects I have in mind.