Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: superchiku on April 07, 2008, 11:00:42 AM

Title: LCD INTERFACING WITH AVR
Post by: superchiku on April 07, 2008, 11:00:42 AM
DO ANY OF YOU HAVE ANY EXPERIENCE IN INTERFACING LCD'S WITH AVR???

If yes then can u tell me how you interfaced lcd with your avr or any microcontroller 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 in advance...

Title: Re: LCD INTERFACING WITH AVR
Post by: Ro-Bot-X on April 07, 2008, 11:40:29 AM
There are 2 kinds of simple alphanumeric LCDs: parallel and serial.

The parallel LCD can be controlled by 8 or just 4 controll bits. I am not sure how this works in C, but in Bascom-AVR they are easy to use. For Arduino I have found a library to use them.

The serial LCD has a microcontroller (or other driver) that takes serial commands and displays them on the parallel LCD. The advantage is that you may use regular serial commands like for printing on the computer's screen (when you use Terminal).

For the ease of use, I would recomend a serial LCD. This way there is no need for any code change. If you really want to get down and dirty, get a smaller AVR (like ATtiny26 for example) and serialize a parallel LCD.
Title: Re: LCD INTERFACING WITH AVR
Post by: superchiku on April 07, 2008, 11:44:56 AM
so serial lcd's will be cool but how do i use them and how i program them??
Title: Re: LCD INTERFACING WITH AVR
Post by: benji on April 07, 2008, 12:29:53 PM
Quote
The parallel LCD can be controlled by 8 or just 4 controll bits. I am not sure how this works in C,
in c you have to embedd the lcd.h library, its as easy as gum
you have functions to send a whole string or one char
you have functions to move the cursor,,an so many things
Title: Re: LCD INTERFACING WITH AVR
Post by: superchiku on April 07, 2008, 12:40:38 PM
please tell me the exact schematic diagram and how to program the serial or paralle lcd in C.

By programming i mean which functions to declare and how to transmit data and all
Title: Re: LCD INTERFACING WITH AVR
Post by: Ro-Bot-X on April 07, 2008, 01:03:01 PM
Check this out: http://www.sparkfun.com/commerce/product_info.php?products_id=461 (http://www.sparkfun.com/commerce/product_info.php?products_id=461) In the links section, you will find schematic, datasheet, code samples.

