chanduchi
Junior Member level 2
Hi friends
Here iam displaying the Voltage on 7 segment display
In this program iam facing diaplay probalm
It is flickering and not showing the correct values on the display
Please solve this problam
Regards
naresh
/* Program for display analog voltage On 7 segment display */
#include<reg51.h>
#include <stdio.h>
void Delay(unsigned int);
sbit R=P1^0; /* ADC control bits*/
sbit W=P1^1;
sbit I=P1^2;
sbit c1=P3^0; /* Latch enable bit for 1 seven segment display*/
sbit c2=P3^1; /* Latch enable bit for 2 seven segment display */
sbit c3=P3^0; /* Latch enable bit for 3 seven segment display */
sbit c4=P3^1; /* Latch enable bit for 4seven segment display */
void main(void)
{
char convert[10] ={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; /* Display elements*/
unsigned char value,value1;
unsigned char a,b,c,s1,s2,s3,s4,a1,b1,d1;
long int f,e;
value1=0;
b=0xc4;
c=0x64;
P0=0xFF; /* P0 is Input Port */
I=0; /* ADC control elements initialization*/
R=1;
W=1;
Value=0;
While (1)
{
W=0;
W=1; /* ADC convertion starts here*/
While(I==1);
R=0;
Value=P0; /*Get the hex number corresponding analog input voltage */
a=value; /* conversion of Hex number to voltage Ex:0XFF=5.00V */
e=a*b;
f=e/c;
s1=f/10; /* Hex to decimal conversion * /
s2=f%10;
s3=s1/10;
s4=s1%10;
a1= convert[s3]; /* seven segment display convertion */
d1= convert[s4];
b1= convert[s2];
if(value=value1)
{
P2=s1;
c1=1; /* Latch enable*/
Delay(100);
c1=0; /* Latch disable*/
P2=s2;
c2=1; /* Latch enable*/
Delay(100);
c2=0; /* Latch disable*/
P2=s3;
c3=1; /* Latch enable*/
Delay(100);
c3=0; /* Latch disable*/
P2=s3;
c3=1; /* Latch enable*/
Delay(100);
c3=0; /* Latch disable*/
}
Value1=value;
R=1;
}
/* Iam using 11.052MHZ Crystal */
void Delay(unsigned int time)
{
unsigned int i,j;
for(i=0;i<time;i++)
for(j=0;j<1275;j++);
}
Here iam displaying the Voltage on 7 segment display
In this program iam facing diaplay probalm
It is flickering and not showing the correct values on the display
Please solve this problam
Regards
naresh
/* Program for display analog voltage On 7 segment display */
#include<reg51.h>
#include <stdio.h>
void Delay(unsigned int);
sbit R=P1^0; /* ADC control bits*/
sbit W=P1^1;
sbit I=P1^2;
sbit c1=P3^0; /* Latch enable bit for 1 seven segment display*/
sbit c2=P3^1; /* Latch enable bit for 2 seven segment display */
sbit c3=P3^0; /* Latch enable bit for 3 seven segment display */
sbit c4=P3^1; /* Latch enable bit for 4seven segment display */
void main(void)
{
char convert[10] ={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; /* Display elements*/
unsigned char value,value1;
unsigned char a,b,c,s1,s2,s3,s4,a1,b1,d1;
long int f,e;
value1=0;
b=0xc4;
c=0x64;
P0=0xFF; /* P0 is Input Port */
I=0; /* ADC control elements initialization*/
R=1;
W=1;
Value=0;
While (1)
{
W=0;
W=1; /* ADC convertion starts here*/
While(I==1);
R=0;
Value=P0; /*Get the hex number corresponding analog input voltage */
a=value; /* conversion of Hex number to voltage Ex:0XFF=5.00V */
e=a*b;
f=e/c;
s1=f/10; /* Hex to decimal conversion * /
s2=f%10;
s3=s1/10;
s4=s1%10;
a1= convert[s3]; /* seven segment display convertion */
d1= convert[s4];
b1= convert[s2];
if(value=value1)
{
P2=s1;
c1=1; /* Latch enable*/
Delay(100);
c1=0; /* Latch disable*/
P2=s2;
c2=1; /* Latch enable*/
Delay(100);
c2=0; /* Latch disable*/
P2=s3;
c3=1; /* Latch enable*/
Delay(100);
c3=0; /* Latch disable*/
P2=s3;
c3=1; /* Latch enable*/
Delay(100);
c3=0; /* Latch disable*/
}
Value1=value;
R=1;
}
/* Iam using 11.052MHZ Crystal */
void Delay(unsigned int time)
{
unsigned int i,j;
for(i=0;i<time;i++)
for(j=0;j<1275;j++);
}