Hello,
The purpose of this post is to pick peoples brains for ideas to overcome a problem I have. There will be many ways to skin the cat, but I just want some ideas to try.
I have a LCD (24x8) character LCD which talks RS232 or TTL Serial, at a fixed 19200 Baud. For this test, I am using a 644P, just because it has 2 Serial ports. I have written some crude libraries for it for large fonts (4x3, 3x3, 2x2) and I am just playing with code at the moment to determine the most efficient way to sent this thing data.
I did a simple test, write to the LCD every loop, writing a few updated variable values to the screen, taking up about 90% of the characters on the screen. I then wrote to the terminal each loop, I had the baud on that set to 19200 also, however put it up to 115200 and had the same result.
What I experienced was the terminal data got updated maybe 3 times a second (lets say that just for arguements sake). The LCD was also updated at this rate.
So it appears that the 19200 baud is slowing down the whole process. If I disconnect the screen and attach it to the computer also, I get the same result. If I then increase the baud rate, the updates then become quicker. I am not loosing data though - from what I can tell. The numbers are still flowing in sequentially (my variables are just Var++ type things each loop).
I am just wondering what is the bottleneck. Is the serial buffer filling up, and therefore it is slowing the processor down? Or is it the serial commands just take that long to execute? Or is it something else.
I am just trying to understand, and then determine the most efficient way to keep an LCD like this updated with data, while not dragging down the uC from computing other stuff.
I could just update the things that have changed on the screen, rather than writing the whole screen at once... I could write every 0.5 seconds or something to the screen, but in doing that I get fast data on the Terminal, and then it stops as the LCD is updated, and then goes fast again. I am just not sure what the bottle neck is.
Code wise, yes I could post the code, but its nothing special what-so-ever. If we ignore the crude libraries I made and just populate the LCD with data, the result would be very similar.
Something like this: (sorry I dont have the code on me at work). Hopefully you get the gist.
int Var1 = 0;
int Var2 = 123;
int Var3 = 745;
int Var4 = 12;
int Var5 = 512;
void setup()
{
Serial.begin(115200); //Serial to Terminal
Serial1.begin(19200); //Serial to LCD
}
void loop()
{
Serial.print("Variable 1 = ");
Serial.println(Var1);
Var1++;
if(Var1 > 10000)
{
Var1 = 0;
}
/**********************LINE 1 of LCD**********************/
//LCD Position 0,0
Serial1.print(0x5C,BYTE);
Serial1.print(0x42,BYTE);
Serial1.print(32,DEC);
Serial1.print(32,DEC);
Serial1.print("Variable 2 = ");
//LCD Position 13,0
Serial1.print(0x5C,BYTE);
Serial1.print(0x42,BYTE);
Serial1.print(45,DEC);
Serial1.print(32,DEC);
Serial1.print(Var2);
Var2++;
if(Var2 > 10000)
{
Var2 = 0;
}
/**********************LINE 2 of LCD**********************/
//LCD Position 0,1
Serial1.print(0x5C,BYTE);
Serial1.print(0x42,BYTE);
Serial1.print(32,DEC);
Serial1.print(33,DEC);
Serial1.print("Variable 3 = ");
//LCD Position 13,1
Serial1.print(0x5C,BYTE);
Serial1.print(0x42,BYTE);
Serial1.print(45,DEC);
Serial1.print(33,DEC);
Serial1.print(Var3);
Var3++;
if(Var3 > 10000)
{
Var3 = 0;
}
/**********************LINE 3 of LCD**********************/
//LCD Position 0,2
Serial1.print(0x5C,BYTE);
Serial1.print(0x42,BYTE);
Serial1.print(32,DEC);
Serial1.print(34,DEC);
Serial1.print("Variable 4 = ");
//LCD Position 13,2
Serial1.print(0x5C,BYTE);
Serial1.print(0x42,BYTE);
Serial1.print(45,DEC);
Serial1.print(34,DEC);
Serial1.print(Var4);
Var4++;
if(Var4 > 10000)
{
Var4 = 0;
}
/**********************LINE 4 of LCD**********************/
//LCD Position 0,3
Serial1.print(0x5C,BYTE);
Serial1.print(0x42,BYTE);
Serial1.print(32,DEC);
Serial1.print(35,DEC);
Serial1.print("Variable 5 = ");
//LCD Position 13,3
Serial1.print(0x5C,BYTE);
Serial1.print(0x42,BYTE);
Serial1.print(45,DEC);
Serial1.print(35,DEC);
Serial1.print(Var5);
Var5++;
if(Var5 > 10000)
{
Var5 = 0;
}
}
Purely a learning exercise, to know what the bottleneck is and how to write code to write to the LCD without slowing the whole uC down, effecting everything else it is doing.
Thanks