Today is...
Monday, June 26, 2017
Welcome to Control.com, the global online
community of automation professionals.
Featured Video...
Featured Video
Watch an animation of a conveyor stacking operation demonstrating the use of a move on a gear command.
Our Advertisers
Help keep our servers running...
Patronize our advertisers!
Visit our Post Archive
Converting Integer Data Type to Celsius or Fahrenheit
Simple conversion escapes me

How do I convert an integer data type to Celsius or Fahrenheit? For example 0-32767

1 out of 1 members thought this post was helpful...

What temperature value does your count of 32767 represent? C or F?
What temperature value does your count of 0 represent? C or F?

32767 = 3400F
It is for scaling a temperature sensor in liquid steel bath.

>What temperature value does your count of 32767 represent?
>C or F?
>What temperature value does your count of 0 represent? C or
>F?

By pvbrowser on 19 June, 2017 - 9:44 am

case C2FAHRENHEIT:
ret = (val * 9.0f / 5.0f) + 32.0f;
break;
case FAHRENHEIT2C:
ret = (val - 32.0f) * 5.0f / 9.0f;
break;

Starting with the raw value stored in a register called "integer" and assuming that 0-32767 = 0-3400F:

DegF = (integer/32767) * 3400

DegC = (DegF - 32)*5/9