Continue to Site

# [SOLVED]how to convert temp sensor output into digital form if it is out of range

Status
Not open for further replies.

#### rohini.embsystem

##### Newbie level 4
Hi,
if i m using a temp sensor which will gimme the output in degree centigrade (accuracy is 0.1 D.C). i m using ADC to convert the o/p of sensor. 4 multiplexed 7 segments are used for display of o/p. if variable unsigned char TEMP_OUT is used to get the sensor o/p. so it's range will be 0-255. if sensor is giving o/p 100.0 so how this can store & convert the 1000 value if it's max range is 255. If i m declaring the variable as unsigned int TEMP_OUT then can it convert the value 100.0(rather 1000)

int8 = 8 bit number. If used as unsigned = 255. If used as signed = -128 to +127
int16 = 16 bit number. If used as unsigned = 65535. If used as signed = -32768 to 32767

Best wishes

I know that range of int, char. my question is if i have declared the TEMP_OUT variable a char then hw it is possible to store 1000(o/p is 100.0 Degree) value if it's range is 0-255.can i use TEMP_OUT a int? will it work?

You can use TEMP_OUT as int or unsigned int, long int , or unsigned long int.

I know that range of int, char. my question is if i have declared the TEMP_OUT variable a char then hw it is possible to store 1000(o/p is 100.0 Degree) value if it's range is 0-255.can i use TEMP_OUT a int? will it work?

Hi...
using an int will definitely work...
however if u want to use a char, u cannot actually store a value higher than 255, in your case "1000", but what u can always do is map it 255.
instead of going in for the jugglery ,take the easier way out...use an int....

cheers...
Vijay

rohini.embsystem

### rohini.embsystem

Points: 2
thanx vijay

There is no need to use float for your calculations, they are quite inefficient.

Calculate your temperature as an integer where values like 1000 for example represent 100.0 degree or 1234 represent 123.4 degree.
Then when you show that value in the display add a dot just before the last character, that will show the number with one decimal point like it was meant to be read.

Alex

Status
Not open for further replies.