Author Topic: Good HD44780 LCD driver for Axon?  (Read 2250 times)

0 Members and 1 Guest are viewing this topic.

Offline OperationIvyTopic starter

  • Jr. Member
  • **
  • Posts: 15
  • Helpful? 0
Good HD44780 LCD driver for Axon?
« on: December 16, 2008, 05:43:36 PM »
Hello, I've been trying to get my 4x20 LCD to work with the Axon but I just realized the driver file I have been using in my source is for an HC164 controller (I don't know what this is.. but it probably wont drive my HD44780 controller, right?). So far the only HD44780 drivers I have found are somewhat cryptic and I'm not really sure how they work. The previous driver I was using was extremely clear and intuitive, which is why it's such a bummer it won't work with my controller. Does anyone have any experience hooking up an LCD that uses this controller (almost all 1 or 2 line displays do) to an Axon, or other ATMega640 project?

EDIT: Brief update - I found some drivers that appear to work here: http://homepage.hispeed.ch/peterfleury/avr-software.html
« Last Edit: December 17, 2008, 01:35:08 AM by OperationIvy »

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: Good HD44780 LCD driver for Axon?
« Reply #1 on: December 17, 2008, 08:27:04 AM »
I typically tell people if you want to use an LCD, get one with a serial interface. It will require zero additional code with the Axon, and takes like seconds to wire it up.

Quote
EDIT: Brief update - I found some drivers that appear to work here: http://homepage.hispeed.ch/peterfleury/avr-software.html

Problem solved? Don't forget to upload/share your source!

Offline OperationIvyTopic starter

  • Jr. Member
  • **
  • Posts: 15
  • Helpful? 0
Re: Good HD44780 LCD driver for Axon?
« Reply #2 on: December 17, 2008, 05:32:32 PM »
Problem solved so far. His code (http://homepage.hispeed.ch/peterfleury/lcdlibrary.zip) clear and well-commented and required no modification to run, except the port and pin numbers you want to use. Here is my control.c:

Code: [Select]
/****************************************************************************
*
*   Copyright (c) 2008 www.societyofrobots.com
*   (please link back if you use this code!)
*
*   This program is free software; you can redistribute it and/or modify
*   it under the terms of the GNU General Public License version 2 as
*   published by the Free Software Foundation.
*
*   Alternatively, this software may be distributed under the terms of BSD
*   license.
*
****************************************************************************/

#include "lcd.h"

void control(void)
{

lcd_init(LCD_DISP_ON); //Initializes display with no cursor

while (1)
{
delay_ms(1000);

lcd_clrscr();
lcd_puts("Line 1");

delay_ms(1000);

lcd_clrscr();
lcd_gotoxy(0,1);
lcd_puts("Line 2");

delay_ms(1000);

lcd_clrscr();
lcd_gotoxy(20,0); //The 4x20 display is actually wired as a
lcd_puts("Line 3"); //2x40, so the third line actually starts
//on the 20th character of the 1st line
delay_ms(1000);

lcd_clrscr();
lcd_gotoxy(20,1); //ditto
lcd_puts("Line 4");

}

}

Offline OperationIvyTopic starter

  • Jr. Member
  • **
  • Posts: 15
  • Helpful? 0
Re: Good HD44780 LCD driver for Axon?
« Reply #3 on: December 21, 2008, 01:18:11 AM »
Quick question about this driver.. probably applies to most other drivers as well..

Given the following commands for sending the LCD data:

Code: [Select]
extern void lcd_putc(char c);
extern void lcd_puts(const char *s);

How would I write a numerical value from a variable to the LCD? Is it possible to create a string that contains a variable's value and then pass it's pointer to the lcd_puts() function?

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: Good HD44780 LCD driver for Axon?
« Reply #4 on: December 21, 2008, 04:20:56 AM »
Quote
Is it possible to create a string that contains a variable's value and then pass it's pointer to the lcd_puts() function?
I don't quite understand your question . . . Something like this will do the job?

Code: [Select]
#include <string.h>

char string_set[] = "hello world im 2 days oldx";

while(string_set[i] != x)
{
lcd_putc(string_set[i]);
i++;
}

Offline OperationIvyTopic starter

  • Jr. Member
  • **
  • Posts: 15
  • Helpful? 0
Re: Good HD44780 LCD driver for Axon?
« Reply #5 on: December 21, 2008, 02:02:47 PM »
Well what I'd like to do is calibrate my sensors using this lcd. So I'd like to be able to do something like:

Code: [Select]
int sensor_val = 224;

lcd_puts("Sensor value = ");
lcd_putc(sensor_val);

Where the output would be "Sensor value = 224."

Obviously that will just print the ascii character associated with 224, but I'm trying to find something that will display the actual value of the variable. Maybe some sort of escape sequence to include a variable with the lcd_puts() function?

Or, using the method you posted, my problem would be simplified to creating a string containing the value of my variable.
« Last Edit: December 21, 2008, 02:09:15 PM by OperationIvy »

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: Good HD44780 LCD driver for Axon?
« Reply #6 on: December 21, 2008, 10:25:38 PM »
try this:

Code: [Select]
lcd_putc(sensor_val & 0x0F);//&0x0F strips ascii off to use in char strings
« Last Edit: December 22, 2008, 01:21:19 AM by Admin »

Offline OperationIvyTopic starter

  • Jr. Member
  • **
  • Posts: 15
  • Helpful? 0
Re: Good HD44780 LCD driver for Axon?
« Reply #7 on: December 22, 2008, 01:09:26 AM »
Hmm, well that didn't work, but I was advised to search the standard C string.h library, and I found the function itoa(), which converts an integer into a string and returns it's pointer. So what I needed to do was:
Code: [Select]

char buffer[40]; //40 column lcd
int sensor_val = 224;

lcd_puts("Sensor value = ");
lcd_puts( itoa(sensor_val, buffer, 10) ); //variable, string to use, base to use

Thanks for the help :)
« Last Edit: December 22, 2008, 01:10:11 AM by OperationIvy »

Offline tristantech

  • Jr. Member
  • **
  • Posts: 34
  • Helpful? 0
Re: Good HD44780 LCD driver for Axon?
« Reply #8 on: January 10, 2009, 10:39:57 PM »
I have a good set of functions in a C header file at my website:

http://www.tristantech.net/articles/LCD-header-file.html

It is for AVRs and HD44780-based LCDs. It should work on the Axon, but I don't own one.
« Last Edit: January 10, 2009, 10:41:36 PM by tristantech »
Hey! Visit my website @ http://www.tristantech.net

 


Get Your Ad Here