Coding for displaying info on a small LCD Display

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

Being a little new at this can anyone suggest a link or document which would outline the basic steps to write code to be displayed on LCD"s

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

Most of the 2 line X 16 char LCDs use the same HD44780 controller.... there are many project in the academy here that have this lcd init and tolk-to-the-lcd code in the project, but 2 issues arise: wiring it up in 4 bit mode or 8 bit mode, and what pins and ports to use. If you are lucky, you have a little dev board that has the lcd already on it and ready to program. (olimex mt128 is an example). One other issue: some of the academy examples are using a 4 or 8 mhz xtal, and the 'delay 40usec' routine to let the controller take a breath is usually hard coded with some magic number of loops at that clock frequency to get it to init right.... not lonf enough if you run it on a nice crisp 16mhz avr.... anyway, do a little digging and get back with us...... One other item: some examples are for gcc c, some for other slightly different compiler directives... Which compiler do you have?

Imagecraft compiler user

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

Don't forget to read the Initialization's Instruction from your LCD manufacturer too. Because there are thousands of controller used in each LCD and each LCD's controller needs its own initialization methods, usually they are similiar but waiting time for controller to do its job. :D

"Chill out with Atmel Corp."
- Scud88.

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

I attached my code.

It was taken from some stuff I found on the net that I used as a start point, and changed as I saw fit.

Here is some test code for that attached libraries.
Though I'm not sure it totally matches the library, as its from different projects/dates, but will give you the idea.

cheers
Mark

int main(void)
{
int i;

LCDInit(LCD_DISP_ON);

while (1)
{

LCDClrscr(); // clear display and home cursor

LCDPuts("LCD Test line 1\n"); // put string to display (line 1) with linefeed
LCDPuts("Line 2"); // cursor is now on second line
LCDGotoXY(7,1);
LCDPutc(':'); // write single char to display

//Test 2: use lcd_command() to turn on cursor

Delay(1000);

LCDCommand(LCD_DISP_ON_CURSOR);// turn on cursor
LCDPuts( "CurOn");

// Test 3: display shift

Delay( 2000);

LCDClrscr(); // clear display home cursor

LCDPuts( "Line 1 longer than 14 characters\n" ); // string from progmemory to display
LCDPuts( "Line 2 longer than 14 characters" );

Delay( 1000);

for ( i=0;i<16;i++)
{
Delay( 100);
LCDCommand(LCD_MOVE_DISP_LEFT);// move BOTH lines 1 pos to the left
}
LCDCommand(LCD_DISP_ON);// turn off cursor
}
return 0;
}

Attachment(s): 

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

ddowns wrote:

...to be displayed on LCD"s

"small LCDs" is such a nebulous term. 7-segment or 14/16-segment "stick" displays? With or without controller? Bias & duty cycle?

Or maybe graphics LCD panels? Which controller? Resolution? bits per pixel?

Or maybe character LCD panels? How many rows and columns? What controller is used? 4-bit or 8-bit interface?

What processor do you intend to use to interface to the beastie? What tool chain are you going to use for programming?

The short answer: There are many projects posted in the Academy section of this Web site that "do" LCDs. The longer answer: To point you to more nearly what you want, more info is necessary.

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

And don't forget to actually check the data sheets for the correct pinout. I have just been working with a display that has the pins reversed from what I have been using in the past and almost blew things up :( This is after some 12 years working with LCDs.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

js wrote:
And don't forget to actually check the data sheets for the correct pinout. I have just been working with a display that has the pins reversed from what I have been using in the past and almost blew things up :( This is after some 12 years working with LCDs.

Sorry to hear your almost losses! 8)

Recently I've jolted 12 volts through an tiny sed1520 122x32 LCD.
The pixels actually turned orange for that moment! But after about an hour everything was fine again !

MY MICROCONTROLLER CAN BEAT THE HELL OUT OF YOUR MICROCONTROLLER /ATMEL

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

ddowns wrote:
Being a little new at this can anyone suggest a link or document which would outline the basic steps to write code to be displayed on LCD"s

If you want to roll your own LCD controller, you can use the ATMega169. For examples on how to do this you can get the AVR Butterfly from Digi-Key for $19.99 and the get the port of the Butterfly code for the WinAVR C compiler - this provide a complete hardware and software solution. I have a free tutorial on getting stated with the Butterfly using WnAVR shown in the link below.

Good Luck,
Joe

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

I haven't used it yet (but expect to Real Soon Now) but I picked up an LCD library for AVR-GCC (WinAVR) from this link.

Don