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-modbus-rtu-plc-ide/assets/pmc_plcide_client_modbusFunctionConfig_reg.svg
Copy file name to clipboardExpand all lines: content/hardware/05.pro-solutions/solutions-and-kits/portenta-machine-control/tutorials/pmc-modbus-rtu-plc-ide/assets/pmc_plcide_client_nodeConfig.svg
Copy file name to clipboardExpand all lines: content/hardware/05.pro-solutions/solutions-and-kits/portenta-machine-control/tutorials/pmc-modbus-rtu-plc-ide/assets/pmc_plcide_customModbus.svg
Copy file name to clipboardExpand all lines: content/hardware/05.pro-solutions/solutions-and-kits/portenta-machine-control/tutorials/pmc-modbus-rtu-plc-ide/assets/pmc_plcide_generalNode.svg
Copy file name to clipboardExpand all lines: content/hardware/05.pro-solutions/solutions-and-kits/portenta-machine-control/tutorials/pmc-modbus-rtu-plc-ide/assets/pmc_plcide_modbus_functions.svg
Copy file name to clipboardExpand all lines: content/hardware/05.pro-solutions/solutions-and-kits/portenta-machine-control/tutorials/pmc-modbus-rtu-plc-ide/content.md
+38-13Lines changed: 38 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -127,7 +127,7 @@ For appropriate Modbus RTU operation, it requires some considerations to be take
127
127
#### Portenta Machine Control Basic Configuration
128
128
<br></br>
129
129
130
-
The Modbus RTU communication for the Portenta Machine Control does not require special pre-configuration. You will only have to make a manual sketch download with the desired protocol role with its properties, and its onboard elements to be used. These onboard elements can be programmable digital I/Os and encoders.
130
+
The Modbus RTU communication for the Portenta Machine Control does not require special pre-configuration. You will only have to make a manual sketch download with the desired protocol role with its properties, and its onboard elements to be used. These onboard elements can be programmable digital I/Os and dedicated digital outputs.
131
131
132
132
Portenta Machine Control can be initialized further in the process if additional changes in configuration is required.
133
133
@@ -153,7 +153,7 @@ If you decide to disable Modbus RTU for the Portenta Machine Control, you can se
153
153
154
154
The General Modbus Node allows to add information regarding the devices compatible with the Modbus messaging service.
155
155
156
-

156
+

157
157
158
158
It will require you to fill in basic information under the `General` tab and parameters to manage under the `Parametrization` tab. The basic information consists of:
159
159
@@ -172,7 +172,7 @@ The Modbus Custom Editor allows you to define a Modbus node with set of pre-defi
172
172
173
173
To open the Modbus Custom Editor window, go to `Tools -> Run Modbus Custom Editor` on PLC IDE.
174
174
175
-

175
+

176
176
177
177
It is a useful feature to have frequently deployed device configuration stored that is compatible with Modbus protocol.
178
178
@@ -214,7 +214,7 @@ The `cnt` status variable uses the following parameters:
214
214
215
215
Upon finalizing the settings, go to `Resources -> Portenta Machine Control` and select the corresponding port, subsequently beginning the `Manual sketch download` process. Navigate to `On-line -> Set up Communication` and activate Modbus RTU, ensuring that the elevated USB port number designated for the Portenta Machine Control is selected.
216
216
217
-

217
+

218
218
219
219
Proceed with `On-line -> Connect` to set up a connection with the Portenta Machine Control server. If everything is set up correctly, we will see a message in the bottom right of the PLC IDE software that says it is connected.
220
220
@@ -225,11 +225,26 @@ Symbols `(1)` and `(2)` show different connection statuses: Portenta Machine Con
225
225
To get the main PLC code onto the Portenta Machine Control, go to the `main` tab in the `Project` section. Then, you can enter the following code:
226
226
227
227
```arduino
228
-
cnt := cnt + 1;
229
-
230
-
IF cnt >= 2750 THEN
231
-
cnt := 0;
228
+
counter_buffer := counter_buffer + 1;
229
+
230
+
IF counter_buffer >= delay_buffer THEN
231
+
IF cnt < 255 THEN
232
+
cnt := cnt + 1;
233
+
ELSE
234
+
cnt := 0;
235
+
END_IF;
236
+
counter_buffer := 0;
232
237
END_IF;
238
+
239
+
// Translate count to binary
240
+
DO_0 := cnt AND 1;
241
+
DO_1 := SHR(cnt,1) AND 1;
242
+
DO_2 := SHR(cnt,2) AND 1;
243
+
DO_3 := SHR(cnt,3) AND 1;
244
+
DO_4 := SHR(cnt,4) AND 1;
245
+
DO_5 := SHR(cnt,5) AND 1;
246
+
DO_6 := SHR(cnt,6) AND 1;
247
+
DO_7 := SHR(cnt,7) AND 1;
233
248
```
234
249
235
250
The role of the Portenta Machine Control server is to continually count until it hits `2750`, then reset. To transfer this counting task to the Portenta Machine Control, you can either select `Download PLC code` or simply hit `F7`. Once everything is in place, a successful upload will look like the image shown below.
@@ -259,11 +274,11 @@ To establish communication with the pre-configured Modbus RTU Server Portenta Ma
259
274
260
275
Use the configuration model applied to the Modbus RTU Server Portenta Machine Control for these settings. The important detail to consider is the Modbus address. Make sure this address corresponds with that of the server Portenta Machine Control or any other compatible device, in case more nodes are added. The setup should resemble the image provided:
261
276
262
-

277
+

263
278
264
279
After setting up the Modbus node for the client Portenta Machine Control,we need to specify the Modbus function responsible for retrieving the counter (`cnt`) data from the server Portenta Machine Control. Right-click on `PMC_RTU_1` or any other name you set with, to see the 'Add' option, which will bring forth a device catalog window showcasing all available Modbus functions:
265
280
266
-

281
+

267
282
268
283
To retrieve the counter data from the server Portenta Machine Control, select the 'Modbus FC-04 (Read Input Registers)' function. Configure the 'General' tab with the following parameters to ensure correct data access:
269
284
@@ -275,7 +290,7 @@ Next, you will need to designate a variable to hold the counter data captured fr
275
290
276
291
The following image shows a visual representation of the anticipated configuration:
277
292
278
-

293
+

279
294
280
295
In this tutorial's demonstration, the client Portenta Machine Control is configured to use WIP
281
296
@@ -290,7 +305,17 @@ The OBJECT also needs labels to reference it later in the main PLC code. A table
290
305
The main program below will be used to fetch counter data, control OBJECTS, and manage corresponding OBJECTS. A successful Modbus TCP communication will process previous tasks accordingly.
291
306
292
307
```arduino
293
-
WIP
308
+
counter := counter + 1;
309
+
310
+
IF counter >= 500 THEN
311
+
DIO_0 := 1;
312
+
END_IF;
313
+
314
+
IF counter >= 1000 THEN
315
+
DIO_0 := 0;
316
+
counter := 0;
317
+
END_IF;
318
+
294
319
```
295
320
296
321
The `counter` variable serves as a global reference for the client Portenta Machine Control. On the other hand, `counter_rec` is tailored for Modbus, storing the data retrieved from the server Portenta Machine Control. We established this variable when setting up the 'Read Input Registers' Modbus function.
@@ -313,7 +338,7 @@ The following short clip shows a briefly expected behavior of the example projec
313
338
314
339
## Conclusion
315
340
316
-
In this tutorial, you have learned to configure the workspace environment to work with Modbus RTU using Arduino PLC IDE and verified that Portenta Machine Control has been correctly set up and Modbus RTU communication is effective using an example project that controls Portenta Machine Control device's on-board features such as programmable digital I/Os and encoders based on customized example.
341
+
In this tutorial, you have learned to configure the workspace environment to work with Modbus RTU using Arduino PLC IDE and verified that Portenta Machine Control has been correctly set up and Modbus RTU communication is effective using an example project that controls Portenta Machine Control device's on-board features such as programmable digital I/Os and dedicated digital outputs based on customized example.
0 commit comments