AVR -> LCD via three wires

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

Having found this about serial control of character LCDs using a 74HC164D shift register, I decided to use it in my project to cut down on cable size and pin usage. To do that I had to write my own control code, so I pretty much copied lcd.h and lcd.c and stripped them down but I can build it back to full lcd.c/h functionality changed them to work with this.
I was thinking of posting this as a project but before doing that I was hoping to get some feedback on it.

Edward

PS. Put here because it is specific to avr-gcc.

Attachment(s): 

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

Btw., there are also LCDs around with I²C (aka. TWI).

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

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

True, but it seems easier to obtain a normal bog standard parallel LCD and a shift register.

Edward

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

Well, you *could* cut it down to two wires:
4bit data bus, connect the ENABLE pin onto the shift register as well as the RS.

There are pointy haired bald people.
Time flies when you have a bad prescaler selected.

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

I don't think so, as you shift data onto the register the old data gets shifted to higher bit numbers, so there is always a chance of something toggling the enable line. You could of course use the CLR pin to make sure data never reaches the Enable line, but then you'd have to have another line bringing it back to 3.

Edward

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

1. Congrats on the three pin implementation!

2. You can get down to two pins if replacing the '164 with a '174 and adding a resistor and a diode. Please let me know if you want the details on this.

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

Definitely ;']

I won't use it for my current project as I already have the '164s but if I produce more I might and if I decide to take this library thing seriously I can add it to that too.

Edward

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

On this page http://www.myke.com/lcd.htm , scroll down to the bottom to find a description of the circuit. The software is for a PIC (and has bugs) but I have successfully implemented code (without bugs) for the AVR to drive this circuit. I'll dig it up for you if you ask nicely :wink:

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

Pretty please? With massively overpowered, energy efficient processors on top? ;']

I think I get the idea around it. Is there any reason it couldn't be done with the 164?

Edward

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

Got another question for the gurus.
Adding the progress bar function from lcd.c to mine:

void lcdProgressBar(u16 progress, u16 maxprogress, u08 length)
{
	u08 i;
	u32 pixelprogress;
	u08 c;

	// draw a progress bar displaying (progress / maxprogress)
	// starting from the current cursor position
	// with a total length of "length" characters
	// ***note, LCD chars 0-5 must be programmed as the bar characters
	// char 0 = empty ... char 5 = full

	// total pixel length of bargraph equals length*PROGRESSPIXELS_PER_CHAR;
	// pixel length of bar itself is
	pixelprogress = ((progress*(length*PROGRESSPIXELS_PER_CHAR))/maxprogress);
	
	// print exactly "length" characters
	for(i=0; i pixelprogress )
		{
			// this is a partial or empty block
			if( ((i*(u16)PROGRESSPIXELS_PER_CHAR)) > pixelprogress )
			{
				// this is an empty block
				// use space character?
				c = 0;
			}
			else
			{
				// this is a partial block
				c = pixelprogress % PROGRESSPIXELS_PER_CHAR;
			}
		}
		else
		{
			// this is a full block
			c = 5;
		}
		
		// write character to display
		lcdDataWrite(c);
	}

}

Any reason why pixelprogress should be 32 bits? The maximum length it would really need to handle would be 0 characters, after that you get strange wrapping. You could reasonably expect progress would be less than maxprogress so that whole calculation

pixelprogress = ((progress*(length*PROGRESSPIXELS_PER_CHAR))/maxprogress)

would be at most 240 (PROGRESSPIXELS is #defined to 6) which could fit in an 8bit unsigned char.
So would it be less expencive to have pixelprogress as 8bits and make sure progress<=maxprogress?

Edward

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

The 164 will take as much room as a 2313 and the cost difference is not that great, then you can use 1 wire (see Microcarl's lcd back pack)

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

You can avoid reality, for a while.  But you can't avoid the consequences of reality! - C.W. Livingston

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

js wrote:
The 164 will take as much room as a 2313 and the cost difference is not that great, then you can use 1 wire (see Microcarl's lcd back pack)

Not sure the cost difference is as small as you indicate, 64cents for the 164 and $2.64 for the 2313 from digikey.

Edward

PS Thanks for the link Carl.

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

You can find 3 wire LCD interacing example with source code here:
lcd-to-atmega-using-3-wires
It worked for me OK.

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

I've implemented a slave TWI (I2C) LCD interface using an ATtiny2313. I'll post it (code & schematic) if anyone is interested.

Don