Wired LCD characters

Thread Starter

R!f@@

Joined Apr 2, 2009
9,918
This is a new problem and I am running out of ideas.

My VA meter is functioning as I wanted except for the proper display part.
That is the wrong messages are coming.

At first I used around 4 msgs and it worked fine.

The VA part uses pointers and "char *Vout" to take out the calculated voltage character by character and display them on LCD.

I removed the over load since I figured I will have current limit which is aslo an overload protection already build in. So I went for over heat shut down.
This part also works and displays proper msgs till it cools down.
All good.

Problem occurs when I added extra 4 msgs at startup of the supply which is only one time.

It was there before but as the code grew the LCD started giving out wrong display all thru out.

The displayed voltage or current shows wrong characters now.

I can fix this if I do not use the start up msgs.
The 4 first time msg that shows the model, spec, owner and version is creating the problem.
If I comment out the " Display_Model();"
which is
Rich (BB code):
char txt1[] = "EvilWorks PS600W";
char txt2[] = "0-23V,0-8(10)A";
char *Vout = "00.00";
char *Iout = "00.00";

// Model Information and spec
void Display_Model(){
     Lcd_Out(1,1,txt1);
     Delay_ms(400);                  //Delay 400ms
     Lcd_Out(2,2,txt2);              //Display spec on 2nd Row.
     Delay_ms(5000);                 //Wait for 5 seconds.
     Lcd_Cmd(_LCD_CLEAR);            //Clear LCD.
     Delay_ms(250);                  //Wait for 250ms.
     Lcd_Out(1,1,"R!f@@ (XXXXXX)"); //Display text2.
     Lcd_Out(2,1,"Software Ver3.0"); //Display text3.
     Delay_ms(5000);                 //Wait for 5 seconds.
     Lcd_Cmd(_LCD_CLEAR);            //Clear LCD
}
Every Msg works flawlessly.

If I add them this thing is going berserk.

I dunno why this is happening. I tried uninstalling and installing the mikroC too. But did not help. I tried other pic's, still same.

I know the PIC is fine cause when I remove the the above 4 msg's all's well.
Even the 4 Msg's are not working, and this drives me nuts.
Atleast they should show, right.

I searched for a long time and read all night long and I could not figure out why.

RB and t0 said something about assigning space for the msg's.
But I still could not figure this out.

This is the final road bump with this project.

I need advice on this

Thanks so far for all of you who helped me to get this far.
 

shteii01

Joined Feb 19, 2010
4,644
Lcd_Out(1,1,"R!f@@ (XXXXXX)"); //Display text2.
Lcd_Out(2,1,"Software Ver3.0"); //Display text3.

These two don't have delay between them.
 

shteii01

Joined Feb 19, 2010
4,644
Those definitions appears in the very first and second lines of the posted code.
Yes, I saw that. But that puts them outside of the user defined function. So since they are not declared in any of the user defined functions, that leaves only two places for them: main{} and global variables. I was asking which one of the two they are.
 

THE_RB

Joined Feb 11, 2008
5,438
I don't do the LCD clearing the way you do.

Of all the commands on the Hitachi 44780 LCD chip, the "clear" command takes the longest. Wiki says 1.52mS required.

Since you have recently had issues with the timing and PIC osc speed in the compiler, it's possible this might be the problem. You should check that. A simple ay is to use this code;
Rich (BB code):
while(1)
{
  Delay_mS(900);  // flash LEDs at 1 second freq 
  LATB = 0xFF;  
  Delay_mS(100);
  LATB = 0x00;
}
And compare to a watch or ticking clock etc. It will be very obvious if the LEDs are not flashing at 1Hz.

You could also force a delay after _CD_CLEAR by adding;
Delay_mS(10);
after each time you clear the LCD. That will show if it is a timing issue.

Other things; MikroC uses RAM for the text strings anyway, so there is no need to declare the text as a global string if you only display it once.
Just do it inline;
Lcd_Out(1,1,"EvilWorks PS600W");
for simpler code and the same RAM usage. :)
 

Thread Starter

R!f@@

Joined Apr 2, 2009
9,918
Did every thing

What RB said, still same.
what t0 showed, still same.


What I do not understand is if the msg are few all is well.

I can get the start-up to work if I do not use the over heat msg's.

I stepped through the code and yet the RAM window shows proper address as the watch window and both show's what the proper characters and the proper msg's are there. It's this friggin LCD not showing any thing.
Do I need more memory PIC ?
 

THE_RB

Joined Feb 11, 2008
5,438
No, it's probably a code bug.

At this point if you are not going to use the debugger you will only find the problem if you strip the code down. Comment out stuff that is not the display code. Try to find out what is trashing the RAM areas where your text strings are displayed. It is probably some pointer error or array writing error.
 

ErnieM

Joined Apr 24, 2011
8,377
Here is a link showing how to use string constants in ROM http://www.mikroe.com/forum/viewtopic.php?t=23196
Also instead of reinstalling I suggest you learn to use the the debugger. It may save you some time in the long run;)
Well that link may work but I have two problems:

First it violates containment by first exposing a local static variable to the outside world. Not the worst of things to do but asking for trouble as it is not a recommended practice.

Next, more seriously, this is used to save RAM, but sticks some reserved RAM in a place where is is not accessible to the rest of the program. Unless explicitly called you can't get a pointer to this buffer.

I would much prefer to make a separate global buffer to use for tasks such as this. Yes, globals are bad but as long as you follow the simple rule of "use it and be done with it" it works fine. For LCD stuff I make one buffer a line width (+1 for the /0) and pass that around everywhere.

The K&R "C Programming Language" specifically covers buffer copying with a marvelous bit of zen code:

Rich (BB code):
//from memory (mistakes are mine not theirs)
codetxt_to_ramtxt(char* dest, const char* source)
{
 while(*dest++ = *source++);  // copy everything until the trailing zero is found
}
 
Last edited:

tshuck

Joined Oct 18, 2012
3,534
When you say the display goes berserk, what do you mean? Displays seemingly random characters?

Are you modifying the pointers at all?

Without seeing the rest of your code, it's hard to debug, however, you seem to want to keep this under lock and key, so our analysis is limited.
 
Top