Temperature conversion c source code – RoboteQ Dual Channel Digital Motor Controller AX500 User Manual

Page 60

Advertising
background image

Connecting Sensors and Actuators to Input/Outputs

60

AX500 Motor Controller User’s Manual

Version 1.9b. June 1, 2007

using the ?m query, or during data logging (see “Analog and R/C Modes Data Logging
String Format” on page 126
)

The analog value that is reported will range from 0 (warmest) to 255 (coldest). Because of
the non-linear characteristics of NTC thermistors, the conversion from measured value to
temperature must be done using the correction curve below.

It should be noted that the temperature is measured inside the controller and that it may
be temporarily be different than the temperature measured outside the case.

Temperature Conversion C Source Code

The code below can be used to convert the analog reading into temperature. It is provided
for reference only. Interpolation table is for the internal thermistors.

int ValToHSTemp(int AnaValue)
{

// Interpolation table. Analog readings at -40 to 150 oC, in 5o intervals

int TempTable[39] ={248, 246, 243, 240, 235, 230, 224, 217, 208, 199, 188, 177,
165, 153, 140, 128, 116, 104,93, 83, 74, 65, 58, 51, 45, 40, 35, 31, 27, 24, 21,
19, 17, 15, 13, 12, 11, 9, 8};

int LoTemp, HiTemp, lobound, hibound, temp, i;

i = 38;

while (TempTable[i] < AnaValue && i > 0)

i--;

if (i < 0)

i = 0;

if (i == 38)

return 150;

else
{

LoTemp = i * 5 - 40;

0

50

100

150

200

250

300

Reported Analog Value

Temperature in Degrees C

-4

0

-3

0

-2

0

-1

0

0

10

20

30

40

50

60

70

80

90 10

0

11

0

12

0

13

0

14

0

15

0

FIGURE 34. Analog reading by controller vs. internal heat sink temperature

Advertising