Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

[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
Joined
May 19, 2010
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
pune
Activity points
1,328
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)
 

hemnath

Advanced Member level 2
Joined
Jun 24, 2012
Messages
676
Helped
61
Reputation
120
Reaction score
57
Trophy points
1,308
Location
Chennai
Activity points
6,409
read about data types ...

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

rohini.embsystem

Newbie level 4
Joined
May 19, 2010
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
pune
Activity points
1,328
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?
 

Joined
Jul 25, 2012
Messages
1,192
Helped
170
Reputation
340
Reaction score
161
Trophy points
1,343
Activity points
0
You can use TEMP_OUT as int or unsigned int, long int , or unsigned long int.
 

vijayjadhav.595

Member level 1
Joined
Sep 22, 2012
Messages
40
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,288
Location
Mumbai,India
Activity points
1,537
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
 

alexan_e

Administrator
Joined
Mar 16, 2008
Messages
11,895
Helped
2,021
Reputation
4,158
Reaction score
2,031
Trophy points
1,393
Location
Greece
Activity points
64,377
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.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top