There is a schematic for a I2C LCD interface and a sample code for Arduino. You can check it out here: http://www.arduino.cc/playground/Code/I2CPortExpanderAndLCDs (http://www.arduino.cc/playground/Code/I2CPortExpanderAndLCDs)
Title: Re: LCD INTERFACING WITH AVR
Post by: pomprocker on April 07, 2008, 01:12:49 PM
don't you just enable UART and then you can do printf(); to the LCD?
Title: Re: LCD INTERFACING WITH AVR
Post by: superchiku on April 07, 2008, 01:22:17 PM
UART with lcd since i never used it i dont know
Title: Re: LCD INTERFACING WITH AVR
Post by: superchiku on April 07, 2008, 01:29:09 PM
somebody got to have a detailed sschematic coz i am not going to get that oone on sparkfun , i have a different 16*2 lcd
Title: Re: LCD INTERFACING WITH AVR
Post by: Ro-Bot-X on April 07, 2008, 02:09:40 PM
http://avr.tavir.hu/images/contents/13b-n.gif (http://avr.tavir.hu/images/contents/13b-n.gif)
Title: Re: LCD INTERFACING WITH AVR
Post by: superchiku on April 07, 2008, 02:41:00 PM
thanks for the schematic but still i have to learn how to program lcd's , u got any sample codes or something or is it the same as normal uart
Title: Re: LCD INTERFACING WITH AVR
Post by: Ro-Bot-X on April 07, 2008, 03:12:19 PM
Well, the explanations are in hungarian (I don't speak the language) but the code and schematics are in english. So you may figure something out of it as I did. http://avr.tavir.hu/modules.php?name=Content&pa=showpage&pid=15 (http://avr.tavir.hu/modules.php?name=Content&pa=showpage&pid=15)
Title: Re: LCD INTERFACING WITH AVR
Post by: pomprocker on April 07, 2008, 04:36:30 PM
I'd think it would be normal UART.

there would be power and ground wires

and then some sort of TX/RX wires

I'm not sure though, I havent gotten their yet.

Check the UART tutorial though, I think I saw some mention of LCD in there.
Title: Re: LCD INTERFACING WITH AVR
Post by: Admin on April 07, 2008, 05:48:58 PM
You just send printf's to UART. Its as easy as a bunny with a pancake on its head:
http://www.societyofrobots.com/microcontroller_uart.shtml
http://www.societyofrobots.com/microcontroller_uart_50_robot.shtml

Oh and please don't demand schematics, thats what google is for:
http://www.societyofrobots.com/robot_faq.shtml#read_datasheet

 ;D
Title: Re: LCD INTERFACING WITH AVR
Post by: Webbot on April 08, 2008, 05:49:49 AM
When you say:

Quote
i have a different 16*2 lcd

Its not clear whether you mean you just have the bare LCD or whether it is serial enabled.

If its not serial enabled then you will need to get a pin-out diagram for the exact model of LCD you've got. Hard to give any more help without knowing what you've got.

If it is serial enabled then it will have connections for: ground, power (normally +5v), signal in/receive, and some also have a signal out/transmit. The last pin, if its there, is used to reply to command like 'tell me you model number and firmware revision'. Obviously the ability to do this, and the exact commands you can send to do things like 'clear screen', 'backlight on' etc vary from one suppllier to another.

You will then follow the UART tutorial and you can use Admins 'rprintf' tools to send text and commands to the LCD.

Its very easy ! Got mine up and going in about 5 minutes.
Title: Re: LCD INTERFACING WITH AVR
Post by: superchiku on April 08, 2008, 07:52:01 AM
i dont have problem with uart as i have implemented them bfore but i dont know if they are serial based or not only think i know that is based on the hitachi 44780 controller with 8 bit and 4 bit operation
Title: Re: LCD INTERFACING WITH AVR
Post by: superchiku on April 09, 2008, 02:36:02 AM
and yes it has a contrast adjustable feature
Title: Re: LCD INTERFACING WITH AVR
Post by: benji on April 09, 2008, 02:57:06 AM
as a first time lcd programing just dont use UART,
open the file lcd.h in your compiler library folder
,watch the functions you can use
,read the hitachi driver datasheet for the commands

maybe if you read the library functions only you can get to program an lcd without looking at the datasheet

i cant give you functions as i use the codevision compiler and im not sure the functions are written the same

there should be functions to send one character
function to send a whole string
function to initialize the lcd
function to move the cursor (x,y)
..........................................................etc

google for some lcd projects ,im sure there are many
Title: Re: LCD INTERFACING WITH AVR
Post by: superchiku on April 09, 2008, 03:03:08 AM
well i have no problems with uart as i have used them bfore i just wanted to know is passing charcacters to lcd different from passing characters to uart and how to initialize the lcd as i got no lcd.h in my winavr iclude directory
Title: Re: LCD INTERFACING WITH AVR
Post by: benji on April 09, 2008, 03:17:24 AM
you can download yourself a lcd.h , search the net
or if you dont want to use it you have to build the functions yourself so you would surely need the driver datasheet
Title: Re: LCD INTERFACING WITH AVR
Post by: superchiku on April 09, 2008, 03:27:14 AM
ok ill do that but after i initialize , where do i connect the tx and rx pins from mcu to lcd and do i need to use max232
Title: Re: LCD INTERFACING WITH AVR
Post by: benji on April 09, 2008, 09:39:06 AM
Quote
where do i connect the tx and rx pins from mcu to lcd and do i need to use max232

max232?? this ic is made to interface TTL (5v(1) - 0v(0))logic into RS-232 levels(+15v(0)  -15v(1)),,,,and vice-versa

i dont think you want it,,although you should check with your lcd datasheet maybe it uses the rs-232 levels? i dont think so
Title: Re: LCD INTERFACING WITH AVR
Post by: superchiku on April 09, 2008, 09:43:05 AM
no it doesnt i can connect directly to tx and rx but how do u think i should start
Title: Re: LCD INTERFACING WITH AVR
Post by: Ro-Bot-X on April 09, 2008, 10:15:27 AM
So you don't have any documentation on your LCD? How expensive it was? If it was under $15 it is a parallel LCD. If it was over $20, it is a serial LCD.

A serial LCD has a second board connected to the board of the LCD with 12-15 pins. this second board has a microcontroller or other circuit that transfers serial data into parallel data. The connections on this second board should be 3 or 4 pins. One for +5V, one for GND, one for Rx and perhaps one for Tx. The first 2 you know how to connect. The Rx pin you need to connect to your microcontroller Tx pin (your microcontroller Transmits data that it is Received by the LCD board). The Tx pin you need to connect to your microcontroller Rx pin for acknoledge or other possible response.

I bet that your LCD is a parallel one. Can you take a picture of the back of the LCD?
Title: Re: LCD INTERFACING WITH AVR
Post by: superchiku on April 09, 2008, 10:29:49 AM
no it doesnt contain 4 pins it contains more than 8 pins , yup i think its parallel so what do i do? it cost under $20 around $8
Title: Re: LCD INTERFACING WITH AVR
Post by: Ro-Bot-X on April 09, 2008, 12:29:22 PM
I allready gave you the schematic...
Title: Re: LCD INTERFACING WITH AVR
Post by: superchiku on April 09, 2008, 12:30:58 PM
so what do i do abt the coding?
Title: Re: LCD INTERFACING WITH AVR
Post by: Ro-Bot-X on April 09, 2008, 01:17:00 PM
do i need to copy paste the code from the links i gave you?
Title: Re: LCD INTERFACING WITH AVR
Post by: superchiku on April 10, 2008, 10:32:54 AM
lol no ill see what i can do but can i expect some help from u like-----a little fundamentals on lcd interfacing just not the circuit schematics...
Title: Re: LCD INTERFACING WITH AVR
Post by: Ro-Bot-X on April 10, 2008, 11:05:20 AM
Take a look at this page: http://www.ladyada.net/learn/arduino/lcd.html (http://www.ladyada.net/learn/arduino/lcd.html)
Even if your LCD pins are different, read about the connections of the pins, download the library and take a look at the code, you will get an idea of what to do. Other than that, you're on your own. Or ask for C programmers around here.
Title: Re: LCD INTERFACING WITH AVR
Post by: superchiku on April 10, 2008, 11:07:13 AM
sooner or later some c programmer will reply, anyway thanks for all the help ,hope someone who has done lcd interfacing with help of c will post :)
Title: Re: LCD INTERFACING WITH AVR
Post by: pomprocker on April 10, 2008, 03:42:02 PM
just include the lcd header file in the SoR utils header.


