Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 26, 2024, 11:52:41 23:52


Login with username, password and session length


Pages: [1] 2 3  All
Print
Author Topic: LCD Special Characters  (Read 16180 times)
0 Members and 1 Guest are viewing this topic.
jcsntoll
Junior Member
**
Offline Offline

Posts: 46

Thank You
-Given: 24
-Receive: 3


« on: November 10, 2009, 07:05:26 19:05 »

Hello,

I have been talking with people in the PROJECTS forum about an Intelligent battery monitor.
http://www.sonsivri.com/forum/index.php?topic=23705.0

I'm told the source code shows the LCD is being loaded with double sized characters.
The original design calls for a KS0066 display, ( hard to find here in the USA. ) and the more common HD44780
is unable to use those special characters.

I've looked over the code, but it has been about 20 years since I programmed in C, and never have with a Pic and LCD.

Is it possible to convert the code to use standard characters so that it is compatible with the HD44780 display?
Or does the code have to be totally re-written ?
http://rapidshare.com/files/257890816/High_Current__High_Voltage_Battery_Capacity_Meter.rar

Thanks!
Logged
DarkClover
Active Member
***
Offline Offline

Posts: 167

Thank You
-Given: 37
-Receive: 60


Still alive...


« Reply #1 on: November 10, 2009, 08:10:04 20:10 »

What exactly do you mean with "double sized characters" ?
Is it the 5x11 dots function ?
The HD44780 is nearly 99% compatible with the KS0066.

Maybe these double size chars are custom generated ones
and you just have to change the RAM-Adress to fit them on
a HD44780 controlled display (I just flow over the KS0066 datasheet)
or if they use some block chars integrated in the ROM they may
have another adress within the HD44780.
I don't think you have to change the code but I'll have a look when
I downloaded it (less free download slots now)
Logged

Not thinking means to believe what others say!
TRY & ERROR... the fundamental principle our existence is based on
DarkClover
Active Member
***
Offline Offline

Posts: 167

Thank You
-Given: 37
-Receive: 60


Still alive...


« Reply #2 on: November 11, 2009, 01:16:05 13:16 »

I skimmed the codes LCD part and I can't see anything
special in the routines. It should work with any usual
HD44780(and compatible) 16x2-LCD too without any problems.
Just give it a try. Otherwise tell me please.

Which program has been used to make those
nice PCB and mechanical illustrations ?
« Last Edit: November 11, 2009, 01:27:58 13:27 by DarkClover » Logged

Not thinking means to believe what others say!
TRY & ERROR... the fundamental principle our existence is based on
jcsntoll
Junior Member
**
Offline Offline

Posts: 46

Thank You
-Given: 24
-Receive: 3


« Reply #3 on: November 11, 2009, 05:50:32 17:50 »

Hmmm...    I'm not sure what program was used to make the drawings.
This is from a Silicon Chip Magazine article. ( June/July 2009 )

My display only shows the first line full of blocks. 
I've triple checked the wiring.  I had to connect my HD44780 differently because it has a pin out of 1 - 16 left to right.
Where the KS0066 display they use on the project has a pin out of 14 - 1,16,15 left to right.
With each number being the same.. ( ie. 16,15 backlight,  14 - D7, 13 - D6...... )

As for the special characters I was going by what PicKit2 said in the Projects thread..
Quote
Looking at the code, I see that the programmer uses a load of special grafics that are sent to the display,(ie double sizeds caractors)  is this your problem? your display can't have these in memory.

Personally I couldn't find where it was loading any special graphics but I do not know C that well.
I know the program is running, because it holds the power regulator chip to +5v ( normally at 3v in sleep mode )
and it turns on the back light, and after a few moments slowly dims it until a button is pressed then it turns it back on.

I've tried a couple different displays, but get the same result.  I'm really stumped here.
I really appreciate your help,
Logged
DarkClover
Active Member
***
Offline Offline

Posts: 167

