Math Check! How to read a 4-20mA temperature sensor?


#1

All -

Just checking my math here. I have a 4-20mA sensor that outputs a temperature between the range of -40F to 140F. I am reading the temperature with a MCP3424 16 bit ADC, and have some questions on how I am scaling and interpreting the input.

Here goes:

I have 32,768 total counts to work with. Therefore, 0mA is 0 counts, and 20mA is 32768 counts.
So, I have 1638.4 counts per mA (32768/20).

Since the sensor starts at 4mA, the actual scale of the sensor is offset by 4mA, or 6553.6 counts.

Therefore, the input range is 6553.6 counts - 32768 counts, for a total of 26214.4 counts of measurement range.

Since the sensor has 100F of temperature range, logic would follow that 262.14 (26214.4 counts/100F) counts is equal to 1F, right?

Does this make sense?

Thank you!


#2

I think you are right up to this point. Just to clarify, the MCP3424 is an 18 bit ADC but I assume you are using it in 16 bit mode (15 SPS). And since it is a differential ADC I assume your front end is configured to use only the positive half giving 15 bits of resolution. Correct so far?

Your sensor has a range of 180F so 180F/16ma = 11.25F/ma = 11.25F/1638.4 counts, therefore 1F = 145.636 counts or 1 count = 0.00687F


#3

Datasheet link for the lazy (like myself)

http://ww1.microchip.com/downloads/en/DeviceDoc/22088b.pdf

Is this something you’ve already implemented and are trying to back calculate for your software? Or are you planning for a future project?


#4

@ChrisGammell - I already have the hardware implemented, and am working on the software. FYI, this is for pool water temperature monitoring. I did take a look at the datasheet, and it looks like I am doing the right thing, but I am trying to verify my numbers.

@1.21Gigawatts - Correct on the single-ended mode. I should’ve specified that - thank you! Also, it would help if I could do math. The difference betweeen -40 to 140 is 180F … ahem not 100F.

So, @1.21Gigawatts has the solution, but I caught an error in my original math that carried through.

There are not 1638.4 counts per mA, rather 2048, as there are 16mA available in the total range, so the total number of counts available (32768) should also be divided by 16.

So - 32768/16 = 2048. 180F / 16mA / 2048 = 0.00549F per ADC count.

Currently, the sensor is showing 24566 counts. Multiplying that by our factor above (24566 * 0.00549) gives:

134.94F

Uh, that makes no sense though, right? I know people are in the pool right now, and they are happy, not screaming, so what gives?

The calculation is showing us absolute temperature - a direct mapping of ADC counts to F - without regard to the range of the sensor. The sensor range starts at -40F, so to get the actual pool temperature, I have to subtract 40F from the value. So, the actual temperature is (drum roll):

94.95F

Not a bad pool temp, if you ask me.

This does raise an interesting question of data interpretation though. The pool is a heated pool, and the heater is set to 87F. There is a traditional alcohol thermometer suspended in the pool approximately 18 inches that currently reads 87F, verifying the heater’s internal temperature sensor.

The temperature sensor that we have been discussing on this forum is in a skimmer basket, which is skimming the top 3" of pool water returning it to the pump. The water travels into the skimmer, through underground return lines, through the filter, the pump, the heater, and then returns back to the pool.

My new question is this:

Does it make sense that the sun could heat the top layer of water to be 7F or greater than the measured pool temp (which is taken from water cooled by underground return lines, lower temperature and high thermal mass of the filter, etc?

New data brings new questions!!!

Thanks for all of the help!


#5

If this were in fact correct, your current sensor count less the offset:

24566 - 6553 = 18013

multiplied by the scale factor:

18013 * .00687 = 123.75F

plus the temperature offset of the sensor:

123.75 + -40 = 83.75F

which seems much more reasonable.

It would help to see the schematic of the front end. I trust you have calibrated the front end?


#6

Good call on the calibration.

I’d also make sure to have another trusty temperature sensor/thermometer right next to yours, if not for accuracy then at least for sanity. Focus on the trusty though. Nothing worse than chasing ghosts because your reference frame is off.


#7

@ChrisGammell - Agreed. Unfortunately, the pool is 2 hours away and I am VPN’ed in without a secondary trusty thermometer handy. I will bring it with me on the next trip…

Also, I have not calibrated the front-end. It’s, how do they say, on the list.

@1.21Gigawatts - Gah, yeah, I am getting turned around and confused. The original division of the 32768 counts should be the full 20mA, so the conversion factor of 0.00687 is good. Currently, at 2PM on a hot Midwestern day of 91F, with the pool in full sunlight, the sensor is reading (with the current method of calculation) 85.11F. This is within 2-3% of what the other systems are reading, and sounds like a good number to me.

That said, I will verify with a known instrument next time I am onsite.

For reference, here is the front end schematic, as requested:

Thank you all so much for the help!