Author Topic: Serial LCD with ATMega8  (Read 6250 times)

0 Members and 1 Guest are viewing this topic.

Offline spizzakTopic starter

  • Full Member
  • ***
  • Posts: 102
  • Helpful? 1
Serial LCD with ATMega8
« on: July 29, 2009, 09:27:08 PM »
I am having trouble getting my LCD to work properly. This is the code im giving it (the analog sensor is the SharpIR).


Code: [Select]
while(1)
{

delay_cycles(23000);
ledon();
delay_cycles(23000);

sensorx=a2dConvert8bit(5);

delay_cycles(23000);
ledoff();
delay_cycles(23000);

rprintf("THE VALUE IS:  %d\r\n", sensorx);



delay_cycles(23000);

}

And this is what its giving:

Can anyone give any ideas what the extra characters might be? Are they missing from my numbers or should my numbers be the ones I'm getting and the characters are just extra? Any ideas?

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: Serial LCD with ATMega8
« Reply #1 on: July 30, 2009, 01:02:47 PM »
Its not clear what your problem is. You mention 'extra characters' but don't say what they are.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline spizzakTopic starter

  • Full Member
  • ***
  • Posts: 102
  • Helpful? 1
Re: Serial LCD with ATMega8
« Reply #2 on: July 30, 2009, 01:27:07 PM »
In the attached picture you can see "VALUE IS: 52###" The ### is where the weird characters are..

Offline guncha

  • Jr. Member
  • **
  • Posts: 40
  • Helpful? 0
Re: Serial LCD with ATMega8
« Reply #3 on: July 30, 2009, 08:45:51 PM »
It could be any number of things. Try printing just the number or just the text, like so rprintf("WAKAWAKA\r\n"); or maybe it's that you don't need both \r and \n. Who knows..

Offline spizzakTopic starter

  • Full Member
  • ***
  • Posts: 102
  • Helpful? 1
Re: Serial LCD with ATMega8
« Reply #4 on: July 31, 2009, 08:00:14 AM »
The other thing is, whenever I try sending any special commands like to clear the screen or reset the cursor location the LCD freezes.. I can write plain text to it no problem but when I send those it freezes until i reboot it... any ideas on what could be causing that? Is there a really simple program that I can use to test the LCD without using all the libraries?

Offline Stephanie

  • Jr. Member
  • **
  • Posts: 46
  • Helpful? 0
Re: Serial LCD with ATMega8
« Reply #5 on: July 31, 2009, 02:16:14 PM »
The weird characters seem to be extra.

Try this (don't change anything in the rprintf statements, there are extra and missing whitespaces on purpose):
Code: [Select]
while(1)
{

delay_cycles(23000);
ledon();
delay_cycles(23000);

sensorx=a2dConvert8bit(5);

delay_cycles(23000);
ledoff();
delay_cycles(23000);

if (sensorx < 10) {
rprintf("SHARP IR READING:  %d\r\n", sensorx); //19 fixed characters, 1 for variable
} else if (sensorx < 100) {
rprintf("SHARP IR READING: %d\r\n", sensorx); //18 fixed characters, 2 for variable
} else {
rprintf("SHARPIR READING: %d\r\n", sensorx); //17 fixed characters, 3 for variable
}


delay_cycles(23000);

}
Let me know if it works.
--- Stephanie

Offline spizzakTopic starter

  • Full Member
  • ***
  • Posts: 102
  • Helpful? 1
Re: Serial LCD with ATMega8
« Reply #6 on: August 03, 2009, 04:34:04 PM »
If I remove the \r\n it prints just the number like I wanted it to. But I still cant get it to print any of the special commands.

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: Serial LCD with ATMega8
« Reply #7 on: August 03, 2009, 06:31:31 PM »
Hi spizzak
We've already covered this in another thread.
Did you try using hypertimal or realterm to make sure your serial output is as expected?
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline spizzakTopic starter

  • Full Member
  • ***
  • Posts: 102
  • Helpful? 1
Re: Serial LCD with ATMega8
« Reply #8 on: August 03, 2009, 08:03:56 PM »
I dont have the required hardware to use Hyperterminal

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: Serial LCD with ATMega8
« Reply #9 on: August 04, 2009, 07:43:46 PM »
You really need to get a level shifter ie from TTL levels to RS232 or UART. Or make your own using Max232 etc. Depending on whether your PC has serial port and/or only UART.

Or if you can afford the extra bucks then a wireless link back to your PC.

This is a fundamental debugging kit. Without it then its hard to tell if your code is wrong, mis-behaving, or whether it is something else.

Ok its yet another 'one off cost' and you were probably hoping to use the LCD for debugging output instead. Which is fine once you get the LCD working (chicken and egg!)

The only other suggestion I can make in the interim, without a pc connection) is to go back to Sparkfun (where you bought the LCD) and see whats on their support forums.

Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline flimflap

  • Jr. Member
  • **
  • Posts: 18
  • Helpful? 1
Re: Serial LCD with ATMega8
« Reply #10 on: August 06, 2009, 07:41:12 AM »
I always used a usb -> ttl converter chip. Same chip sparkfun used in:
http://www.sparkfun.com/commerce/product_info.php?products_id=718

 

SMF spam blocked by CleanTalk