Thank You
-Given: 37
-Receive: 60


Still alive...


« Reply #4 on: November 12, 2009, 05:11:37 17:11 »

Okay if your display only shows one line of blocks it won't be initialized.
Make a test with a simple display code and write some text on it to check if there is no other problem.
Like: http://www.piclist.com/techref/io/lcd/4b16x2lcd-ab.htm
Then connect it again as defined in the schematic. (maybe use 10k pulldown for the ENABLE pin)

then have a look for the contrast. I had a problem where the display didn't show anything and it took a while till i checked
that my contrast voltage was to low Smiley (The blocks were shown before initialisation too)

A little tip for the contrast:
Don't connect the potentiometer to VCC too without some savety constructions (e.g. current regulation resistor).
It's because you can burn up the display if you come to close to VCC. It should work the same way if you just control
the contrast to GND and you don't need savety.

Do you hear the beep when you switch on the circuit ?
It should come before the display is initialized. If that works Put the initBeep(); inside the initSequence-function after the initLCD(); call.
If the beep comes and the display still don't work quad check the connections.
Logged

Not thinking means to believe what others say!
TRY & ERROR... the fundamental principle our existence is based on
TomJackson69
Active Member
***
Offline Offline

Posts: 218

Thank You
-Given: 26
-Receive: 63


« Reply #5 on: November 14, 2009, 04:33:40 16:33 »

jcsntoll ,

Since you have the LCD displayed on the first line then I think it is timing problem. If you could increase the delay between LCDE = 0 and LCDE = 1.

Look at the main display routine:

"

volatile void writeLCD(byte data, byte command)
{
      int i;
      byte firstdata;
      byte seconddata;
      byte interrupt;
   
      firstdata=swapBits(data);
      seconddata=swapBits(data<<4);
      LCDE=0;
      if(command==LCDCOMMAND)LCDRS=0; else LCDRS=1;
      PORTB=firstdata;
      interrupt=INTCONbits.GIE;
      INTCONbits.GIE=0;
      _asm
          nop
          nop
      _endasm
      LCDE=1;
      _asm
         nop
         nop
      _endasm
      LCDE=0;
      PORTB=seconddata;
      _asm
          nop
          nop
         nop
         nop
      _endasm
      LCDE=1;
      _asm
         nop
         nop
      _endasm
      LCDE=0;
      PORTB&=scanLn;
      _asm
          nop
         nop
          nop
      _endasm
      if(interrupt)INTCONbits.GIE=1;
      for(i=0; i<LCD_DELAY; i++)
      {   
         _asm
            nop
            nop
         _endasm
      }
}

"
You see lot of "NOP". I think if you increase the delay here, it could help. Try this:

      _asm
             nop
             nop
             nop
             nop
             nop
             nop
             nop
             nop
      _endasm


You can put more or less NOP until you see the display stable.

Since the LCD already show some char on the first line, then contrast is OK. Double size char would not display on one line, unless you custom the double size char to disolay on two lines; which is less likely in this case. I think the designer of this project is use ROM char build-in.

So, goto "volatile void writeLCD(byte data, byte command)" function to change the delay to see if it works. I wish I have more time to look at the program in depth. I will check back to see if you have solve the problem.

Here is a good macro to use:
#ifndef    Nops
   #define Nops(NumTime)  __asm__ volatile(".rept " #NumTime "\n\t nop\n\t .endr")
#endif


Example of use: Nops(10);   // it will insert 10 "nop" in to your program

In the function above, replace all the:

      _asm
             nop
             nop
             nop
      _endasm

with: Nops(10);    // 10 or 12 or 8 or whatever number of nop to get the LCD display.


Use this macro will reduce typing. Remember to put this macro in the header "batterymeter.h" or on the other header.


Good luck,

Tom

« Last Edit: November 14, 2009, 04:47:54 16:47 by TomJackson69 » Logged

