Pages: [1]   Go Down
Author Topic: Sparkfun serLCD v2.5 connectivity issues.  (Read 1850 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 35
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just got a Spark Fun serial enable LCD for use with my power monitor project.  The problem is that if I just leave the LCD screen plugged in and I upload new code, or I just hit the reset button the screen just dies out on me.  I'm running the LCD over a soft serial connection.  If after I've performed a reset I pull the ground then plug it back in I'm in business, which makes me think it may be something in my setup loop but I'm not finding what it could be.  Anyone have any ideas?  The code I'm using is found below:

Code:
#include <SoftwareSerial.h>

//setup my pins
#define rxPin 5
#define txPin 4
#define Relay 7

//initialize my interrupt
volatile int state = LOW;

//initialize my software serial port.
SoftwareSerial LCD =  SoftwareSerial(rxPin, txPin);
byte pinState = 0;


void setup()
{
  //define my pinmodes
  pinMode(Relay, OUTPUT);
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  
  //attach my interupt
  attachInterrupt(0, control, CHANGE);
  
  // set the data rate for the SoftwareSerial port
  LCD.begin(9600);
  delay(100);
  
  //turn backlight on
  backlightOn();
  
  //clear the screen
  clearLCD();

}

void loop()
{
  digitalWrite(Relay, state);
  selectLineOne();
  LCD.print("Relay status: ");
  LCD.print(state);
  delay(500);
}

void control()
{
  state = !state;
}

void clearLCD(){
  LCD.print(0xFE, BYTE);   //command flag
  LCD.print(0x01, BYTE);   //clear command.
}
void backlightOn(){  //turns on the backlight
  LCD.print(0x7C, BYTE);   //command flag for backlight stuff
  LCD.print(157, BYTE);    //light level.
}
void backlightOff(){  //turns off the backlight
  LCD.print(0x7C, BYTE);   //command flag for backlight stuff
  LCD.print(128, BYTE);     //light level for off.
}
void backlight50(){  //sets the backlight at 50% brightness
  LCD.print(0x7C, BYTE);   //command flag for backlight stuff
  LCD.print(143, BYTE);     //light level for off.
}
void serCommand(){   //a general function to call the command flag for issuing all other commands  
  LCD.print(0xFE, BYTE);
}

//SerialLCD Functions
void selectLineOne(){  //puts the cursor at line 0 char 0.
  LCD.print(0xFE, BYTE);   //command flag
  LCD.print(128, BYTE);    //position
}
void selectLineTwo(){  //puts the cursor at line 2 char 0.
  LCD.print(0xFE, BYTE);   //command flag
  LCD.print(192, BYTE);    //position
}
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I am having the exact same problem using the NewSoftSerial library. Does anyone know how to fix this? Is it a timing issue during setup?
Logged

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

The SoftwareSerial library is obsolete. You should be using the NewSoftSerial library. I have a sparkfun serial LCD and I don't have these issues using NewSoftSerial.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello PaulS,

thanks for your reply. I am already using NewSoftSerial, as written above. I tried it again after rebooting, rewiring, crossing fingers and doing a little rain dance and now it works like a charm. I am not sure what I did wrong though :/

Thx again
Logged

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

Knock off the rain dancing. We've had enough already.

Go do a sun dance, instead. Please.

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 10
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

And I found that your screen will go dark and freeze with something like:

       LCD.print(0x7C, BYTE);   //command flag for backlight stuff
       LCD.print(backlight_level, BYTE);  // Sets the backlight level
       LCDmessage("LCD bcklt level is:",backlight_level); // Prints current backlight level

Printing right after adjusting backlight is something the LCD backpack doesn't like.

This minor delay will solve the problem:

       LCD.print(0x7C, BYTE);   //command flag for backlight stuff
       LCD.print(backlight_level, BYTE);
       delay(5);   // Prevents the LCD from freezing
       LCDmessage("LCD bcklt level is:",backlight_level);      
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3942
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Bingo!  Thanks a million!  Just got one of these displays (V2.5) and this issue adjusting the backlight was driving me crazy.  Otherwise the thing seems to work well and I had it jumping through most of the hoops.  I was able to get by with a delay as short as 2mS, but 1mS was not enough.  But I'm going with 5mS as in your example, figuring that'll give a little added safety margin.

Not sure whether if this is a bug or a feature  smiley-wink but it definitely should be documented!

SoftwareSerial and NewSoftSerial seem to work identically for me, at least as far as my little test (Arduino Uno, IDE ver 0022).
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

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

Quote
SoftwareSerial and NewSoftSerial seem to work identically for me, at least as far as my little test (Arduino Uno, IDE ver 0022).
NewSoftSerial has advantages, though. It supports much higher speeds (up to 57600) and has an available() method to report whether there is data to read.
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3942
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That's what I gather.  I'm new to Arduinos (and loving it!), but saw a lot of references to NewSoftSerial so I downloaded it to try it out.  Just taking baby steps at this point, so probably not doing anything that stretches the capabilities of SoftwareSerial.  My little test sketch is 2364 bytes with SoftwareSerial and 4068 bytes with NewSoftSerial.  SoftwareSerial does have the available() method as well.

What I haven't seen is an "official" status of SoftwareSerial.  Is it still being actively developed and maintained?  Maybe it's been abandoned given that NewSoftSerial seems to gathered a fair amount of steam.  If so, that might be good reason to avoid it as well.

Appreciate your input!
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Pages: [1]   Go Up
Jump to: