Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] PIC and HD44780 display "ghost" characters

Status
Not open for further replies.

Veketti

Full Member level 3
Full Member level 3
Joined
Sep 14, 2014
Messages
164
Helped
0
Reputation
0
Reaction score
0
Trophy points
16
Activity points
1,700
Dear All,

I have been struggling to custom clear HD44780 compliant display with MikroC and PIC mikrocontroller. Issue is characters left from previous command in the display. I don't want to run "Lcd_Cmd(_LCD_CLEAR);" as it makes the display flicker. Eg. I show "Intake Eff: xx.x %". "Intake Eff:" doesn't change but the numbers after that do change. I can for example use "Lcd_Out(1, 15, 37);" to get the % sign to always to the last column but if the numbers change say two digit to one digit the ghost digit will stay there. How have you overcome this? I'm thinking is the only way to check the length of the char variable and somehow make it always say 5 characters long by filling the empty values with spaces?

Thank you in advance.
 

'Ghost' character are usually a en electro-chemical effect where a previously displayed character is still showing AFTER it has been over written, I think in this case you are referring to the previous contents that have not been overwritten.

Rather than clear the whole display, can you use cursor positioning so you only update part of the display then use print formatting commands to set the field width of the number you are writing. It should overwrite the previous contents, with leading zeroes or spaces are required.

For example: printf(< string >,"Intake Eff: %02.2f %",< the value you want to print >); then print the 'string' to the LCD.

Brian.
 

Try this.

Code:
IntToStr(intValue, str);
Ltrim(str);
strcat(str, "  ");
Lcd_Out(1,12,str);

If you are using say PIC16F877A then mikroC doesn't have sprintf() library for it and you have to use IntToStr() or FloatToStr() but if you are using PIC18F then you can use sprintf() library and neatly format the output string for fixed width.
 

I'm thinking is the only way to check the length of the char variable and somehow make it always say 5 characters long by filling the empty values with spaces?

Something like this. Or, probably more straightforward, using sprintf() formatting to generate the intended output.

I agree that LCD_Clear is usually unwanted. But you can perform a smooth clear by writing out full display lines filled up with spaces.
 

Sorry - should have written 'sprintf' rather than 'printf'. I wasn't aware MikroC didn't include it in the 16F library although I can understand why.
printf and sprintf normally allow fixed length fields so they are a safe and reliable way to produce the required characters to completely overwrite the previous text.

Brian.
 

This forum is Awesome. So helpful persons.

I'm indeed using 16F series pic so no sprintf.
baileychic, tried your code, but it messed up the content and show various symbols instead of the numbers.

I can have it somehow work correctly by this:
Code:
char PI_EffChar[30];
float PI_Eff;
...
Float2Ascii(PI_Eff, PI_EffChar, 1);
 ...
 Lcd_Out(1,1,"P.I. hs:");
 Lcd_Out_Cp(PI_EffChar);
 Lcd_Out_Cp("   ");
 Lcd_chr(1,15,37);
...

Basically writing spaces after the content of PI_EffChar variable and then writing "%" sign to the second last column of the display. But then the percentage sign flickers as first that position is written with empty and right after that % sign. There must be some better way to do this?
 

Dear All,
if the numbers change say two digit to one digit the ghost digit will stay there.
You just need to cover up 1's place digit that didn't get over written. Write the number and a space or 2 spaces if you ever have a 3 digit number.
Unless you really want the % sign in the same column all the time, I would write the number and a space % sign and a space (or 2).
 

Ok, I got it working with this:
Code:
int LengthOfString;
Lcd_Out(1,1,"P.I. hs:");
LengthOfString = strlen(PI_EffChar);
LengthOfString = LengthOfString+9;
Lcd_Out_Cp(PI_EffChar);
Lcd_Out(1,LengthOfString,"%     ");

But when I tried to use for -loop to fill the rest with spaces it end up in error "Pointer required".
Code:
void EfficiencyDisplay(char PI_EffChar, char TI_EffChar)
{
     int LengthOfString,i;
     LengthOfString = strlen(PI_EffChar);
     for (i=LengthOfString ; I == 9 ; i++) PI_EffChar[i] = ' ';

Even if I set the value of PI_EffChar to another char inside the procedure it doesn't work. Eg. PI_EffChar2 = PI_EffChar; it will then say "assigning to non-lvalue". How should this for loop be correctly done in this case?
 

Ok, got it. Found very nice tutorial which tells there are 3 ways of passing arrays to functions:
Link

So basically I was missing [] from the procedure declaration.

Here's the functional code:
Code:
void EfficiencyDisplay(char PI_EffChar[], char TI_EffChar[])
{
     int LengthOfString,i;
     LengthOfString = strlen(PI_EffChar)-2; // get the length of string. Minus 2 as the decimal is not needed.
     for (i=LengthOfString ; I < 9 ; i++)
     {
      if (i == LengthOfString) {
         PI_EffChar[i] = 37; // First is % sign
      }
      else PI_EffChar[i] = 32; // Then the rest is spaces
     
     }
     Lcd_Out(1,1,"P.I. hs: ");
     Lcd_Out_Cp(PI_EffChar);

Still don't get it why I wasn't able to assing string array to another one inside the procedure.. But nevermind, that's not needed.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top