CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PROBLEM with PIC18f4550 and LCD4x20
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
monsterz



Joined: 21 Jun 2010
Posts: 10

View user's profile Send private message

PROBLEM with PIC18f4550 and LCD4x20
PostPosted: Mon Jun 21, 2010 4:22 am     Reply with quote

Hi, im facing the problem of pic18f4550 and LCD 4x20, i get the ccs LCD420.C file from the ccs library, and it cant work, the LCD show up with black bar code... can any1 help me. thank alot. Here my example of my code. By the way i connect the pin
// B0 enable
// B1 rs
// B2 rw
// B4 D4
// B5 D5
// B6 D6
// B7 D7

#include "main.h"
#include <LCD420.c>

lcd_gotoxy ( 1, 1 );
printf ( lcd_putc, "KWH:" );
displayInt ( ikWattHrs );
lcd_putc ( '.' );
lcd_putc ( fkWattHrs + '0' );
monsterz



Joined: 21 Jun 2010
Posts: 10

View user's profile Send private message

PostPosted: Mon Jun 21, 2010 4:29 am     Reply with quote

HERE my LCD code get from ccs library
Code:

////////////////////////////////////////////////////////////////////////////
////                             LCD420.C                               ////
////            Driver for common 4x20 LCD modules                      ////
// As defined in the following structure the pin connection is as follows:
//     B0  enable
//     B1  rs
//     B2  rw
//     B4  D4
//     B5  D5
//     B6  D6
//     B7  D7
//

#byte lcd = 6                        // This puts the entire structure
                                     // on to port B (at address 6)


+++++++++++++++++++++++++++
Most driver code removed.

Reason: Forum Rule #10

10. Don't post the CCS example code or drivers

-- Forum Moderator
+++++++++++++++++++++++++++
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jun 21, 2010 2:53 pm     Reply with quote

I don't see in your code where you call lcd_init(). One reason for getting
black boxes is if the LCD is not initialized. You need to call lcd_init()
at the beginning of main().
monsterz



Joined: 21 Jun 2010
Posts: 10

View user's profile Send private message

PostPosted: Tue Jun 22, 2010 1:37 am     Reply with quote

i have called the lcd_init() but still getting the same error, i try to use the LCD.c library file and it works but just for lcd 16x2 . And now i am trying to use lcd 20 x 4 by using the library LCD420.c and it doesnt work..

Anyone face this problem before?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jun 22, 2010 11:38 am     Reply with quote

Quote:
#byte lcd = 6

I just noticed the problem. PortB is set to 6 with a #byte statement.
That's correct for a 16F877, but PortB is at a different address for the
18F4550. Edit the #byte statement and change the address to 0xF81.
Then it should work.
monsterz



Joined: 21 Jun 2010
Posts: 10

View user's profile Send private message

PostPosted: Sun Jun 27, 2010 7:58 am     Reply with quote

it is fine now... but now the problem is my 5v regulator is hot.. is it the software cause my regulator hot? because i hvae double cheaked my LCD and PIC, and they are fine.. and i suspect is the lcd.h problem.. by the way i have changed my PIC to 16f877a
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Sun Jun 27, 2010 10:09 am     Reply with quote

What is your incoming supply voltage (feeding the regulator)?.
What is running off the regulator (PIC, plus LCD, +?)?.
Does the LCD have backlighting?. What type?.
What heatsinking is on the regulator?.
What capacitors have you got on the regulator, and where are they placed relative to the regulator?.

The 'odds' are that it is just the amount of current that the regulator is having to deliver, at the voltage it is dropping...
However one common problem, that can make this much worse, is the regulator oscillating (hence the last question).

Best Wishes
monsterz



Joined: 21 Jun 2010
Posts: 10

View user's profile Send private message

PostPosted: Mon Jun 28, 2010 2:22 am     Reply with quote

incoming voltage is 9Vdc
the regulator just supply for PIC + LCD only
The LCD have backlight, 4x20 brand JHD204A
there are not heatsinking on the regulator
the regulator is 7805 output 5Vdc and 1A
there are not capacitor on my regulator

