Page 1 of 1

RTD value is not displayed well.

Posted: 23 Jun 2023, 08:41
by kimgama
hello.

I am using Revpi Compact.

I am trying to read RTD values with Python. It's not working..

It is read normally in Node-red and PLC Loader programs.

When I run it as python code, the values are displayed differently.

The code used is below

Upload a screen capture as well.

I look forward to your help.

thank you.
RTD_value_error.png
RTD_value_error.png (428.34 KiB) Viewed 3312 times

Code: Select all

import datetime
import time
import revpimodio2
rpi = revpimodio2.RevPiModIO( autorefresh = True )

while True:
	time_stamp = datetime.datetime.utcnow().isoformat()
	print("TIME:",time_stamp)
	ai_value   = rpi.io['RTD_Value_1'].value
	ai_value2   = rpi.io['RTD_Value_2'].value
	core_temp = rpi.io['Core_Temperature'].value
	frequency = rpi.io['Core_Frequency'].value
	
	print("PT100_1:",ai_value)	
	print("PT100_2:",ai_value2)	
	print("Frequency: ", frequency)
	print("CPU: ",core_temp)
	time.sleep(0.5)
	

Re: RTD value is not displayed well.

Posted: 23 Jun 2023, 08:47
by RevPiModIO
Hi kimgama!

You are using the "Memory-Values", which just define the type of your analog inputs.

Just change your Code like this:

Code: Select all

        # Change RTD_Value_* to AIn_*
	ai_value   = rpi.io['AIn_1'].value / 10
	ai_value2   = rpi.io['AIn_2'].value / 10
Now you get the temperature with a decimal place.

Greeting
Sven

Re: RTD value is not displayed well.

Posted: 27 Jun 2023, 00:57
by kimgama
thank you!
It works very well.