|
| 1 | +--- |
| 2 | +title: 'Modbus TCP Communication with Portenta Machine Control & Opta™' |
| 3 | +difficulty: intermediate |
| 4 | +description: "Modbus TCP communication on a temperature industrial application using a Portenta Machine Control, Opta™, a temperature sensor, and the Arduino® PLC IDE." |
| 5 | +tags: |
| 6 | + - Thermocouple |
| 7 | + - IEC-61131-3 |
| 8 | + - PLC-IDE |
| 9 | + - Opta™ |
| 10 | +author: 'Christopher Mendez' |
| 11 | + |
| 12 | +hardware: |
| 13 | + - hardware/05.pro-solutions/solutions-and-kits/portenta-machine-control |
| 14 | + - hardware/07.opta/opta-family/opta |
| 15 | + |
| 16 | +software: |
| 17 | + - plc-ide |
| 18 | +--- |
| 19 | + |
| 20 | +## Overwiew |
| 21 | + |
| 22 | +In this tutorial, a Portenta Machine Control and an Opta micro PLC will be used as a **server** and a **client** respectively to share temperature information through a 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. |
| 23 | + |
| 24 | +## Goals |
| 25 | + |
| 26 | +- Learn how to measure temperature with the Portenta Machine Control using a thermocouple and the PLC IDE |
| 27 | +- Learn how to use the Modbus protocol over TCP/IP using the PLC IDE |
| 28 | +- Leverage Arduino Pro products for real industrial applications |
| 29 | + |
| 30 | +## Hardware and Software Requirements |
| 31 | + |
| 32 | +### Hardware |
| 33 | +- [Portenta Machine Control](https://store.arduino.cc/products/arduino-portenta-machine-control) (x1) |
| 34 | +- [Opta™](https://store-usa.arduino.cc/collections/opta-family) (x1) |
| 35 | +- Type K thermocouple (x1) |
| 36 | +- Ethernet cables (x2) |
| 37 | +- Wired internet access |
| 38 | +- 24 VDC Power Supply (x2) |
| 39 | +### Software |
| 40 | +- The [Arduino PLC IDE](https://www.arduino.cc/pro/software-plc-ide) (including Arduino PLC IDE Tools) |
| 41 | +- [Portenta Machine Control - PLC IDE Activation](https://docs.arduino.cc/tutorials/portenta-machine-control/plc-ide-setup-license) |
| 42 | + |
| 43 | +## Instructions |
| 44 | + |
| 45 | +### Solution Wiring |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | +- 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. |
| 50 | + |
| 51 | +- In the __Opta micro PLC__, connect the power supply to the respective inputs on the screw terminals. |
| 52 | + |
| 53 | +- Connect both the PMC and the Opta to your router using ethernet cables. |
| 54 | + |
| 55 | +### Portenta Machine Control Setup |
| 56 | + |
| 57 | +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. |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | +We need a license for this product to be used with the PLC IDE that we can buy directly from the [Arduino store](https://store-usa.arduino.cc/products/plc-key-portenta-machine-control), it will include a **product key** needed to activate the device. |
| 62 | + |
| 63 | +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. |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | +Once the runtime is flashed, navigate to **On-line > Set up communication**, open the **Modbus** properties and select the **secondary** serial port, then click "OK". |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | +Now, in the upper left corner, click on the **Connect** button and wait for the base program to be uploaded. A green **Connected** flag should appear in the lower right corner if everything goes well. |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | +The device will show its activation status, in this case, **No License** as is the first time we are using it with the PLC IDE. To activate it, paste the **product key** you bought in the highlighted box and click on **Activate**. |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | +After that, the status should say **OK**, and now you are ready to start programming the Portenta Machine Control with the PLC IDE. |
| 81 | + |
| 82 | +If want 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). |
| 83 | + |
| 84 | +#### Modbus TCP - Server |
| 85 | +For the Modbus TCP configuration, on the **resources tab** go to the **Ethernet** section. As noticed, the Modbus TCP Slave mode is always enabled, so you don't have to make any changes. |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | +### Opta Micro PLC Setup |
| 91 | + |
| 92 | +#### Modbus TCP - Client |
| 93 | + |
0 commit comments