Author Topic: Interfacing LCD  (Read 4348 times)

0 Members and 1 Guest are viewing this topic.

Offline rahulmagooTopic starter

  • Jr. Member
  • **
  • Posts: 23
  • Helpful? 0
Interfacing LCD
« on: June 27, 2008, 08:51:45 AM »
hello,
Do any one has any experience in interfacing LCD with AVR (Atmega16)??


If yes then can you  tell me how you interfaced lcd with your avr  and how you displayed letters and stuff on your lcd.
PLEASE be clear in the following points.

How to connect an lcd with avr?

How to command the lcd to display characters on its screen?

How to program your avr for interfacing with an lcd?

Any kind of code example will be highly helpful..

Thanks


Offline airman00

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
    • Narobo.com - Mechatronics and related
Re: Interfacing LCD
« Reply #1 on: June 27, 2008, 12:23:02 PM »
what kind of LCD - parallel one or a serial one
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline rahulmagooTopic starter

  • Jr. Member
  • **
  • Posts: 23
  • Helpful? 0
Re: Interfacing LCD
« Reply #2 on: June 28, 2008, 02:14:04 AM »
I am just a beginner..i really don't know whether my LCD is serial or parallel..i bought it for around rs.200(~5$).
It look similar to one shown here: http://www.onlinetps.com/ViewItem.php?ItemID=3

Offline benji

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: Interfacing LCD
« Reply #3 on: June 28, 2008, 03:16:07 AM »
it lookslike just another 2*16 lcd
it has more than 10 pins so i guess its not serial
you should have the driver datasheet to know the lcd commands
i guess its the same ol hitachi HD4478
google lcd microcontroller interface , your gonna have loads of tutorials

the interface options im aware of is
1/ 8 bit interface
2/ 4 bit interface
3/ connect lcd as external memory
good ol' BeNNy

Offline rahulmagooTopic starter

  • Jr. Member
  • **
  • Posts: 23
  • Helpful? 0
Re: Interfacing LCD
« Reply #4 on: June 28, 2008, 01:31:35 PM »
I have Atmega16 and i am using AVR studio.
Writing a code in C to display it on my LCD is creating all problem. If any one could help me in providing any sample code...even if the code is to display name or any simple code would really help me in solving my problem.

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
    • izua electronics
Re: Interfacing LCD
« Reply #5 on: June 28, 2008, 01:46:23 PM »
Tell us what your problem is, show us what you have made up till now, and we'll try to help you.
Without any input from your side, we can't know what you are doing wrong.
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline rahulmagooTopic starter

  • Jr. Member
  • **
  • Posts: 23
  • Helpful? 0
Re: Interfacing LCD
« Reply #6 on: June 28, 2008, 01:58:44 PM »
As i ve said before i am just a beginner...basically my problem is that i am not able to code in AVR studio..

When i set my port(say B) to high it works fine without any compilation error...but when i set a pin(say B 4)...it shows a compilation error... ???
So can any one please help me in writing a program in AVR studio..as i want 2 program my Amega16 to set its 2 pins as input and 2 pins as output.

Offline benji

  • Supreme Robot
  • *****
  • Posts: 830
  • Helpful? 0
Re: Interfacing LCD
« Reply #7 on: June 28, 2008, 02:37:34 PM »
right ur your code here, with the copiler errors
good ol' BeNNy

Offline airman00

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
    • Narobo.com - Mechatronics and related
Re: Interfacing LCD
« Reply #8 on: June 28, 2008, 10:14:01 PM »
use google like benji said, there are loads of tutorials
http://homepage.hispeed.ch/peterfleury/avr-lcd44780.html


perhaps someone could write a better one on this site???

Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
    • izua electronics
Re: Interfacing LCD
« Reply #9 on: June 28, 2008, 11:03:46 PM »
I have a hunch your problem is not the LCD itself, but the fact that you don't know the language. Start simple, make a led flash.
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline rahulmagooTopic starter

  • Jr. Member
  • **
  • Posts: 23
  • Helpful? 0
Re: Interfacing LCD
« Reply #10 on: June 29, 2008, 04:29:58 AM »
I wrote a code for blinking LED which is:
#include <avr/io.h>
#include <avr/delay.h>

void MSDelay(unsigned int);
int main()
{
   DDRB=0;
   while(1)
   {PORTB=~PORTB;
    MSDelay(25);
      
   }
   
}
void MSDelay(unsigned int itime)
{
   unsigned int i,j;
   for(i=0;i<itime;i++)
   for(j=0;j<125;j++);
}


this code dose not show any problem(any compilation error)...this works for all the pins of port B...if I want for a specific PIN say(B 2)...the code gives compilation error :'(

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
    • izua electronics
Re: Interfacing LCD
« Reply #11 on: June 29, 2008, 05:29:10 AM »
Do you know how to set/clear/toggle a single bit in a byte in winAVR?
And you know that C has no idea of pins, ports, and the such, you are just operating on bytes, right?

To set a single bit in a byte, you need to do something like
byte |= mask
where mask, is a bitmask of the bits you want to set.
for example, to set bits 3 and 6 you can do something like
mask = (1 << 3) | (1 << 6)

or, simply, to set bits 3 and 6 in a byte
byte |= (1<<3) | (1 <<6)

to clear a bit, invert your mask (~ operator) and do a logical and with your byte and the mask (and = &)
to toggle some bits, use XOR (^)

« Last Edit: June 29, 2008, 05:34:12 AM by izua »
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline rahulmagooTopic starter

  • Jr. Member
  • **
  • Posts: 23
  • Helpful? 0
Re: Interfacing LCD
« Reply #12 on: June 29, 2008, 08:27:32 AM »
Thanks a lot izua...u really helped me....and thanks to others also
Thanks!!!  :)