Skip to content

Commit 67f7a43

Browse files
Merge pull request #1028 from arduino/sync/jorgetrujilloroman/portenta-machine-control/tp100-rtd-pmc
[PC-1200] Connecting RTD and Thermocouple to Portenta Machine Control
2 parents 6caab68 + 3ef78e8 commit 67f7a43

20 files changed

+212
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
---
2+
title: 'Connect an RTD/Thermocouple to the Portenta Machine Control'
3+
difficulty: beginner
4+
description: "Connect an RTD or a Thermocouple to Portenta Machine Control and monitor the values using the Arduino PLC IDE."
5+
tags:
6+
- RTD
7+
- Thermocouple
8+
- PT100
9+
- IEC-61131-3
10+
- PLC
11+
- PLC-IDE
12+
author: 'Jorge Trujillo Román'
13+
hardware:
14+
- content/hardware/05.pro-solutions/solutions-and-kits/portenta-machine-control
15+
software:
16+
- ide-v1
17+
- ide-v2
18+
- arduino-cli
19+
- web-editor
20+
- plc-ide
21+
---
22+
23+
## Introduction
24+
RTDs (Resistance Temperature Detectors) and Thermocouples are used for temperature measurement in various industrial fields. **RTDs** are sensors that change resistance in response to temperature variation. They are used regularly in industries that require precise temperature measurements, such as food processing and pharmaceuticals.
25+
26+
On the other hand, **Thermocouples** are transducers that provide a voltage proportional to the temperature difference between two junctions. They are widely used in industrial applications such as HVAC systems, diesel engines, and power plants.
27+
28+
Both RTDs and thermocouples have unique characteristics, which make them suitable for different applications depending on the required accuracy, speed, and temperature range.
29+
30+
In this tutorial, we will use a two-wire **PT100** RTD to obtain temperature measurements. We will also briefly discuss how to connect a three-wire RTD and a thermocouple.
31+
32+
## Goals
33+
The goals of this tutorial are:
34+
- Learn about the differences between RTD and thermocouples
35+
- Learn how to connect an RTD or thermocouple to the Portenta Machine Control
36+
- Understand the operation of the Portenta Machine Control's Temperature Probe inputs
37+
- Learn about PLC IDE functions and variables
38+
- Read the temperature values using the Arduino PLC IDE
39+
40+
## Hardware and Software Requirements
41+
### Hardware Requirements
42+
- [Portenta Machine Control](https://store.arduino.cc/products/arduino-portenta-machine-control) (x1)
43+
- Micro-USB cable (x1)
44+
- PT100 RTD (x1)
45+
46+
### Software Requirements
47+
- The [Arduino PLC IDE](https://www.arduino.cc/pro/software-plc-ide) (Including Arduino PLC IDE Tools)
48+
- If you have not done so, set up and activate the Portenta Machine Control license following the steps of [this tutorial](https://docs.arduino.cc/tutorials/portenta-machine-control/plc-ide-setup-license)
49+
50+
## Temperature Sensors
51+
52+
### RTD
53+
A **Resistance Temperature Detector**, or **RTD**, is a temperature sensor that works by measuring the variation in the electrical resistance of a metallic element as a function of the temperature changes. The most commonly used metal for RTDs is platinum: one common type of RTD sensor is the PT100, where PT stands for platinum and 100 refers to the nominal resistance of the sensor at 0°C.
54+
55+
As the temperature increases, the resistance of the metal element in the RTD increases predictably and linearly. The resistance variation can be measured using an external circuit or measuring instrument and converted into a temperature reading, using a calibration curve or formula putting into relation the resistance value with the temperature.
56+
57+
RTDs are commonly used in industrial applications where the temperature measurement is critical for process control and safety. They are preferred over other types of temperature sensors because of their high accuracy, stability, and repeatability over a narrow temperature range.
58+
59+
### Thermocouples
60+
61+
A **thermocouple** is a temperature sensor made of two different metals, having dissimilar electrical conductivity, joined together at one end. When the junction is heated or cooled, a voltage is generated due to the thermoelectric effect: this voltage can be measured and converted into a temperature reading.
62+
63+
Thermocouples are used in a wide range of applications where temperature measurement is necessary, including industrial processes such as furnace and boiler monitoring, temperature control of plastic extrusion machines, and temperature measurement in power plants. They are also used in HVAC systems, automotive engines, and aerospace applications.
64+
65+
## Connections
66+
67+
![Temperature Probe Inputs](./assets/temp-probes-inputs.png)
68+
69+
Depending on the sensor you use, you will need to perform different connection settings. Find below three tables showing how to connect a two-wire RTD (PT100), a three-wire RTD (PT100) or a thermocouple.
70+
71+
### Two Wires RTD Connection
72+
The 2-wire RTD configuration is the simplest of the RTD circuit designs, but is more prone to errors.
73+
74+
| Channel 0 | Channel 1 | Channel 2 |
75+
|--------------------------------------|---------------------------------------|---------------------------------------|
76+
| Connect RTD pin to TP0 | Connect RTD pin to TP1 | Connect RTD pin to TP2 |
77+
| Connect RTD pin to TN0 | Connect RTD pin to TN1 | Connect RTD pin to TN2 |
78+
| Jumper between TP0 and RTD0 | Jumper between TP1 and RTD1 | Jumper between TP2 and RTD2 |
79+
80+
In this tutorial, we will use a two-wire RTD, so we will configure **channel 0** as described in the table. This is done by connecting one pin of the PT100 to the TP0 input, the other pin to TN0, and connecting a jumper between TP0 and RTD0 pins as you can see in the following picture:
81+
82+
![Two Wires Connection to Channel 0](./assets/two-wire-connection.png)
83+
84+
### Three Wires RTD Connection
85+
The 3-wire RTD configuration is the most commonly used RTD circuit design. In this configuration, two wires link the sensing element to the monitoring device on one side of the sensing element, and one links it on the other side.
86+
87+
| Channel 0 | Channel 1 | Channel 2 |
88+
|-----------------------------------|-----------------------------------|-----------------------------------|
89+
| Connect RTD pin to TP0 | Connect RTD pin to TP1 | Connect RTD pin to TP2 |
90+
| Connect RTD pin to TN0 | Connect RTD pin to TN1 | Connect RTD pin to TN2 |
91+
| Connect the RTD pin to the RTD0 | Connect the RTD pin to the RTD0 | Connect the RTD pin to the RTD0 |
92+
93+
***Do not connect any pin to GND***
94+
95+
![Three Wires Connection to Channel 0](./assets/three-wire-connection.png)
96+
97+
### Thermocouples Connection
98+
99+
Connect **only non-grounded thermocouples** (grounded thermocouples are not supported). Do not connect both a thermocouple and a PT100 to a single same channel.
100+
The thermocouples supported by the Portenta Machine Control are:
101+
- Thermocouple Type K, non-grounded
102+
- Thermocouple Type J, non-grounded
103+
104+
| Channel 0 | Channel 1 | Channel 2 |
105+
|---------------------------------|---------------------------------|---------------------------------|
106+
| Connect the positive pin to TP0 | Connect the positive pin to TP1 | Connect the positive pin to TP2 |
107+
| Connect the negative pin to TN0 | Connect the negative pin to TN1 | Connect the negative pin to TN2 |
108+
109+
110+
***Do not connect any pin to GND***
111+
112+
![Thermocouple Connection to Channel 0](./assets/thermocouple-connection.png)
113+
114+
## PLC IDE
115+
116+
### Creating the Project
117+
118+
Once we have correctly [connected](#connections) the sensor to the Portenta Machine Control, the following steps are carried out in the Arduino PLC IDE. We assume that you have previously made the initial configuration of the Portenta Machine Control and activated [the necessary license](https://store.arduino.cc/products/plc-key-portenta-machine-control) to use it. If you have not done this, it is explained in the [configuration tutorial](https://docs.arduino.cc/tutorials/portenta-machine-control/plc-ide-setup-license) mentioned above.
119+
120+
First, we need to **create a new project**. To do this, open the Arduino PLC IDE and click on "New Project" or by clicking on ```File > New project```:
121+
122+
![New Project](./assets/new-project.png)
123+
124+
Name the project and select "Portenta Machine Control 1.0" as the project target; press OK:
125+
126+
![Project Info](./assets/project-info.png)
127+
128+
### Behavior Setting
129+
130+
Once the project has been created, to visualize the "Temperature probes" inputs of the board, you need to go to the **Resources** Tools window and click on "**Temperature probes**". If you cannot find this window, you can try to click on: ```View > Tools Windows > Resources```.
131+
132+
![Resources Window](./assets/resources.png)
133+
134+
After clicking on "Temperature Probes" we will see a table containing the three temperature probe inputs of the board. We have to make sure that the "**Behavior setting**" is set according to our RTD or thermocouple sensor.
135+
136+
In this case, we are using a two-wires PT100 sensor, so we will select the "**RTD TWO WIRES**" option. In case a different sensor is connected, the right choice must be operated (i.e. THERMOCOUPLE for thermocouple):
137+
138+
![Behavior Setting](./assets/behavior.png)
139+
140+
By default the TP00 input is disabled. To enable it, you only need to click next to "False" on TP00 "Enable" row and set it as "**True**":
141+
142+
![Enabling Input](./assets/enabling-input.png)
143+
144+
Once enabled, we are ready to continue to the next step creating the necessary variables.
145+
146+
### Creating the Variables
147+
148+
***By default the project creates an automatic type int global variable called "cnt". You can delete it by right-clicking on it and clicking delete.***
149+
150+
To visualize the temperature values, we need to create a variable to save the values. To do this, we need to go to **Global vars** section and right-click on it, select "New variable" and select "Automatic" type. You can also do it by going to ```Project > New object > New variable > Automatic```.
151+
152+
![Creating a Global Variable](./assets/global-variable.png)
153+
154+
A New Variable Window will appear, set **TP00** as the variable name. This is just a name, not related to the name of the input, so you can set a name of your choice.
155+
156+
![Set a Variable Name](./assets/variable-name.png)
157+
158+
On type, press the **[...]** button and scroll down to find and select the "**sysTempProbesType**". This variable has the automatic process to convert the RTD values into real-type temperature values.
159+
160+
![Choosing Variable Type](./assets/variable-type.png)
161+
162+
***Note: ensure that you have marked the User Type option to visualize the sysTempProbesType variable type***
163+
164+
When it is done, press the **OK** button:
165+
166+
![TP00 Variable](./assets/TP00-var.png)
167+
168+
Repeat the previous steps to create a new variable called "**temp0**" and type "**REAL**". With this last variable, we will directly store the temperature value of the sysTempProbesType variable in [real numbers](https://en.wikipedia.org/wiki/Real_number) as you will see in the following steps.
169+
170+
![Temp0 Variable](./assets/temp0-var.png)
171+
172+
If everything is correct, when you double-click on **Global_vars**, a table with the two variables should appear as in the following image:
173+
174+
![Global Variables](./assets/all-variables.png)
175+
176+
### Main Program Code
177+
178+
Now that we have created the variables, we have to make it work by defining the variables in the **main** program code. To do this, double-click on "main" and write the next lines in the code box:
179+
180+
```
181+
TP00 := sysTempProbes[0];
182+
temp0:= systempProbes[0].temperature;
183+
```
184+
Next, plug in your device, make sure it is connected to the Arduino PLC IDE and click the compile button to make sure there are no errors in the code.
185+
186+
If you are not sure about how to connect your device, you can check it on [the setup tutorial](https://docs.arduino.cc/tutorials/portenta-machine-control/plc-ide-setup-license#5-connect-to-the-device).
187+
188+
![Program Compilation](./assets/compiling-connecting.png)
189+
190+
If there are no errors when compiling, you can download the code to the device by clicking on the button found next to the connection symbol. You may see a warning message about the need for a cold restart to download the code. Click Yes:
191+
192+
![Downloading PLC Code](./assets/download-plc-code.png)
193+
194+
### Watch the Values
195+
196+
To visualize the values once we have downloaded the code into the Portenta Machine Control, we need to drop the variables in the "**Watch**" section as shown in the following animation. If you can't see the "Watch" window, you can try going to: ```View > Tool Windows > Watch```.
197+
198+
![Watch Variables](./assets/watch-variables.gif)
199+
200+
## Conclusion
201+
RTDs are best for high-accuracy temperature measurements within a narrow range of up to 600°C. Thermocouples are better for high-temperature applications up to 2300°C, fast response times, and harsh environments. RTDs are used in laboratories and industrial process control, while thermocouples are used in industrial applications like furnaces and aerospace.
202+
203+
We have learned how to connect RTD and Thermocouple sensors to a Portenta Machine Control and how to monitor the temperature values through the Arduino PLC IDE.
204+
205+
We have also learned that there are many different types of RTDs and thermocouples and that we have to choose one according to our needs.
206+
207+
## Next Steps
208+
Now that we know how to use these temperature sensors, we can implement them in a real industrial or domestic environment, such as an ambient temperature monitoring project.
209+
210+
- For more information on programming in the Arduino PLC IDE using IEC-61131-3 languages, please refer to the tutorial [Introduction to Programming with the Arduino PLC IDE](https://docs.arduino.cc/tutorials/portenta-machine-control/plc-programming-introduction) tutorial.
211+
212+
- If you are interested in how to set up the CAN bus communication, you can check out the [CAN Bus Setup with Arduino PLC IDE](https://docs.arduino.cc/tutorials/portenta-machine-control/can-setup) tutorial.

0 commit comments

Comments
 (0)