then in your main you would just use a


printf("blah blah blah");
Title: Re: LCD INTERFACING WITH AVR
Post by: Webbot on April 10, 2008, 06:21:19 PM
Quote
sooner or later some c programmer will reply, anyway thanks for all the help ,hope someone who has done lcd interfacing with help of c will post
I doubt it!

So you have an LCD  that you don't know if its serial/parallel, don't have spec sheets, don't know how it works, can't give much info - but you expect us 'mere programmers' to tell you how to make everything work!

My only advice would be to have an infinite number of monkeys with an infinite number of keyboards and eventually they may be able to create something that works. Code monkies  ;D

Ask specific questions: not 'I have a really cheap something - how do I make it work'. Quick answer is "buy something that is known to work"
Title: Re: LCD INTERFACING WITH AVR
Post by: superchiku on April 11, 2008, 12:02:24 AM
man give relevant answers , i know it is parallel lcd and i know that i have to initialize everything myself , i was justt looking for someone who knows c and has one it bfore so that ill be knowing what to do just not merely doing a hit and trial analysis with the lcd
Title: Re: LCD INTERFACING WITH AVR
Post by: JesseWelling on April 11, 2008, 06:46:56 AM
If you want to learn you are going to have to take an active part in your own education.

I don't mean to be a prick, but I'll always think twice now before helping you.
Title: Re: LCD INTERFACING WITH AVR
Post by: superchiku on April 11, 2008, 11:01:28 AM
sorry man , well what i meant is that i go through some code esamples in C so that i would atleast have an idea of what iam doing, i didnt meant to be harsh its just that iam highly tensed doing this project which requires lcd, uart and also rf communication , sorry if i have hurt anyone..
Title: Re: LCD INTERFACING WITH AVR
Post by: benji on April 11, 2008, 01:59:33 PM
as i said before , googling such a thing would help you better

