|
|
View previous topic :: View next topic |
Author |
Message |
shambhuvetal
Joined: 29 Aug 2008 Posts: 17 Location: Pune
|
PIC16F917, in built LCD in 1/3 mux |
Posted: Fri Aug 29, 2008 8:54 am |
|
|
Hello,
I am working on PIC16f917 & using 7 seg. LCD in 1/3 multiplexing mode.
I am using PCM compiler version 3.
I use standard program given in CCS example file.
but at a time two segments are turned on when i try to glow only one
segment.
first it glow SEG 1 of COM0 & COM1 when i try for SEG1 of COM0 only
2nd it glow SEG 1 of COM1 & COM2 when i try for SEG1 of COM1 only
2nd it glow SEG 1 of COM2 & COM1 when i try for SEG1 of COM2 only
Plz help me to solve this problem. _________________ shambhuvetal |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
shambhuvetal
Joined: 29 Aug 2008 Posts: 17 Location: Pune
|
Not satishfied |
Posted: Sun Aug 31, 2008 6:35 am |
|
|
Dear friend
thanks for u r reply but,
before i put my problem , to this forum
i have tried all the ways to solve this problem.
i already use the code u have suggested but i am not able to solve the problem.
i am not able to understand is it LCD problem or PCM cross compiler problem or whatever code i have written.
Even i have try Waveform B & LCD interrupt also to resolve this problem
but each time result is same.
Please Please help me.
Shambhu
_________________ shambhuvetal |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Aug 31, 2008 4:47 pm |
|
|
Did you buy the LCD board or did you make the board by yourself ?
If you bought the board, then post the manufacturer and part number
of the board. Also post a link to the board's web page. |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Sun Aug 31, 2008 11:49 pm |
|
|
Quote: | I use standard program given in CCS example file. |
Did you make changes necessary to adapt the code to the 1/3 mux used by your LCD?
Generally, I suggest to check the SFR settings carried out by the driver against the expected setup according to the PIC16F917 data sheet with the debugger. I noticed, that some settings, e. g. 1/2 or 1/3 bias mode are apparently done implicitely by lcd_setup() and neither changeable nor documented. (The said 1/4 bias doens't exist, BTW). I guess, that 1/3 bias is used for all multiplex modes. |
|
|
shambhuvetal
Joined: 29 Aug 2008 Posts: 17 Location: Pune
|
I got soln with new problem |
Posted: Thu Sep 04, 2008 5:36 am |
|
|
Dear friend,
When I invert all the signals the 1/3 multiplexed LCD works
properly. I turn on & off each segment separately, e.g. to turn on seg1.
LCD_SYMBOL(0xFE, DIGIT1);
This turns on only SEG0 of Digit one.
Now new problem arise.
To display no. 3, I must turn on SEG A of COM0 COM1 & COM2. When such situation arise, LCD display 3 & then after few moment it display 1. i.e. seg with COM0 COM1 & COM2 turn on then it shows problem.
Pl.Help _________________ shambhuvetal |
|
|
shambhuvetal
Joined: 29 Aug 2008 Posts: 17 Location: Pune
|
LCD Problem |
Posted: Tue Sep 16, 2008 11:54 am |
|
|
Hi,
I am using CCS's PCM 4.13 cross compiler & PIC 16f917 IC
to drive BEL's B303 1/3 mux 7 seg LCD.
when i try to turn on 3 seg of com0 all three seg are turned off.
when i try to turn on 2 seg of com0 it works properly.
as well as my VLCD voltages are fluctuating .
anybody can help me ?
_________________ shambhuvetal |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Sep 16, 2008 12:05 pm |
|
|
I asked you these questions above. You did not answer:
Quote: | Did you buy the LCD board or did you make the board by yourself ?
If you bought the board, then post the manufacturer and part number
of the board. Also post a link to the board's web page. |
Also, post a link to the data sheet for your LCD.
We are not mind-readers. |
|
|
shambhuvetal
Joined: 29 Aug 2008 Posts: 17 Location: Pune
|
LCD problem |
Posted: Tue Sep 16, 2008 11:39 pm |
|
|
I have mfg my own board.
I am using BEL's B303 LCD.
Attaching datasheet Link for LCD.
Schematic is as follow.
Code: | PIC16f917 Pin No. LCD B303 Pin no.
27 1
28 2
29 3
30 4
33 5
34 6
35 7
36 8
8 9
9 10
10 11
22 12
37 COM0
38 COM1
4 COM2 |
VLCD1,2,3 are connected as specified in datasheet.
Link for LCD datasheet. Selected LCD is B303.
http://www.bel-india.com/BELWebsite/images/Liquid%20Crystal%20Display.pdf _________________ shambhuvetal |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Sep 17, 2008 12:21 am |
|
|
Post the test program that you have written. |
|
|
shambhuvetal
Joined: 29 Aug 2008 Posts: 17 Location: Pune
|
Test Program |
Posted: Wed Sep 17, 2008 3:39 am |
|
|
Hello PCM Programmer
Attaching program for reference
Code: |
/*-----------------------------------------------------------*/
#if defined(__PCM__)
#include <16F917.h>
#DEVICE ICD=TRUE
#fuses INTRC_IO,NOWDT,NOPROTECT
#use delay(clock=8000000)
#endif
#define VLCD_ENABLE 0x10
#byte CMCON0 = 0x9c
#byte SEGEN0 = 0x11c
#byte SEGEN1 = 0x11d
#byte SEGEN2 = 0x11e
#byte PIR2 = 0x0D
#byte PIE2 = 0x10B
#byte LCDPS = 0x108
#byte INTCON = 0x0B
#byte LCDCON = 0x107
#bit LCDEN = LCDCON.7
#bit LCDIF = PIR2.4
int1 FlagFrame = 0;
//------------------COM0 as LSB------------------------------
#define DIGIT4 COM0+17, COM1+18, COM2+17, COM1+17, COM0+18, COM1+19, COM2+19, COM2+18
#define DIGIT3 COM0+20, COM1+0 , COM2+20, COM1+20, COM0+0 , COM1+1 , COM2+1 , COM2+0
#define DIGIT2 COM0+2 , COM1+3 , COM2+2 , COM1+2 , COM0+3 , COM1+21, COM2+21, COM2+3
#define DIGIT1 COM0+22, COM1+23, COM2+22, COM1+22, COM0+23, COM1+16, COM2+16, COM2+23
//-------------------------------------------------------------
#define CON COM0+16
#define DIG5MS COM0+19
#define MINUSE COM0+1
#define BAT COM0+21
/*------------------------------------------------------------*/
byte const Seg7[11] =
{ 0xc0, //0
0xf9, //1
0xa4, //2
0xb0, //3
0x99, //4
0x92, //5
0x82, //6
0xf8, //7
0x80, //8
0x90, //9
0xff //BLANK
};
void main()
{
int8 i = 0,j=0,k,l;
CMCON0 = 0x07;
/*
INTCON = 0xC0;
LCDCON = 0x9A;
LCDPS = 0xB5;
PIE2 = 0x10;
LCDIF = 0;
*/
SEGEN0 = 0x0f;
SEGEN1 = 0;
SEGEN2 = 0xff;
setup_lcd(LCD_MUX13| VLCD_ENABLE,5);
LCD_SYMBOL(0xff,DIGIT1);
LCD_SYMBOL(0xff,DIGIT2);
LCD_SYMBOL(0xff,DIGIT3);
LCD_SYMBOL(0xff,DIGIT4);
LCD_SYMBOL(0xff,BAT);
LCD_SYMBOL(0xff,MINUSE);
LCD_SYMBOL(0xff,DIG5MS);
LCD_SYMBOL(0xff,CON);
delay_ms(1000);
LCD_SYMBOL(0,DIGIT1);
delay_ms(1000);
LCD_SYMBOL(0,DIGIT2);
delay_ms(1000);
LCD_SYMBOL(0,DIGIT3);
delay_ms(1000);
LCD_SYMBOL(0,DIGIT4);
delay_ms(1000);
while(TRUE)
{
for(i=0;i<4;i++)
{
for(j=0;j<9;j++)
{
LCD_SYMBOL(Seg7[1],DIGIT1);
LCD_SYMBOL(Seg7[4],DIGIT2);
LCD_SYMBOL(Seg7[7],DIGIT3);
LCD_SYMBOL(Seg7[1],DIGIT4);
delay_ms(1000);
}
}
}
}
/*-----------------------------------------------------------*/
|
_________________ shambhuvetal |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Sep 17, 2008 11:43 am |
|
|
I think your program has a large number of errors in it.
For example, you have these definitions for the segments for Digit 1:
Quote: | #define DIGIT1 COM0+22, COM1+23, COM2+22, COM1+22, COM0+23, COM1+16, COM2+16, COM2+23 |
I looked at your data sheet for the LCD 303. It's on pages 55 and 56.
It has a chart showing the internal connections in the LCD, between the
pins and the segments and the commons. Then I looked at your
table of connections between the PIC pins and the LCD. With that
information, I then made this table, which shows the assignment of
PIC segment drivers and COMs to the character segments on the LCD.
Code: |
Seg Com0 Com1 Com2
17 4F, 4E, 5DP
18 4A, 4G, 4D
19 4B, 4C, 5BC
20 3F, 3E, 4DP
0 3A, 3G, 3D
1 3B, 3C, --
2 2F, 2E, 3DP
3 2A, 2G, 2D
21 2B, 2C, BATT
22 1F, 1E, 2DP
23 1A, 1G, 1D
16 1B, 1C, CONT
|
With that table, you can write the #define statements for the CCS
lcd functions. For the right-hand digit (Digit #1), these are the
correct definitions. (I don't know how you invented your definitions):
Code: |
// 1A 1B 1C 1D 1E 1F 1G 2DP
#define DIGIT1 COM0+23, COM0+16, COM1+16, COM2+23, COM1+22, COM0+22, COM1+23, COM2+22 |
The correct #define statements also need to be written for Digits 2, 3, 4.
Then you have this table in your code:
Quote: | byte const Seg7[11] =
{ 0xc0, //0
0xf9, //1
0xa4, //2
0xb0, //3
0x99, //4
0x92, //5
0x82, //6
0xf8, //7
0x80, //8
0x90, //9
0xff //BLANK
}; |
I don't know how you made this table. It looks like you are
doing inverted definitions. The standard table looks like this:
Code: | // 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,0xE6}; |
Then in the rest of your code you sometimes use the CCS lcd functions,
but sometimes you write directly to registers. Also, you have tons of
code to setup other symbols. Then you try to write a loop to display
lots of characters. You should only try to write 12345 initially.
Just see if you can get the LCD to do that one simple thing. Basically,
you need to fix all your code. I don't really want to do it for you. |
|
|
shambhuvetal
Joined: 29 Aug 2008 Posts: 17 Location: Pune
|
Thanks !!!!!!!!!!!!!!!! |
Posted: Thu Sep 18, 2008 8:38 am |
|
|
Hello PCM programmer,
Thank you very much.
you have taken lot of effort to find out problems.
I will implement your suggestions as early as possible.
for now i will say only
Thanks again & again
: _________________ shambhuvetal |
|
|
shambhuvetal
Joined: 29 Aug 2008 Posts: 17 Location: Pune
|
LCD Problem |
Posted: Fri Sep 19, 2008 1:08 am |
|
|
Hi,
I have implemented all suggestions.
but still its not working.
hence attaching code.
Code: | /
*-------------------------------------------------------*/
#if defined(__PCM__)
#include <16F917.h>
#fuses INTRC_IO,NOWDT,NOPROTECT
#use delay(clock=8000000)
#endif
#define VLCD_ENABLE 0x10
// Digit segments A B C D E F G DP
// b7 b6 b5 b4 b3 b2 b1 b0
/*-------------------------------------------------------*/
#define DIGIT4 COM0+18, COM0+19, COM1+19, COM2+18, COM1+17, COM0+17, COM1+18, COM2+17
#define DIGIT3 COM0+0 , COM0+1 , COM1+1 , COM2+0 , COM1+20, COM0+20, COM1+0 , COM2+20
#define DIGIT2 COM0+3 , COM0+21, COM1+21, COM2+3 , COM1+2 , COM0+2 , COM1+3 , COM2+2
#define DIGIT1 COM0+23, COM0+16, COM1+16, COM2+23, COM1+22, COM0+22, COM1+23, COM2+22
//--------------------------------------------------------
// The following array tells the CCS lcd_symbol() function which
// segments to turn on, to display the numbers from 0 to 9.
// 0 1 2 3 4 5 6 7 8 9 Blank
byte const Digit_Map[11] ={0xFC,0x60,0xDA,0xF2,0x66,0xB6,0xBE,0xE0,0xFE,0xE6,0x00};
#define BLANK 0 // For a blank digit, don't turn on any segments.
//===================================
void main()
{
delay_ms(100);
setup_lcd(LCD_MUX13|VLCD_ENABLE, 5);
while(TRUE)
{
LCD_SYMBOL(Digit_Map[1],DIGIT1);
LCD_SYMBOL(Digit_Map[2],DIGIT2);
LCD_SYMBOL(Digit_Map[3],DIGIT3);
LCD_SYMBOL(Digit_Map[4],DIGIT4);
delay_ms(2000);
}
}
/*----------------------------------------------------------*/
|
List file generated is:
Code: |
CCS PCM C Compiler, Version 4.076 19-Sep-08 11:32
Filename: uCN-1100.lst
ROM used: 214 words (3%)
Largest free fragment is 2048
RAM used: 7 (2%) at main() level
8 (2%) worst case
Stack: 1 locations
*
0000: MOVLW 00
0001: MOVWF 0A
0002: GOTO 018
0003: NOP
.................... #if defined(__PCM__)
.................... #include <16F917.h>
.................... //////// Standard Header file for the PIC16F917 device ////////////////
.................... #device PIC16F917
.................... #list
....................
.................... #fuses INTRC_IO,NOWDT,NOPROTECT
.................... #use delay(clock=8000000)
0004: MOVLW 22
0005: MOVWF 04
0006: BCF 03.7
0007: MOVF 00,W
0008: BTFSC 03.2
0009: GOTO 017
000A: MOVLW 02
000B: MOVWF 78
000C: CLRF 77
000D: DECFSZ 77,F
000E: GOTO 00D
000F: DECFSZ 78,F
0010: GOTO 00C
0011: MOVLW 97
0012: MOVWF 77
0013: DECFSZ 77,F
0014: GOTO 013
0015: DECFSZ 00,F
0016: GOTO 00A
0017: RETLW 00
.................... #endif
.................... #define VLCD_ENABLE 0x10
.................... // Digit segments A B C D E F G DP
.................... // b7 b6 b5 b4 b3 b2 b1 b0
.................... /*---------------------------------------------------------------------------------------*/
.................... #define DIGIT4 COM0+18, COM0+19, COM1+19, COM2+18, COM1+17, COM0+17, COM1+18, COM2+17
.................... #define DIGIT3 COM0+0 , COM0+1 , COM1+1 , COM2+0 , COM1+20, COM0+20, COM1+0 , COM2+20
.................... #define DIGIT2 COM0+3 , COM0+21, COM1+21, COM2+3 , COM1+2 , COM0+2 , COM1+3 , COM2+2
.................... #define DIGIT1 COM0+23, COM0+16, COM1+16, COM2+23, COM1+22, COM0+22, COM1+23, COM2+22
.................... //--------------------------------------------------------------------------------------
.................... // The following array tells the CCS lcd_symbol() function which
.................... // segments to turn on, to display the numbers from 0 to 9.
.................... // 0 1 2 3 4 5 6 7 8 9 Blank
.................... byte const Digit_Map[11] ={0xFC,0x60,0xDA,0xF2,0x66,0xB6,0xBE,0xE0,0xFE,0xE6,0x00};
.................... #define BLANK 0 // For a blank digit, don't turn on any segments.
....................
....................
.................... //===================================
.................... void main()
.................... {
0018: CLRF 04
0019: BCF 03.7
001A: MOVLW 1F
001B: ANDWF 03,F
001C: MOVLW 71
001D: BSF 03.5
001E: MOVWF 0F
001F: MOVF 0F,W
0020: BCF 03.5
0021: BSF 03.6
0022: CLRF 07
0023: CLRF 08
0024: MOVLW 0F
0025: MOVWF 1C
0026: CLRF 1D
0027: MOVLW FF
0028: MOVWF 1E
0029: BCF 03.6
002A: BCF 1F.5
002B: BCF 1F.6
002C: MOVLW 00
002D: BSF 03.5
002E: MOVWF 11
002F: CLRF 17
0030: MOVLW 07
0031: MOVWF 1C
.................... delay_ms(100);
0032: MOVLW 64
0033: BCF 03.5
0034: MOVWF 22
0035: CALL 004
.................... setup_lcd(LCD_MUX13|VLCD_ENABLE, 5);
0036: MOVLW 92
0037: BSF 03.6
0038: MOVWF 07
0039: MOVLW 25
003A: MOVWF 08
.................... while(TRUE)
.................... {
.................... LCD_SYMBOL(Digit_Map[1],DIGIT1);
003B: BSF 08.4
003C: MOVLW 60
003D: MOVWF 77
003E: BTFSS 77.7
003F: BCF 12.7
0040: BTFSC 77.7
0041: BSF 12.7
0042: BTFSS 77.6
0043: BCF 12.0
0044: BTFSC 77.6
0045: BSF 12.0
0046: BTFSS 77.5
0047: BCF 15.0
0048: BTFSC 77.5
0049: BSF 15.0
004A: BTFSS 77.4
004B: BCF 18.7
004C: BTFSC 77.4
004D: BSF 18.7
004E: BTFSS 77.3
004F: BCF 15.6
0050: BTFSC 77.3
0051: BSF 15.6
0052: BTFSS 77.2
0053: BCF 12.6
0054: BTFSC 77.2
0055: BSF 12.6
0056: BTFSS 77.1
0057: BCF 15.7
0058: BTFSC 77.1
0059: BSF 15.7
005A: BTFSS 77.0
005B: BCF 18.6
005C: BTFSC 77.0
005D: BSF 18.6
005E: BCF 08.4
.................... LCD_SYMBOL(Digit_Map[2],DIGIT2);
005F: BSF 08.4
0060: MOVLW DA
0061: MOVWF 77
0062: BTFSS 77.7
0063: BCF 10.3
0064: BTFSC 77.7
0065: BSF 10.3
0066: BTFSS 77.6
0067: BCF 12.5
0068: BTFSC 77.6
0069: BSF 12.5
006A: BTFSS 77.5
006B: BCF 15.5
006C: BTFSC 77.5
006D: BSF 15.5
006E: BTFSS 77.4
006F: BCF 16.3
0070: BTFSC 77.4
0071: BSF 16.3
0072: BTFSS 77.3
0073: BCF 13.2
0074: BTFSC 77.3
0075: BSF 13.2
0076: BTFSS 77.2
0077: BCF 10.2
0078: BTFSC 77.2
0079: BSF 10.2
007A: BTFSS 77.1
007B: BCF 13.3
007C: BTFSC 77.1
007D: BSF 13.3
007E: BTFSS 77.0
007F: BCF 16.2
0080: BTFSC 77.0
0081: BSF 16.2
0082: BCF 08.4
.................... LCD_SYMBOL(Digit_Map[3],DIGIT3);
0083: BSF 08.4
0084: MOVLW F2
0085: MOVWF 77
0086: BTFSS 77.7
0087: BCF 10.0
0088: BTFSC 77.7
0089: BSF 10.0
008A: BTFSS 77.6
008B: BCF 10.1
008C: BTFSC 77.6
008D: BSF 10.1
008E: BTFSS 77.5
008F: BCF 13.1
0090: BTFSC 77.5
0091: BSF 13.1
0092: BTFSS 77.4
0093: BCF 16.0
0094: BTFSC 77.4
0095: BSF 16.0
0096: BTFSS 77.3
0097: BCF 15.4
0098: BTFSC 77.3
0099: BSF 15.4
009A: BTFSS 77.2
009B: BCF 12.4
009C: BTFSC 77.2
009D: BSF 12.4
009E: BTFSS 77.1
009F: BCF 13.0
00A0: BTFSC 77.1
00A1: BSF 13.0
00A2: BTFSS 77.0
00A3: BCF 18.4
00A4: BTFSC 77.0
00A5: BSF 18.4
00A6: BCF 08.4
.................... LCD_SYMBOL(Digit_Map[4],DIGIT4);
00A7: BSF 08.4
00A8: MOVLW 66
00A9: MOVWF 77
00AA: BTFSS 77.7
00AB: BCF 12.2
00AC: BTFSC 77.7
00AD: BSF 12.2
00AE: BTFSS 77.6
00AF: BCF 12.3
00B0: BTFSC 77.6
00B1: BSF 12.3
00B2: BTFSS 77.5
00B3: BCF 15.3
00B4: BTFSC 77.5
00B5: BSF 15.3
00B6: BTFSS 77.4
00B7: BCF 18.2
00B8: BTFSC 77.4
00B9: BSF 18.2
00BA: BTFSS 77.3
00BB: BCF 15.1
00BC: BTFSC 77.3
00BD: BSF 15.1
00BE: BTFSS 77.2
00BF: BCF 12.1
00C0: BTFSC 77.2
00C1: BSF 12.1
00C2: BTFSS 77.1
00C3: BCF 15.2
00C4: BTFSC 77.1
00C5: BSF 15.2
00C6: BTFSS 77.0
00C7: BCF 18.1
00C8: BTFSC 77.0
00C9: BSF 18.1
00CA: BCF 08.4
.................... delay_ms(2000);
00CB: MOVLW 08
00CC: BCF 03.6
00CD: MOVWF 21
00CE: MOVLW FA
00CF: MOVWF 22
00D0: CALL 004
00D1: DECFSZ 21,F
00D2: GOTO 0CE
.................... }
00D3: BSF 03.6
00D4: GOTO 03B
.................... }
.................... /*-------------------------------------------*/
00D5: SLEEP
Configuration Fuses:
Word 1: 3FE4 NOWDT PUT NOPROTECT MCLR NOCPD BROWNOUT IESO FCMEN NODEBUG INTRC_IO |
output on display is like thise:
Code: | ______
| | | | | |
| | | | | |
| |
|_____ * |
|
_________________ shambhuvetal |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Sep 19, 2008 11:39 am |
|
|
I think it's possible that the mapping of the segments is not correct.
The problem could be that:
1. Your connections between the PIC and the LCD may not really be
the same as the list that you have posted.
2. Your LCD may be different than the BEL data sheet.
I suggest that you try to make only one digit work (not 4 digits).
Try to display the number "1" in the lowest digit. If that works,
then try other numbers, but only display them in the lowest digit.
(The digit on the right side of the LCD). |
|
|
|
|
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
|