Black squares on HD44780 LCD

Go To Last Post
12 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I've tried to use an HD7780 LCD screen with an AVR ATmega8 (4-bit interfacing). I used the exact same code as on https://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=281379#281379 (except that I changed the ports to reflect my own setup). However, something strange happens. When I turn the power on, I see two lines of black squares. When I turn the power off, the black boxes disappear and in a flash I the text "4-bit avr-gcc" appears on the first row, which is the one it is supposed to be showing. The text only stays for a couple of ms I guess, then it disappears as well as the power is turned off. So I know the connections are right, and also the initialization must be ok (I assume you can't send characters over unless the display is initialized?). I don't konw what the problem might be. Anyone knows?

Thank you,

Yoran

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Adjust the contrast.

You don't say the size of the display. A 2-line moderate-width character LCD that is uninitialized shows black boxes on the top line, and not on the bottom. Adjust your contrast until you see this.

Remember I said "uninitialized". Hold your AVR in reset at power-up to enforce that.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You need to adjust the contrast.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The dark boxes are coming

(now where have I heard that before?)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

10K - 20K potentiometer, One end to VCC, other end to ground, wiper to contrast pin on LCD.

Quote:
The dark boxes are coming
(now where have I heard that before?)

It's 3 or 4 o'clock in the morning in western Russia and Svo' is prolly sleeping...

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Allright, great I tried it with the pot and it works perfectly! Amazing, cause I was stuck on this LCD display for a long time... Thanks to you all.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just to say that another way to vary the contrast voltage is to connect pin 3 to an AVR pin and use PWM. I do the following - with the contrast connected to PC0:

// The following two ISRs are doing "poor man's PWM" 
//  but this allows it to be on a pin of my choice
ISR(TIMER0_COMP_vect) {
	PORTC &= ~(1<<PC0);
}
ISR(TIMER0_OVF_vect) {
	PORTC |= (1<<PC0);
}

int main(void) {

...
	// going to use PORTC.0 to PWM the contrast voltage
	DDRC = (1<<DDC0);
	TIMSK |= ((1<<OCIE0) | (1<<TOIE0)); // use both interrupts
	OCR0 = 10; // 10 out of 256 means very short on period (low voltage)
	TCCR0 = (1<<CS00); // timer on - nice high PWM frequency

	// Might later consider PWMing the backlight voltage too
	// so it would also be adjustable ...

If I want to vary the contrast of the display in software I just change OCR0

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

connect pin 3 to an AVR pin and use PWM.

Do you send the PWM "raw", or do you have a cap (or even more filtering)?

Is it sensitive to PWM rate? I.e., if you were to use /1024 and low OCR0 values do you see it in the contrast "flickering"?

And why didn't I ever think of this in the last 10 years?

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In general, the current consumption of the contrast-pin is very low. That means you can use a 4k7 resistor or even higher. Now for the cap, it depends on what the pwm-freq is. Your /1024 @ 1MHz internal RC osc. will result in 4 Hz PWM (256 steps)
A varying voltage due to pwm will be visible if it's over 50mV or so (epends on the specific display of course) That is 40 dB. Thus appr. 7 steps of 6 dB (single RC-filter). RC-time is 250ms * 2^7 = 32 seconds. Not very feasible, a 6 Farad cap :lol:
A double filter can help, but not with 4Hz. But if the pwm freq is higher, a fairly reasonable cap of 100uF will do fine. That's what I use in general.

Nard

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tricia, and Ulyana. You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Lee,

As you know I'm just a bit-basher so I don't do any of that fancy "capacitor" nonsense. I kind of figured that because I'm using CS00 that I needn't worry about the frame rate and that I'd just get a variable voltage. After a bit of "fiddling" I found that 10/256 seemed reasonable (for my particular PSU level and LCD module). If Vcc is 5.0V I guess I'm giving it about 0.2V this way.

In fact the idea came out of desperation. An LCD module arrived in the post at home one morning and I simply didn't have a suitable pot. lying around so I just tried to think of some other way I could vary the voltage.

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

And why didn't I ever think of this in the last 10 years?

Can't tell about the first eight or nine years, but for the last one or two it was simply because you weren't observant enough. Cliff has been suggesting this PWM-for-contrast-control in a number of LCD threads recently.

On the flickering wories: I've just assuemd that LCDs are slow enough that a fairly high PWM voltage would be averaged out by the physics of the display.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Cliff has been suggesting this PWM-for-contrast-control in a number of LCD threads recently.

Probably under the disguise of posts about that "other" brand of C compiler. [Can "free" software be a brand?]

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.