Con Rong Chau Tien
DarkClover
Active Member
***
Offline Offline

Posts: 167

Thank You
-Given: 37
-Receive: 60


Still alive...


« Reply #6 on: November 14, 2009, 09:42:26 21:42 »

Does it work now with the tryouts and changed timings ?
If not it could maybe be some problem with the PCB (if you have done one)
maybe there is a little cut in there.
Logged

Not thinking means to believe what others say!
TRY & ERROR... the fundamental principle our existence is based on
TomJackson69
Active Member
***
Offline Offline

Posts: 218

Thank You
-Given: 26
-Receive: 63


« Reply #7 on: November 14, 2009, 10:07:21 22:07 »

jcsntoll ,

After my last posted, I have a though about the project. Since, this is a nice project and was public as an artical then, I think the project has to work. The display problem could cause by wiring error?

I think it is better to check out the LCD on a different circuit to make sure the LCD is not a problem. As you have mention that the program is running but the LCD is not. Also, try to check the wiring from the PIC to the LCD, line by line, and all the pins from the LCD to PIC and ground.

Try to solve the LCD problem before edit the software may be the right way. Let me know how it come out.

Tom
Logged

Con Rong Chau Tien
jcsntoll
Junior Member
**
Offline Offline

Posts: 46

Thank You
-Given: 24
-Receive: 3


« Reply #8 on: November 15, 2009, 01:09:45 01:09 »

Thank you everyone one.

I think it has to be a programming issue, something in the init maybe.

I have verified the LCD, and the PCB.
I also agree with your logic of this being a public project..  but the article calls for the KS0066 LCD ( with a weird pin out )
 I do not have any of those, so I'm using a HD44780 with a standard pin out.
I've made a cable to connect the PCB and LCD.. and have verified continuity.
I also agree since the first row is blocks, the power and contrast are correct.

I will try adding the NOP commands, as well as maybe look at the init of the LCD itself.
Thanks for your help, and I will post my results.
Logged
jcsntoll
Junior Member
**
Offline Offline

Posts: 46

Thank You
-Given: 24
-Receive: 3


« Reply #9 on: November 15, 2009, 09:30:10 21:30 »

Well I feel silly.


Could someone help me compile this?   I downloaded both MPLAB C18 ( as stated in the source )
and installed it into MPLAB IDE.

I'm not sure the steps I need to do to compile this into hex so I can load it.
Logged
TomJackson69
Active Member
***
Offline Offline

Posts: 218

Thank You
-Given: 26
-Receive: 63


« Reply #10 on: November 16, 2009, 05:52:43 05:52 »

jcsntoll,

Go to the directory that you unziped the project.
Let say:"\111429_Battery_Capacity_Meter_Software_Version_7.30\Battery Capacity Meter"

In this dirctory you will see two file for the project: "Battery Capacity Meter.Microchip MPLAB. project" and "Battery Capacity Meter.Microchip MPLAB.workspace".

Double click on the "Battery Capacity Meter.Microchip MPLAB.workspace" and you will be in the MPLAB IDE with Battery Capacity Meter project.

I think this project is already setup so you just go to Project > Buildall. The new HEX file will be create in the same project directory if compiled without error.

Good luck,

Tom
Logged

Con Rong Chau Tien
jcsntoll
Junior Member
**
Offline Offline

Posts: 46

Thank You
-Given: 24
-Receive: 3


« Reply #11 on: November 16, 2009, 03:13:05 15:13 »

That's what I figured, but something must not be correct.
All I get is a bunch of .pre and .o files.

also I noticed in the configs that there is a batch file that is called when the compile is complete.
( just copies a file into the PC software folder.  that is not being called either )

wow I never expected this project to be so much trouble.
Logged
TomJackson69
Active Member
***
Offline Offline

Posts: 218

Thank You
-Given: 26
-Receive: 63


« Reply #12 on: November 16, 2009, 04:24:44 16:24 »

jcsntoll,

