+ Post New Thread
Results 1 to 11 of 11
  1. #1
    Full Member level 1
    Points: 922, Level: 6

    Join Date
    Oct 2010
    Location
    kathmandu,nepal
    Posts
    119
    Helped
    3 / 3
    Points
    922
    Level
    6

    real values in 7-segment

    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!

  2. #2
    Advanced Member level 3
    Points: 5,915, Level: 18

    Join Date
    Dec 2010
    Location
    USA, midwest
    Posts
    960
    Helped
    308 / 308
    Points
    5,915
    Level
    18

    Re: real values in 7-segment

    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 The Seven-Segment LED



    •   Alt12th September 2011, 04:08

      advertising

        
       

  3. #3
    Administrator
    Points: 37,858, Level: 47
    Achievements:
    Created Album pictures Created Blog entry 7 years registered
    alexan_e's Avatar
    Join Date
    Mar 2008
    Location
    Greece
    Posts
    11,889
    Helped
    2084 / 2084
    Points
    37,858
    Level
    47
    Blog Entries
    6

    Re: real values in 7-segment

    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
    Please don't make requests for help in private using PM. Create a thread in the forum so that other members can benefit from the posted answers.

    Consider reading this before posting : How To Ask Questions The Smart Way



  4. #4
    Full Member level 1
    Points: 922, Level: 6

    Join Date
    Oct 2010
    Location
    kathmandu,nepal
    Posts
    119
    Helped
    3 / 3
    Points
    922
    Level
    6

    Re: real values in 7-segment

    * 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!



  5. #5
    Administrator
    Points: 37,858, Level: 47
    Achievements:
    Created Album pictures Created Blog entry 7 years registered
    alexan_e's Avatar
    Join Date
    Mar 2008
    Location
    Greece
    Posts
    11,889
    Helped
    2084 / 2084
    Points
    37,858
    Level
    47
    Blog Entries
    6

    Re: real values in 7-segment

    The first way I have described works fine for you, you are either using ADC to read the value or a digital I2C sensor but in any case the value can easily be handled as an integer until the time it will be shown in the display.

    Take a look at the following project to understand what I mean
    Interfacing Temperature Sensor with AVR Microcontrollers - LM35 | eXtreme Electronics
    Please don't make requests for help in private using PM. Create a thread in the forum so that other members can benefit from the posted answers.

    Consider reading this before posting : How To Ask Questions The Smart Way



    •   Alt12th September 2011, 08:33

      advertising

        
       

  6. #6
    Full Member level 1
    Points: 922, Level: 6

    Join Date
    Oct 2010
    Location
    kathmandu,nepal
    Posts
    119
    Helped
    3 / 3
    Points
    922
    Level
    6

    Re: real values in 7-segment

    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



  7. #7
    Administrator
    Points: 37,858, Level: 47
    Achievements:
    Created Album pictures Created Blog entry 7 years registered
    alexan_e's Avatar
    Join Date
    Mar 2008
    Location
    Greece
    Posts
    11,889
    Helped
    2084 / 2084
    Points
    37,858
    Level
    47
    Blog Entries
    6

    Re: real values in 7-segment

    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
    Please don't make requests for help in private using PM. Create a thread in the forum so that other members can benefit from the posted answers.

    Consider reading this before posting : How To Ask Questions The Smart Way



  8. #8
    Full Member level 1
    Points: 922, Level: 6

    Join Date
    Oct 2010
    Location
    kathmandu,nepal
    Posts
    119
    Helped
    3 / 3
    Points
    922
    Level
    6

    Re: real values in 7-segment

    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



  9. #9
    Administrator
    Points: 37,858, Level: 47
    Achievements:
    Created Album pictures Created Blog entry 7 years registered
    alexan_e's Avatar
    Join Date
    Mar 2008
    Location
    Greece
    Posts
    11,889
    Helped
    2084 / 2084
    Points
    37,858
    Level
    47
    Blog Entries
    6

    Re: real values in 7-segment

    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
    Please don't make requests for help in private using PM. Create a thread in the forum so that other members can benefit from the posted answers.

    Consider reading this before posting : How To Ask Questions The Smart Way


    1 members found this post helpful.

    •   Alt12th September 2011, 10:17

      advertising

        
       

  10. #10
    Full Member level 1
    Points: 922, Level: 6

    Join Date
    Oct 2010
    Location
    kathmandu,nepal
    Posts
    119
    Helped
    3 / 3
    Points
    922
    Level
    6

    Re: real values in 7-segment

    :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?



  11. #11
    Administrator
    Points: 37,858, Level: 47
    Achievements:
    Created Album pictures Created Blog entry 7 years registered
    alexan_e's Avatar
    Join Date
    Mar 2008
    Location
    Greece
    Posts
    11,889
    Helped
    2084 / 2084
    Points
    37,858
    Level
    47
    Blog Entries
    6

    Re: real values in 7-segment

    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
    http://www.edaboard.com/thread223766.html#post954482

    Alex
    Please don't make requests for help in private using PM. Create a thread in the forum so that other members can benefit from the posted answers.

    Consider reading this before posting : How To Ask Questions The Smart Way



--[[ ]]--