I need to ajust the brightness to the HD44780 LCD from time a time based on a photoresistor. But i'm driving the LCD with a I2C Module and inbuilt setBacklight(0-255); function doesn't work. By looking at module i can see a transistor connected to VLED-, what the purpose of that?
The backlight on those i2c modules is driven by a transistor from an output pin on the 8574 chip.
The backpack will provide on/off control of the backlight but it cannot provide dimming since the 8574 can only provide simple HIGH or LOW output signals.
The library setBacklight() does the best it can and since the backpack h/w does not support dimming it can't do dimming.
Backlight on/off control should be working. If it isn't then there is some other issue
If you want to do dimming you will have to make some modifications to the h/w and then use an additional Arduino pin.
There is already a transistor on the board so you don't need to add another transistor or FET to provide LCD backlight dimming.
However, you will have to make some simple modifications to the backpack and connect another wire from the backpack transistor to an Arduino PWM pin.
What you will need to do is figure out how the LED and jumper is wired up.
If you are lucky, you will be able to remove the jumper and wire the Arduino pwm pin to one of the header pins.
But it all depends on how the backpack is wired.
You will need to figure out the connections and how the traces are wired for the LED, jumper, and transistor.
Once you know that you will know how and were to connect the additional wire to the Arduino pwm pin.
bperrybap:
The backlight on those i2c modules is driven by a transistor from an output pin on the 8574 chip.
The backpack will provide on/off control of the backlight but it cannot provide dimming since the 8574 can only provide simple HIGH or LOW output signals.
The library setBacklight() does the best it can and since the backpack h/w does not support dimming it can't do dimming.
Backlight on/off control should be working. If it isn't then there is some other issue
If you want to do dimming you will have to make some modifications to the h/w and then use an additional Arduino pin.
There is already a transistor on the board so you don't need to add another transistor or FET to provide LCD backlight dimming.
However, you will have to make some simple modifications to the backpack and connect another wire from the backpack transistor to an Arduino PWM pin.
What you will need to do is figure out how the LED and jumper is wired up.
If you are lucky, you will be able to remove the jumper and wire the Arduino pwm pin to one of the header pins.
But it all depends on how the backpack is wired.
You will need to figure out the connections and how the traces are wired for the LED, jumper, and transistor.
Once you know that you will know how and were to connect the additional wire to the Arduino pwm pin.
--- bill
hi bill, Thanks for your explanation
Backlight on/off control is working, But i need control the dimming.
Jumper can be removed (5v flowing in that pins - POSITIVE backlight module)
As i already have the module soldered into LCD i cant follow the traces, but transistor is connected to VLED GND, because other traces go into module backs i can't see it anymore.
Can i use a arduino PWM pin with a PNP transistor to feed the 5v backlight jumper? Or maybe attach PWM pins directly with a low resistor? Backlight shouldn't suck more than 40ma?
Just because the backlight is switched on with positive logic from the PCF8574 doesn't necessary mean that the jumper is a direct connection from the backlight anode to 5v. I have seen many variations on how the jumper is wired up.
So you are saying that you have verified that the Jumper is a jumper from 5v to the anode of the LED backlight?
Even so, you still have a couple of options.
wire the Arduino PWM pin directly to the jumper header pin to supply the 5v. (only if backlight is low current)
use the onboard transistor by cutting a trace and splicing in a new wire.
The first might be the easiest but you need to measure the backlight current to see what it is.
Some of the old LCDs use as much as 200ma but some of the newer 16x2 LCDs only use 2ma for the backlight.
If the current is low, then you could simply connect a wire from the arduino pin to the jumper header that runs to the backlight anode. (make sure not to connect to the header pin for 5v or you will instantly fry the Arduino pin)
But if you do this option, you will still have to set the 8574 pin correctly to connect the backlight cathode to ground.
i.e. setBacklight(255);
To use the onboard transistor you could cut the trace (or desolder the pin and lift the leg) going to the PCF8574 pin that controls the on board transistor and then solder your new wire to that trace. That way you will have full control over the backlight with a single Arduino pin.
So you are saying that you have verified that the Jumper is a jumper from 5v to the anode of the LED backlight?
Yes
Maybe i will go for trace cut but before that i will test direct current on jumper. Can a analog pin produce same effect as a PWM?
I'm using the HD44780 2004 LCD 20x4 and i can't find the backlight current specification. Any clue?
sn4k3:
Maybe i will go for trace cut but before that i will test direct current on jumper. Can a analog pin produce same effect as a PWM?
I'm using the HD44780 2004 LCD 20x4 and i can't find the backlight current specification. Any clue?
Which processor are you using?
The AVR chips don't have analog outputs. (some of the ARM chips do)
The AVR chips have analog inputs and digital outputs. you have to look at which pins support pwm.
The function analogWrite() was a very bad name as it has nothing to do with analog voltages and the argument is a digital pin number and not an analog pin number like analogRead() uses.
But LEDs don't really like analog voltages anyway.
PWM is the way to go since the human eye sensors are slow and will do the smoothing and make it appear to be brighter/dimmer vs blinking.
20x4 displays tend to use quite a bit more current than the 16x2 displays.
Most of the datasheets either don't specify the current or it is wrong anyway. The best thing it to measure it.
Connect your meter between the jumper header pins. It will only take a few seconds to measure.
The AVR chips don't have analog outputs. (some of the ARM chips do)
The AVR chips have analog inputs and digital outputs. you have to look at which pins support pwm.
Yes sorry, i forget about that. But still analog pins can be used as digital pins right?
PWM is the way to go since the human eye sensors are slow and will do the smoothing and make it appear to be brighter/dimmer vs blinking.
I will go for it
20x4 displays tend to use quite a bit more current than the 16x2 displays.
Most of the datasheets either don't specify the current or it is wrong anyway. The best thing it to measure it.
Connect your meter between the jumper header pins. It will only take a few seconds to measure.
I have done and i get stable 25mA at jumper pins, but not sure about that low value ^^
I hooked D3 directly to jumper and used the following code:
void setup() {
// put your setup code here, to run once:
pinMode(DD3, OUTPUT);
Serial.begin(9600);
}
void loop() {
for(int i = 254; i >= 0; i--)
{
Serial.println(i);
analogWrite(DD3, i); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
delay(20);
}
for(int i = 1; i <= 255; i++)
{
Serial.println(i);
analogWrite(DD3, i); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
delay(20);
}
}
It works well
I gona leave it run for a time to test.
The max is 40ma.
There is a maximum per port that can reduce that if there are high loads on other pins, but assuming
you don't have other pins driving loads then you should fine.
bperrybap:
The max is 40ma.
There is a maximum per port that can reduce that if there are high loads on other pins, but assuming
you don't have other pins driving loads then you should fine.
--- bill
Yes, currently almost all pins including analogs are hooked to something (some are sensors others are transistors) still i will need more pins and i will use a atmega1284p to have more spare pins.
Be careful when using this frequently repeated information.
From datasheet section 28.1:
The ABSOLUTE MAXIMUM DC current per I/O pin is 40 mA.
"This is a stress rating only and functional operation of the device at these or other conditions beyond those indicated in the operational sections of this specification is not implied."
As Bill mentioned, there are other limitations based on how the other I/O pins are loaded.
sn4k3:
I need to adjust the brightness to the HD44780 LCD from time a time based on a photoresistor.
The fact is, proportional brightness control of the LCD is simply unnecessary.
If you attach a resistor across the LED control resistor (which can be done by connecting it across two of the LCD terminals, either pins 1 and 16 or 2 and 15, depending on the circuit), you have the two appropriate brightness levels, "Day" and "Night".
If you really want a third (or fourth) "dusk" level, just connect a resistor from another Arduino pin to the LED. Since this resistor will not correspond to the full current, the pin loading will not be a problem.
please how did you connect this to the LCD, i am new to arduino
sn4k3:
UPDATE:
I hooked D3 directly to jumper and used the following code:
void setup() {
// put your setup code here, to run once:
pinMode(DD3, OUTPUT);
Serial.begin(9600);
}
void loop() {
for(int i = 254; i >= 0; i--)
{
Serial.println(i);
analogWrite(DD3, i); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
delay(20);
}
for(int i = 1; i <= 255; i++)
{
Serial.println(i);
analogWrite(DD3, i); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
delay(20);
}
}
It works well :)
I gona leave it run for a time to test.
Thanks
I have this same unit - there were a lot of ugly backlight artifacts, and angle of viewing was really bad as a result, however I found when you add a 50R resistor in series to its 5V power from the Arduino, the display looks MUCH nicer (no more artifacts !).
Also, to dim it, just put a 10K pot across the LED jumper pins at back (remove the jumper of course)
david_niwdoog:
I have this same unit - there were a lot of ugly backlight artifacts, and angle of viewing was really bad as a result, however I found when you add a 50R resistor in series to its 5V power from the Arduino, the display looks MUCH nicer (no more artifacts !).
This sounds very much as if you do not comprehend how to use the contrast potentiometer.