Society of Robots - Robot Forum
Electronics => Electronics => Topic started 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...
-
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.
-
so serial lcd's will be cool but how do i use them and how i program them??
-
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
-
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
-
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)
-
don't you just enable UART and then you can do printf(); to the LCD?
-
UART with lcd since i never used it i dont know
-
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
-
http://avr.tavir.hu/images/contents/13b-n.gif (http://avr.tavir.hu/images/contents/13b-n.gif)
-
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
-
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)
-
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.
-
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
-
When you say:
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.
-
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
-
and yes it has a contrast adjustable feature
-
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
-
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
-
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
-
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
-
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
-
no it doesnt i can connect directly to tx and rx but how do u think i should start
-
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?
-
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
-
I allready gave you the schematic...
-
so what do i do abt the coding?
-
do i need to copy paste the code from the links i gave you?
-
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...
-
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.
-
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 :)
-
just include the lcd header file in the SoR utils header.
then in your main you would just use a
printf("blah blah blah");
-
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"
-
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
-
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.
-
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..
-
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
-
yes ill do that thanks for all ur help jesse did get angry on m for my useless bragging , really sorry abt that
-
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
-
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
-
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 ;))
-
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 :)
-
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)
-
hmm mine is a parallel lcd :-\
-
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...
-
is it in english?
-
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
-
babel fish?
-
Well, there is a word named google but... never mind... :P
look here:
http://babelfish.altavista.com/ (http://babelfish.altavista.com/)
-
nice 1 ;)