Skip to content

Commit 34d4b3c

Browse files
committed
PMC part finished
1 parent e14a13a commit 34d4b3c

File tree

7 files changed

+48
-0
lines changed

7 files changed

+48
-0
lines changed
Loading
Loading
Loading
Loading
Loading
Loading

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

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,54 @@ For the Modbus TCP configuration, on the **resources tab** go to the **Ethernet*
8686

8787
![Modbus set to slave mode](assets/slave-mode.png)
8888

89+
Now, go to **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.
90+
91+
In this case, the following configurations are used.
92+
93+
```arduino
94+
// Enable usage of EtherClass, to set static IP address and other
95+
#include <PortentaEthernet.h>
96+
arduino::EthernetClass eth(&m_netInterface);
97+
98+
void setup()
99+
{
100+
// Configure static IP address
101+
IPAddress ip(10, 0, 0, 157); // Portenta IP address
102+
IPAddress dns(10, 0, 0, 1); // gateway IP address
103+
IPAddress gateway(10, 0, 0, 1); // gateway IP address
104+
IPAddress subnet(255, 255, 255, 0);
105+
// If cable is not connected this will block the start of PLC with about 60s of timeout!
106+
eth.begin(ip, dns, gateway, subnet);
107+
108+
}
109+
```
110+
![Network settings for Modbus TCP](assets/ip-setup.png)
111+
112+
Now, let's 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**, we give it a name, in this case: `temp_send`, change the variable address to `25000`, and the type to `REAL`.
113+
114+
![Temperature variable setup](assets/var-setup.png)
115+
116+
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.
117+
118+
![Temperature probe configuration](assets/probe-setup.png)
119+
120+
Finally, let's go to the **main program** in **project** and match the temperature variable with the temperature sensor lectures as follows:
121+
122+
```
123+
temp_send := sysTempProbes[0].temperature;
124+
```
125+
126+
![Main program for the server](assets/main-code.png)
127+
128+
To check if everything is okay, click on compile, and if no error is shown, you can upload the code to your Portenta Machine Control.
129+
130+
![Project compiled with no errors](assets/compile.png)
131+
132+
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.
133+
134+
You should see the temperature value measured by the sensor.
135+
136+
![Live temperature measurement on the PMC](assets/temp-check.gif)
89137

90138
### Opta Micro PLC Setup
91139

0 commit comments

Comments
 (0)