I have modified the "volatile void writeLCD(byte data, byte command)" routine with some more delay. See below:

Code:
volatile void writeLCD(byte data, byte command)
{
int i;
byte firstdata;
byte seconddata;
byte interrupt;

firstdata=swapBits(data);
seconddata=swapBits(data<<4);
LCDE=0;
if(command==LCDCOMMAND)LCDRS=0; else LCDRS=1;
PORTB=firstdata;
interrupt=INTCONbits.GIE;
INTCONbits.GIE=0;
// _asm
//    nop
//    nop
// _endasm
DelayStrobe();
LCDE=1;
// _asm
// nop
// nop
// _endasm
DelayStrobe();
LCDE=0;
PORTB=seconddata;
// _asm
//    nop
//    nop
// nop
// nop
// _endasm
DelayStrobe();
LCDE=1;
// _asm
// nop
// nop
// _endasm
DelayStrobe();
LCDE=0;
PORTB&=scanLn;
// _asm
//    nop
// nop
//    nop
// _endasm
DelayStrobe();
if(interrupt)INTCONbits.GIE=1;
for(i=0; i<LCD_DELAY; i++)
{
// _asm
// nop
// nop
// _endasm
DelayStrobe();
}
}

And here is the "DelayStrobe()"

Code:
void DelayStrobe(void)
{
_asm
   nop
nop // Increase or decrease to make it works
   nop // This is about 4uS delay
   nop
nop
   nop
   nop
nop
   nop
   nop
nop
   nop
   nop
nop
   nop
   nop
nop
   nop
   nop
nop
   nop
_endasm
}

I compiled with some warning (suspicious pointer conversion) which is the way the the owner of this project was using ROM char ....

Anyways, here is the HEX file you can try out to see if it works. Use the above modified routine in your project to compile. The project can be compile as it.



Tom
« Last Edit: November 16, 2009, 04:36:06 16:36 by TomJackson69 » Logged

Con Rong Chau Tien
jcsntoll
Junior Member
**
Offline Offline

Posts: 46

Thank You
-Given: 24
-Receive: 3


« Reply #13 on: November 16, 2009, 06:42:41 18:42 »

Thank you very much.. I think I must have something installed wrong or not setup correctly with the compiler.
Not sure,  I've never compiled C with MPLAB.

I will try the new Hex tonight when I get home..   Sorry for being such a Noob!  I never expected this project
to be so much work! haha
Logged
DarkClover
Active Member
***
Offline Offline

Posts: 167

Thank You
-Given: 37
-Receive: 60


Still alive...


« Reply #14 on: November 16, 2009, 09:30:15 21:30 »

Nah everybody is a noob in his own way, just try try try.

How is it now with the whole thing ?
Does it work ? Does the display as it should Smiley
Logged

Not thinking means to believe what others say!
TRY & ERROR... the fundamental principle our existence is based on
jcsntoll
Junior Member
**
Offline Offline

Posts: 46

Thank You
-Given: 24
-Receive: 3


« Reply #15 on: November 17, 2009, 03:01:58 03:01 »

GRRrrrr..  Same result.

I have RE-verified the wiring.

Could I trouble you for a hex that just holds RA5 low ( two turn on the regulator )
and does the most simple LCD init, and just writes "Testing" or something on the display?
Just to prove the display works ok, or not.

Logged
DarkClover
Active Member
***
Offline Offline

Posts: 167

Thank You
-Given: 37
-Receive: 60


Still alive...


« Reply #16 on: November 17, 2009, 04:02:16 16:02 »

Connect RA5 directly or over a 1k resistor with GND. This should enable LM257.
Then comment everything inside the initSequence except initLCD(); (it should work too).

And replace the original void main(void){.... with this:
I'm not a pro at PIC but it should work.

Code:
void main(void)
{
byte key;
byte scrollingMode;

TRISC=INIT_TRISC;
TRISB=INIT_TRISB;
PORTC=0;
PORTB=0;
delayMs(100);
initSequence();
writeStringLCD(0, (rom char*)"Test Test 1.2.3");

while(1){}
}
Logged

Not thinking means to believe what others say!
TRY & ERROR... the fundamental principle our existence is based on
jcsntoll
Junior Member
**
Offline Offline

Posts: 46

Thank You
-Given: 24
-Receive: 3


« Reply #17 on: November 18, 2009, 06:09:59 18:09 »

Thanks DarkClover,
But I seem to be missing something with the compiler.

I've installed MPLAB IDE, and MC18, and they are linked together as far as I can tell.
When I click the Build All button, it greys out for a bit, like it's working. Then returns.
When I check my project folder I have some .o files but I do not have a .hex or .asm file at all.
Am I missing a step or software??

Sorry I'm sure this question belongs in another topic.

Maybe I'll try and write a simple PicBasic code to test it, and confirm the wiring and LCD connections.
If I knew were I could find the LCD the project calls for here in the states, I would just order it and be done with it.
But the one they list from Altronics would cost over $50USD after shipping and things.
Logged
DarkClover
Active Member
***
Offline Offline

Posts: 167

Thank You
-Given: 37
-Receive: 60


Still alive...


« Reply #18 on: November 18, 2009, 07:26:57 19:26 »

ummm maybe could you send me the makefile from the Pic C-compiler?
At the AVR C-compiler there is often a line in the makefile which has a
delete command for the hex.

I can't believe that the problem is the controller of the display but
I'll disabuse myself.

At the weekend I'll give it a try to translate the codepart for the LCD to
AVR and try it. Maybe there is really just a timing problem as TomJacksn said.
By the way, at which speed does your PIC run (real speed)?
Logged

Not thinking means to believe what others say!
TRY & ERROR... the fundamental principle our existence is based on
TomJackson69
Active Member
***
Offline Offline

Posts: 218

Thank You
-Given: 26
-Receive: 63


« Reply #19 on: November 19, 2009, 08:32:15 20:32 »

jcsntoll,

Can you post your circuit so I have a look. The reason is that may be the connection is not right; since you have said the LCD you are using is different than the one in the project.

Just show the part that the PIC is connected to the LCD and all 14 pins (or 16 pins) of the LCD. Since  most HD44780 LCD controller have compatible connection.

After you post part of your circuit (specially the LCD connection) I will write a routine for just test the LCD. I think that will help. Right now, even I want to write a routine, I still don't know how is your connection (4 bits or 8 bits). Make sure you give the information of the LCD too (pin out...).

So, in conclusion, I need pin out of the LCD, pin connection fron PIC to LCD and all other pins from the LCD connected to where. Also the crystal speed.

Tom
Logged

Con Rong Chau Tien
jcsntoll
Junior Member
**
Offline Offline

Posts: 46

Thank You
-Given: 24
-Receive: 3


« Reply #20 on: November 21, 2009, 02:39:19 02:39 »

Sure thing Tom,  If you go to the Altronics site and look up the datasheet for the KS0066 LCD they call for in the project,
http://www.altronics.com.au/index.asp?area=item&id=Z7013

You can see the pin out is strange for a LCD.  starting from the left it runs 14 - 1, 16,15
Where must LCD's run 1-14,15,16.

So I wired mine to match, Power,Gnd, E, RW, D4-D7...
It's just a generic LCD with HD44780 and backlight..  the back light works great.. Auto dim works and re-lights when a key is pressed.

The processor is a PIC18F2550, running with a 20Mhz crystal..

Also I think the build fails before it completes, but I'm not sure why.. attached is the error file.
Logged
TomJackson69
Active Member
***
Offline Offline

Posts: 218

Thank You
-Given: 26
-Receive: 63


« Reply #21 on: November 21, 2009, 07:28:40 19:28 »

jcsntoll,

I have looked the output file and see only warning. You have not show the complete output file. Is it successfull compiled? or error?

If it is error then show the error message. May be linker error or missing file due to wrong setup of the Library Search Path ets...

Go to Project/Build Option/Project then
Go to Directories and select where the MCC18 directory is locate. May be you are missing the "c018iz_e.o" file. This file is located at "C:\Program Files\Microchip\MC18\lib". You can go to this dir and copy this file to your project dir (it will be default search dir.

Anyways, show complete compiled output file, it show something about why compiled error.

I don't have Rapid Share account so I can not up load the whole project for you. In few more day when I have time, I will spend more time on your project problems.

Before I get off, I want you to try one thing. Try to take the keypad out of the circuit to see if the display will display. Because the 4 line of the keypad is connected to the 4 data line to the LCD via the diodes. Remove the keypad to see how it works (ofcourse you have no keypad). If you don't want to remove the keypad then disconnect one end of the diode (4 of them, I think D2-6). This should give the LCD 4 data lines without the keypad interfear. The LCD from Allelectronic is just a standard 16x2 LCD and should work with the way the "IniLCD routine" initialize (4 data line, 2 line). Like you said, the system is working then there must be TIMING or CONNECTION problem (maybe both, I doubt it).

Tom
« Last Edit: November 21, 2009, 07:42:36 19:42 by TomJackson69 » Logged

Con Rong Chau Tien
jcsntoll
Junior Member
**
Offline Offline

Posts: 46

Thank You
-Given: 24
-Receive: 3


« Reply #22 on: November 21, 2009, 09:09:23 21:09 »

I must have something setup or installed wrong. I'm not sure what.
I have MPLAB installed with MCC18.  I have MCC18 toolset with correct path names selected as the
Language Toolsuite.

But when I click build all, all that gets created are a series of .o files
( main.o, and 9 usb files )

That's it, I'm not sure what you expect for the output file.  I've attached the main.o but not sure if that's what you
are asking for.

I have tried the project without the keypad and I get the same result.
I really appreciate everyones help with this.  

I've tried to build this project in Proteus, but my computer does not seem to have the resources to run it.
( using the original hex )
« Last Edit: November 21, 2009, 09:11:30 21:11 by jcsntoll » Logged
oldvan
Senior Member
****
Offline Offline

Posts: 372

Thank You
-Given: 154
-Receive: 107


If the van is a Rockin'...


WWW
« Reply #23 on: November 21, 2009, 10:33:59 22:33 »

I took a look at main.o, it is not inteded to be human-readable but may still hold a few clues.

It is possible the length of the path you to your project is a problem to the compiler,
E:\Documents and Settings\Administrator\Desktop\111429_Battery_Capacity_Meter_Software_Version_7.30\Battery Capacity Meter\
is awfully deep.  

It couldn't hurt to try placing the project in c:\pic\meter\ and seing if it compiles there.

Spaces in file names can also cause confusion for some programs, but that is rare these days.
« Last Edit: November 21, 2009, 10:36:31 22:36 by oldvan » Logged

Give a man a fish and you feed him for a day.
Teach a man to fish and he will sit around in a boat drinking beer all day.
TomJackson69
Active Member
***
Offline Offline

Posts: 218

Thank You
-Given: 26
-Receive: 63


« Reply #24 on: November 21, 2009, 11:44:55 23:44 »

jcsntoll,

Sorry for the comfusing. The output file I am talking about is the output screen when you build the project (in the window OUTPUT/Build). Just like the first one you posted but more detail. At the end of build, it will tell you whether the project is build successfull or fail. Try this, click Project/Build All and then copy the constent of that output window to a file. If you post that file, I think I can see what is wrong. If you are able to compile your project with successfull then it is easier for you to debug.

If you already build the circuit in Proteus, post that project file, I can run on my computer to see if it will display.

Regards,

Tom
Logged

Con Rong Chau Tien
Pages: [1] 2 3  All
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC