Skip to content

Commit e8e6bcd

Browse files
committed
Tutorial content update
1 parent d2b468c commit e8e6bcd

File tree

10 files changed

+66
-44
lines changed

10 files changed

+66
-44
lines changed

content/hardware/05.pro-solutions/solutions-and-kits/portenta-machine-control/tutorials/pmc-modbus-rtu-plc-ide/assets/pmc_plcide_client_relaySet.svg

Lines changed: 0 additions & 9 deletions
This file was deleted.

content/hardware/05.pro-solutions/solutions-and-kits/portenta-machine-control/tutorials/pmc-modbus-rtu-plc-ide/assets/pmc_plcide_server_mainCode.svg

Lines changed: 0 additions & 9 deletions
This file was deleted.

content/hardware/05.pro-solutions/solutions-and-kits/portenta-machine-control/tutorials/pmc-modbus-rtu-plc-ide/assets/pmc_plcide_server_statVar.svg

Lines changed: 0 additions & 9 deletions
This file was deleted.

content/hardware/05.pro-solutions/solutions-and-kits/portenta-machine-control/tutorials/pmc-modbus-rtu-plc-ide/content.md

Lines changed: 66 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,7 @@ The example project will be used to test the Modbus RTU connection between two P
184184

185185
To create a live handshake verification procedure between two Portenta Machine Control devices, the example project will slightly modify its default example code using the counter ('cnt') variable and broadcast the counter data.
186186

187-
-- TEST SETUP
188-
189-
Based on the counter data it receives from the "Modbus RTU Server Portenta Machine Control," the "Modbus RTU Client Portenta Machine Control" will activate the relay and the status LED. You may learn how to configure the Modbus RTU role for each Portenta Machine Control device using the role-specific sections.
187+
Based on the counter data it receives from the "Modbus RTU Server Portenta Machine Control," the "Modbus RTU Client Portenta Machine Control" will control the programmable digital I/Os and the digital outputs. Each Portenta Machine Control will have a simple dedicated task using previously mentioned elements. You will learn how to configure the Modbus RTU role for each Portenta Machine Control device and its processes using the role-specific sections.
190188

191189
You may access the entire example project [here](assets/ModbusRTU_PMC_Example.zip) if you would like to test it right away. Every setting and component is ready to be assembled and uploaded to the corresponding Portenta Machine Control.
192190

@@ -206,11 +204,11 @@ To configure the Portenta Machine Control as a Modbus RTU Server, navigate to th
206204

207205
Alternative values can be used per requirements if needed.
208206

209-
The subsequent image displays the `Status variables (volatile)` window. Within this window, we will define the `cnt` variable, specifying its access address and data type for Modbus RTU transmission.
207+
The subsequent image displays the `Status variables (volatile)` window. Within this window, we will define the `counter_stack` variable, specifying its access address and data type for Modbus RTU transmission.
210208

211-
![Arduino PLC IDE - Portenta Machine Control Server Status Variable](assets/pmc_plcide_server_statVar.svg)
209+
![Arduino PLC IDE - Portenta Machine Control Server Status Variable](assets/pmc_plcide_server_statVar.png)
212210

213-
The `cnt` status variable uses the following parameters:
211+
The `counter_stack` status variable uses the following parameters:
214212

215213
* Address: 25000 (dec) / 0x61A8 (hex)
216214
* Name: cnt
@@ -238,6 +236,7 @@ IF counter_buffer >= delay_buffer THEN
238236
cnt := 0;
239237
END_IF;
240238
counter_buffer := 0;
239+
counter_stack := counter_stack + 1;
241240
END_IF;
242241
243242
// Translate count to binary
@@ -249,11 +248,21 @@ DO_4 := SHR(cnt,4) AND 1;
249248
DO_5 := SHR(cnt,5) AND 1;
250249
DO_6 := SHR(cnt,6) AND 1;
251250
DO_7 := SHR(cnt,7) AND 1;
251+
252+
IF counter_stack > 50 THEN
253+
counter_stack := 0;
254+
END_IF;
252255
```
253256

254-
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.
257+
The role of the Portenta Machine Control server will be to use a binary counter programmed with digital outputs parametrized with a sub-counter variable. The sub-counter variable will be defined as `cnt` and cycle within 8-Bit map value. The counter speed will be controlled by `counter_buffer` and `delay_buffer` as a customizable timed factor. We will use the `counter_stack` as the shared Modbus counter variable for the client Portenta Machine Control.
258+
259+
![Arduino PLC IDE - Portenta Machine Control Server Global Variables](assets/pmc_plcide_server_globalVars.png)
260+
261+
The `counter_buffer` and `delay_buffer` variables are added using `New Variable` option found within right-clicking on `Global_vars`. The `counter_buffer` can be added as an `automatic` variable, while `delay_buffer` variable has been added initially as a `constant` variable with initial value assigned.
255262

256-
![Arduino PLC IDE - Portenta Machine Control Server Main Code](assets/pmc_plcide_server_mainCode.svg)
263+
To upload the main PLC code 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.
264+
265+
![Arduino PLC IDE - Portenta Machine Control Server Main Code](assets/pmc_plcide_server_mainCode.png)
257266

258267
Upon completing these steps, you will have effectively set up a Portenta Machine Control device to function as a Modbus RTU Server. The following section will guide you on how to configure another Portenta Machine Control as a Modbus RTU Client.
259268

@@ -302,31 +311,59 @@ In this tutorial's demonstration, the client Portenta Machine Control is configu
302311

303312
The image below shows how it should look within the PLC IDE interface:
304313

305-
![Arduino PLC IDE - Portenta Machine Control Client OBJECT Table](assets/pmc_plcide_device_localDO.png)
314+
![Arduino PLC IDE - Portenta Machine Control Client Digital Outputs Table](assets/pmc_plcide_device_localDO.png)
306315

307316
The OBJECT also needs labels to reference it later in the main PLC code. A table displaying the variable names designated for OBJECT can be seen below:
308317

309-
![Arduino PLC IDE - Portenta Machine Control Client OBJECT Table](assets/pmc_plcide_client_relaySet.svg)
318+
![Arduino PLC IDE - Portenta Machine Control Client Digital Programmable I/O Table](assets/pmc_plcide_device_DIO.png)
310319

311-
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.
320+
The main program below will be used to fetch counter data, control programmable digital I/Os, and manage corresponding digital outputs. A successful Modbus RTU communication will process previous tasks accordingly.
312321

313322
```arduino
314-
counter := counter + 1;
323+
counter := counter_rec;
315324
316-
IF counter >= 500 THEN
325+
IF counter >= 10 THEN
317326
DIO_0 := 1;
318327
END_IF;
319328
320-
IF counter >= 1000 THEN
329+
IF counter >= 20 THEN
330+
DIO_1 := 1;
331+
END_IF;
332+
333+
IF counter >= 30 THEN
334+
DIO_2 := 1;
335+
END_IF;
336+
337+
IF counter >= 40 THEN
338+
DIO_3 := 1;
339+
END_IF;
340+
341+
IF counter >= 50 THEN
321342
DIO_0 := 0;
322-
counter := 0;
343+
DIO_1 := 0;
344+
DIO_2 := 0;
345+
DIO_3 := 0;
346+
server_opCycle := server_opCycle + 1;
323347
END_IF;
324348
349+
// Translate count to binary
350+
DO_0 := server_opCycle AND 1;
351+
DO_1 := SHR(server_opCycle,1) AND 1;
352+
DO_2 := SHR(server_opCycle,2) AND 1;
353+
DO_3 := SHR(server_opCycle,3) AND 1;
354+
DO_4 := SHR(server_opCycle,4) AND 1;
355+
DO_5 := SHR(server_opCycle,5) AND 1;
356+
DO_6 := SHR(server_opCycle,6) AND 1;
357+
DO_7 := SHR(server_opCycle,7) AND 1;
325358
```
326359

327-
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.
360+
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 which is related to `counter_stack` data from server Portenta Machine Control. We established this variable when setting up the 'Read Input Registers' Modbus function.
361+
362+
The client Portenta Machine Control will use four digital programmable outputs and complete digital outputs as a operation indicator. Each time the `counter` marks new tenth value, it will activate corresponding digital programmable output to first digit of the counter value. For example, if the `counter` reaches `10`, the digital programmable output #1 will turn on.
363+
364+
Once the `counter` reaches `50` and resets, it will flag that one operation cycle has been completed. This will process will loop and use the digital outputs as a process cycle counter represented in a form of binary counter. This cyclic counter value is stored using `server_opCycle`.
328365

329-
Once you have successfully compiled and downloaded the main PLC code, the interface for the client Portenta Machine Control should mirror the image provided below:
366+
With this, we will compile and upload the main PLC code, the interface for the client Portenta Machine Control should mirror the image provided below:
330367

331368
![Arduino PLC IDE - Portenta Machine Control Client Main Code](assets/pmc_plcide_client_mainCode.png)
332369

@@ -342,6 +379,18 @@ The following short clip shows a briefly expected behavior of the example projec
342379

343380
![Example Project Result](assets/pmc_plcide_rtu_example_result.gif)
344381

382+
The server Portenta Machine Control will:
383+
384+
- Run a binary counter using digital outputs as visual indicators, mapped within 8-Bit boundary.
385+
- Shared Modbus counter variable will increase every time 8-Bit binary counter completes one cycle.
386+
- Binary counter speed can be controlled modifying buffer variables with desired values.
387+
388+
The client Portenta Machine Control will:
389+
390+
- Receive server counter information via Modbus protocol.
391+
- Translate and trigger corresponding programmable digital I/Os.
392+
- Use complete unit cycle of the programmable digital I/Os and represent total operation cycle with binary counter visualized using digital outputs.
393+
345394
## Conclusion
346395

347396
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

Comments
 (0)