Skip to content

Commit b704496

Browse files
committed
Julian Review updates
1 parent 1ddfb24 commit b704496

File tree

1 file changed

+48
-35
lines changed
  • content/hardware/05.pro-solutions/solutions-and-kits/portenta-machine-control/tutorials/pmc-opta-modbus-tcp

1 file changed

+48
-35
lines changed

content/hardware/05.pro-solutions/solutions-and-kits/portenta-machine-control/tutorials/pmc-opta-modbus-tcp/content.md

Lines changed: 48 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: 'Modbus TCP with Portenta Machine Control & Opta™'
33
difficulty: intermediate
4-
description: "Modbus TCP communication on a real industrial application using a Portenta Machine Control, Opta™, a temperature sensor, and the Arduino® PLC IDE."
4+
description: "Learn to use Modbus TCP communication on a real industrial application using a Portenta Machine Control, Opta™, a temperature sensor, and the Arduino® PLC IDE."
55
tags:
66
- Thermocouple
77
- IEC-61131-3
@@ -17,18 +17,20 @@ software:
1717
- plc-ide
1818
---
1919

20-
## Overview
20+
## Overview & Video Tutorial
2121

22-
In this tutorial, a Portenta Machine Control and an Opta micro PLC will be used as **server** and **client** respectively to share temperature information through Modbus TCP using the PLC IDE. The server will do the measurements using a type K thermocouple and the client will activate its relay outputs when a certain threshold is reached.
22+
In this tutorial, a Portenta Machine Control and an Opta micro PLC will be used as **server** and **client** respectively to share temperature information through Modbus TCP using the PLC IDE. The server will do the measurements using a type K thermocouple and the client will activate its relay outputs when a certain threshold is reached.
2323

24-
Here is a detailed guide in video format if you are a visual learner.
24+
We have prepared a detailed guide in video format in case you are a visual learner.
2525

2626
<iframe width="100%" height="480" src="https://www.youtube.com/embed/reBrbCq86uQ?si=q0EkR-B8bR0MeF5p" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
2727

28+
If you prefer to follow the tutorial in a written format, or need to review the steps and code done in the video tutorial, in the following sections you will find a step-by-step guide explaining how the temperature measurement and Modbus communication between both devices were done.
29+
2830
## Goals
2931

3032
- Learn how to measure temperature with the Portenta Machine Control using a thermocouple and the PLC IDE
31-
- Learn how to use the Modbus protocol over TCP/IP using the PLC IDE
33+
- Discover how to use the Modbus protocol over TCP/IP using the PLC IDE
3234
- Leverage Arduino Pro products for real industrial applications
3335

