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 support@ccsinfo.com

Problem in configuring a 7-Segment LCD with PIC16F913
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
ajitmutalik



Joined: 30 Sep 2006
Posts: 5

View user's profile Send private message

Problem in configuring a 7-Segment LCD with PIC16F913
PostPosted: Sat Sep 30, 2006 1:02 pm     Reply with quote

Hi,
I am writing a small application using PIC16F913(SSOP package).
The application consists of putting BCD data onto LCD.
I am using CCS C compiler standard function to configure the LCD i.e. SETUP_LCD();
But I am not able to get the desired data pattern on the LCD screen. The data on the screen is always flickering.
I am using 1/4 multiplex and 1/3 bias.
After a few attempts (I have burnt quite a few PIC's in attempt of measuring VLCD), I could observe that the LCD reference voltage at VLCD pins is not remaining constant. I could observe a pattern at VLCD pins which is similar to the segment pins of the LCD.
Could this fluctuation in the voltage be the reason of flicker?
Can anybody suggest me correct LCD configuration?
Are there any limitations for using LCD with the help of CCS C compiler?
_________________
Ajit
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Sep 30, 2006 1:22 pm     Reply with quote

1. Are you using a demo board that you bought, or did you build it
yourself ? If you bought the board, then post the Manufacturer
and part number of the board. Also provide a link to the web page
for the board.

2. What 7-segment LCD are you using ? Post the manufacturer and
part number.

3. What version of the CCS compiler are you using ? (hopefully not
vs. 4.xxx -- it's not really ready yet). You can find the version by
looking at the top of the .LST file for your project. The .LST file is
in your project directory.

4. Can you post a very small test program that shows the problem ?
I think you can do this with less than 30 lines of code. Please don't
post any more than that. These 30 lines should show all #fuses,
#use statements, #include statements, etc. Be sure to show the
code that calls the CCS functions that do the LCD setup. Also show
the code that attempts to write characters to the LCD. (In other
words, a small, but complete little test program).

I have to go away the rest of the day, so I can't work on this until later.
If someone else has an answer, then of course they should reply too.
ajitmutalik



Joined: 30 Sep 2006
Posts: 5

View user's profile Send private message

PostPosted: Sat Sep 30, 2006 1:53 pm     Reply with quote

hi,
here are the answers,
1. The board which I am using is custom built.
2. I am using 5.1 digits 7-seg LCD display. It is from Truly semiconductors.
3. I am using CCS C version 3.242
4. Test Program:

Please find the LCD mapping as #define for each digit.

#include <16F913.h>
#fuses NOWDT, NOPUT, MCLR, NOCPD, BROWNOUT, IESO, FCMEN, INTRC_IO
#use delay(clock=4000000)
//////////////////////////////////////////////////////////////////////////////////////// LCD Configuration //
/////////////////////////////////////////////////////////////////////////////////////////
// Digit segments A B C D E F G DP
// b7 b6 b5 b4 b3 b2 b1 b0
#define DIGIT6 COM3+11, COM2+11, COM1+11, COM0+11,
COM1+12, COM3+12, COM2+12, COM0+12
#define DIGIT5 COM3+8, COM2+8, COM1+8, COM0+8,
COM1+9, COM3+9, COM2+9, COM0+9
#define DIGIT4 COM3+6, COM2+6, COM1+6, COM0+6,
COM1+7, COM3+7, COM2+7, COM0+7
#define DIGIT3 COM3+4, COM2+4, COM1+4, COM0+4,
COM1+5, COM3+5, COM2+5, COM0+5
#define DIGIT2 COM3+2, COM2+2, COM1+2, COM0+2,
COM1+3, COM3+3, COM2+3, COM0+3
#define DIGIT1 COM3+0, COM2+0, COM1+0, COM0+0,
COM1+1, COM3+1, COM2+1, COM0+1
#define CLOCK COM3+14, COM2+14, COM1+14, COM0+14,
COM1+13, COM3+13, COM2+13, COM0+13
//
#define BLANK 0
#define DOT 1
// character 0 1 2 3 4 5 6 7 8 9
byte const Digit_Map[10] = {0xFC,0x60,0xDA,0xF2,0x66,0xB6,0xBE,0xE0,0xFE,0xF6}; // for display 0 - 9
byte const Diag_Map[12] = {0x00,0x02,0x0C,0x50,0xA0,0xFE,0x01,0x08,0x02,0x10,0x20,0xFF};
// for diagnostic pattern

//byte Second_Line[7];
/////////////////////////////////////////////////////////////////////////////////////////

void lcd_putc(char c)
{
byte segments;

if((c>=0)&&(c<=9))
segments=Digit_Map[c];
else if (c <16>= 16)
{
lcd_symbol(0x00,DIGIT1);
lcd_symbol(0x00,DIGIT2);
lcd_symbol(0x00,DIGIT3);
lcd_symbol(0x00,DIGIT4);
lcd_symbol(0x00,DIGIT5);
lcd_symbol(0x00,DIGIT6);
lcd_symbol(0x00,CLOCK);
switch(c)
{
case 16:
{
lcd_symbol(DOT,DIGIT1);
break;
}
case 17:
{
lcd_symbol(DOT,DIGIT2);
break;
}
case 18:
{
lcd_symbol(DOT,DIGIT3);
break;
}
case 19:
{
lcd_symbol(DOT,DIGIT4);
break;
}
case 20:
{
lcd_symbol(DOT,DIGIT5);
break;
}
case 21:
{
lcd_symbol(DOT,DIGIT6);
break;
}
case 22:
{
lcd_symbol(Diag_Map[6],CLOCK);
break;
}
case 23:
{
lcd_symbol(Diag_Map[7],CLOCK);
break;
}
case 24:
{
lcd_symbol(Diag_Map[8],CLOCK);
break;
}
case 25:
{
lcd_symbol(Diag_Map[9],CLOCK);
break;
}
case 26:
{
lcd_symbol(Diag_Map[10],CLOCK);
break;
}
default:
{
lcd_symbol(Diag_Map[11],DIGIT1);
lcd_symbol(Diag_Map[11],DIGIT2);
lcd_symbol(Diag_Map[11],DIGIT3);
lcd_symbol(Diag_Map[11],DIGIT4);
lcd_symbol(Diag_Map[11],DIGIT5);
lcd_symbol(Diag_Map[11],DIGIT6);
lcd_symbol(Diag_Map[11],CLOCK);
}
}

}
else
{
if ((c <= 9) || (c == 11) || (c == 15))
{
lcd_symbol((segments+DOT),DIGIT6);
}
else
{
lcd_symbol(segments,DIGIT6);
}

lcd_symbol(segments,DIGIT5);
lcd_symbol(segments,DIGIT4);
lcd_symbol(segments,DIGIT3);
lcd_symbol(segments,DIGIT2);
lcd_symbol(segments,DIGIT1); }
}


void main()
{
byte number = 0;
setup_lcd(LCD_MUX14 | LCD_INTRC,4);
/* Configure LCD - 1. 1/4 Multiplexing
2. LCD clock source is internal oscillataor (31kHz/32) with prescalar of 4.
3. Type A waveform */


for(number = 0; number <= 27; number++ )
{
lcd_putc(number); /* Function call to display the number */
delay_ms(4000);
}
}
_________________
Ajit
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Sep 30, 2006 11:24 pm     Reply with quote

I couldn't find an active website for Truly Semiconductors.
The company may not exist anymore.


Do you have the external bias resistors installed ?
The data sheet shows how to do this. For the mode you have
selected, they say to use three 10K resistors in series for the
1/3 bias mode.
ajitmutalik



Joined: 30 Sep 2006
Posts: 5

View user's profile Send private message

PostPosted: Sun Oct 01, 2006 4:06 am     Reply with quote

hi,
Yes, I have connected three 10K resistors across the pins 13,12 and 11.

But today when I observed the voltages across VLCD1,2,3 pins ....... I could see pattern similar to the one which is present at the Segment pins.
The voltage at these pins is not at all constant.
Also I measured the resistance values for the 10K resistors and found the resistor connected across pins 11 and 12 to be 350 ohms. I measured with power supply disconnected.
Then removed the controller IC and then measured the resistance again and I found it to be 10K.

I am confused, as to how the reference voltage is not remaining constant.
_________________
Ajit
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Oct 01, 2006 12:45 pm     Reply with quote

I think one of the problems is that the VLCD pins are not enabled.

Look at Microchip appnote AN1013:
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en025460
It shows a project similar to your project. Look in the source code file
called INIT917.ASM (in the zip file).
They setup LCDCON with the VLCDEN bit set = 1. (This is bit 4)
Quote:

BANKSEL LCDCON
MOVLW B'10010010'
MOVWF LCDCON


Here is the .LST file code from your program. Notice that the VLCDEN
bit is = 0. So the VLCD pins are not enabled. The value of 0x8B is
loaded into LCDCON. This is 1000 1101 in binary. Notice that bit 4
is 0. This means the VLCD pins are disabled.
Quote:
... setup_lcd(LCD_MUX14 | LCD_INTRC, 4);
0689: MOVLW 8B // Value to load into LCDCON
068A: BSF 03.6 // Bank select
068B: MOVWF 07 // LCDCON register

068C: MOVLW 24
068D: MOVWF 08


You can fix this by making the following changes to your program.
1. Add the #define statement for VLCD_ENABLE.
2. Add that constant to the setup_lcd() statement.
See the code shown below:
Quote:

#define VLCD_ENABLE 0x10

setup_lcd(LCD_MUX14 | LCD_INTRC | VLCD_ENABLE , 4);


After re-compiling the program with the changes shown above,
we get the following code in the .LST file. Notice that instead of 0x8B,
the value loaded into LCDCON is now 0x9B.
Quote:

.... setup_lcd(LCD_MUX14 | LCD_INTRC | VLCD_ENABLE , 4);
0689: MOVLW 9B
068A: BSF 03.6
068B: MOVWF 07
068C: MOVLW 24
068D: MOVWF 08

This change may not fix all your problems. You may have several
problems. But at least this should help.
Guest








PostPosted: Tue Oct 03, 2006 1:41 am     Reply with quote

hi,
thanks for the suggestion.

I tried with enabling the LCDEN bit in LCDCON; but still the problem persists.

I checked the same piece of code with 16F916 and it works
Is there any difference for the LCD configuration in 16F913 and 16F916?
or may be some hardware consideration which I have missed out?
My company wants to use 16F913 due to cost factor :(
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Oct 03, 2006 2:17 am     Reply with quote

There is no errata document on the silicon for the 16F91x series.

Have you tried another 16F913 ? Maybe the first one was a bad chip.
ajitmutalik



Joined: 30 Sep 2006
Posts: 5

View user's profile Send private message

PostPosted: Tue Oct 03, 2006 2:58 am     Reply with quote

yes I tried with different 16F913 also.
I tried with almost 10-15 different 16F913 samples.
It worked with only 1 and rest are failing.

but I tried with 2 different 16F916 microcontrollers and the same code worked there.

I am getting confused now.
_________________
Ajit
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Oct 03, 2006 1:44 pm     Reply with quote

1. It could be a problem with the setup of the LCD controller inside
the PIC.

2. There could be some silicon errata that has not been published by
Microchip.

3. It could be a problem with the bias resistor network.
Look at the bias voltages on the VLCD pins with an oscilloscope.
Compare the voltage on the 16F913 with the 16F917. Are there
any differences ?

The Microchip appnote AN658 says this about the resistor values:
Quote:

The resistance values are determined by two factors:
display quality and power consumption. Display quality
is a function of the LCD drive waveforms.

Since the LCD panel is a capacitive load, the waveform is
distorted due to the charging and discharging currents.
This distortion can be reduced by decreasing the value
of resistance. However this change increases the
power consumption due to the increased current now
flowing through the resistors. As the LCD panel
increases in size, the resistance value must be
decreased to maintain the image quality of the display.

So it's possible that changing the bias resistor values could make
a difference.


4. Can you post the exact part number of the LCD that you're using ?
Post a link to the data sheet. If you can do this, then maybe I
can see what are the proper values for the bias resistors.

5. Also post a list of connections between the PIC pins and the LCD pins.
ajitmutalik



Joined: 30 Sep 2006
Posts: 5

View user's profile Send private message

PostPosted: Fri Oct 06, 2006 12:37 am     Reply with quote

I dont have 16F917, I checked the behaviour with 16F916 and sometimes it worked.
For the failed board I checked the VLCD voltages with 16F916 and 16F913 and found it to be the same.
I disabled the LCD configuration and I get a const voltage 1.6V for all VLCD pins.
Also I tried to reduce the resistance values, from 100K to 10K and then to 7.5K; but no difference.
The surprising part is the same software works with some PCBs but it doesnt work with rest.
This lead my suspect towards soldering.

Another behaviour I observed is that the resistance value doesn't remain constant. Once it dropped till 750ohm (it was 10K). Is lead capacitance of PIC creating problems?

The LCD I am using for the project is a custom made for my company by Truly semiconductors, so no specific part no for the same and I can not share that info out of this ........... very sorry :(

The Pin listing goes like this:
Microcontroller LCD
Segx - Segx
x - 0 to 12(except for Seg10 which is not connected)
I am using all the COM pins that also is one-to-one mapped.
Pin no 27 & 28 of mc i.e. Seg14 & Seg13 resp. are pulled down thru a 10K resistor.

Now, I am suspecting the Pin 17&28 connection too :(
_________________
Ajit
Tadashi Konno



Joined: 15 Jul 2007
Posts: 1

View user's profile Send private message

ICSP pin (PICkit2)
PostPosted: Mon Jul 16, 2007 8:56 am     Reply with quote

Hi,
I am studying PIC16F917 to controll 7-seg LCD panel.
But I also found flickering screen in LCD segment.

Today , I can erase this flicker !

I have used PICkit2(ICSP) to program PIC .
The Vdd and GND of PIC is supplised from PICkit2
The ICSP use 39 and 40 pins , so these pin share with seg13 and seg14.
There is no flickering screen when Vdd and GND of PIC is supplised from another switching Voltage.
deepakomanna



Joined: 06 Mar 2007
Posts: 92
Location: Pune,India

View user's profile Send private message AIM Address Yahoo Messenger

vlcden bit..of 16f913
PostPosted: Tue Nov 20, 2007 6:30 am     Reply with quote

dear sir,
While searching, I found this thread & little bit confused.
in this thread you told to enable VLCDEN bit.
Quote:
#define VLCD_ENABLE 0x10

setup_lcd(LCD_MUX14 | LCD_INTRC | VLCD_ENABLE , 4);

But in data sheet they given VLCDEN == 1 after reset.
Also see this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=25360&highlight=16f913
_________________
Thank You,
With Best Regards,
Deepak.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Nov 20, 2007 11:52 am     Reply with quote

Quote:
but in data sheet they given VLCDEN == 1 after reset.

I'll show you how to check this.

Make a small test program, like this:
Code:

#include <16F913.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT
#use delay(clock = 4000000)

//======================================
void main()
{

while(1);
}

Set the Project Options to make the .LST file in Symbolic format.
Then compile the program and look at the .LST file:
Code:

... void main() 
... { 
0004:  CLRF   FSR
0005:  BCF    STATUS.IRP
0006:  MOVLW  1F
0007:  ANDWF  STATUS,F
0008:  BSF    STATUS.RP1
0009:  CLRF   LCDCON   //  This sets the VLCDEN bit = 0.
000A:  CLRF   LCDPS
000B:  CLRF   LCDSEO
000C:  CLRF   LCDSE1
000D:  CLRF   11E
000E:  BCF    STATUS.RP1
000F:  BCF    ADCON0.VCFG0
0010:  BCF    ADCON0.VCFG1
0011:  MOVLW  00
0012:  BSF    STATUS.RP0
0013:  MOVWF  ANSEL
0014:  CLRF   CMCON1
0015:  MOVLW  07
0016:  MOVWF  CMCON0

Notice that the startup code inserted by the compiler sets the LCDCON
register to 0x00. The VLCDEN bit is in this register. So it is set = 0.
That's why, if you want to use the LCD module, you need to set the
VLCDEN bit = 1.

CCS normally puts in start-up code to turn Port A into a digital port,
and disable the comparator, and in this case, to disable the LCD module.
They want the PIC to start up in a "safe" condition.
deepakomanna



Joined: 06 Mar 2007
Posts: 92
Location: Pune,India

View user's profile Send private message AIM Address Yahoo Messenger

vlcden bit..of 16f913
PostPosted: Tue Nov 20, 2007 10:45 pm     Reply with quote

Thats ok,
but ,
http://www.ccsinfo.com/forum/viewtopic.php?t=25360&highlight=16f913
in this you told as,

Quote:
If you look at the pin diagram in the 16F916 data sheet, you'll see that
those pins are shared with the VLCD module. Then if you look at the
LCDCON register description, you'll see that the VLCDEN bit is set = 1
(i.e., it's enabled) after reset. So those pins are not in digital i/o
mode after reset.

Then if you look at the CCS startup code in the .LST file, you'll see
that they don't turn that bit off. They don't change LCDCON at all.


So to turn off that bit, one quick way is to add the line shown in bold,
to your program, below:

#use fast_io(c)

void main()
{
setup_lcd(LCD_DISABLED);

set_tris_c(0);

while(1);
}

See bold letters
And in 16f616 & 16f913 not much difference.
_________________
Thank You,
With Best Regards,
Deepak.
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