Pages: [1]   Go Down
Author Topic: 16x2 Display displays random symbols after a few iterations.  (Read 170 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've pasted the relevant part of my code below. The DoControl command is part of the PID library. Every ten seconds, I command it to log the input, and output in percent to the screen. However, it will often display random symbols, scroll these random symbols, and make it impossible to interface with the screen. However, it will often return to normal after several more iterations of the while loop. I am uncertain what is causing this. Thanks.

void Run()
{
 
  startTime = millis();
  lastLogTime = millis();
 
  lcd.clear();
  lcd.setCursor(0,0);
  //Write Set Point to Screen
  lcd.print("Sp: ");
  lcd.print(Setpoint);
  lcd.write(1);
  lcd.print("C   ");

   SaveParameters();
   myPID.SetTunings(Kp,Ki,Kd);

   
   while(true)
   {
   
     buttonStateRight = digitalRead(buttonPinRight);
     buttonStateLeft = digitalRead(buttonPinLeft);
     
      if (buttonStateRight == buttonStateLeft  && buttonStateRight == HIGH)
      {
         delay(200);
         opState = MENU;
         return;
      }
     
     if (tuning)
        {
        lcd.clear();
        lcd.print(F("Tuning..."));
        }
       
     
      DoControl();
     
      if (millis() - lastLogTime > logInterval) 
      {
       
      //Write Input To Screen 
      lcd.setCursor(0,1);
      lcd.print(Input);
      lcd.write(1);
      lcd.print("C : ");
      //Write output percent to Screen
      float pct = map(Output, 0, WindowSize, 0, 1000);
      lcd.setCursor(10,1);
      lcd.print(pct/10);
      //lcd.print(Output);
      lcd.print("%   ");
      //Log Data to Serial
      lastLogTime = millis();
      Serial.print((millis() - startTime)/10000);
      Serial.print("           ");
      Serial.print(Input);
      Serial.print("           ");
      Serial.print(Output/100);
      Serial.print("           ");
      Serial.println(Setpoint);
       
      }

      delay(100);
   }
}
Logged

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

Quote
I've pasted the relevant part of my code below.
Maybe so and maybe not.

You really should post all of your code, and you should enclose your code in 'code' tags (use the octothorpe symbol).


Don
Logged

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

Quote
Code:
      lcd.write(1);
      lcd.print("C : ");
My crystal ball tells me that you are using a custom character for the 'degree' symbol.  You might want to see if your LCD controller already has such a symbol.  Typically it is at address 0xDF.

Don
Logged

Pages: [1]   Go Up
Jump to: