Society of Robots - Robot Forum
Software => Software => Topic started by: Trumpkin on May 28, 2009, 04:26:20 PM
-
I got a couple of used lm016l LCDs http://pdf1.alldatasheet.com/datasheet-pdf/view/146552/HITACHI/LM016L.html (http://pdf1.alldatasheet.com/datasheet-pdf/view/146552/HITACHI/LM016L.html.) free at a robotics meeting. I tried hooking one of them up to my ATmega168 using the code and schematic from here http://www.pocketmagic.net/?p=447 i modified the makefile for the ATmega168. All the "boxes" on the first line of the lcd light up but that's it. I tripled checked my connections so I'm assuming it's a programming problem.
-
Arduino has a library for LCDs, you can look into the source code for info. Also you could just run the Arduino program in the mega168 just to test out the LCD.
-
Here's a picture of my lcd turned on. using this code:
// ATMega8 LCD Driver
//
// (C) 2009 Radu Motisan , [email protected]
// www.pocketmagic.net (http://www.pocketmagic.net)
// All rights reserved.
//
// test.c: sample test for the HD44780 LCD functions
// For more details visit the website.
#include "lcd.h"
int main()
{
int i=0;
lcd_init();
while(1)
{
i = (i+1)%10;
//lcd_clrscr();
lcd_home();
lcd_string2("Hello World! %d\npocketmagic.net",i);
for (int i=0;i<10;i++) //some delay
_auxDelay(1000000);
}
return 0;
}
-
Are you sure its not the LCD? You got it for free... Did try both of the LCD's or just the one?
-
Yeah It probably is the LCD, as soon as I get the time I'll hook up the other one.
-
Does the contrast pot adjust the contrast?
-
yes, the pot adjusts contrast.
-
Finally got around to connecting the other LCD display, it does the same thing the first one did. I then disconnected everything but power and ground (and the pot), and it still did the same thing. If anyone with an HD44780 LCD screen they know works would test this guys library: http://www.pocketmagic.net/?p=447 (http://www.pocketmagic.net/?p=447) (the one I'm using) that would be great!
-
I may be able to adapt the code to my atmega and see if my lcd woks. If not I can probably give you a version of the code I'm using. Are you using the exact same pin out that your link specifies?
-
Yep, I'm using the exact same pin configuration that the link specifies. Thanks!
-
try this code
declare to initialize
LCD_init()
try writing a charter with LCD_write();
if this works I'll send you my print library for strings
-
I took a bit of a break from this to work on some other stuff. sonictj, this is the code I'm using with your library:
#include "at8LCD.h"
int main()
{
LCD_init();
LCD_write('A');
}
I get these errors when compiling:
LCD.c:5: undefined reference to `LCD_init'
LCD.c:6: undefined reference to `LCD_write'
I'm sure there is something really obvious that I'm doing wrong. :D
-
well it shouldn't say LCD.c:5: undefined reference to `LCD_init'. this would mean you have a file LCD.c with the same function. The files I sent were at8LCD.c, and .h
I noticed one issue with my code where I put the wrong variable in write's function prototype. This shouldn't have cause the problem but here is the corrected library
-
when you get the message undefined refference to some function, this typically means you wrote a function in a .c file, which is recognozed, but the header file doesn't correlate. Example you forget the function prototype, or you don't link your .c file to the appropriate header file.
You can send me your project folder and I can see if I can get it to compile.
-
well it shouldn't say LCD.c:5: undefined reference to `LCD_init'. this would mean you have a file LCD.c with the same function. The files I sent were at8LCD.c, and .h
LCD.c is the file containing this program:
#include "at8LCD.h"
int main()
{
LCD_init();
LCD_write('A');
}
-
I don't know if I can help unless I see your project if you can zip it up and attach it I can probably find whats wrong and let you know asap.
-
Here it is. I realise that there are a bunch of files I don't need.
-
well I found an error on my part I used LCD.h for the reference to the header file at8LCD ;D, but that didn't fix the problem. I noticed you were using your own makefile, so for the hell of it I usde the gcc self generating one and everything worked. I also change main to
#include "at8LCD.h"
int main()
{
while(1){
LCD_init();
LCD_write('A');
}
return 0 ;
}
before your code was reaching the end of main which should never happen. Here is the corrected version. Just go into configuration options generate to makefile for your specific device/ settings, and compile. That should do it.
-
Thanks, that compiled! I'll get back to you on whether it works or not.
-
hmmm... still doesn't work.
-
A bit late, but is there anything I can do to help?
Cheers,
Radu M.
-
Turned out it was just a couple of bad LCDs, I got a new one and it works fine. :-[ Thanks anyway.
-
I see. If you're still using my code you might want to get the latest version. It's in the same blog post.
Cheers!