Society of Robots - Robot Forum

Software => Software => Topic started by: Trumpkin on May 28, 2009, 04:26:20 PM

Title: LCD problem
Post 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.
Title: Re: LCD problem
Post by: Razor Concepts on May 28, 2009, 04:31:18 PM
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.
Title: Re: LCD problem
Post by: Trumpkin on May 29, 2009, 07:03:50 AM
Here's a picture of my lcd turned on. using this code:
Quote
//  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;
}
Title: Re: LCD problem
Post by: awally88 on May 31, 2009, 04:08:05 AM
Are you sure its not the LCD? You got it for free... Did try both of the LCD's or just the one?
Title: Re: LCD problem
Post by: Trumpkin on May 31, 2009, 01:18:43 PM
Yeah It probably is the LCD, as soon as I get the time I'll hook up the other one.
Title: Re: LCD problem
Post by: Razor Concepts on May 31, 2009, 01:19:53 PM
Does the contrast pot adjust the contrast?
Title: Re: LCD problem
Post by: Trumpkin on June 01, 2009, 07:52:09 PM
yes, the pot adjusts contrast.
Title: Re: LCD problem
Post by: Trumpkin on June 08, 2009, 11:47:50 AM
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!
Title: Re: LCD problem
Post by: sonictj on June 08, 2009, 02:21:17 PM
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?
Title: Re: LCD problem
Post by: Trumpkin on June 08, 2009, 03:23:02 PM
Yep, I'm using the exact same pin configuration that the link specifies. Thanks!
Title: Re: LCD problem
Post by: sonictj on June 08, 2009, 04:00:54 PM
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
Title: Re: LCD problem
Post by: Trumpkin on July 07, 2009, 11:28:33 AM
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:
Quote
#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
Title: Re: LCD problem
Post by: sonictj on July 07, 2009, 11:40:12 AM
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
Title: Re: LCD problem
Post by: sonictj on July 07, 2009, 11:45:20 AM
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.
Title: Re: LCD problem
Post by: Trumpkin on July 07, 2009, 12:26:16 PM
Quote
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:
Code: [Select]
#include "at8LCD.h"

int main()
{
   LCD_init();
   LCD_write('A');
}
Title: Re: LCD problem
Post by: sonictj on July 07, 2009, 01:06:26 PM
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.
Title: Re: LCD problem
Post by: Trumpkin on July 07, 2009, 01:34:05 PM
Here it is. I realise that there are a bunch of files I don't need.
Title: Re: LCD problem
Post by: sonictj on July 07, 2009, 02:36:00 PM
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

Code: [Select]
#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.
Title: Re: LCD problem
Post by: Trumpkin on July 07, 2009, 04:24:58 PM
Thanks, that compiled! I'll get back to you on whether it works or not.
Title: Re: LCD problem
Post by: Trumpkin on July 07, 2009, 05:43:40 PM
hmmm... still doesn't work.
Title: Re: LCD problem
Post by: radhoo on October 13, 2009, 04:17:33 PM
A bit late, but is there anything I can do to help?

Cheers,
Radu M.
Title: Re: LCD problem
Post by: Trumpkin on October 14, 2009, 12:14:35 PM
Turned out it was just a couple of bad LCDs, I got a new one and it works fine.  :-[ Thanks anyway.
Title: Re: LCD problem
Post by: radhoo on October 16, 2009, 03:48:06 PM
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!