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.

real values in 7-segment

Status
Not open for further replies.

ucsam

Advanced Member level 4
Joined
Oct 12, 2010
Messages
119
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
kathmandu,nepal
Activity points
2,058
hello!
I want to display the float value in 7-segment, but i just can't figure it out..

I think that if i know the exact position in the data den we can find out where to put the decimal point but since the decimal point cannot be passed in array ( i guess so, correct me if i am wrong) please help me provide me some links or codes or just even ideas!

thanks!
 

On some 7-segment displays, they have a separate pin for a decimal point LED (dp). That function is not built into a BCD-to-7 seg driver, but you can certainly wire a digital output line on your controller to a small-signal transistor, to turn the decimal point on/off.

Read **broken link removed**
 

usually you create a circuit where you expect specific values, for example 0.0v to 10.0v or a temperature like 0.0 degree to 70.0 so instead of calculating the float value you calculate an integer (using a multiplier) and then you add the dot manually in the display to show the result , for example values 0 to 700 are shown as '0' '.' '0' '0' to '7' '.' '0' '0'
I suppose you are asking for a similar case, what is the source of your float?

An alternative is to use printf with floats but it will consume a lot of code space
C Tutorial – printf, Format Specifiers, Format Conversions and Formatted Output | CodingUnit Programming Tutorials

Alex
 

* we cannot use prinf function while interfacing with 7-segment


I am building a temperature sensor where the Farenheit temperature is in float, so i must know where is the position of the decimal point. Thanks for your reply but it seems i cannot use that method. Please help me..i was thinking if i can do some mathematics and find out where the decimal point is.. Please help me!

Thank you!
 


thanks for your quick reply but i still don't get it..because i am using 8051 and keil c i went through the link, i understood what you were trying to explain but i still don't get HOW TO MAKE MY MICROCONTROLLER understand that the incoming data is real or not since i don't have much segments multiplexed!

---------- Post added at 08:49 ---------- Previous post was at 08:43 ----------

* i must also know the position of the decimal so that i can put the decimal point manually
 

can you provide some info of the values you receive from your sensor, it is either analog or digital and in any case YOU are the one who is converting it into a float, when you receive the measurement result it is a (probably unsigned) hex value so what the code in the link does is to handle the result as an integer (using a known multiplier) until it needs to be shown in the display.

Alex
 

i get the output from lm35 with adc0804 but i want my system to show temperature at both Celcius and Farenheit. The farenheit conversion part gives me the real values.
The conversion code is as follows:


float convert(unsigned char temp_value)
{
float out_value;
out_value=((180*temp_value)+3200)/100;
return(out_value);
}



now if u input 32 in the function the it would give back 89.6
 

so the input is an 8bit value

the result range if you remove the divider (100) is

((180*0)+3200)=3200
((180*255)+3200)=49100

the above numbers are still integers if you don't divide them with 100 and the decimal position is exactly the same, two digits from the back so to show these integers in the display you convert them to ASCII and put the dot in the second decimal from the back

3200= '3','2','0','0' which will be shown as '3','2','.','0','0'
49100= '4','9','1','0','0' which will be shown as '4','9','1','.','0','0'

this is in case of an LCD, since you are using led you only have to turn on the dot of the second character from the end and just show the integer right justified

Alex

---------- Post added at 12:17 ---------- Previous post was at 11:31 ----------

actually you don't even need the second decimal because it will always be 0 so you only need 4 led display
 
  • Like
Reactions: ucsam

    ucsam

    Points: 2
    Helpful Answer Positive Rating
:D thanks man! never thought that part! you guys are great i will try to use it but the solution you said gives me decimal point even when there are no points needed! (32 like 32.00 and it seems dumb!) i want my system to determine
itself Find out if its a real number if yes den place decimal otherwise just return the calculation. Can we do that? i mean i know once i define it as float it will always have 0.0000 but can we still have any solution?
 

Usually (actually I have never seen different) all temperature readings use a fixed pint decimal so they show 50.0 or 50.1 etc, they don't hide the decimal where it is 0 and I see no reason for you to implement it this way.
Also as I have noted in my previous post you only need one decimal since, the second will always be 0 in your case because 180 multiplied with any integer gives 0 as last digit.

I you need a custom integer to char array function check
https://www.edaboard.com/threads/223766/#post954482

Alex
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top