Pages: [1]   Go Down
Author Topic: 16x2 LCD Scrolling Half-Nonsense, Searching Google No Success, HELP Requested :)  (Read 892 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 37
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It was recommended I shorten my spiel, so let me summarize my problem.

I have an UNO setup running code to turn a few relays on and off.  It's a timer mechanism for this larger machine.

THE PROBLEM:

I had all of this running, originally. It was great. Every 2 hours or so, I would have an issue with the LCD characters going "nonsense" but the addition of 10nF caps on the LCD power helped limit the problem.

Trouble is, I had to modify the system for larger relays. I didn't change anything, *honestly.* I just put in some new relay boards with slightly higher current ratings.

Now, I have this new lcd "nonsense" issue. I get what looks roughly like the characters i'm supposed to be getting, but a few artifacts and this persistent "scrolling" issue. You can see in my code I never use the scrolling function of the library.  I'll try to add pictures soon.

I'm running one of the standard Microtivity 16x2 LCDs.  I bought it off Amazon. I don't think it's the source of the problems,

I have:
Tried a second LCD. Same exact problem.
Inspected all the wiring for frays or PCB problems. nothing.

Still Considering:
Rewiring everything??
Switching out my Atmega328??
NO IDEA:(

I will:
Upload a picture, soon.
See uploaded pictures, below.

MY CODE IN SUMMARY:
Code:
#include <LiquidCrystal.h>
 long StartTime;
 int debounce = 1200;
 int reading;
 int previous;
 int bounceTime;
 int state;
LiquidCrystal lcd(7, 8, 9, 10, 11,12);
void setup() {
pinMode(BeginSwitch,INPUT);
lcd.begin(16, 2);
delay(50);
lcd.print("Hello,*****!");
delay(750);
}

void loop(){
 //BEGINING POTIOMETER TIMING SECTION
digitalWrite(PressPower,HIGH);
digitalWrite(PressPower2,HIGH);
digitalWrite(FanPower,LOW);
digitalWrite(PressLight,LOW);
  // Next, Convert the analog readings (which go from 0 - 1023) to a time (0- 180) minutes:
state = HIGH;
digitalWrite(BeginSwitch,HIGH);        //This sets a pull-up resistor on begin switch.
do{                          
  int Potvalue2 =(analogRead(Pot2));
  Time= (Potvalue2*(180/1023.0));
  lcd.clear();
  lcd.print("Inputing Timer");
  lcd.setCursor(2,2);
  lcd.print(Time,DEC);
  lcd.setCursor(6,2);
  lcd.print("minutes");
  delay(200);
  reading = digitalRead(BeginSwitch);                                            
if (reading != previous) {
    // reset the debouncing timer
    bounceTime = millis();
  }
  if ((millis() - bounceTime) > debounce) {
    state = reading;
  }
  previous = reading;  
}while(state==HIGH);
 //End BeginSwitchState section statement
delay(250);   //Trying to avoid the bounce of the switch.
lcd.clear();
lcd.print("Switch to Power");
  StartTime=millis();

MY CODE IN FULL:  

Code:
[size=6pt]#include <LiquidCrystal.h>
const int PressPower = 18;  //
const int PressPower2 =19;  //A0 = pin 14, A1=15,A2=16,A3=17,A4=18,A5=19
const int Pot2 = A2;   //Pot2 is actually the only pot.  (Originally there was a course and fine adjust, but the fine was enough.)
const int BeginSwitch = 3;
/* Begin switch will be a switch "Open" if timing is to be measured,
"closed" if timing is finished measuring". I.E,  I'm pulling it from 5v to 0v
when the switch is pressed. This is so I can use the internal pull-up*/
//NOTE: IF TROUBLE UPLOADING: Disconnect pins 0 and 1 during the upload. They can interfere sometimes.
 long Time;
 long FanDuration;
 long FanCountDown;
 long FanTime;
 long StartTime;
 long PressEndTime;
 int debounce = 1200;
 int reading;
 int previous;
 int bounceTime;
 int state;
const int PressLight =13;
const int FanPower = 2; //We avoid Pihn 13, for now, because of built in LED
LiquidCrystal lcd(7, 8, 9, 10, 11,12);
void setup() {
    // put your setup code here, to run once:
digitalWrite(PressPower,HIGH);
digitalWrite(PressPower,HIGH);
pinMode(BeginSwitch,INPUT);
pinMode(PressPower,OUTPUT);
pinMode(PressPower2,OUTPUT);
pinMode(FanPower,OUTPUT);
pinMode(PressLight,OUTPUT);
pinMode(Pot2,INPUT);
lcd.begin(16, 2);
delay(50);
lcd.print("Hello,*****!");
delay(750);
}

void loop(){
 //BEGINING POTIOMETER TIMING SECTION
digitalWrite(PressPower,HIGH);
digitalWrite(PressPower2,HIGH);
digitalWrite(FanPower,LOW);
digitalWrite(PressLight,LOW);
  // Next, Convert the analog readings (which go from 0 - 1023) to a time (0- 180) minutes:
state = HIGH;
digitalWrite(BeginSwitch,HIGH);        //This sets a pull-up resistor on begin switch.
do{                          
  int Potvalue2 =(analogRead(Pot2));
  Time= (Potvalue2*(180/1023.0));
  lcd.clear();
  lcd.print("Inputing Timer");
  lcd.setCursor(2,2);
  lcd.print(Time,DEC);
  lcd.setCursor(6,2);
  lcd.print("minutes");
  delay(200);
  reading = digitalRead(BeginSwitch);                                            
if (reading != previous) {
    // reset the debouncing timer
    bounceTime = millis();
  }
  if ((millis() - bounceTime) > debounce) {
    state = reading;
  }
  previous = reading;  
}while(state==HIGH);
 //End BeginSwitchState section statement
delay(250);   //Trying to avoid the bounce of the switch.
lcd.clear();
lcd.print("Switch to Power");
  StartTime=millis();
  do
    {    
       digitalWrite(PressPower,LOW);          //YOU CAN USE A PULL DOWN RESISTOR TO TRY AND FORCE IT AS GROUND.  I.E, resistor to grn.
       digitalWrite(PressPower2,LOW);
       digitalWrite(PressLight,HIGH);
       lcd.clear();
       long CountDownSeconds = (millis()-StartTime)/1000;  
       long CountDown=Time-(CountDownSeconds/60);
       lcd.print("ON, Countdowns");
       lcd.setCursor(1,2);
       lcd.print(CountDown,DEC);
       lcd.setCursor(3,2);
       lcd.print("mins=");
       lcd.setCursor(8,2);
       long Seconds=(Time*60)-CountDownSeconds;
       lcd.print(Seconds,DEC);
       lcd.setCursor(13,2);
       lcd.print("Sec");
       delay(500);
       PressEndTime=millis();
     }while((millis()-StartTime) < (Time*60*1000));
  digitalWrite(PressPower,HIGH);
  digitalWrite(PressPower2,HIGH);
  digitalWrite(PressLight,LOW);
    do {
    digitalWrite(FanPower,HIGH);
    lcd.clear();
    lcd.print("Fan Time!");
    lcd.setCursor(2,2);
    FanCountDown=(millis()-PressEndTime)/1000;      //"FanCountDown" is actually a count UP.  
    long Timer=(90*60)-FanCountDown;        //FAN COUNTDOWN IN SECONDS
    lcd.print(Timer,DEC);
    delay(500);
    }while(FanCountDown<(90*60));                                                                              
 //END OF FAN POWER SEQUENCE
  digitalWrite(FanPower,LOW);
  delay(1000);
      for(long t=1;t<8667;t++) {
//This should give a 3 day delay before the circuit resets to input (even though the switch is on "GO!", the debounce should be stuck in reading = previous)
//I believe I could just remove the void loop but I decided not to. Will research sleep mode later.
        lcd.clear();
        lcd.print("Done,******!");
        lcd.setCursor(0,2);
        lcd.print("(Turn Off Timer)");
         delay(150000);      
  }  
}//END OF PROGRAM  // Personal Note, you might not need the void loop, since this only runs once
[/size]
« Last Edit: July 30, 2012, 07:46:43 pm by Kinnishian » Logged

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

I should clarify that the rest of the code continues to work properly, even while the LCD goes whack. And I can watch my potentiometer adjust values change,  between all the nonsense characters.

I have an 100nF cap across the gnd and 5v lines, I have a larger cap on thee 12v IN (I was concerned about a voltage drop from when I turn on the fans), and I have a 10nF cap on the LCD logic power lines (which technically I think amounts to having another 10nF cap on the 0v to 5v lines. What can I say? I had a lot of caps lying around.)
« Last Edit: July 30, 2012, 01:54:44 pm by Kinnishian » Logged

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

Images!



Logged

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

Just realized that I may have reduced the delays on each loop. I thought "this is stupid, why delay, if it uses as much processor brain to delay?."  *Finally* I have thought of something that has changed since the original successful implementation.  This could increase the rate of writing to the LCD, thus garbling shit up. I will look try this as a fix.
Logged

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

No beuno. The problems remain.
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 36
Posts: 4327
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You will have a much better chance of getting some help if you condense all of this down to a short description of your problem.  Essentially you should state what display you expected to get and what display you actually did get.

Also - condense the code down to the minimum amount that still demonstrates the problem.


Don
« Last Edit: July 30, 2012, 07:01:00 pm by floresta » Logged

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

Sure, I'll do both.
Logged

Pages: [1]   Go Up
Jump to: