Three wire Serial LCD - new line issue

I selected a three wire LCD (2x16) as I thought it maybe the simplest to drive.

I purchased a LONGTECH LCD with a serial back-board. all works as expected except I can't force a new (second) line. Text wraps OK, but

void setup(){

  Serial.begin(9600);
  Serial.print(254,BYTE);
  Serial.print(0x48,BYTE); //start up LCD
  delay(50);

  clearLCD();

  Serial.print(254,BYTE);
  delay(50);
  Serial.print("firstline");


  newLine();

  Serial.print(254,BYTE);
  delay (50);
  Serial.print("secondline");

}

void newLine()
{
  Serial.print(254, BYTE);
  delay(50);
  Serial.print(0xC0,BYTE); // 0xC0 doesn't work
  
}

void clearLCD()
{
  Serial.print(254, BYTE);
  Serial.print(0x51, BYTE);
}

void loop(){

}

I have also found that I need to put delays every where or some text is missed.

0xC0 doesn't work. Also the data sheet that comes with the serial board shows how to set the cursor at a specific location - that doesn't work either.

I welcome an comments

// move the cursor to a specific place
// e.g.: cursorSet(3,2) sets the cursor to x = 3 and y = 2
void cursorSet(int xpos, int ypos)
{  
#define HSIZE 16
#define VSIZE 2
  int pos;
  pos = (ypos * HSIZE) + xpos;
  pos += 0x80;

  // cur pos still broken
  Serial.print(pos, HEX);

  Serial.print(254, BYTE);
  Serial.print(pos, BYTE);
}

doesn't work....

A link to the data sheet for the serial back-board would be a help.

Don

Sorry .. link to datasheet

www.vintagecomputercables.com/datasheet/LCDRS2.pdf

Also the following was provided by the supplier of the LCD. All seems to work other the new line and set cursor.

//  *
//  * ------------
//  *  Control a Serial LCD Display
//  *  
//  *  Tested on a Matrix Orbital model LCD0821 display.
//  *  Other diplays will work but may have slightly different 
//  *  command codes and hardware setups. 
//  *   
//  *  Copyleft 2006 by djmatic 
//  *  
//  *   ------------
//  *
//  *


// Declare your program variables here


// Arduino and LCD setup 

void setup()
{
  Serial.begin(9600);
  Serial.print(254, BYTE);
  Serial.print(0x48, BYTE);    
  backlightOn();  
}




//  MAIN CODE

void loop()
{ 
   //backlightOn();  // turn the backlight on all the time
   clearLCD();
   Serial.print("toysdownunder.com");  
   delay(5000);
  
}

void shiftLeft() {
  Serial.print(0xFE,BYTE);
  Serial.print(0x55,BYTE);
  Serial.print(0,BYTE);
}


//  LCD  FUNCTIONS-- keep the ones you need. 

// clear the LCD
void clearLCD(){
  Serial.print(0xFE, BYTE);
  Serial.print(0x51, BYTE);
}

// move the cursor to the home position
void cursorHome(){
  Serial.print(254, BYTE);
  Serial.print(70, BYTE);
}

void newLine(){
  cursorSet(0,1);
}

// move the cursor to a specific place
// e.g.: cursorSet(3,2) sets the cursor to x = 3 and y = 2
void cursorSet(int xpos, int ypos){  
  Serial.print(254, BYTE);
  Serial.print(69, BYTE);               
  Serial.print(xpos);   //Column position   
  Serial.print(ypos); //Row position 
} 


// backspace and erase previous character
void backSpace() { 
  Serial.print(78, BYTE);
  Serial.print(8, BYTE); 
}


// move cursor left
void cursorLeft(){    
  Serial.print(254, BYTE); 
  Serial.print(73, BYTE);   
}


// move cursor right
void cursorRight(){
  Serial.print(254, BYTE); 
  Serial.print(74, BYTE);   
}


// turn on backlight
void backlightOn(){
  Serial.print(0xFE, BYTE); 
  Serial.print(0x52, BYTE);      
}


// turn off backlight
void backlightOff(){
  Serial.print(0xFE, BYTE); 
  Serial.print(0x53, BYTE);   
}

kend:

In the example code posted in Reply #2 you will see that they use a combination of decimal and hex values in their Serial.print() statements. It will help if you convert all of the decimal values to hex since their Command Summary on page 11 only shows the hex values. Follow the expanded [u]ASCII chart[/u] link at http://web.alfredstate.edu/weimandn if you aren't fluent in hex.

The value 254 is the same as 0xFE and that this is the prefix that tells the LCD back-board controller that the next byte is a command to be executed rather than a character to be displayed.

void newLine()
{
  Serial.print(254, BYTE);
  delay(50);
  Serial.print(0xC0,BYTE); // 0xC0 doesn't work

}

Why should it work? I don't understand where the 0xC0 comes from. According to the command summary on page 11 all of the commands fall in the range 0x41 - 0x58.

The controller on the LCD display does not have a 'new line' command so it is not likely that the back-board controller will have one either. You will probably have to specifically set the cursor to the beginning of the second line. Have you tried their cursorSet() routine?

Don

you would expect it to use CR or LF instead of 0xC0. Have you tried those? CR is decimal 13, LF is decimal 10.