Society of Robots - Robot Forum
Software => Software => Topic started by: spizzak 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).
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?
-
Its not clear what your problem is. You mention 'extra characters' but don't say what they are.
-
In the attached picture you can see "VALUE IS: 52###" The ### is where the weird characters are..
-
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..
-
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?
-
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):
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.
-
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.
-
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?
-
I dont have the required hardware to use Hyperterminal
-
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.
-
I always used a usb -> ttl converter chip. Same chip sparkfun used in:
http://www.sparkfun.com/commerce/product_info.php?products_id=718