# Question on logical equation on my C programming.

Status
Not open for further replies.

#### maniac84

##### Full Member level 6
Hi guys,
I have a situation on my C programming here and just wondering whether my solution is the correct way:

I have a LED display with particle count sensor and will show 6 digit of seven segment numbers as the count value. The sensor will give voltage input value. The input is from 0V to 10V. So the range of 0V-10V need to be shown in the display as 000000 to 999999 count.
My solution is:
Display number = Input voltage * 99999.9
For example:
Display number = 10.000*99999.9=999999
Display number = 5.500*99999.9=549999
Display number = 2.300*99999.9=229999

Is this the correct solution? I notice that I will get a lot of 9 on the display value.

Last edited:

#### ud23

Code:
Display number = 10.000*99999.9=999999;
Display number = 5.500*99999.9=549999;
Display number = 2.300*99999.9=229999;

What you want to do with this logic?If i understand correctly if your input voltage is 10 v you want to display as 10.0000 v then why you multiplying it with 99999.9?what is final display value i mean how many decimal point value to be display ?

#### maniac84

##### Full Member level 6
Code:
Display number = 10.000*99999.9=999999;
Display number = 5.500*99999.9=549999;
Display number = 2.300*99999.9=229999;

What you want to do with this logic?If i understand correctly if your input voltage is 10 v you want to display as 10.0000 v then why you multiplying it with 99999.9?what is final display value i mean how many decimal point value to be display ?
Nope. If input is 10V, the display will be showing 999999 which is the max value of the particle count.
All round number. No decimal point.

#### ud23

ya so your logic should work.it is simply y=m.x; and it would be linear if your input voltage is linear.

#### maniac84

##### Full Member level 6
ya so your logic should work.it is simply y=m.x; and it would be linear if your input voltage is linear.

I see.
But is it the most suitable solution? My display value will get lots of 9.

#### ud23

I see.
But is it the most suitable solution? My display value will get lots of 9.

this logic working and reason for getting many 9 is your input voltage reading for example if you can read your input voltage=5.5495 then your output 554949 so i don't know your adc bit resolution if you can read voltage with micro voltage accuracy then this logic work with less 9 or accurately.

#### maniac84

##### Full Member level 6
this logic working and reason for getting many 9 is your input voltage reading for example if you can read your input voltage=5.5495 then your output 554949 so i don't know your adc bit resolution if you can read voltage with micro voltage accuracy then this logic work with less 9 or accurately.

My ADC only support up to 3 decimal point...
So, I'll get lots of 9 behind.. =(

Status
Not open for further replies.