Go Down

Topic: 16x2 Display displays random symbols after a few iterations. (Read 535 times) previous topic - next topic

eevje

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);
   }
}

floresta

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

floresta

Quote
Code: [Select]
      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

Go Up