Go Down

Topic: Backlight and I2C on LCD Display (Read 7410 times) previous topic - next topic

bperrybap

But that fritzing sketch does not match how you said things were wired.
i.e. it shows the backlight wired up.

If you disconnect pins 15 and 16 from the LCD and the backlight is still on,
then your LCD uses a pinout that is different from the way you have it wired.

How are you connecting the wires to the actual module?
Have you soldered the wires or header to the LCD?
I would be better for us to see  some actual pictures of your wiring.
Make sure that they are clear enough for us to see the wiring and the soldering
on the LCD.

Here is what I'd recommend.
- Find a datasheet for your LCD and verify the pinout
- use a proper contrast circuit (a single resistor to ground is not a proper circuit - use a pot)
- Use this library:
https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home
(Make sure to install it properly, which means removing any other LiquidCrystal_I2C library)
I would install it in you local sketchbook/libraries directory and name it "LiquidCrystal"
that way it will override the LiquidCrystal library that comes with the IDE.
- use the full constructor to specify how you have the PCF8574 wired up.
Code: [Select]
LiquidCrystal_I2C(i2cAddr, En, Rw, Rs, d4, d5, d6, d7, backlighPin, pol);


If you have it wired up as shown in the fritzing diagram, then your constructor should be:
Code: [Select]
   LiquidCrystal_I2C(i2cAddr, 4, 5, 6, 0, 1, 2, 3, 7, POSITIVE);


Some of the examples on fm's site and included with the library,
are out of date or are for fm's i2c backpack so ignore any code
that attempts to use/configure a backlight pin. The constructor specifies all that is needed.
You will then initialized and use the LCD the same way as the standard LiquidCrystal library
but you will have backlight control using backlight() and noBacklight().

--- bill

Zarnick

I'll try that as soon as possible.
But why a resistor to the ground isn't a proper circuit? (really newbie question I know, but hell, I am a newbie ;))

bperrybap


I'll try that as soon as possible.
But why a resistor to the ground isn't a proper circuit? (really newbie question I know, but hell, I am a newbie ;))

The Vo input signal (LCD module pin 3) is used to control the contrast of the pixels.
You feed that pin a voltage. It isn't an input current that needs to be limited like with an LED.
The lower the voltage you provide to the Vo signal, the more intense the pixels will be.
To high of a voltage and no pixels show up, to low and all the pixels will be on including the ones
that are not supposed to be on.
When using a single resistor to ground you are essentially just grounding the pin.
Some LCDs will have an acceptable contrast when the Vo signal is grounded but many won't
and will simply turn on all the pixels including the ones that should be off.
To set the voltage on the Vo signal, you can use a 2 resistor voltage divider between two voltages.
The voltage divider will create a voltage that is between the two voltages that is proportionally
between the voltages with the same ratio as the ratio of the two resistors.
You can either use 2 fixed resistors or pot.
A pot allows you to vary the two resistors of the voltage divider to control the output voltage, and
that varying voltage is what allows you to adjust the contrast on the LCD.

--- bill

MAS3


But why a resistor to the ground isn't a proper circuit? (really newbie question I know, but hell, I am a newbie ;))



By the way, did you know a potentiometer consists of 2 resistors in the way it is applied here to control the contrast ?
It doesn't do what you seem to think it does the way you hacked it.
Have a look at "blink without delay".
Did you connect the grounds ?
Je kunt hier ook in het Nederlands terecht: http://arduino.cc/forum/index.php/board,77.0.html

Zarnick

Ok, so here are the pictures.
I've added a trimpot for the contrast (thanks for the tip ;)) and here's the circuit:

And some closeups:




This is the LCD Pins:


The LCD I'm using a generic GM1602K.

The code I've used was this one (with the new library you guys told me about):
Code: [Select]

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(32,4,5,6,0,1,2,3,7,POSITIVE);  // Set the LCD I2C address
void setup()
{
  // Switch on the backlight
  lcd.begin(16,2);               // initialize the lcd
  lcd.clear();
  lcd.noBacklight();
  lcd.home ();                   // go home
  lcd.print("Hello, ARDUINO "); 
  lcd.setCursor ( 0, 1 );        // go to the next line
  lcd.print (" WORLD!  ");     
}

void loop()
{

}


And of course, the backlight is still on.
As for who soldered it, I got it already soldered up.

MAS3

Earlier you showed a picture identifying your transistor as a BC548.
Is that the one you actually used ?
If not, what one did you use ?
Have a look at "blink without delay".
Did you connect the grounds ?
Je kunt hier ook in het Nederlands terecht: http://arduino.cc/forum/index.php/board,77.0.html

bperrybap


Earlier you showed a picture identifying your transistor as a BC548.
Is that the one you actually used ?
If not, what one did you use ?

Good questions.
If it is a BC548, then it appears top me that the transistor is wired up incorrectly.
Ground should be connected to the Emitter.

Zarnick,
look at the transistor datasheet to verify the pinout and wire it up as shown in
that second diagram you provided earlier.
BTW, if you are interested, here is a nice tutorial on transistors:
https://www.youtube.com/watch?v=F-Cv7CMHoGM

--- bill

MAS3

Have a look at "blink without delay".
Did you connect the grounds ?
Je kunt hier ook in het Nederlands terecht: http://arduino.cc/forum/index.php/board,77.0.html

Zarnick

I'm sorry for the mixup, what I'm actually using is a NPN2222

Paul__B


- use a proper contrast circuit (a single resistor to ground is not a proper circuit - use a pot)

Actually, a resistor to ground is a perfectly proper circuit.   :D

On the LCD board is a five resistor array, 2k2 resistors totalling 11k, from Vo to Vcc defining the six multiplex voltages for the LCD.  The contrast voltage required is generally about 4.5 to 4.8V.  If you put a resistor between 330 ohms and 1k in series with this internal resistor chain, from Vo to Gnd, this will generally provide a suitable contrast voltage.  And the display will generally work (at 4.5 to 5V supply) with Vo connected directly to ground.  Whilst a 10k potentiometer is one way of defining the voltage, 90% of its travel it totally wasted (which is even funnier when it is a ten turn pot!).  A 1k variable resistor (a pot with the wiper connected to one end) makes just as much or more sense.

And - there is no sensible reason to muck about generating this voltage using PWM as there is no reason to adjust the voltage once initially calibrated.  In general, the only problem with contrast is when the supply voltage varies.

Nor is there generally any reason to set the backlight to other than two or possibly three levels.  You want it fully bright for daylight viewing, dimmer at night time to be easier on the eyes, or off (only) if you are operating from batteries or solar power.  I have been trying to think of how to set these three levels using one Arduino pin - haven't quite figured it out yet.

Zarnick

Thanks Paul, I want some even simpler thing with the backlight, either on or off! But I'm not being able to make it....I honestly don't know what to try anymore...

bperrybap


Nor is there generally any reason to set the backlight to other than two or possibly three levels.  You want it fully bright for daylight viewing, dimmer at night time to be easier on the eyes, or off (only) if you are operating from batteries or solar power.  I have been trying to think of how to set these three levels using one Arduino pin - haven't quite figured it out yet.



With a few changes  to the library code and wiring,
you could get 4 levels of dimming  using the PCF8574 and no extra Arduino pins.
You would use two of the output pins on the PCF8574 to control the backlight vs just one.
There is no need to support setting the R/W pin for reads so if you wire the LCD R/W pin to ground
that frees up a PCF8574 pin.
Then you can use two transistors with different current limiting resistors to control the back light.
If both are off the backlight is off.
Then you have 3 combinations of the two output pins, to provide up to 3 levels of on brightness.

You could do the same using another arduino pin in addition to the existing PCF8574 backlight control pin,
but if you are going to make h/w changes to the backpack and s/w changes to the i2c library code to support the 4 levels,
might as well just use the available PCF8574 pin rather than use another Arduino pin.

--- bill

floresta

Quote
On the LCD board is a five resistor array, 2k2 resistors totalling 11k, from Vo to Vcc defining the six multiplex voltages for the LCD.  The contrast voltage required is generally about 4.5 to 4.8V.  If you put a resistor between 330 ohms and 1k in series with this internal resistor chain, from Vo to Gnd, this will generally provide a suitable contrast voltage.  And the display will generally work (at 4.5 to 5V supply) with Vo connected directly to ground.  Whilst a 10k potentiometer is one way of defining the voltage, 90% of its travel it totally wasted (which is even funnier when it is a ten turn pot!).  A 1k variable resistor (a pot with the wiper connected to one end) makes just as much or more sense.


If using a resistor between pin 3 and GND 'makes just as much or more sense' then I wonder why the vast majority of data sheets that provide any information on how to feed this pin specify using a potentiometer. 

Don

Zarnick

Maybe because not all LCD will have a good contrast with a specific resistor, but once you found and you can use a fixed resistance, why not?

MAS3

That remark tells you still don't understand the difference between a single resistor and the potentiometer in the fashion it is used here.
If you are using a single resistor directly connected between pin 3 and GND , then it is just a pull down resistor or a current limiting resistor.
Paul__B points out that this board (i have no idea about other boards) has already some resistors, and the extra resistor adds to that.
That will create an entirely different effect.

If you are using a potentiometer which has its ends tied to the power supply and the center contact as an output, you are creating an adjustable voltage divider.
And that is completely different from a single current limiting or pull down resistor.
Even in the circuit mentioned by Paul__B the voltage divider will do a different thing than the single resistor.

As you are going to use the voltage divider more often while experimenting, you need to understand this.
Have a look at "blink without delay".
Did you connect the grounds ?
Je kunt hier ook in het Nederlands terecht: http://arduino.cc/forum/index.php/board,77.0.html

Go Up