Help with LM61 temperature calculation

Guys

I am looking to use an LM61 to measure temperature.

The problem I am having is the conversion from the LM61 O/P and the displayed value.

In the data sheet, attached, it gives:-

7.3.1 LM61 Transfer Function
The LM61 follows a simple linear transfer function to achieve the accuracy as listed in Electrical Characteristics.
Use Equation 1 to calculate the value of VO.
VO = 10 mV/°C × T°C + 600 mV
where
• T is the temperature in °C
• VO is the LM61 output voltage

Using

BattTemp = (((float)(analogRead(Batt_Temp_Pin)/1024) * 5.0)-0.6)*100;

and various other permutations, always gives me silly answers.
For example, if the A/D reading is 1023, the answer would be 439.5C and if A/D is 1 then the answers would be -59.5C, neither of which is anywhere near the data sheet values

T Operating temperature
LM61C –30 to 100°C
LM61B –25 to 85°C

The above calculations were done on a calculator, as I can’t incorporate into the sketch till I work out the formula.

Can anyone help me, please?

TIA

Fof

lm61.pdf (1.17 MB)

Not 100% sure on this code, but if you use ;

  map(batt_temp_pin,1,1024,0,5);

before you do your calculation, it will amend the reading on the analog pin from 0-1024 to it's corresponding value between 0 and 5 V. Then use that in your calculation.

That (I think) will give you the reading on your pin in V. Then rearrange the formulae on the datasheet for T

Thanks, John

Will try that, in a few mins. Pity map only returns ints, not floats.

Can't have everything, unfortunately.

Fof

Sorry, John

This is not the way, as the result of map is an int. This means I will only get 6 temp readings, corresponding to 0, 1, 2, 3, 4, 5 volts.

Back to the drawing board.

Fof

What ADC reading do you get at 25C? Should be about 174, if not, sumpin' ain't right. Try:

float BattTemp = analogRead(Batt_Temp_Pin) * 500.0 / 1024 - 60;

This is not the way, as the result of map is an int.

You could map the input to a value 100 times larger than you need and divide the result by 100 to give a float with 2 decimal places. Leave the output as an int until all calculations have been done and maybe only divide by 100 for the purposes of displaying the result. Doing this will avoid calculations involving floats which are time consuming.

IamFof:
Sorry, John

This is not the way, as the result of map is an int. This means I will only get 6 temp readings, corresponding to 0, 1, 2, 3, 4, 5 volts.

Back to the drawing board.

Fof

Ahh damn! My apologies sir. My inexperience is showing. Hope you can make use of the map function somehow though.
Sorry!

Thanks, guys

No worry, John. UKHeliBob has shown how to use map to include decimals.

Another problem, uncovered after rereading the data sheet, is that the LM61 O/P is independent of the supply voltage and is typically 300mV - 1600mV, giving -30C - 100C, @10mV/degC. Hence the ridulous "temperature" values I was getting, using the calculator.

I guess I am going to have to use the internal 2v56 reference, and then calculate only the relevent ADC values (once I work out how to do that).

Fof

EDIT: Corrected the internal ref from 2v4 to 2v56.

Sometimes I uprise myself with my stupidity.

Why do I need to calculate the temps for the out of range values? I am NEVER going to see temps anything like them. Duhhhhh!

All I need to do, nown is crack the formula.

IamFof:
Thanks, guys

No worry, John. UKHeliBob has shown how to use map to include decimals.

Ahhh. I tried. I failed. I'll retire now and hide in the corner :smiley: :smiley:

Haha, glad you have it sorted though.