Dangerous Prototypes

Other projects => Past projects => USB serial LCD backpack => Topic started by: gnomishworks on January 12, 2012, 05:42:03 am

Title: Arduino and Serial connection
Post by: gnomishworks on January 12, 2012, 05:42:03 am
Can't get the Seeeduino LCD backpack to work with serial. Not even the backlight works..

void setup() {
  Serial1.begin(9600);
}

void loop() {
  // Example usage:
  clearLCD();
  backlightOn();
  //Print text on each line
  selectLineOne();
  delay(100);
  Serial1.print("Line One");
  delay(500);
  backlightOff();
}
//Serial1LCD Functions
void selectLineOne(){  //puts the cursor at line 0 char 0
  Serial1.write(0xFE);  //start command flag
  Serial1.write(0x47);  //position
  Serial1.write(2);    //position
  Serial1.write(0x9A);  //end command flag
}
void clearLCD(){
  Serial1.write(0xFE);  //start command flag
  Serial1.write(0x58);  //clear lcd command
  Serial1.write(0x9A);  //end command flag
}
void backlightOn(){  //turns on the backlight
  Serial1.write(0xFE);  //start command flag
  Serial1.write(0x42);  //backlight on
  Serial1.write(30);  //Stay on for 30 min 
  Serial1.write(0x9A);  //end command flag
}
void backlightOff(){  //turns off the backlight
  Serial1.write(0xFE);  //start command flag
  Serial1.write(0x46);  //backlight off 
  Serial1.write(0x9A);  //end command flag
}
void backlight50(){  //sets the backlight at 50% brightness
  Serial1.write(0xFE);  //start command flag
  Serial1.write(0x98);  //backlight brightness
  Serial1.write(128);    //backlight level
  Serial1.write(0x9A);  //end command flag
}

Any ideas?
Thanks
Title: Re: Arduino and Serial connection
Post by: ian on January 12, 2012, 08:27:01 am
Hi gnomishworks,

I'm sorry, I don't know what hardware this is. This forum is for our PIC-based LCD backpack, not an AVR/Arduino shield.
Title: Re: Arduino and Serial connection
Post by: gnomishworks on January 12, 2012, 02:57:47 pm
Ian

This is the PIC USB/serial backpack.. http://dangerousprototypes.com/docs/PIC_LCD_backpack (http://dangerousprototypes.com/docs/PIC_LCD_backpack)

I connected a standard HD44780 and can run the test program provided over USB and or LCDSmartie and it works fine. I wanted to use the RX/TX line on the board to connect to the serial port on an Arduino.

So has anyone tested the serial port of the PIC_LCD_Backpack?

It doesn't appear to work with the commands listed on the site.

Thanks
Title: Re: Arduino and Serial connection
Post by: ian on January 12, 2012, 03:20:17 pm
I'm sorry, my mistake. I thought you meant a Seeeduino LCD backpack.

I do not think the serial port is enabled in the default firmware. We have a new version with an open source USB stack that needs to be released. I will get this to you in a few days.
Title: Re: Arduino and Serial connection
Post by: gnomishworks on January 12, 2012, 05:18:44 pm
Awesome! It would also be helpful if someone could provide a basic example of getting it working.

Thanks
Title: Re: Arduino and Serial connection
Post by: ian on January 12, 2012, 05:24:56 pm
I think this will do the trick. It is UART only (no USB). It runs at 115200bps (can change for you if needed), and it echoes the input on the TX pin so you see what it sees. I did the echo test and made sure it executed the commands, but it is not tested completely. Please try backlight first.

Connect the PGC and PGD pins of the ICSP header and plug in the LCD backpack to enter update mode. Then run the .bat file in the firmware update.

You code looks good to me for a test.
Title: Re: Arduino and Serial connection
Post by: gnomishworks on January 13, 2012, 04:54:50 pm
Ian

Loaded the firmware no problem and tried basic backlight on, which kind of works. Tried backlight on/off with a one second delay. No luck. Tried to send characters, no luck.

So it kind of working and it may be my inexperience, but I am not having much luck.

Even if I had a Microchip C example I am sure I can convert it to what I am using, but I appear to be lost.
Title: Re: Arduino and Serial connection
Post by: ian on January 14, 2012, 10:04:21 am
Thanks for testing, it could also be a problem with the code. I will try it out and give youi instructions or an updated firmware.

