NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Project Help and Ideas » 4x40 LCD

January 08, 2012
by Rick_S
Rick_S's Avatar

Did you ever need more room on your LCD display than the 4x20 provided with the NerdKit? Well I'll admit, I didn't really NEED more room, I just thought the idea would be nice. So when I came across a 4x40 LCD for under $3.00 US, I couldn't pass it up. The other good part of this display is that it's chipset is compatable with the HD44780 in the NerdKit LCD.

LCD-Front

LCD-Back

Once I got my display, I had to solder in a 16 pin (2x8) Header connector so I could wire it up. That done, I simply made up a cable and was ready to start testing it out.

Here is a breakdown of the pinout of this LCD Vs the Standard NerdKit LCD.

Pinout-Chart

As you can see, the pin callouts are very similar, there are a couple of differences though.

  1. There are two enable lines E1 and E2
  2. The pinout while in the same order is reversed
  3. Pins 15 and 16 are not for a backlight (the display I purchased has no backlight)

1st Question, Why 2 enable lines? Because this display has two full chipsets to control all the screen positions. According to the datasheet for the HD44780, it has character ram for 80 characters. On the NK LCD, this is 4X20=80. This display however has 160 available characters so it needs 2 chipsets. To control them independantly, there is an enable for each chipset to designate whether you are writing to the upper half of the display or the lower half.

To make the display work, I made a new library completely based on the NK original lcd.c library. I called the new library lcd_4x40.c

Here is a photo of the LCD displaying our familiar initial load. (The offset is on purpose BigGrin_Green )

Initial_load_message

To use this library, you will have to make a couple of changes. 1st you will have to change your makefile so it creates an object file for the library and includes it at compile time.

Here is the makefile I used:

GCCFLAGS=-g -Os -Wall -mmcu=atmega328p
LINKFLAGS=-Wl,-u,vfprintf -lprintf_flt -Wl,-u,vfscanf -lscanf_flt -lm
AVRDUDEFLAGS=-c avr109 -p m328p -b 115200 -P  com12
LINKOBJECTS=../libnerdkits/delay.o ../libnerdkits/lcd_4x40.o ../libnerdkits/uart.o

all:    initialload.hex

initialload.hex:    initialload.c
    make -C ../libnerdkits
    avr-gcc ${GCCFLAGS} -o ../libnerdkits/lcd_4x40.o -c ../libnerdkits/lcd_4x40.c
    avr-gcc ${GCCFLAGS} ${LINKFLAGS} -o initialload.o initialload.c ${LINKOBJECTS}
    avr-objcopy -j .text -O ihex initialload.o initialload.hex

initialload.ass:    initialload.hex
    avr-objdump -S -d initialload.o > initialload.ass

program:    initialload.hex
    avrdude ${AVRDUDEFLAGS} -U flash:w:initialload.hex:a

