Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to display a floating point number on three common cathod seven segment display

To display a floating point number (0.0 to 99.9) on three common cathod seven
segment displays using multiplexing.
In the program variable n accepts the floating point number. It may accept an
input from The result will be 12.6. You can also accept a value from Analog to digital
converter(after converting the output into float); like the following:-

while(1){
getadc=ADC_PORT;
n=(getadc*5)/1023;

}

To display a floating point number (0.0 to 99.9) on three common cathod seven
segment displays using multiplexing. Pin a,b,c,d,e,f,g and dp of each
seven segment display are connected to PORTB pin 0 to pin 7 through
330 Ohm Resistors. 3 pins of PORTA are connected to the base
of three BC548B Transistors respectively through 1K Resistors.
Collectors of each Transistor is connected to common pins of each Seven Segment
Display. All the emitters are connected to ground.
Processor: pic16F876A with 20MHz Xtal also tested with 16F84a with 4Mhz
Compiler: MikroC Pro
For Hi-Tech C compiler place the following three lines at the top

#include <htc.h>
#define _XTAL_FREQ 20000000
__CONFIG(FOSC_HS & WDTE_OFF & LVP_OFF & CPD_OFF & WRT_OFF & DEBUG_OFF & CP_OFF);
////////////////////////////////////////////////////////////////////////////////////////////////////

#define FND_one_ON 0x01;
#define FND_two_ON 0x02;
#define FND_three_ON 0x04;

sbit FND_one_latch_Direction at TRISA0_bit;
sbit FND_two_latch_Direction at TRISA1_bit;
sbit FND_three_latch_Direction at TRISA2_bit;

void disp_digits(int n);
void fnd_display(int val,int pos);
unsigned char lup[11]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x67};

void main() {

int digits[2];
float n;
int ls,rs;
int i,j;
i=0;

FND_one_latch_Direction =0;
FND_two_latch_Direction =0;
FND_three_latch_Direction =0;
TRISB=0;
n=12.56; //Here I am accepting a floating point value
n=n+0.05; //to round off
ls=n; //ls contains digits before decimal place
rs=(n-ls)*10;

if(ls<=9)
{
digits[0]=0;
digits[1]=ls;
}
else
{

digits[1]=ls%10;
digits[0]=ls/10;


}

while(1){
for(i=0;i<=1;i++)
{
Delay_ms(5);
fnd_display(digits,i);
}
Delay_ms(5);
fnd_display(rs,2);
}
}
void fnd_display(int val,int pos){

switch(pos){

case 0:
PORTA=FND_one_ON;
PORTB=lup[val];
break;
case 1:
PORTA= FND_two_ON;
PORTB=lup[val]+0x80;
break;
case 2:
PORTA= FND_three_ON;
PORTB=lup[val];
break;

}
return ;
}

fndfloat.JPG

sch.png

Comments

There are no comments to display.

Part and Inventory Search

Blog entry information

Author
papunblg
Read time
2 min read
Views
691
Last update

More entries in Uncategorized

More entries from papunblg

Share this entry

Back
Top