3436
## Hardware and Software Requirements
@@ -39,7 +41,7 @@ Here is a detailed guide in video format if you are a visual learner.
3941
- Type K thermocouple (x1)
4042
- Ethernet cables (x2)
4143
- Wired internet access
42-
- 24 VDC Power Supply (x2)
44+
- 24 VDC/0.5 A power supply (x2)
4345
### Software
4446
- The [Arduino PLC IDE](https://www.arduino.cc/pro/software-plc-ide) (including Arduino PLC IDE Tools)
4547
- [Portenta Machine Control - PLC IDE Activation](https://store-usa.arduino.cc/products/plc-key-portenta-machine-control?queryID=undefined&selectedStore=us)
@@ -50,21 +52,21 @@ Here is a detailed guide in video format if you are a visual learner.
5052

5153
![Real Application Wiring Setup](assets/Wiring-white-small.png)
5254

53-
- In the __Portenta Machine Control__, connect the thermocouple terminals to TP0 and TN0 respectively. The 24 VDC power supply to the 24-volt input and GND.
55+
- In the __Portenta Machine Control__: connect the thermocouple terminals to TP0 and TN0 respectively and the 24 VDC power supply to the 24-volt input and GND.
5456

55-
- In the __Opta micro PLC__, connect the power supply to the respective inputs on the screw terminals.
57+
- In the __Opta micro PLC__: connect the power supply to the respective inputs on the screw terminals.
5658

57-
- Connect both the PMC and the Opta to your router using ethernet cables.
59+
- Connect both the Portenta Machine Control and the Opta to your local network using ethernet cables.
5860

5961
### Portenta Machine Control Setup
6062

6163
After downloading the [PLC IDE](https://www.arduino.cc/pro/software-plc-ide), open it and create a __new project__ for the Portenta Machine Control.
6264

63-
![New project for the PMC](assets/new-project.png)
65+
![New project for the Portenta Machine Control](assets/new-project.png)
6466

6567
A license is needed for this product to be used with the PLC IDE, you can buy it directly from the [Arduino store](https://store-usa.arduino.cc/products/plc-key-portenta-machine-control), and it will include the **product key** to activate the device.
6668

67-
Connect the PMC to the computer using a micro USB cable, the board needs to run a specific program (runtime) in order to interact with the **PLC IDE**. To flash it, select the device serial port and click on download.
69+
Connect the Machine Control to the computer using a micro USB cable, the board needs to run a specific program (runtime) in order to interact with the **PLC IDE**. To flash it, select the device serial port and click on download.
6870

6971
![Runtime program download](assets/runtime.png)
7072

@@ -81,7 +83,7 @@ The device will show its activation status, in this case, **No License** as it i
8183

8284
![Activation process](assets/activate.png)
8385

84-
After that, the status should say **OK**, and now you are ready to start programming the Portenta Machine Control with the PLC IDE.
86+
After the activation, the status should say **OK**. Now you are ready to start programming the Portenta Machine Control with the PLC IDE.
8587

8688
To learn more about the PLC IDE first setup, continue reading this [detailed guide](https://docs.arduino.cc/software/plc-ide/tutorials/plc-ide-setup-license/#6-license-activation-with-product-key-portenta-machine-control).
8789

@@ -90,9 +92,9 @@ For the Modbus TCP configuration, on the **resources tab** go to the **Ethernet*
9092

9193
![Modbus set to slave mode](assets/slave-mode.png)
9294

93-
Now, go to the **sketch editor** and uncomment the library and setup function code lines. As the IP, we must use the same as the Portenta Machine Control, as it is connected to your router, you can find it on its configurations.
95+
Go to the **sketch editor** and uncomment the library and setup function code lines. As the IP, we must use the same as the Portenta Machine Control, as it is connected to your local network, you can find it on its configurations.
9496

95-
In this case, the following configurations are used.
97+
In this case, the following configurations are used:
9698

9799
```arduino
98100
// Enable usage of EtherClass, to set static IP address and other
@@ -102,7 +104,7 @@ arduino::EthernetClass eth(&m_netInterface);
102104
void setup()
103105
{
104106
// Configure static IP address
105-
IPAddress ip(10, 0, 0, 157); // PMC IP address
107+
IPAddress ip(10, 0, 0, 157); // Portenta Machine Control IP address
106108
IPAddress dns(10, 0, 0, 1); // gateway IP address
107109
IPAddress gateway(10, 0, 0, 1); // gateway IP address
108110
IPAddress subnet(255, 255, 255, 0);
@@ -113,15 +115,15 @@ void setup()
113115
```
114116
![Network settings for Modbus TCP](assets/ip-setup.png)
115117

116-
Now, create the variable that will be shared with the temperature sensor data in the network. For this, we go to **status variables** and click on **Add**. Configure it as follows:
118+
Now create the variable that will be shared with the temperature sensor data in the network. Go to **status variables** and click on **Add**. Configure it as follows:
117119

118120
- Name: `temp_send`
119121
- Address: `25000`
120122
- PLC type: `REAL`
121123

122124
![Temperature variable setup](assets/var-setup.png)
123125

124-
Next, go to **Temperature probes** and select the sensor type, for this tutorial, enable the **thermocouple** connected to the first channel by setting it to true.
126+
Next go to **Temperature probes** and select the sensor type, for this tutorial, enable the **thermocouple** connected to the first channel by setting it to true.
125127

126128
![Temperature probe configuration](assets/probe-setup.png)
127129

@@ -137,13 +139,13 @@ To check if everything is okay, click on compile, and if no error is shown, you
137139

138140
![Project compiled with no errors](assets/compile.png)
139141

140-
Once uploaded, click on the **Connect** button again. Now, you can monitor the **temp_send** variable in the **Watch** window dragging and dropping it from the __Global shared__ variables in the project tab.
142+
Once uploaded, click on the **Connect** button again. Now you can monitor the **temp_send** variable in the **Watch** window dragging and dropping it from the __Global shared__ variables in the project tab.
141143

142-
You should see the temperature value measured by the sensor.
144+
You should see the temperature value measured by the sensor inside the "Watch" window.
143145

144-
![Live temperature measurement on the PMC](assets/temp-check.gif)
146+
![Live temperature measurement on the Machine Control](assets/temp-check.gif)
145147

146-
### Opta Micro PLC Setup
148+
### Opta Micro PLC Setup
147149

148150
Now the server is configured, create a new project, this time for the Opta™ micro PLC that will be the Client or Master.
149151

@@ -164,7 +166,9 @@ Now, in the upper left corner, click on the **Connect** button and wait for the
164166

165167
![Connecting the board](assets/connected-opta.png)
166168

167-
***The Opta™ doesn’t need any license activation to be used with the PLC IDE***
169+
***The Opta™ is Pre-Licensed so you don't have to buy any license to use it with the PLC IDE***
170+
171+
If the Opta status says **No License**, click on the **Activate PLC runtime** button to activate it. Learn more about this case in this [guide](https://docs.arduino.cc/tutorials/portenta-machine-control/plc-ide-setup-license/#7-license-activation-with-pre-licensed-products-opta).
168172

169173
#### Modbus TCP - Client
170174

@@ -176,27 +180,27 @@ In the **Ethernet** tab, enable the Modbus TCP Master mode.
176180

177181
Then right-click on the **Ethernet** tab, click on **Add** and select the _Generic Modbus device_.
178182

179-
![Modbus Device Configuration 1](assets/modbus-device.png)
183+
![Modbus Device Configuration - Step 1](assets/modbus-device.png)
180184

181185
On the `Generic Modbus_1` device settings, enter the Server IP, the one from the Portenta Machine Control.
182186

183-
![Modbus Device Configuration 2](assets/modbus-device-2.png)
187+
![Modbus Device Configuration - Step 2](assets/modbus-device-2.png)
184188

185189
Right-click on the device and add the **FC-04 Modbus** function that will let us read the server input registers.
186190

187-
![Modbus Device Configuration 3](assets/modbus-device-3.png)
191+
![Modbus Device Configuration - Step 3](assets/modbus-device-3.png)
188192

189-
Now, click on the function and in the general settings, enter the shared variable address that you defined earlier in the server, `25000` in this case.
193+
Now click on the function and in the general settings, enter the shared variable address that you defined earlier in the server, `25000` in this case.
190194

191-
![Modbus Device Configuration 4](assets/modbus-device-4.png)
195+
![Modbus Device Configuration - Step 4](assets/modbus-device-4.png)
192196

193197
In the Input Register tab, create a label for it, which could be `temp_reg`.
194198

195199
![Label the register](assets/modbus-device-5.png)
196200

197-
Now, go to the **sketch editor** and uncomment the library and setup function code lines. As the IP, we must use the same as the Opta™.
201+
Go to the **sketch editor** and uncomment the library and setup function code lines. As the IP, we must use the same as the Opta™.
198202

199-
In this case, the following configurations are used.
203+
In this case the following configurations are used:
200204

201205
```arduino
202206
// Enable usage of EtherClass, to set static IP address and other
@@ -217,15 +221,15 @@ void setup()
217221
```
218222
![Network settings for Modbus TCP](assets/ip-setup-opta.png)
219223

220-
Finally, define the Opta™ outputs behavior in function of the temperature read from the Portenta Machine Control. For this, go to the **resources tab > Relay Outputs** and give a variable name to each relay, in this case, call them `relay_1`, 2, 3 and 4 respectively.
224+
Finally, define the Opta™ outputs behavior in function of the temperature read from the Portenta Machine Control. To do this, go to the **resources tab > Relay Outputs** and give a variable name to each relay, in this case, call them `relay_1`, `relay_2`, `relay_3` and `relay_4` respectively.
221225

222226
![Outputs definitions](assets/outputs-opta.png)
223227

224-
The same with the LED outputs, `LED1`, 2, 3 and 4.
228+
The same with the LED outputs, `LED1`, `LED2`, `LED3` and `LED4`.
225229

226230
![LEDs definitions](assets/led-opta.png)
227231

228-
Now, go to the main code in the Project tab. Create a variable by right-clicking on the local variables window and then **insert**, call it **temp_local** and _integer_ as the type.
232+
Now go to the main code in the Project tab. Create a variable by right-clicking on the local variables window and then **insert**, call it **temp_local** and _integer_ as the type.
229233

230234
![Create a local variable](assets/variable-opta.png)
231235

@@ -277,12 +281,21 @@ With the final code written, compile the project and upload it the the Opta™ m
277281

278282
You can leave each device connected separately to the internet router or connect them together directly with one ethernet cable. The first option will let you update the preferred device remotely as you can access it through the local network.
279283

280-
Now, you can expose the temperature sensor to some heat and monitor it from the PLC IDE. The Opta™ relay outputs and LEDs will close and turn on when the temperature surpasses the programmed thresholds respectively.
284+
Now you can expose the temperature sensor to some heat and monitor it from the PLC IDE. The Opta™ relay outputs and LEDs will close and turn on when the temperature surpasses the programmed thresholds respectively.
281285

282286
![Testing the project](assets/final.gif)
283287

284-
#### Conclusion
288+
### Conclusion
285289

286290
In this tutorial you learned how to communicate two Arduino PRO products using the Modbus TCP protocol, demonstrating a simple application of sharing temperature data to control a device's outputs.
287291

288-
As you can notice, the configuration process is very straightforward and the results were as expected.
292+
As you can notice, the configuration process is very straightforward and the results were as expected, being a good starting point to adapt the work done here to create your own professional solution.
293+
294+
#### Next Steps
295+
296+
Extend your knowledge about the Portenta Machine Control, PLC IDE and the variety of industrial protocols it supports by following these tutorials:
297+
298+
- [Programming Introduction with Arduino PLC IDE](https://docs.arduino.cc/tutorials/portenta-machine-control/plc-programming-introduction/)
299+
- [Tank Thermoregulation with Portenta Machine Control & Opta™](https://docs.arduino.cc/tutorials/portenta-machine-control/pmc-opta-temp-ctrl/)
300+
- [Connect an RTD/Thermocouple to the Portenta Machine Control](https://docs.arduino.cc/tutorials/portenta-machine-control/rtd-thermocouple-pmc/)
301+
- [Arduino PLC IDE Setup & Device License Activation](https://docs.arduino.cc/tutorials/portenta-machine-control/plc-ide-setup-license/)

0 commit comments

Comments
 (0)