clean:
    rm -f *.o
    rm -f *.hex
    rm -f ../libnerdkits/*.o

Here is the library:

// lcd_4x40.c
// by Rick Shear
// based on
// lcd.c
// for NerdKits
// mrobbins@mit.edu
//
// PIN DEFINITIONS:
//
//
// PD2-5 -- LCD DB4-7 (pins 11-14) (was PB3-6)
// PD6 -- LCD E1 (pin 6) (was PA5)
// PD7 -- LCD RS (pin 4) (was PA4)
// PB1 -- LCD E2 (pin 15)

#include <avr/io.h>
#include <avr/pgmspace.h>
#include <inttypes.h>
#include <stdio.h>

#include "lcd_4x40.h"
#include "delay.h"

// define a couple of global variables for the enable lines

uint8_t E1 = 0;
uint8_t E2 = 0;

// lcd_set_type_data()
void lcd_set_type_data() {
  PORTD |= (1<<PD7);
}

// lcd_set_type_command()
void lcd_set_type_command() {
  PORTD &= ~(1<<PD7);
}

// lcd_write_nibble(...)
void lcd_write_nibble(char c) {

  // NOTE: only 2 or 3 work in the delays here.

  // set data
  PORTD &= ~(0x0f << 2);
  PORTD |= (c&0x0f) << 2;

  // Toggle E1 if in 1st two rows
  if(E1){PORTD |= (1<<PD6); delay_us(1); PORTD &= ~(1<<PD6); delay_us(1);}
  // Toggle E2 if in 2nd two rows
  if(E2){PORTB |= (1<<PB1); delay_us(1); PORTB &= ~(1<<PB1); delay_us(1);}
}

void lcd_write_byte(char c) {
  lcd_write_nibble( (c >> 4) & 0x0f );
  lcd_write_nibble( c & 0x0f );
  delay_us(80);
}

void lcd_clear_and_home() {
  // Perform clear and home on both chipsets.
  E1=1;
  E2=1;
  lcd_set_type_command();
  lcd_write_byte(0x01);
  delay_ms(50);
  lcd_write_byte(0x02);
  delay_ms(50);
  // Cursor is at home position of both Chipsets, disable #2 so top set works unless otherwise 
  // directed elswhere.
  E2 = 0;

}

void lcd_home() {
  // Perform clear and home on both chipsets.
  E1=1;
  E2=1;
  lcd_set_type_command();
  lcd_write_byte(0x02);
  delay_ms(50);
  // Cursor is at home position of both Chipsets, disable #2 so top set works unless otherwise 
  // directed elswhere.
  E2 = 0;
}

void lcd_write_data(char c) {
  lcd_set_type_data();
  lcd_write_byte(c);
}

// lcd_write_int16
void lcd_write_int16(int16_t in) {
  uint8_t started = 0;

  uint16_t pow = 10000;

  if(in < 0) {
    lcd_write_data('-');
    in = -in;
  }

  while(pow >= 1) {
    if(in / pow > 0 || started || pow==1) {
      lcd_write_data((uint8_t) (in/pow) + '0');
      started = 1;
      in = in % pow;
    }

    pow = pow / 10;
  }

}

// lcd_write_int16_centi
// assumes that its measured in centi-whatevers
void lcd_write_int16_centi(int16_t in) {
  uint8_t started = 0;

  uint16_t pow = 10000;

  if(in < 0) {
    lcd_write_data('-');
    in = -in;
  }

  while(pow >= 1) {
    if(in / pow > 0 || started || pow==1) {
      lcd_write_data((uint8_t) (in/pow) + '0');
      started = 1;
      in = in % pow;
    }

    if(pow == 100) {
      if(!started) {
        lcd_write_data('0');
      }
      lcd_write_data('.');
      started = 1;
    }

    pow = pow / 10;
  }

}

void lcd_write_string(const char *x) {
  // assumes x is in program memory
  while(pgm_read_byte(x) != 0x00)
    lcd_write_data(pgm_read_byte(x++));
}

void lcd_goto_position(uint8_t row, uint8_t col) {
  lcd_set_type_command();

  // 20x4 LCD: offsets 0, 0x40, 20, 0x40+20
  uint8_t row_offset = 0;
  switch(row) {
    case 0: row_offset = 0; E1=1; E2=0; break;
    case 1: row_offset = 0x40; E1=1; E2=0; break;
    case 2: row_offset = 0; E1=0; E2=1; break;
    case 3: row_offset = 0x40; E1=0; E2=1; break;
  }

  lcd_write_byte(0x80 | (row_offset + col));
}

void lcd_line_one()   { lcd_goto_position(0, 0); }
void lcd_line_two()   { lcd_goto_position(1, 0); }
void lcd_line_three() { lcd_goto_position(2, 0); }
void lcd_line_four()  { lcd_goto_position(3, 0); }

// lcd_init()
void lcd_init() {
  // set pin driver directions
  // (output on PD7,PD6, and PD3-6)
  DDRD |= 0xfc;
  DDRB |= (1<<PB1);
  // initialize both chipsets
  E1=1;
  E2=1;

  // wait 100msec
  delay_ms(100);
  lcd_set_type_command();

  // do reset
  lcd_write_nibble(0x03);
  delay_ms(6);
  lcd_write_nibble(0x03);
  delay_us(250);
  lcd_write_nibble(0x03);
  delay_us(250);

  // write 0010 (data length 4 bits)
  lcd_write_nibble(0x02);
  // set to 2 lines, font 5x8
  lcd_write_byte(0x28);
  // disable LCD
  //lcd_write_byte(0x08);
  // enable LCD
  lcd_write_byte(0x0c);
  // clear display
  lcd_write_byte(0x01);
  delay_ms(5);
  // enable LCD
  lcd_write_byte(0x0c);
  // set entry mode
  lcd_write_byte(0x06);

  // set cursor/display shift
  lcd_write_byte(0x14);

  // clear and home
  lcd_clear_and_home();
}

int lcd_putchar(char c, FILE *stream) {
  lcd_write_data(c);
  return 0;
}

For the .h file, simply copy the original NerdKit lcd.h file into a new file called lcd_4x40.h as no changes were necessary from the original.

Here is a modified initialload.c that I used to test the display and some positioning.

// initialload.c
// for NerdKits with ATmega168
// mrobbins@mit.edu

#define F_CPU 14745600

#include <stdio.h>

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <inttypes.h>

#include "../libnerdkits/delay.h"
#include "../libnerdkits/lcd_4x40.h"

// PIN DEFINITIONS:
//
// PC4 -- LED anode

int main() {
   uint8_t i=0;
  // fire up the LCD
  lcd_init();
  lcd_home();

  // print message to screen
  //             20 columns wide:
  //                     01234567890123456789
while(1){
  lcd_write_string(PSTR("  Congratulations!  "));
  lcd_goto_position(1,7);
  lcd_write_string(PSTR("********************"));
  lcd_goto_position(2,14);
  lcd_write_string(PSTR("  Your USB NerdKit  "));
  lcd_goto_position(3,20);
  lcd_write_string(PSTR("      is alive!     "));
  delay_ms(2000);
  lcd_home();
  lcd_write_string(PSTR("Overwriting text from home position..."));
  delay_ms(2000);
  lcd_goto_position(2,5);
  lcd_write_string(PSTR("Printing text Row 3 Column 6"));
  delay_ms(2000);
  for(i=10;i>0;i--){
    lcd_goto_position(1,10);
    lcd_write_string(PSTR("Clearing Screen in   "));
    lcd_goto_position(1,29);
    lcd_write_int16(i);
    delay_ms(999);
    }

  lcd_clear_and_home();
  delay_ms(1000);
  }

  return 0;
}

If you are interested in the display, I found them at a company called Prime Electronics Here is a link to them

Happy Programming Cheers

Rick

January 08, 2012
by Rick_S
Rick_S's Avatar

One other note, if you do get one of these displays, let me know if you find any bugs.

Rick

January 09, 2012
by Rick_S
Rick_S's Avatar

I forgot one detail, be careful when wiring the connector. If you do install a header connector like I did (from the back side) the pin order is opposite what would be standard.

On a standard header the pins would be numbered like this:

1  2
3  4
5  6
7  8
9  10
11 12
13 14
15 16

Since this is wired from the back side they are reversed like this:

2  1
4  3
6  5
8  7
10 9
12 11
14 13
16 15

If you are used to standard header layouts, it's easy to get your mind turned around.

Rick

January 15, 2012
by Rick_S
Rick_S's Avatar

I was just thinking as I was looking at the display on my desk. If anyone is interested, I could take the post from above and put it in the library so it doesn't get lost in the forum.

If no-one responds, I'll take it that no-one is interested and leave it alone.

Rick

January 15, 2012
by Ralphxyz
Ralphxyz's Avatar

Yeah Rick, I got four of the 4x40 LCD after you made your post.

Please put this in the Nerdkits Community Library

I do not know when I will ever get around to having the time to set them up but I sure like the 4x40 concept.

Ralph

January 15, 2012
by Rick_S
Rick_S's Avatar

Library article added HERE.

Rick

April 24, 2012
by Ralphxyz
Ralphxyz's Avatar

Hey Rick, what will I have to do to use your I2C LCD backpack?

I was thinking maybe I could use one of the unused pins for E2.

But that is just off the top of my head without looking into it yet.

I should have my 4x40 LCD running today.

Ralph

April 24, 2012
by Rick_S
Rick_S's Avatar

Electrically, you could probably tie into one of the unused outputs on the expander for E2. The library would also need modified to support the display similarly to how I did the standard library.

Rick

April 24, 2012
by Ralphxyz
Ralphxyz's Avatar

Now in looking at your library I am really getting dangerous and wondering why there is a E1 and E2.

Well I understand why there are two enables as you explain but they are doing the same functions in the code.

There are a couple of places you turn E2 off but I haven't figured the exact reason why.

So I am "thinking" about just using the E1 pin and splitting it to pin 9 and 15 on the 4x40 header.

They would both be enabled at the same time what is the problem with that?

Besides it is not conventional.

Ralph

April 24, 2012
by Rick_S
Rick_S's Avatar

If you re-read my first post in this thread, you'll see why there are two enable lines. The display is essentially two displays in one with the top two lines controlled by one controller and the bottom two lines controlled by another. The data lines for the two controllers are tied together and they are individually controlled by the separate enable lines. If you tie the enable lines together, the top two lines and the bottom two lines will display the same data.

Rick

April 25, 2012
by Ralphxyz
Ralphxyz's Avatar

That would be "if you re-re-re-re-read my first post in this thread".

It will all eventually sink in, oh well back to the unused pin idea which is to bad because then I'd actually have to do some programming.

Ralph

April 25, 2012
by Rick_S
Rick_S's Avatar

:D I have to re-re-re-re-read things often myself... takes a few times to fully sink in sometimes. If you usea an unused output on the expander, you'll have plenty of programming to do :)

Rick

April 25, 2012
by Ralphxyz
Ralphxyz's Avatar

Yeah, and I am not a programmer but I play one on TV.

Ralph

April 25, 2012
by Ralphxyz
Ralphxyz's Avatar

Ok I am "trying" to do it your way.

I have everything explicitly wired as you directed but my LCD does not light up.

No blackbars no nothing.

I compiled your initialload program and made a .hex so I guess it compiled but the make output was different than I expected.

miniMac:4x40lcd Me$ make
make -C ../libnerdkits
make[1]: Nothing to be done for `all'.
avr-gcc -g -Os -Wall -mmcu=atmega328p -o ../libnerdkits/lcd_4x40.o -c ../libnerdkits/lcd_4x40.c
avr-gcc -g -Os -Wall -mmcu=atmega328p -Wl,-u,vfprintf -lprintf_flt -Wl,-u,vfscanf -lscanf_flt -lm -o initialload.o initialload.c ../libnerdkits/delay.o ../libnerdkits/lcd_4x40.o ../libnerdkits/uart.o
avr-objcopy -j .text -O ihex initialload.o initialload.hex
miniMac:4x40lcd Me$

Of course your Makefile syntax is different than the standard Nerdkit Makefile so I am not surprised the make output is different.

So why wouldn't the LCD light up?

Ralph

April 25, 2012
by Rick_S
Rick_S's Avatar

Ralph,

I just e-mailed you my hex that worked on my display...

Rick

April 25, 2012
by Ralphxyz
Ralphxyz's Avatar

Thanks, still trying to figure out why the LCD does not work. I would assume there ought to be black bars.

There is no backlight I can not use that as a working indicator.

Speaking of backlight the are A and K connection points.

Ralph

April 25, 2012
by Rick_S
Rick_S's Avatar

Sorry Ralph, I don't understand what you are asking. If you are asking about the A & K on the back of the display board, I think the board was designed to have a backlight but the version we have does not have one. Maybe double check your wiring, remember, header connectors like that have the odds on one side and evens on the other, they aren't like ic's they go:

1  2
3  4
5  6
7  8
9  10
11 12
13 14
15 16

Also the pattern may be reversed depending on which side of the board you are on.

Rick

April 25, 2012
by Ralphxyz
Ralphxyz's Avatar

I am asking why the LCD is blank, no black bars in programing mode.

The backlight A K is just a curiosity.

Ralph

April 25, 2012
by Rick_S
Rick_S's Avatar

I haven't connected mine in a while so I can't validate, but I believe if everything is connected correctly and if the right contrast resistor is used, it should behave just like the NK display. If you ignore the 2nd enable and just wire it like the NK display, the 1st two lines should work with thier(NK Guys) library except lines 2 & 4 will be at the end of lines 1 & 2. I'm sure you've re-checked the wiring, next maybe you verify the power and contrast to make sure it's good. If I have time tomorrow I'll dig out my display and connect it and get you some close up photo's. How did you connect to the display? Did you modify a ribbon cable or solder directly into the display board? Do you have a photo?

Rick

April 25, 2012
by Ralphxyz
Ralphxyz's Avatar

I soldered on a header and have jumper wires.

My voltage regulator is really heating up and I only see 2+ volts across the rails so it acts like there is a short.

I only have VDD (pin 13) and GND (pins 14 + 16) no other wiring.

Ralph

April 25, 2012
by Rick_S
Rick_S's Avatar

Weird... does sound like a short somewhere. Maybe time to get the magnifier out and check for solder bridges. Hopefully you didn't get a bum display.

April 26, 2012
by Rick_S
Rick_S's Avatar

Ralph,

I did plug in my display this morning (power and ground in appropriate places and the contrast resistor installed) and confirmed it does display the two black bars,

May 03, 2012
by Ralphxyz
Ralphxyz's Avatar

Rick, where did you get the pinout from?

AVRfreaks and most of the Arduino code I have seen

Pin no. Symbol Function
1       DB7     Data bus line
2       DB6     Data bus line
3       DB5     Data bus line
4       DB4     Data bus line
5       DB3     Data bus line
6       DB2     Data bus line
7       DB1     Data bus line
8       DB0     Data bus line        
9       E1       Enable 1
10     R/W     Data read / write   
11     RS      Register select signal
12     Vo      Contrast Adjust 
13     Vss     Power supply(GND)       
14     Vdd     Power supply(+)  
15     E2       Enable 2            
16     Vee     Negative voltage

17        A        Power supply for LED B/L (+)
18        K        Power supply for LED B/L (- )

They list 4x40 Pin 13 as GND and Pin 14 as Vdd

You show just the opposite.

I just got back to playing with this.

Ralph

May 03, 2012
by Ralphxyz
Ralphxyz's Avatar

Yup, that did it!!

It's working with 4x40 Pin 14 Vdd(+) Pin 13 Gnd(-).

Now to test your library!!

Ralph

May 03, 2012
by Ralphxyz
Ralphxyz's Avatar

Your initialload.c program works great!!

I could not load your .hex and could not load the .hex I compiled so I just used the Makefile from the Nerdkit's initialload program and the program compiled and loaded fine.

Now to get my Graphic LCD working and then I like to do a touch screen but I probable will need a different mcu than the 328 or 168.

Thanks, I really appreciate your great projects.

Ralph

May 03, 2012
by Rick_S
Rick_S's Avatar

Good catch Ralph, Sorry for that. I'll fix that on my blog right away. If you have any problems with the display because of this let me know...

May 03, 2012
by Rick_S
Rick_S's Avatar

I've updated the library post here with the proper pinout chart. Thanks again Ralph. I'm also deleting the image that is incorrect so the pinout chart above in this thread will be missing.

May 10, 2012
by Ralphxyz
Ralphxyz's Avatar

Now this is strange, I tried modifying your 4x40 initialload but only lines 1 and 2 displays text!

So I went back to your original code and still only got lines 1 and 2.

Then I noticed the MakeFile was for an atmega328p but the initialload.c program is for a ATmega168, there is no

#include "../libnerdkits/io_328p.h"

which isn't strictly required for 328 code to run as long as you do not make any calls for io_328p.h components.

Any way I set everything up for a 168 and only get two rows of faint black boxes with the box in position 1, on line 1 and 3, blinking.

For the 328 I get text in line 1 and two with black boxes on line three, not sure if the position one box is blinking, I do not believe it is.

So once agin something strange is happening that I can not restore the original program.

I hate all of the wires so I made up the ribbon cable.

I forgot how easy it is to break the IDC (insulation displacement connector) if you do not have the proper tools so I ordered IDC compression tool off ebay and still managed to break a couple of connectors before figured out how to use it (two steps don't use compressor for final piece).

I "believe" the wiring is correct as it did work once.

Ralph

May 10, 2012
by Rick_S
Rick_S's Avatar

Check the 2nd enable line. If it isn't connected properly, the lower half won't initialize. You are using the 4x40 library right?? As for the io_328p.h stuff, I added those definitions to the main libraries a long time ago, so I don't always think of using that include.

Rick

May 10, 2012
by Ralphxyz
Ralphxyz's Avatar

Now this is interesting.

I connected my scope to E1 and definitely can see when E1 is enabled but when looking at E2 I do not see the enable!

Wish I knew how to take a picture with my scope also it would be nice to get the PC interface working.

Ralph

May 10, 2012
by Ralphxyz
Ralphxyz's Avatar

Darn now the enable on E2 is showing up on my scope so the E2 enable is firing.

I switched LCD's to make sure I didn't have a bad LCD, both show the same result.

Well now line three is flickering and showing:

fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff

33333333333333333333333333333333333333

box box box box box box box box box box box box

and line four will occasionally have characters.

May 11, 2012
by Rick_S
Rick_S's Avatar

I don't know what is causing that, maybe an intermittant connection?? Confused

You're trying to just run with the unmodified library right?

May 11, 2012
by Ralphxyz
Ralphxyz's Avatar

"unmodified library"??

This is with your lcd_4x40.c library from above with the renamed NerdKit lcd.h.

Ralph

May 11, 2012
by Rick_S
Rick_S's Avatar

That's all I was using. I don't know why it isn't working there?? This may be another of your mysteries. LOL

Seriously though, maybe there is an intermittant connection somewhere. Have you tried it without the ZIF socket just plugging the micro into your board? I know you are a big proponent of the disassemble/re-assemble so I'm sure you've tried that. I'm at a loss and just grasping at straws.

Sorry I can't help more, I'd really like to see it going again.

Rick

May 11, 2012
by Ralphxyz
Ralphxyz's Avatar

Darn, I got it working using your initialload.hex that you sent me!!

I loaded it using AVRStudio on my Windows 7 machine and it runs correctly!!

Now I'll need to figure out how to use your MakeFile on my Mac or figure out how to use my MakeFile, geesch my beard hair has really turned white since I started learning microprocessor programming.

Ralph

May 12, 2012
by Rick_S
Rick_S's Avatar

Ralph,

Reading another thread made me think. Did you change the compiler optimizations in the make file? The Macs have been having issues unless you change the -Os to -O0 (Dash Letter O number Zero) to turn off optimizations. If you haven't done that, give it a shot. That might fix the erratic behavior.

Rick

May 12, 2012
by Ralphxyz
Ralphxyz's Avatar

Ok, I have not done any programming for the past 6 months so I m not thinking as a programmer.

My problem was I am not including your lcd_4x40.c Library!!

You say:

For the .h file, simply copy the original NerdKit lcd.h file into a new file called lcd_4x40.h as no changes were necessary from the original.

Which I did, but how is your Library included?

I cannot call it lcd_4x40.h if the Nerdkit lcd.h file wants to be included as lcd_4x40.h.

Of course I could give it any name but I was not thinking as a programmer so that fact escaped me :-)

I have never had a problem with the compiler optimizations.

Ralph

May 13, 2012
by Rick_S
Rick_S's Avatar

lcd_4x40.c is compiled into an object file and linked in the makefile. That is how the same header file can call functions in a different 'c' file. As for the optimizations, it was just a thought seeing how many people seem to have issue with them. I haven't really done any programming on my mac mini... Actually haven't even turned it on in a couple of months Sad Face so I don't know if the optimizations would effect me or not.

Rick

May 13, 2012
by Ralphxyz
Ralphxyz's Avatar

lcd_4x40.c is compiled into an object file and linked in the makefile

Strange the compiler didn't complain about not finding lcd_4x40.o.

Of course I wasn't thinking as a progrmmer (I have been doing my brick path for the past six months) so I need to be reminded to actually compile lcd_4x40.c into an object file.

So once agin thank you for your great projects and exceptional help.

Ralph

May 13, 2012
by Rick_S
Rick_S's Avatar

It probably wouldn't complain because with the standard NK makefile, lcd.c is linked and it has the same function names. So the program was satisfied. Using lcd.c though would give you only the top two lines being functional. The first half of line 1 being line 1, the second half being line 3. The first half of line 2 would be line 2 and the second half line 4. That would explain the "gibberish" you were seeing.

How's the brick path coming?

May 13, 2012
by Ralphxyz
Ralphxyz's Avatar

Yeah, that probable explains it, ha. Oh well I consider myself to be a second year student in a electronics/microprocessor class so it is not surprising.

The brick path is reaaally unbelievable. People say it has a lot of character, it certainly isn't your typical brick path installed by a professional that knoew what they were doing. But I love it and being outdoors at lest 4 hours a day is so good for me. I spent the last 20 years sitting at my desk for 12 to 2o hours a day and sometimes more acting like I was a network administrator/webmaster.

I haven't updated the website lately I have laid most of the brick path and have one lamp post working plus I have been doing a lot of restoring the landscaping that got torn up in the excvation work.

And for those of you wondering wht the heck a brick path has to do with Nerdkits, well I do need a light controller for the path lights that will be controlled by a Nerdkit mcu :-).

Lamp Post Controller.

Ralph

May 13, 2012
by Rick_S
Rick_S's Avatar

You have some beautiful property there Ralph. Someday I'd like to move to a coastal area and get out of the middle here where I am. I'm figuring further south than you are. I'm hopeful that if all goes as planned, by the time I get around to retirement age, I'll have my home paid off and be able to sell and buy outright with little to no mortgage for my silver years. That's the goal anyway. Wink

May 14, 2012
by Ralphxyz
Ralphxyz's Avatar

Rick I am trying to compile your lcd_4x40.c, yes I changed the name.

The pin defines are not being found.

4x40LCD.c: In function 'lcd_set_type_data':
4x40LCD.c:31: error: 'PD7' undeclared (first use in this function)
4x40LCD.c:31: error: (Each undeclared identifier is reported only once
4x40LCD.c:31: error: for each function it appears in.)
4x40LCD.c: In function 'lcd_set_type_command':
4x40LCD.c:36: error: 'PD7' undeclared (first use in this function)
4x40LCD.c: In function 'lcd_write_nibble':
4x40LCD.c:49: error: 'PD6' undeclared (first use in this function)
4x40LCD.c:51: error: 'PB1' undeclared (first use in this function)
4x40LCD.c: In function 'lcd_init':
4x40LCD.c:178: error: 'PB1' undeclared (first use in this function)
make.exe: *** [4x40LCD.hex] Error 1

I am using Programmers NotePad in Window 7 (as long as it doesn't crash, geesch Windows 7 is worse that XP for getting "BSD" (Blue Screen ofDeath).

I have not used Windows 7 for development enviroment for a long time so I do not know if there is something I hven't done after the last Windows 7 rebuild.

Ralph

May 14, 2012
by Rick_S
Rick_S's Avatar

I modified my pin definition files in the avr-gcc install to include the missing definitions. If you haven't done that, you'll need to include the io_328p.h you mentioned earlier. That should fix the undefined pin callouts.

Rick

May 15, 2012
by Ralphxyz
Ralphxyz's Avatar

Rick said:

If you haven't done that,

(That's a quote in case you haven't read the stupid Markdown manual)

And why would I want to do that??

Just to not have to:

#include "../libnerdkits/io_328p.h"

Ralph

May 15, 2012
by Ralphxyz
Ralphxyz's Avatar

Darn making the object file is not that straight forward.

I've done it in the past just using a Nerdkit MakeFile but I think I need your MakeFile or your lcd_4x40.o file.

Here are my latest errors:

../libnerdkits/lcd.o: In function `lcd_set_type_data':
D:\Nerdkits\Code\libnerdkits/lcd.c:22: multiple definition of `lcd_set_type_data'
C:\Users\Ralphxyz\AppData\Local\Temp/ccUGYt0g.o:D:\Nerdkits\Code\LCD4x40/4x40LCD.c:32: first defined here
../libnerdkits/lcd.o: In function `lcd_set_type_command':
D:\Nerdkits\Code\libnerdkits/lcd.c:27: multiple definition of `lcd_set_type_command'
C:\Users\Ralphxyz\AppData\Local\Temp/ccUGYt0g.o:D:\Nerdkits\Code\LCD4x40/4x40LCD.c:37: first defined here

etc. etc.

D:\Nerdkits\Code\libnerdkits/lcd.c:27: multiple definition of `lcd_clear_and_home'
C:\Users\Ralphxyz\AppData\Local\Temp/ccUGYt0g.o:D:\Nerdkits\Code\LCD4x40/4x40LCD.c:63: first defined here
../libnerdkits/lcd.o: In function `lcd_init':
D:\Nerdkits\Code\libnerdkits/lcd.c:160: multiple definition of `lcd_init'
C:\Users\Ralphxyz\AppData\Local\Temp/ccUGYt0g.o:D:\Nerdkits\Code\LCD4x40/4x40LCD.c:178: first defined here
c:/winavr-20090313/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr5/crtm328p.o:(.init9+0x0): undefined reference to `main'
make.exe: *** [4x40LCD.hex] Error 1

Of course I do not believe I have ever seen a step by step instruction on making a .o file so I am winging it and you know the trouble that means.

Ralph

May 15, 2012
by Rick_S
Rick_S's Avatar

Did you get these errors with my makefile? I had the program file with the makfile in their own folder. lcd_4x40.c and lcd_4x40.h in libnerdkits.

The line in the makefile that creates the object file is:

avr-gcc ${GCCFLAGS} -o ../libnerdkits/lcd_4x40.o -c ../libnerdkits/lcd_4x40.c

You should be able to type that in the command line(substituting the value for GCCFLAGS) to manually creat the .o file.

May 15, 2012
by Ralphxyz
Ralphxyz's Avatar

All right I'll try with your MakeFile that would make sense.

Ralph

May 15, 2012
by Ralphxyz
Ralphxyz's Avatar

See I can do it, I have the lcd_4x40.o and a new lcd_4x40.hex using your MakeFile!!

Now to get into trouble making changes to your initialload.c.

I have a muti-sensor ground temperature project in mind that I'll use the 4x40 LCD for. At $3.00 apiece I will not mind dedicating a LCD to a project.

Thanks again for your projects and your faithful help.

Ralph

May 15, 2012
by Rick_S
Rick_S's Avatar

No problem Ralph, glad it all worked out. My latest thing is playing with tube guitar amps. Kinda fun playing with 500 - 600VAC transformers. :D

Rick

May 16, 2012
by Ralphxyz
Ralphxyz's Avatar

Kinda fun playing with 500 - 600VAC transformers.

Is that where you always keep your other hand in your pocket?

Now, are you learning to play the guitar and learning how to build a tube amplifier at the same time?

I am able to change your initialload.c program and compile the changes, this is great.

Ralph

May 16, 2012
by Rick_S
Rick_S's Avatar

Haven't started formal lessons yet, but am having fun building amps. I finished my 1st amp head using an old fender schematic with different tubes. As for the hand in the pocket, I don't do that but I do have a very real respect for the high voltage.

Glad to hear the compiling is going smoothly now.

Rick

May 16, 2012
by Ralphxyz
Ralphxyz's Avatar

I had a electrician (the crew boss) get across a couple of hundred volt 3 phase, he sure wished he had kept his other hand in his pocket.

That's the first thing I was taught working on high voltage, of course that was power busses that I was learning on.

Ralph

May 17, 2012
by Rick_S
Rick_S's Avatar

Yeah, at work with the 440V 3 Phase electrical cabinets for the machines, I always keep one hand behind my back. It's important also to overcome the natural tendancy to touch what you are pointing at when discussing something in the cabinet as well.

Don't worry though, I plan to be around for a while to keep pestering you guys Wink

Rick

July 21, 2012
by killercow
killercow's Avatar

Hi Rick,

Thanks for fixing up the library to handle the 40x4 display. I purchased a couple of these 40x4 and the 40x2's. The 40x2's connect like the LCD that came with the kit. The 40x4's, on the other hand, needed to be toned out while looking at your chart and the KS0066 PDF file.

I also had issues with E2 not firing correctly...odd. I ended up swapping E1 & E2 at the LCD and the bottom half worked. Then I swapped them back and I was in business.

Pin - function
1   - Ground (Vss)
2   - +5 (Vcc)
3   - LCD Contrast (Vee)
4   - RS
5   - R/W
6   - E1
7   - E2
8   - DB0
9   - DB1
10   - DB2
11   - DB3
12   - DB4
13   - DB5
14   - DB6
15   - DB7
16   - Unused?

Pins 1 thru 6 are compatible with the NerdKit, E2 causes the data lines to be shifted over one to make them odd for wiring. But, who cares....I got 40x4 now...WooHoo!!!

Thanks again to you and the rest of the gang.

Kevin

July 21, 2012
by Rick_S
Rick_S's Avatar

No problem, glad it worked out for you. It's good to know it works with a different diplay. Does that display have a backlight?

July 22, 2012
by killercow
killercow's Avatar

The 40x4 doesn't have a back light, the 40x2 does though.

July 22, 2012
by Rick_S
Rick_S's Avatar

The 40x4 I got didn't have backlight either. I was just curious whether the one you got did since it didn't say in the listing.

Post a Reply

Please log in to post a reply.

Did you know that LEDs (light emitting diodes) only conduct current in one direction, like normal diodes? Learn more...