Display Float Value on three 7-segment display

Go To Last Post
20 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

I am using ATmega16 @8MHz internal oscillator and its 10-bit ADC.

I want to display floating value on three number of 7-segment display.

for example. if ADC_pin looks 100mV the 7-segment
display shows 20.4 or 20.5 and if
ADC_pin looks 200mV the display is
40.9 and if ADC_pin looks 1V the
display is 204 and so on.

In other words,the 7-segment display
shows values 00.0 till 999. OR every
equivalent values on ADC_pin.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What programming language?

Oh and by 00.0 do you mean 0.00? In other words are you saying you want to represent the ADC reading from 0.00 to 999.00 (but .0 obviously not displayable?) If so then that looks like you are asking for 100,000 discrete steps in something that can only deliver 1024 different values?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
In other words are you saying you want to represent the ADC reading from 0.00 to 999.00
It sounds to me like he wants values from 0.0 to 999.0 which is 10000 steps. Still 10 times what is actually available, but certainly better.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I want to display values looks like below,

00.0-00.1-00.2.......00.9-01.0-01.1-01.2.....01.9-02.0

02.1.......02.9-03.0...04.0...06.0...09.0-09.1-09.2....
....09.9-10.0-10.1-10.2....20.0...60.0.....90.0....99.0....100-101-102.....200...300...700..900...999 then roll over to 00.0

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

One idea is calculate everything in tenthvolts and turn on the decimal point in digit 1,2 or 3 depending on the value in tenthvolts. If you do all the calcs in floating point and convert it to a string, the decimal will be in a char by itself, so you need to set the dp in digit 1 2 or 3 depending on what char the dp was in the string. Man this is hard to describe in words.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The obvious solution is to use sprintf() from the printf_flt library. e.g. %03.2f and display the first 3 digits.

So you scale your ADCW result to give you the f-p result that you want. e.g. float result = 0.97559 * ADCW;

0 0.00
1 0.98
2 1.95
...
1022 997
1023 998

Be realistic. Only small ADCW values less than 103 will display the decimals.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Switch from linear scale voltage(Volts) to logarithmic (Bells) if you need

Quote:
00.0-00.1(...)999

that dynamics. With linear scale that is unrealistic to achieve not only that accuracy but even resolution (~17 bits).
This ADC returns only ~1000 values, you know. With dithering you could perhaps get a readable 14-bit values but nothing close to 17 bits.

And of course you can make some switched ranges (if you apply 0.01U to ADC1, 0.1U to ADC2,..,100U to ADC5) but then switching needs to be made seamlessly (requires linearity).

wlkwd

No RSTDISBL, no fun!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you dear David,

How to move decimal point on 7-segment display.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

How to move decimal point on 7-segment display.

Each 7 segment has 8 segments (a..g and dp). To light the decimal on one of them you enable the "dp" segment. To "move" it you switch it off in the old position and switch in on the the new position. You have 3 to choose from.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Switch from linear scale voltage(Volts) to logarithmic (Bells) if you need that dynamics.
Certainly an improvement as it would reduce the number of possible values on the display to 2800. However, will it meet the requirements of what needs to be displayed? That depends on the target audience and use. I'd wager that the vast majority of lay people would have no clue what a "Bell" was. I did a Google search for electrical units and found nothing that even mentioned Bells.

A better solution would be to convert the signal itself to logarithmic. Not being an EE, I have no clue on how to do that.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
A better solution would be to convert the signal itself to logarithmic.

Well, that is what I meant but perhaps that was not written clear enough.
Instead of measuring U with ADC, you measure log(U). Then with that log(U) you can do what you want. You can display that directly in logarithmic scale or convert it in software back to linear scale (but injecting rounding errors).

Quote:
Not being an EE, I have no clue on how to do that.

y=log(x)

nixzx

No RSTDISBL, no fun!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Log unit is "bel" not bell.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

imranahmed wrote:
Log unit is "bel" not bell.

I thought that Alexander Graham was Bell :)
jytel

No RSTDISBL, no fun!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Anyone knows about how to display float value on 7-segment
display.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Anyone knows about how to display float value on 7-segment
display.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Can you write 123 to the led display? Good. There must be a subroutine/function that converts the integer 123 to character '1' '2' '3', then it does a segment lookup to get the 7 bits needed to light the segments for digit 1, etc. Note that there is an extra bit left after the seven segment bits are assigned. I'll betcha that bit is the decimal point for that digit. Lets say the segment data is in an array of 3 bytes called unsigned char segdat[3]; you turn on the dp for digit 0 something like if(dpondig[0]) segdat[0] |= 0x80; else segdat[0] &= ~0x80; Did this help?

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Usually a float value would be made displayable with printf()/sprintf(). If you have:

float f = 3.14;

then to get the 3.14 in to a format that can be understood by a human you would use:

char buff [10];
sprintf(buff, "%f", f);

after which buff[] will contain:

buff[0] = '3'
buff[1] = '.'
buff[2] = '1'
buff[3] = '4'
buff[4] = 0

That has the 3, 1, and 4 you will then want to display on the actual digits and the position of the '.' in there tells you which of the three d.p. segments on your 3 digit display to illuminate (in this case the one at the bottom right of the top digit. So convert '3' to 3 and then use it in your segment lookup to set the top digit. Also turn on the d.p. of that top digit. Then convert '1' to 1 and use that to look up and set the middle digit and finally convert '4' to 4 and then lookup that up and set the bottom digit.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There are leds with the decimal point on the left and on the right, so some programming is required...
.001 could display 1mv with left decimal (1.1v ref with 1023 counts is about 1mv per lsb), and 5.00 would read 5V using 5V vcc and aref=vcc.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Dear bob,

I can successfully display values 0-999 but problem in
displaying float values.

I am trying your suggestions.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Dear clawson,

Thank you for description, I am doing this.