|
|
View previous topic :: View next topic |
Author |
Message |
deepakomanna
Joined: 06 Mar 2007 Posts: 92 Location: Pune,India
|
problem to display decimal point |
Posted: Sat May 12, 2007 4:32 am |
|
|
Dear Sir,
i am using 16f913, MPLAB 7.5 Ver. & CCS PCM C Compiler, Version 3.249, 34534.
here i want to display 0.0 digits on a glass lcd display.
initially i display 00,then i am trying to disply 0.0,
the right most digit will not displaying.displying 0. only.
here is my short code.
Code: |
#include<16F913.h>
#fuses INTRC_IO,NOWDT,PUT,/*****/MCLR,PROTECT,NOCPD,NOBROWNOUT,NOPROTECT,NOIESO,NOFCMEN
#use delay(clock=8000000)
// A B C D E F G DP
// b7 b b5 b4 b3 b2 b1 b0
#define DIGIT1 COM3+6, COM2+6, COM0+6, COM1+6, COM0+5, COM3+5, COM2+5, COM1+5 // DISPALYS 0 FROM RIGHT SIDE
#define DIGIT2 COM3+7, COM2+7, COM0+7, COM1+7, COM0+4, COM3+4, COM2+4 // DISPALYS 1 FROM RIGHT SIDE
#define DIGIT3 COM3+8, COM2+8, COM0+8, COM1+8, COM0+3, COM3+3, COM2+3 // DISPALYS FROM RIGHT SIDE
#define DIGIT4 COM3+9, COM2+9, COM0+9, COM1+9, COM0+2, COM3+2, COM2+2 // DISPALYS FROM RIGHT SIDE
#define DIGIT5 COM3+11, COM2+11, COM0+11, COM1+11, COM0+1, COM3+1, COM2+1 // DISPALYS FROM RIGHT SIDE
#define DIGIT6 COM3+12, COM2+12, COM0+12, COM1+12, COM0+0, COM3+0, COM2+0 // DISPALYS FROM RIGHT SIDE
#define VLCD_ENABLE 0x10
#define BLANK 0
byte const Digit_Map[10] = {0xFC,0x60,0xDA,0xF2,0x66,0xB6,0xBE,0xE0,0xFE,0xF6};
int8 i;
void init_CPU();
void lcd_putc(int);
int8 lcd_pos ;
byte segments;
void main()
{
int number ;
init_CPU();
number = 0;
i = 0;
lcd_pos = 1;
while(TRUE)
{
lcd_putc(number);
if(number++== 9)
{
number = 0;
}
delay_ms(1000);
}
}
void lcd_putc(int c)
{
if((c>=0)&&(c <= 9))
{
segments=Digit_Map[c];
}
switch(lcd_pos)
{
case 1:
LCD_SYMBOL(segments,DIGIT1);
LCD_SYMBOL(0x01,DIGIT1);
LCD_SYMBOL(Digit_Map[i],DIGIT2);
if(segments == Digit_Map[9])
{
segments = Digit_Map[0];
i++;
if(i == 10 )
i = 0;
}
else
lcd_pos = 1;
break;
}
}
void init_CPU()
{
/************** PORT SETTINGS ****************/
PORT_B_PULLUPS(0XC0);
SET_TRIS_A(0X80);
SET_TRIS_B(0XC0);
SET_TRIS_C(0X27);
SET_TRIS_E(0X08);
SETUP_COMPARATOR(NC_NC_NC_NC);
SETUP_LCD( LCD_MUX14 | LCD_INTRC |VLCD_ENABLE , 2);
segments=BLANK;
lcd_symbol(segments,DIGIT6);
lcd_symbol(segments,DIGIT5);
lcd_symbol(segments,DIGIT4);
lcd_symbol(segments,DIGIT3);
lcd_symbol(segments,DIGIT2);
lcd_symbol(segments,DIGIT1);
}
|
_________________ Thank You,
With Best Regards,
Deepak. |
|
|
MarcosAmbrose
Joined: 25 Sep 2006 Posts: 38 Location: Adelaide, Australia
|
Re: problem to display decimal point |
Posted: Sun May 13, 2007 12:56 am |
|
|
Well since number is an int there's not a lot to be gained by displaying as an decimal point, but if you want to display a decimal 0 you can format your output with a printf
Code: |
printf(lcd_putc,"%d.0",number);
|
deepakomanna wrote: | Dear Sir,
i am using 16f913, MPLAB 7.5 Ver. & CCS PCM C Compiler, Version 3.249, 34534.
here i want to display 0.0 digits on a glass lcd display.
initially i display 00,then i am trying to disply 0.0,
the right most digit will not displaying.displying 0. only.
here is my short code.
|
|
|
|
deepakomanna
Joined: 06 Mar 2007 Posts: 92 Location: Pune,India
|
problem to display decimal point |
Posted: Sun May 13, 2007 9:26 pm |
|
|
but sir, here i am incrementing right most digit i.e. .0 from 0-9. and the decimal point i have to blink in every sec.
Further to display the decimal point i made change in code is
Code: | byte const Digit_Map[11] = {0xFD,0x61,0xDB,0xF3,0x67,0xB7,0xBF,0xE1,0xFF,0xF7,0x00}; |
plz reply soon _________________ Thank You,
With Best Regards,
Deepak. |
|
|
Ttelmah Guest
|
|
Posted: Mon May 14, 2007 2:25 am |
|
|
First comment, the 'best' way to us an integer, is to use the %w format.
If you use:
Code: |
int16 val;
val=123;
printf(lcd_putc,"%4.1w",val);
|
The compiler will output the integer value '123', as "12.3". You can increment/decrement the integer as you want, without problems...
Now, the reason for the large 'silence', is that your code is written in a way that makes it very hard to follow what you are doing, and how you are trying to do it. Learn to use comments, and lay things out in a logical way. Keep lcd_putc, so that it handles a single character, as in the example, ex92lcd.c. All you need 'add' to the lcd_putc function, is in the line, where it puts 'segments=blank', if the value arriving is not a digit, you simply set 'segments=', and the value neded to drive the DP. Then if you send a value to it with %w, it should work.
Best Wishes |
|
|
|
|
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
|