You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/hardware/05.pro-solutions/solutions-and-kits/portenta-machine-control/tutorials/pmc-opta-modbus-tcp/content.md
+63-1Lines changed: 63 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -156,7 +156,7 @@ Now, in the upper left corner, click on the **Connect** button and wait for the
156
156
157
157

158
158
159
-
***The Opta doesn’t need any license activation to be used with the PLC IDE***
159
+
***The Opta™ doesn’t need any license activation to be used with the PLC IDE***
160
160
161
161
#### Modbus TCP - Client
162
162
@@ -216,3 +216,65 @@ Finally, define the Opta™ outputs behavior in function of the temperature read
216
216
The same with the LED outputs, LED1, 2, 3 and 4.
217
217
218
218

219
+
220
+
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.
221
+
222
+

223
+
224
+
In the code editor, match the local variable with the shared one sent by the Portenta Machine Control.
225
+
226
+
And once stored locally, design the logic to control the outputs as you want. In this case, four different temperature levels will be set to control each output with the temperature rise respectively. Copy and paste the following script into the **main code** section.
227
+
228
+
```
229
+
temp_local:= temp_reg;
230
+
231
+
IF temp_local >= 30 THEN
232
+
relay_1 := TRUE;
233
+
LED1 := TRUE;
234
+
ELSE
235
+
relay_1 := FALSE;
236
+
LED1 := FALSE;
237
+
END_IF;
238
+
239
+
IF temp_local >= 50 THEN
240
+
relay_2 := TRUE;
241
+
LED2 := TRUE;
242
+
ELSE
243
+
relay_2 := FALSE;
244
+
LED2 := FALSE;
245
+
END_IF;
246
+
247
+
IF temp_local >= 70 THEN
248
+
relay_3 := TRUE;
249
+
LED3 := TRUE;
250
+
ELSE
251
+
relay_3 := FALSE;
252
+
LED3 := FALSE;
253
+
END_IF;
254
+
255
+
IF temp_local >= 100 THEN
256
+
relay_4 := TRUE;
257
+
LED4 := TRUE;
258
+
ELSE
259
+
relay_4 := FALSE;
260
+
LED4 := FALSE;
261
+
END_IF;
262
+
263
+
```
264
+

265
+
266
+
With the final code written, compile the project and upload it the the Opta™ micro PLC.
267
+
268
+
### Final Test
269
+
270
+
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.
271
+
272
+
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.
273
+
274
+

275
+
276
+
#### Conclusion
277
+
278
+
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.
279
+
280
+
As you can notice, the configuration process is very straightforward and the results were as expected.
0 commit comments