new serial 2041, garbled output

LK/ELK/VK/PK/OK/MX/GLK/EGLK/GVK/GLT Series

Moderators: Henry, Mods

Post Reply
daryll.decius
LCD?
Posts: 3
Joined: Mon May 20, 2013 12:26 pm

new serial 2041, garbled output

Post by daryll.decius »

Hello, i recently bought serial 2041 for use with an Arduino, the manual online says it should have come with jumpers installed to indicate 19200, however i cannot see any jumpers installed on j0-j3, which should indicate 1200 baud if i'm reading this correctly. My problem comes when i try and send commands to the LCD, none of the commands work correctly and test send over the serial port, at 1200 baud, and in fact any other speed just shows up as what look like random ascii characters. i'm providing pictures of the j0-j3 pins to confirm the configured baud rate and pictures
2013-05-20 11.43.10.jpg
2013-05-20 11.43.10.jpg (281.11 KiB) Viewed 5266 times
of the output from simple commands so you can get a better sense of the problem.
the first picture is the back of the 2041 showing the jumper configuration for 232, 1200 baud(apparently), and the serial adapter.
the second is the startup screen without any input
the third is a sample sketch using a software serial port, at 1200 baud, which if working should clear the display and show 'hello world'
i've included the sketch below for reference as most of the sketches differ in the command codes they use and some that say they are for serial, are in fact for parallel.
I would really appreciate any help anyone can give me on this matter.

// Use the softwareserial library to create a new "soft" serial port
// for the display. This prevents display corruption when uploading code.
#include <SoftwareSerial.h>

// Attach the serial display's RX line to digital pin 2
SoftwareSerial mySerial(3,2); // pin 2 = TX, pin 3 = RX (unused)

void setup()
{
mySerial.begin(1200); // set up serial port for 1200 baud
delay(500); // wait for display to boot up
}

void loop()
{
mySerial.write(254); // move cursor to beginning of first line
mySerial.write(128);

mySerial.write(" "); // clear display
mySerial.write(" ");

mySerial.write(254); // move cursor to beginning of first line
mySerial.write(128);

mySerial.write("Hello, world!");

while(1); // wait forever
}
Attachments
2013-05-20 12.08.54.jpg
2013-05-20 12.08.54.jpg (305 KiB) Viewed 5266 times
2013-05-20 12.08.17.jpg
2013-05-20 12.08.17.jpg (335.91 KiB) Viewed 5266 times
2013-05-20 11.51.20.jpg
2013-05-20 11.51.20.jpg (340.12 KiB) Viewed 5266 times

Clark
Matrix Orbital
Matrix Orbital
Posts: 881
Joined: Fri Aug 17, 2007 10:58 am
Location: Matrix Orbital
Contact:

Re: new serial 2041, garbled output

Post by Clark »

Hello Daryll,

The communication settings of our LCD2041 were once configured using hardware jumpers, but are now set up via software commands. From the images provided, it appears you have a newer, PCB Rev2.0 unit, so please checkout the most recent manual, located here. The default baud rate for the display will be 19200, and you can force that speed by placing a jumper on the pins exposed at J3, as indicated in the Manual Override section of your manual.

Also, please consult your Arduino Uno documentation to confirm the voltage levels the controller supplies for serial communication. I believe that board will communicate at TTL levels, if that is the case, please place your display into TTL mode by carefully removing the 232 protocol resistors and either placing 0 ohm resistors or solder bridges on the TTL pads.

Finally, for your clear display command, please try sending the bytes 254 88. For a quick piece of Arduino sample code, you might check out this demo at the Arduino Playground.

Thanks,
Troy
Troy Clark
Design & Development
Matrix Orbital

daryll.decius
LCD?
Posts: 3
Joined: Mon May 20, 2013 12:26 pm

Re: new serial 2041, garbled output

Post by daryll.decius »

Thanks for the quick response, Troy. I have changed the jumper configuration to TTL and got the LCD to communicate with the Arduino. I can now display text messages, however the command characters (0x0C) are also being displayed as erroneous data on the display in between words. my syntax is as follows
Serial.write (0xFE); // the command directive
Serial.write (0x0C); // to clear the screen
Serial.print("Line One");
Serial.write(0xFE); // command directive
Serial.write(0x0A); // CR, go to next line
Serial.print("Line two");
etc...
when the clear screen command is issued an ascii character is also displayed on screen.
Also i have used the manual override to set defaults but i am confused as to the "edit and save settings", how do i do that? i'm assuming this refers to the PC software? I haven't been able to use any of the PC options as my system doesn't have a legacy serial port and i was unable to get it to communicate over usb using a serial/usb adapter. In addition i have somehow sent a command to the LCD to only turn on the 1st and 3rd lines, i was simply trying to get the display to move to the next line after printing some text and when i ran the sketch the display 'turned off' the 2nd and 4th lines and now displays the following (see pic below). in the second picture you can see the serial monitor output is correct except for the strange character after Line Four, which actually, i believe either the clear screen or new line command..
any suggestions would be much appreciated.
one step forward, two steps back

Thanks!
Daryll
Attachments
2013-05-21 13.06.55.jpg
2013-05-21 13.06.55.jpg (347.7 KiB) Viewed 5259 times
2013-05-21 13.02.23.jpg
2013-05-21 13.02.23.jpg (250.45 KiB) Viewed 5259 times

Clark
Matrix Orbital
Matrix Orbital
Posts: 881
Joined: Fri Aug 17, 2007 10:58 am
Location: Matrix Orbital
Contact:

Re: new serial 2041, garbled output

Post by Clark »

No worries Daryll,

I see you have added the command prefix 0xFE before sending the special characters 0x0C and 0x0A, however, the command prefix is not required for special characters. If you remove the 0xFE write from the two code instances you have documented below I believe your erroneous data problem will be solved.

As for manual override, it will be temporary. That is, the display checks for the jumper when it powers up; if it is on settings will be forced to defaults, if it is off the settings will be loaded from memory. To make permanent changes, you can set and save commands, or use the remember function, to transfer your desired settings into memory. A PC will not be required.

Finally, to solve the issue of writing to lines 1 and 3 only, please experiment with the line wrap and scroll settings. Note that these will be set to default, all 4 lines showing, with the override jumper in place. If you can only write to lines 1 and 3 even in manual override mode you may have a hardware problem.

Thanks,
Troy
Troy Clark
Design & Development
Matrix Orbital

daryll.decius
LCD?
Posts: 3
Joined: Mon May 20, 2013 12:26 pm

Re: new serial 2041, garbled output

Post by daryll.decius »

Thanks Troy, i really appreciate the quick responses. works a treat.
however, some constructive criticism, you might think about adding some code examples to the manual, some of the syntax for the commands aren't very intuitive and i would have beat my head against the wall for a few days if you hadn't pointed out that i didn't actually need to include the command precursor to the code. Also a few of the codes like the clearsceen and setcursor commands are still a little bit of a mystery as to exactly how to get them to work, for example the setcursor is just 0x47 [col][row] but doesn't show how that should be implemented in c for example or on an arduino specifically. including just a single line of code showing how these commands are phrased in even one programming language would greatly relieve what i'm sure is a good deal of frustration.
On that note, when i try and use the set cursor position command, such as
serial.write(0x47)[1][0]
it acts as though i'm defining an array, which is what i would expect it to do, but that's not at all what the example is saying should happen... i guess i'll just have to keep experimenting and see what i can get.
Again, thanks for the help!
Daryll
Attachments
2013-05-21 20.14.33.jpg
2013-05-21 20.14.33.jpg (240.77 KiB) Viewed 5259 times

Clark
Matrix Orbital
Matrix Orbital
Posts: 881
Joined: Fri Aug 17, 2007 10:58 am
Location: Matrix Orbital
Contact:

Re: new serial 2041, garbled output

Post by Clark »

Not a problem Daryll,

The reason we don't have code in the manual is that we've created a whole application note section here. There are just too many languages to stuff into an already rather lengthy manual, so we've stored a number examples in an ever expanding section on our .ca site.

Thanks,
Troy
Troy Clark
Design & Development
Matrix Orbital

Post Reply