Obtaining RTD Temperature Readings Using groov RIO

Intro:

Currently, the groov RIO does not support RTD sensors as inputs used to measure temperature. However, there is a way to measure and receive temperature data with an RTD PT100 using just a groov RIO and a little math.
The process consists of configuring the sensor as a resistance input, and taking the Ohms value shown from the sensor reading and converting it using PAC Control, CODESYS, Node-RED, or SSH to get a temperature reading.

Configuring the I/O Channel in groov Manage:

  • Wire the RTD as a thermistor. If you have a three wire sensor, just use two wires.
  • Open groov Manage and select the channel that the sensor is wired to
  • Click on configure and use the resistance input type “0-400k Ohms Analog Input” (shown below)
  • Don’t worry about scaling as that will be done in the software.
  • Give the point a name. Note: if you are using PAC Control the name will be overwritten by the name you use in the strategy after you do a download, so keep that in mind.
  • Click save after you are done setting up the point.

Converting the Sensor Reading from Resistance to Temperature (degrees C or F):

PAC Control

  • Configure the I/O channel(s) from your RIO that you would like to measure.
  • Define a numeric float variable for the RTD temperature to be displayed (degrees C or F)
  • When creating a chart to do this conversion, include an OptoScript block and use the code shown below. On the left side of the equation write the name of the variable defined earlier and choose the correct equation for either Celsius or Fahrenheit.
  • |584x390.086642599278

Node-RED

(This uses ScratchPad float index 1 for °C and index 2 for °F)

[{"id":"2be3322fd48c4b6a","type":"function","z":"eb891162369b57fb","name":"Calculate °C & °F","func":"var coef = 0.00391;\nvar RTD1 = msg.payload;\n\nmsg.tempC = ((RTD1 / 100) - 1) / coef;\nmsg.tempF = 1.8 * (((RTD1 / 100) - 1) / coef) + 32;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":290,"y":100,"wires":[["0c57813c89a3da96","8abbfa9a6fe64aa5"]]},{"id":"856f1381d553562c","type":"groov-io-input","z":"eb891162369b57fb","device":"931f146ae03bee95","dataType":"channel-analog","moduleIndex":"0","channelIndex":"2","mmpAddress":"0xF0D81000","mmpType":"int32","mmpLength":"1","mmpEncoding":"ascii","sendInitialValue":true,"deadband":"1","scanTimeSec":"1.0","name":"RTD1","x":110,"y":100,"wires":[["2be3322fd48c4b6a"]]},{"id":"0c57813c89a3da96","type":"groov-io-write","z":"eb891162369b57fb","device":"931f146ae03bee95","dataType":"mmp-address","moduleIndex":"","channelIndex":"","mmpAddress":"0xF0D82004","mmpType":"float","mmpLength":"1","mmpEncoding":"ascii","value":"tempC","valueType":"msg","name":"ScratchPad 1 (°C)","x":510,"y":80,"wires":[[ ]]},{"id":"8abbfa9a6fe64aa5","type":"groov-io-write","z":"eb891162369b57fb","device":"931f146ae03bee95","dataType":"mmp-address","moduleIndex":"","channelIndex":"","mmpAddress":"0xF0D82008","mmpType":"float","mmpLength":"1","mmpEncoding":"ascii","value":"tempF","valueType":"msg","name":"ScratchPad 2 (°F)","x":510,"y":120,"wires":[[]]},{"id":"931f146ae03bee95","type":"groov-io-device","address":"localhost","msgQueueFullBehavior":"DROP_OLD"}]
  • Install the package node-red-contrib-groov-io.
  • Import the flow above.
  • Add your device and admin-level API key.
  • Make sure the module and channel are set for your RTD resistance.
  • Deploy the flow and see calculated temperatures in the ScratchPad float area.

SSH (Python)

(This uses ScratchPad float index one for °C and index two for °F. Also, set index zero to 1 to stop the program from looping.)

import time
import optommp
mod = 0
chn = 2
dev = optommp.O22MMP()
flag = dev.GetScratchPadFloatArea(0)
while(flag != 1):
RTD1 = dev.GetAnalogPointValue(mod, chn)
tempC = ((RTD1 / 100) - 1) / 0.00391
tempF = 1.8 * (((RTD1 / 100) - 1) / 0.00391) + 32
dev.SetScratchPadFloatArea(1, tempC)
dev.SetScratchPadFloatArea(2, tempF)
time.sleep(2)
flag = dev.GetScratchPadFloatArea(0)
dev.close()
  • Use pip to install the optommp module.
  • Create or upload a *.py file with the above code.
  • Make sure the module and channel are set for your RTD resistance.
  • Make sure the ScratchPad float area index zero is set to anything but 1.
  • Run the script and see calculated temperatures in the ScratchPad float area.
  • To stop the script from looping, set index zero to equal 1.

CODESYS

  • Configure one channel of a RIO to the 0-400K RTD input.

  • Use the same OptoScript code shown in the PAC Control section with the built in temperature conversion.

RTD vs ICTD

Here is an example graph showing how the RTD temperature tracked alongside Opto22’s ICTD temperature sensor. Both were connected to the same RIO with the RTD configured as above and the ICTD configured as per the user’s guide.

We moved both sensors between vessels of cold and hot water to give a little swing to the temperature range.

Of course the RTD is rated for a much wider temperature range than the ICTD, but this graph should give a confidence boost to the accuracy of the probe connected to the RIO while measuring resistance with the conversion occurring in PAC Control OptoScript.

The natural resistance curve of the RTD flattens out at the top and bottom of its range, and there is no scaling option in the RIO when in resistance mode, so you need to keep these factors in mind when deciding if using the RIO in this mode with your RTD application.

7 Likes

wow - thank you so much for this!

2 Likes