When im using Hightech C compiler LCD.H , my regulator are not problem, but when im using CCS C compliler LCD.H, my regulator is hot.. is it something problem with the LCD.H driver file
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Mon Jun 28, 2010 2:59 am     Reply with quote

Around your regulator, you _must_ have a small capacitor right close to the output, between the output pin and ground. Something like 0.1uF. You should also have a capacitor close to the input of similar size. These should be as close to the regulator as possible, and are _essential_.

Now, there is nothing in the LCD driver that should affect the power being drawn, provided:
You have the LCD pin selection setup right. Something that would cause problems would be (for example), to have the driver told to use LCD chip select, then have the pin connected to a supply rail... So, look carefully at the LCD setups.
Remember also that everything else in the code also changes (I/O configuration, how pins are initialised etc. etc...).

You should wire the regulator properly 'anyway', but solve the code setup as well.
Have a look at <why_is_my_regulator_getting_hot.htm>

Best Wishes
monsterz



Joined: 21 Jun 2010
Posts: 10

View user's profile Send private message

PostPosted: Mon Jun 28, 2010 4:13 am     Reply with quote

ya, im connecting 0.33uF and 0.1uF connected at the input and output, but i still get the same problem.

In hightech C, the LCD.h library, the R/W is connected to ground.
But in CCS compiler the LCD.h driver, the R/W is connected to PIC pin

That i suspect the r/w will be floating and cause the regulator hot.. is it possible??
I have asked my lecturers, and my lecturers also dunno wat is going wrong... Do any 1 using LCD.H driver provided by ccs compiler and facing this problem b4? thankyou
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Mon Jun 28, 2010 4:34 am     Reply with quote

A floating pin, should only draw a few mA. It should be avoided, and is 'bad' all round, but is unlikely to be the whole problem.
However, why are you changing the hardware?. Just setup the CCS driver to use the same layout as the HiTech one. I really would say that you almost certainly have the hardware wrong somewhere relative to the software configuration.
You setup the 'enable' pin, using the line:
#define LCD_ENABLE_PIN PIN_XX

where 'XX' is the pin name you want to use. If you don't want to use hardware enable (you don't have to, but it is slower), then just leave this pin undefined.

Also, look at every other pin. Are all the unused PIC pins driven high or low (either in software or hardware). They should be.

Best Wishes
monsterz



Joined: 21 Jun 2010
Posts: 10

View user's profile Send private message

PostPosted: Mon Jun 28, 2010 4:48 am     Reply with quote

The hardware part is ok... because if im using battery my regulator is fine..

Last edited by monsterz on Mon Jun 28, 2010 5:03 am; edited 1 time in total
monsterz



Joined: 21 Jun 2010
Posts: 10

View user's profile Send private message

PostPosted: Mon Jun 28, 2010 4:52 am     Reply with quote

is that ok with my program??
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Mon Jun 28, 2010 5:00 am     Reply with quote

First, remove the code. Read the header of the file, and the terms of this group. Don't post CCS code here.
_All_ you need post, is the defines you are using, which are not in what you have posted. You also need to post the physical connections you are using to the LCD.
monsterz



Joined: 21 Jun 2010
Posts: 10

View user's profile Send private message

PostPosted: Mon Jun 28, 2010 5:11 am     Reply with quote

From LCD.h driver I have connected
Code:

//     D0  enable
//     D1  rs
//     D2  rw
//     D4  D4
//     D5  D5
//     D6  D6
//     D7  D7
//
//   LCD pins D0-D3 are not used and PIC D3 is not used.

void main()
{
lcd_init();
lcd_gotoxy ( 1, 1 );
printf ( lcd_putc, "V:%.1fV    ", VrmsUpdated );       
         
lcd_gotoxy ( 10,1);
printf ( lcd_putc, "I:%.1fA    ", VrmsUpdated );
}

The hardware part is contruct with perfect...With battery it work but if
with adapter or DC power supply it can't work. My lcd screen show
2 black lines:
==========
==========
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group