-search for lcd.h
-dowload it
-if you want to know how it works read whats inside the functions and the lcd driver datasheet

you can post an lcd funcion here if you dont uinderstand how it works and we may help
Title: Re: LCD INTERFACING WITH AVR
Post by: superchiku on April 11, 2008, 02:02:23 PM
yes ill do that thanks for all ur help jesse did get angry on m for my useless bragging , really sorry abt that
Title: Re: LCD INTERFACING WITH AVR
Post by: Admin on April 20, 2008, 03:04:44 PM
superchiku, all the answers are in the datasheet, and my tutorials explain exactly how to do it.

My code does it all for you.

You just need to think and do it. Spend a good 30 min trying to solve your problem before asking a question - that way you don't ask 'dumb' questions, and not get 'useless' answers.

Just take the time -> only you can build your own robot :P
Title: Re: LCD INTERFACING WITH AVR
Post by: superchiku on April 27, 2008, 07:32:05 AM
well iam doing it all because i dont want to be dependant on your given functions , there is no problem in learning it myself and thats why my question sounds dumb coz all the people here are so dependant on the admin's function that they are telling me just use rprintf and you will get your answers , i dont wanna do that , i want to learn it myself which i will eventually even if no on helps me..

sorry if i sounded rude on that ... i just dont want to spoon feed myself
Title: Re: LCD INTERFACING WITH AVR
Post by: Admin on April 29, 2008, 02:55:49 PM
Under that same logic, why are you buying sheets of plastic when you can manufacture your own by mixing chemicals? Why not make your own homemade capacitors and LEDs? At some point, you need to decide that you are making a robot and not the individual components.

If your goal is to learn how the uart works, by all means read the AVR datasheet for details. But if your goal is to get an LCD to work, use someone else's serial code :P

(btw, I didn't write rprintf, its from AVRlib ;))
Title: Re: LCD INTERFACING WITH AVR
Post by: superchiku on May 01, 2008, 12:27:16 AM
well we can keep something for ourselves isnt it sir , the serial code is for serial lcd's but mine isnt one so that was the problem but ill get it to work somehow no worries :)
Title: Re: LCD INTERFACING WITH AVR
Post by: TrickyNekro on May 03, 2008, 05:13:31 PM
well...
I have the answer which is not mine... but from a fellow guy back at the old days of prototyping at my old forum...
He got the attiny2313 to fully control an LCD via UART... and well it's easy (using BASCOM... there is a ready to use piece of code as an example...)

The bad thing for you is that it's documented in Greek... ha... sorry translate it...
I may have a tutorial about how's this is done... on AVRs but in summer...

I got my board exams in 16 days... ha!!! And I'm done with school... yea!

Well, I always talk too much... here is the link... enjoy people...
http://www.ptyxiouxos.net/greekbotics/e107/news.php?extend.62 (http://www.ptyxiouxos.net/greekbotics/e107/news.php?extend.62)
Title: Re: LCD INTERFACING WITH AVR
Post by: superchiku on May 04, 2008, 06:18:47 AM
hmm mine is a parallel lcd  :-\
Title: Re: LCD INTERFACING WITH AVR
Post by: TrickyNekro on May 04, 2008, 08:31:53 AM
But yes... that's the concept!!!

He gets a parallel LCD and they via a attiny2313 makes serial connection possible...
it's an add on the parallel LCD... not an LCD...
Title: Re: LCD INTERFACING WITH AVR
Post by: superchiku on May 04, 2008, 10:19:17 AM
is it in english?
Title: Re: LCD INTERFACING WITH AVR
Post by: TrickyNekro on May 04, 2008, 11:02:09 AM
nope... use babel fish man...
Although it's a nice tutorial... it will show you even how to change the fuse bit in the Attiny2313...

Cheers,
Lefteris
Title: Re: LCD INTERFACING WITH AVR
Post by: superchiku on May 04, 2008, 11:36:50 AM
babel fish?
Title: Re: LCD INTERFACING WITH AVR
Post by: TrickyNekro on May 04, 2008, 11:47:05 AM
Well, there is a word named google but... never mind... :P

look here:
http://babelfish.altavista.com/ (http://babelfish.altavista.com/)
Title: Re: LCD INTERFACING WITH AVR
Post by: superchiku on May 05, 2008, 11:48:14 AM
nice 1  ;)