As a note - the LCD driver firmware we used in the backpack does not support the backlight delay option (yet), so I wouldn't expect it to work.
Title: Re: Arduino and Serial connection
Post by: ian on January 16, 2012, 12:41:47 pm
I think I found the problems. The documentation has the 0x9e command to end - that is actually part of the LCD driver we used and it refers to another extended command for the #twatch network LCD backpack. You do not need to end commands at all, I'm sorry for the errors in the documentation.

Here is a sample Bus Pirate session controlling a 2x16 LCD. First Backlight on, then position the courser to row 1 col 1, then type hello world:

Code: [Select]
UART>0xfe 0x42 0x00 //backlight on
WRITE: 0xFE
WRITE: 0x42
WRITE: 0x00
UART>0xfe 0x47 1 1 //position to 1,1
WRITE: 0xFE
WRITE: 0x47
WRITE: 0x01
WRITE: 0x01
UART>"Hello world" //send hello world as ascii text
WRITE: "Hello world"
UART>0xfe 0x46 //turn off backlight
WRITE: 0xFE
WRITE: 0x46
UART>
Title: Re: Arduino and Serial connection
Post by: gnomishworks on January 16, 2012, 03:42:43 pm
Ian

Great. I will give that a try. I did manage to get some things working over the weekend, but I noticed two other issues. The home command seems to start at the second character away from home. Also I do get random characters once in awhile on the LCD and I am thinking either there is a bug or 115200 is to fast. Let me know if you can replicate these issues.

Thanks
Dave
Title: Re: Arduino and Serial connection
Post by: WDZaphod on March 22, 2012, 09:57:31 am
Hello,

do I understand right - the SERIAL LCD Backpack is not capable to understand serial commands, just USB?
I just bought two of them to control Displays via Arduino (serial), and I'm pretty lost because it doesn't work at all.
Is there any official release for a firmware now, what supports serial connection to the serial backpack? :-/
Title: Re: Arduino and Serial connection
Post by: ian on March 26, 2012, 06:45:57 pm
You are correct, sorry for the issues. For now you can use this firmware for serial input:

viewtopic.php?f=60&t=3446&view=unread#p34444 (http://dangerousprototypes.com/forum/viewtopic.php?f=60&t=3446&view=unread#p34444)

An official release will be available "soon".
Title: Re: Arduino and Serial connection
Post by: WDZaphod on April 24, 2012, 12:00:25 pm
Any idea yet about the new serial firmware?
Can you pls. upload some other Baud rate versions of this Beta Version? 56k would be nice :-)

Greetings from Switzerland,
Michael
Title: Re: Arduino and Serial connection
Post by: ian on April 24, 2012, 01:28:13 pm
HiMichael,

I'm sorry, there are some teething pains with the new open source USB stack, and I have not been willing to release new firmwares using it (including the USB/Serial LCD backpack).

Here are two new firmware versions, with 57600bps and 9600bps.
Title: Re: Arduino and Serial connection
Post by: WDZaphod on April 24, 2012, 01:33:48 pm
Great, I think this will help :-)
Thanks a lot, I will try!
Title: Re: Arduino and Serial connection
Post by: ian on May 02, 2012, 11:36:51 am
Will anyone still subscribed please help test the v1.1beat1 firmware release:
viewtopic.php?f=60&t=3992&p=39940#p39940 (http://dangerousprototypes.com/forum/viewtopic.php?f=60&t=3992&p=39940#p39940)

It integrates the USB and UART modes. After power up it will go into 9600bps UART mode if there's no USB connection within about 3-5seconds. I tested it with the Bus Pirate and it seems to be solid. I also included an update to work better with LCDproc, the Linux LCD driver application.

Any feedback would be greatly appreciated.

( ! ) Fatal error: Uncaught exception 'Elk_Exception' with message 'Please try again. If you come back to this error screen, report the error to an administrator.' in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
( ! ) Elk_Exception: Please try again. If you come back to this error screen, report the error to an administrator. in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
Call Stack
#TimeMemoryFunctionLocation
10.01182104128session_write_close ( )...(null):0
20.01212235720ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.01212236496Database_MySQL->query( ).../DatabaseHandler.php:119
40.05692375232Database_MySQL->error( ).../Db-mysql.class.php:273