RTD input with decimal places

Topics about the Software of Revolution Pi
Post Reply
duelingcats
Posts: 6
Joined: 14 Nov 2024, 07:34

RTD input with decimal places

Post by duelingcats »

Hello,

I am just getting started using RevPi, so I my familiarity with several of the menus and areas is limited at the moment. I was testing connecting a RTD P100 to the RTD1 input.

I am following https://revolutionpi.com/documentation/ ... lue-editor docs for the Multiplier, Divisor, and Offset, but I am just not understanding it quite well.

So for example, if I want the value in #.# C, having 1 decimal place precision, do I just use Multiplier = 1, Divisor = 1, Offset = 0?

When I use the following values, I am not getting any decimal places in PiTest: Multiplier = 18, Divisor = 100, Offset = 32. I thought this would give me #.#F, so one digit decimal place.

Image
User avatar
dirk
KUNBUS
Posts: 2214
Joined: 15 Dec 2016, 13:19

Re: RTD input with decimal places

Post by dirk »

Hello duelingcats, these parameters change the measured value and allow you to use an offset for a measurement. To display the values you have to format them in an application. You can use the printf command in Bash to format numbers. To display the number 1234 as 12.34 °C, you can divide it by 100 and then format it with printf to include two decimal places and the desired suffix.

Here is the command:

Code: Select all

printf "%.2f °C\n" $(echo "1234 / 100" | bc -l)
I have created a test setup with which "1234" can be output via the variable you are using "RTDValue_1":
chrome_gtKiDFTgqH.png
So in your case it should work with, i.e. that code:

Code: Select all

RTD=$(piTest -1 -q -r RTDValue_1)
printf "%.2f °C\n" $(echo "$RTD / 100" | bc -l)
12.34 °C
In general, you can of course also use a high-level language like Python just to round it off.
With an f-string (Python 3.6+):

Code: Select all

value = 1234
formatted = f"{value / 100:.2f} °C"
print(formatted)
The whole thing can then be implemented using a process image on real data:

Code: Select all

import revpimodio2

# Establishing a connection to the RevPi
rpi = revpimodio2.RevPiModIO(autorefresh=True)

# Name of the RTD channel
rtd_channel = "RTDValue_1"

# RTD-Daten auslesen
raw_value = rpi.io[rtd_channel].value  # Read raw value (e.g. 1234)

# Convert and format temperature
temperature = raw_value / 100.0
formatted_temperature = f"{temperature:.2f} °C"

print(f"Channel {rtd_channel}: {formatted_temperature}")
duelingcats
Posts: 6
Joined: 14 Nov 2024, 07:34

Re: RTD input with decimal places

Post by duelingcats »

Thanks for the fast response Dirk.

I still don't see where I am getting an additional decimal place of accuracy when using the printf command to divide by 100. That is moving the decimal place, as expected, rather than giving an additional digit of accuracy

As seen in my screenshot, the value of the RTDValue_1 is still 68 and I am trying to get an additional digit of accuracy such as 68.2, 68.3, etc.

Image
duelingcats
Posts: 6
Joined: 14 Nov 2024, 07:34

Re: RTD input with decimal places

Post by duelingcats »

I have continued adjusting the Multiplier, Divisor, and Offset values to try and get values with more digits past the decimal place. In the screenshot below, I made these adjustments for °F. The output value of 69.62 °F appears valid based upon the ambient temperature of where the probe is, so I was thinking this may be the correct value.

Could you confirm that using using the following Multiplier, Divisor, and Offset values is the correct way to get °F with one to two digits past the decimal place?

Image

I also was working with getting values in °C and in doing so I put the probe on a cold ice pack that was chilled below 0°C. When I checked piTest, The value appeared to overflow (underflow?) to 65531 when I expected it to be a few degrees below 0°C.

Image
User avatar
dirk
KUNBUS
Posts: 2214
Joined: 15 Dec 2016, 13:19

Re: RTD input with decimal places

Post by dirk »

Hi okay this goes wild - like it :) So two things here
  • If you want more precision, you need to use a PT1000 4 wire RTD setup
  • If you want to convert in Fahrenheit, you need to multiply the Celsius value with 1.8 then add 32
So yes I think this is the right way to use the mulitplier, divisor and offset in PiCtory, looks good.

Here is some Python code for it so you can verify your results

Code: Select all

# Function to convert Celsius to Fahrenheit
def celsius_to_fahrenheit(celsius):
    fahrenheit = (celsius * 9/5) + 32
    return fahrenheit

# Input from user
celsius = float(input("Enter temperature in Celsius: "))
fahrenheit = celsius_to_fahrenheit(celsius)

# Display the result
print(f"{celsius}°C is equal to {fahrenheit}°F")

duelingcats
Posts: 6
Joined: 14 Nov 2024, 07:34

Re: RTD input with decimal places

Post by duelingcats »

In regards to the negative °C value, the temperature I had the PT100 probe exposed to was around -3C, and based upon the spec sheet for the probe I got it was still within applicable ranges. It only wrapped around into a large int when it was in the negative range. I don't think it was the probe fault in this case.
duelingcats
Posts: 6
Joined: 14 Nov 2024, 07:34

Re: RTD input with decimal places

Post by duelingcats »

duelingcats wrote: 10 Jan 2025, 16:11 In regards to the negative °C value, the temperature I had the PT100 probe exposed to was around -3C, and based upon the spec sheet for the probe I got it was still within applicable ranges. It only wrapped around into a large int when it was in the negative range. I don't think it was the probe fault in this case.
Any further assistance with this previous issue? I do not think it is a hardware issue. The temperature only went 65533+ right after the values went into the negatives which leads me to think it has something it do with a signed int value.
Post Reply