Pages: [1]   Go Down
Author Topic: Working with a Mega and a CrystalFontz 634 serial display  (Read 447 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello everyone!

I am working with a Mega and a Crystalfontz 634 serial display.

The display is a model SKD204-634SG-LG which is older and no longer supported but has the same settings as the newer 634 displays.  The datasheet can be found here: http://www.crystalfontz.com/products/document/342/

I have JPB and JPE closed and I am able to display text on the screen.  Using the serial.print("whatever i want to show up"); command I can send text easily.

My issue being that whenever I try to issue commands using the Serial.write(); I am hitting a wall, mostly I presume that because I haven't programmed in a while but whenever I send something like put the cursor at this spot on this line it's not working properly.

Serial.write(17,010,02); //should put my character in column 10 row 3 but it's not because this generates a compile error

Serial.write(17);
Serial.write(10);
Serial.write(2);  The crystalfontz forum suggested sending the commands like this but it won't work properly either because as it turns out I am issuing 3 commands.

According to the documentation:

Send "Control+Q" followed by one byte for the column (0-19),
and a second byte for the row (0-3). The upper-left position
is 0,0. The lower-right
position is 19,3.
For example, to move the cursor to column 11 of the second line: sending the commands as \017\010\001

Sending \017\010\001 to the display does exactly that, it displays \017\010\001

Anyone have any suggestions?  I know there are newer displays available and if I absolutely have to I will buy one but I have had this one sitting in a box just waiting to be used.

Thanks in advance!

Mike
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 615
Posts: 49386
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Serial.write() has an overload that takes an array and the number of values in the array to write. Perhaps you could use that.

However, putting data on the serial port using 3 write() calls results in EXACTLY the same data. Unless you are doing something in between. Like trying to use the serial port for the LCD and for debugging (to the PC).

Another thing to keep in mind is that 10 and 010 are not the same value.

Posting some real code is a good idea.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You are correct, I'll post the code I am using tonight after I get home.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is just a simple rtc clock test that I modified to check output to my lcd

"/* YourDuino.com Example Software Sketch
 DS1307 Real Time Clock test
 CONNECTIONS:
 Ground
 +5V
 -----(Arduino) (Mega) ------
 SDA  Analog A4   20
 SCL  Analog A5   21
 
 Based on: http://github.com/adafruit/RTClib
 Also see: http://www.ladyada.net/learn/breakoutplus/ds1307rtc.html
 terry@yourduino.com */

/*-----( Import needed libraries )-----*/
#include <Wire.h>
#include "RTClib.h"
#include <SoftwareSerial.h>

SoftwareSerial myLCD(15,14);
/*-----( Declare objects )-----*/
RTC_DS1307 RTC;



void setup()   /*----( SETUP: RUNS ONCE )----*/
{
  pinMode(53, OUTPUT); //This pin used for the 5v on RTC
  pinMode(13, OUTPUT);// This pin is for the LCD backlight
  Serial.begin(9600);  // Ready to print to Serial Monitor 
  delay(500); 
 // Serial.println("YourDuino DS1307 RTC Test. http://yourduino.com");
 myLCD.begin (9600);
  Wire.begin();        // Start the Wire (I2C communications)
  RTC.begin();         // Start the RTC Chip
  digitalWrite(53, HIGH);//enable power for the RTC
  digitalWrite(13, HIGH);//enable power for the backlight
 /* Set the date / time to the time this program was compiled.
    Comment this OUT, AND upload, to let the clock just run.  */
  //RTC.adjust(DateTime(__DATE__, __TIME__));
 
 myLCD.write(26);//Initialize LCD
 
}/*--(end setup )---*/

void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
{
  DateTime now = RTC.now();  //Get the current data
 
 //LCD output
  myLCD.write(12);
  myLCD.print("   Der Sprinkler!   ");
  myLCD.write(13);
 
 
  myLCD.print("Date: ");
  myLCD.print(now.month(), DEC);
  myLCD.print('/');
  myLCD.print(now.day(), DEC);
  myLCD.print('/');
  myLCD.print(now.year(), DEC);
  myLCD.write(5);
   
  myLCD.print("Time:");
  myLCD.print(now.hour(), DEC);
  myLCD.print(':');
  myLCD.print(now.minute(), DEC);
  myLCD.print(':');
  myLCD.print(now.second(), DEC);
  //myLCD.write(30);
 
 
 
  delay(1000);
}"
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is just a simple rtc clock test that I modified to check output to my lcd

Quote
"/* YourDuino.com Example Software Sketch
 DS1307 Real Time Clock test
 CONNECTIONS:
 Ground
 +5V
 -----(Arduino) (Mega) ------
 SDA  Analog A4   20
 SCL  Analog A5   21
 
 Based on: http://github.com/adafruit/RTClib
 Also see: http://www.ladyada.net/learn/breakoutplus/ds1307rtc.html
 terry@yourduino.com */

/*-----( Import needed libraries )-----*/
#include <Wire.h>
#include "RTClib.h"
#include <SoftwareSerial.h>

SoftwareSerial myLCD(15,14);
/*-----( Declare objects )-----*/
RTC_DS1307 RTC;



void setup()   /*----( SETUP: RUNS ONCE )----*/
{
  pinMode(53, OUTPUT); //This pin used for the 5v on RTC
  pinMode(13, OUTPUT);// This pin is for the LCD backlight
  Serial.begin(9600);  // Ready to print to Serial Monitor 
  delay(500); 
 // Serial.println("YourDuino DS1307 RTC Test. http://yourduino.com");
 myLCD.begin (9600);
  Wire.begin();        // Start the Wire (I2C communications)
  RTC.begin();         // Start the RTC Chip
  digitalWrite(53, HIGH);//enable power for the RTC
  digitalWrite(13, HIGH);//enable power for the backlight
 /* Set the date / time to the time this program was compiled.
    Comment this OUT, AND upload, to let the clock just run.  */
  //RTC.adjust(DateTime(__DATE__, __TIME__));
 
 myLCD.write(26);//Initialize LCD
 
}/*--(end setup )---*/

void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
{
  DateTime now = RTC.now();  //Get the current data
 
 //LCD output
  myLCD.write(12);
  myLCD.print("   Der Sprinkler!   ");
  myLCD.write(13);
 
 
  myLCD.print("Date: ");
  myLCD.print(now.month(), DEC);
  myLCD.print('/');
  myLCD.print(now.day(), DEC);
  myLCD.print('/');
  myLCD.print(now.year(), DEC);
  myLCD.write(5);
   
  myLCD.print("Time:");
  myLCD.print(now.hour(), DEC);
  myLCD.print(':');
  myLCD.print(now.minute(), DEC);
  myLCD.print(':');
  myLCD.print(now.second(), DEC);
  //myLCD.write(30);
 
 
 
  delay(1000);
}"
Logged

0
Offline Offline
Shannon Member
****
Karma: 207
Posts: 12194
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Serial.write(17,010,02); //should put my character in column 10 row 3 but it's not because this generates a compile error
write() is not varargs like that.  There is a write (byte*, int len) I think.
Quote
Serial.write(17);
Serial.write(10);
Serial.write(2);  The crystalfontz forum suggested sending the commands like this but it won't work properly either because as it turns out I am issuing 3 commands.
Nevermind what they suggested, did it work??  I cannot see why it shouldn't work as it just sends 3 bytes down the serial link.

Quote
According to the documentation:

Send "Control+Q" followed by one byte for the column (0-19),
and a second byte for the row (0-3). The upper-left position
is 0,0. The lower-right
position is 19,3.
For example, to move the cursor to column 11 of the second line: sending the commands as \017\010\001

Sending \017\010\001 to the display does exactly that, it displays \017\010\001
What code did you try?  C has octal or hex escape codes so you'd need either "\021\012\001" or "\x11\x0A\x01" anyway.  The notation in that pdf isn't C.
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

After nearing my wit's end this code is working the way I want it to with one exception.

I can place the info on any line I want except whenever I try to put something on line 0 or in column 0

myLCD.write(17);//Set cursor position command
myLCD.write(10);//This is for my column placement
myLCD.write(0);//should put my cursor on row 0 but instead I get an error "call of overloaded 'write(int)' is ambiguous" when I check the code or compile

using myLCD.write(); won't work either  smiley-confuse


Quote
/* YourDuino.com Example Software Sketch
 DS1307 Real Time Clock test
 CONNECTIONS:
 Ground
 +5V
 -----(Arduino) (Mega) ------
 SDA  Analog A4   20
 SCL  Analog A5   21
 
 Based on: http://github.com/adafruit/RTClib
 Also see: http://www.ladyada.net/learn/breakoutplus/ds1307rtc.html
 terry@yourduino.com */

/*-----( Import needed libraries )-----*/
#include <Wire.h>
#include "RTClib.h"
#include <SoftwareSerial.h>

SoftwareSerial myLCD(15,14);
/*-----( Declare objects )-----*/
RTC_DS1307 RTC;



void setup()   /*----( SETUP: RUNS ONCE )----*/
{
  pinMode(53, OUTPUT); //Apply 5v to pin 53 for clock
  pinMode(13, OUTPUT);
  Serial.begin(9600);  // Ready to print to Serial Monitor 
  delay(500); 
 // Serial.println("YourDuino DS1307 RTC Test. http://yourduino.com");
 myLCD.begin (9600);
  Wire.begin();        // Start the Wire (I2C communications)
  RTC.begin();         // Start the RTC Chip
  digitalWrite(53, HIGH);
  digitalWrite(13, HIGH);
 /* Set the date / time to the time this program was compiled.
    Comment this OUT, AND upload, to let the clock just run.  */
  //RTC.adjust(DateTime(__DATE__, __TIME__));
 
 myLCD.write(26);
 
}/*--(end setup )---*/

void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
{
  DateTime now = RTC.now();  //Get the current data
 

  // LCD output
  myLCD.write(12);
  myLCD.print("   Der Sprinkler!   ");
  myLCD.write(13);
 
  myLCD.print(now.month(), DEC);
  myLCD.print('/');
  myLCD.print(now.day(), DEC);
  myLCD.print('/');
  myLCD.print(now.year(), DEC);
 
  myLCD.write(17);
  myLCD.write(12);
  myLCD.write(1);
   
  myLCD.print(now.hour(), DEC);
  myLCD.print(':');
  myLCD.print(now.minute(), DEC);
  myLCD.print(':');
  myLCD.print(now.second(), DEC);
  //myLCD.write(30);
 
  myLCD.write(19);

 
  delay(1000);
}
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 615
Posts: 49386
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
myLCD.write(0);//should put my cursor on row 0 but instead I get an error "call of overloaded 'write(int)' is ambiguous" when I check the code or compile
Since YOU know that the value should be sent as a byte, why not tell the compiler that? There are several ways. A couple:
Code:
byte zero = 0;
myLCD.write(zero);

or

Code:
myLCS.write((byte)0);
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
myLCD.write(0);//should put my cursor on row 0 but instead I get an error "call of overloaded 'write(int)' is ambiguous" when I check the code or compile
Since YOU know that the value should be sent as a byte, why not tell the compiler that? There are several ways. A couple:
Code:
byte zero = 0;
myLCD.write(zero);

or

Code:
myLCS.write((byte)0);

Paul I tried this
Code:
myLCD.write((byte)0);
and it worked like a charm!  Thank you so much!
Logged

Pages: [1]   Go Up
Jump to: