Difference between revisions of "MISC-TN-026: Automated test equipment (ATE) monitoring with SBCSPG gateway, ThingsBoard IoT, and Fledge"

From DAVE Developer's Wiki
Jump to: navigation, search
(Enabling the connection to the PLC)
(Testbed)
Line 31: Line 31:
  
 
===Enabling the connection to the PLC===
 
===Enabling the connection to the PLC===
As described in MISC-TN-024, the PLC is connected to a different subnet, namely 192.168.30.0/24. To test the connection to the PLC, after adding the required subnet configuration, the <code>modbus</code> command line tool was used, which is provided by the <code>modbus_cli</code> package.
+
As described in MISC-TN-024, the PLC is connected to a different subnet, namely 192.168.30.0/24. For testing the connection to the PLC, after adding the required subnet configuration, the <code>modbus</code> command line tool was used, which is provided by the <code>modbus_cli</code> package.
  
 
<pre class="board-terminal">
 
<pre class="board-terminal">
 
root@sbcspg:/usr/local/fledge/python/fledge/plugins/north# ip addr add 192.168.30.253/24 dev eth0 label eth0:1
 
root@sbcspg:/usr/local/fledge/python/fledge/plugins/north# ip addr add 192.168.30.253/24 dev eth0 label eth0:1
 +
 +
armbian@sbcspg:~/devel/fledge$ pip install modbus_cli
 +
Defaulting to user installation because normal site-packages is not writeable
 +
Requirement already satisfied: modbus_cli in /home/armbian/.local/lib/python3.9/site-packages (0.1.8)
 +
Requirement already satisfied: colorama in /home/armbian/.local/lib/python3.9/site-packages (from modbus_cli) (0.4.6)
 +
Requirement already satisfied: umodbus in /home/armbian/.local/lib/python3.9/site-packages (from modbus_cli) (1.0.4)
 +
Requirement already satisfied: pyserial~=3.4 in /usr/local/lib/python3.9/dist-packages (from umodbus->modbus_cli) (3.5)
 +
 +
[notice] A new release of pip is available: 23.0 -> 23.0.1
 +
[notice] To update, run: python3 -m pip install --upgrade pip
 +
...
 +
armbian@sbcspg:~$ ./.local/bin/modbus 192.168.30.42:502 300
 +
Parsed 0 registers definitions from 1 files
 +
300: 32 0x20
 
</pre>
 
</pre>
  
  
  
root@sbcspg:/usr/local/fledge/python/fledge/plugins/north# history | grep mosq
+
 
  205  history | grep mosq
 
 
root@sbcspg:/usr/local/fledge/python/fledge/plugins/north# apt install mosquitto mosquitto-clients
 
root@sbcspg:/usr/local/fledge/python/fledge/plugins/north# apt install mosquitto mosquitto-clients
 
Reading package lists... Done
 
Reading package lists... Done
Line 105: Line 118:
 
[notice] A new release of pip is available: 23.0 -> 23.0.1
 
[notice] A new release of pip is available: 23.0 -> 23.0.1
 
[notice] To update, run: python3 -m pip install --upgrade pip
 
[notice] To update, run: python3 -m pip install --upgrade pip
 +
 +
 
armbian@sbcspg:~/devel/fledge$ ./.local/bin/modbus 192.168.30.42:502 300 Parsed 0 registers definitions from 1 files 300: 33 0x21^C
 
armbian@sbcspg:~/devel/fledge$ ./.local/bin/modbus 192.168.30.42:502 300 Parsed 0 registers definitions from 1 files 300: 33 0x21^C
 +
 
armbian@sbcspg:~/devel/fledge$ cd
 
armbian@sbcspg:~/devel/fledge$ cd
 +
 
armbian@sbcspg:~$ ./.local/bin/modbus 192.168.30.42:502 300 Parsed 0 registers definitions from 1 files 300: 33 0x21
 
armbian@sbcspg:~$ ./.local/bin/modbus 192.168.30.42:502 300 Parsed 0 registers definitions from 1 files 300: 33 0x21
 
Parsed 0 registers definitions from 1 files
 
Parsed 0 registers definitions from 1 files
Line 126: Line 143:
 
KeyError: ':'
 
KeyError: ':'
 
^C
 
^C
armbian@sbcspg:~$ ./.local/bin/modbus 192.168.30.42:502 300
 
Parsed 0 registers definitions from 1 files
 
300: 34 0x22
 
  
  

Revision as of 09:29, 27 February 2023

Info Box
SBCSPG-1.jpg Applies to SBCSPG
Cloud-computing-banner.jpg Applies to IoT
Warning-icon.png This technical note was validated against specific versions of hardware and software. It may not work with other versions. Warning-icon.png


History[edit | edit source]

Version Date Notes
1.0.0 February 2023 First public release

Introduction[edit | edit source]

In essence, this Technical Note (TN) is very similar to this one. There is a noticeable difference, however, as a different software stack was used on the edge device. In this case, LF Edge was utilized.

Testbed[edit | edit source]

The edge device is the SBCSPG gateway running Debian Bullseye. To deploy this distribution onto the target, the same approach described here was used. Unlike Orca SBC, SBCSPG is based on a 32-bit ARM Cortex-A7 processor, though. As such, a different image was used.

To install Fledge, the apt-based approach described here was followed. It is worth to remember that some dependencies were handled manually. For instance, autoconf and libtool packages were installed manually.

Enabling the connection to the PLC[edit | edit source]

As described in MISC-TN-024, the PLC is connected to a different subnet, namely 192.168.30.0/24. For testing the connection to the PLC, after adding the required subnet configuration, the modbus command line tool was used, which is provided by the modbus_cli package.

root@sbcspg:/usr/local/fledge/python/fledge/plugins/north# ip addr add 192.168.30.253/24 dev eth0 label eth0:1

armbian@sbcspg:~/devel/fledge$ pip install modbus_cli
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: modbus_cli in /home/armbian/.local/lib/python3.9/site-packages (0.1.8)
Requirement already satisfied: colorama in /home/armbian/.local/lib/python3.9/site-packages (from modbus_cli) (0.4.6)
Requirement already satisfied: umodbus in /home/armbian/.local/lib/python3.9/site-packages (from modbus_cli) (1.0.4)
Requirement already satisfied: pyserial~=3.4 in /usr/local/lib/python3.9/dist-packages (from umodbus->modbus_cli) (3.5)

[notice] A new release of pip is available: 23.0 -> 23.0.1
[notice] To update, run: python3 -m pip install --upgrade pip
...
armbian@sbcspg:~$ ./.local/bin/modbus 192.168.30.42:502 300
Parsed 0 registers definitions from 1 files
300: 32 0x20



root@sbcspg:/usr/local/fledge/python/fledge/plugins/north# apt install mosquitto mosquitto-clients Reading package lists... Done Building dependency tree... Done Reading state information... Done The following additional packages will be installed:

 libcjson1 libdlt2 libev4 libmosquitto1 libwebsockets16

Suggested packages:

 apparmor

The following NEW packages will be installed:

 libcjson1 libdlt2 libev4 libmosquitto1 libwebsockets16 mosquitto mosquitto-clients

0 upgraded, 7 newly installed, 0 to remove and 8 not upgraded. Need to get 715 kB of archives. After this operation, 1,492 kB of additional disk space will be used. Do you want to continue? [Y/n] Get:1 http://deb.debian.org/debian bullseye/main armhf libcjson1 armhf 1.7.14-1 [20.5 kB] Get:2 http://deb.debian.org/debian bullseye/main armhf libdlt2 armhf 2.18.6-1+deb11u1 [46.1 kB] Get:3 http://deb.debian.org/debian bullseye/main armhf libev4 armhf 1:4.33-1 [38.6 kB] Get:4 http://deb.debian.org/debian bullseye/main armhf libmosquitto1 armhf 2.0.11-1 [83.5 kB] Get:5 http://deb.debian.org/debian bullseye/main armhf libwebsockets16 armhf 4.0.20-2 [163 kB] Get:6 http://deb.debian.org/debian bullseye/main armhf mosquitto armhf 2.0.11-1 [253 kB] Get:7 http://deb.debian.org/debian bullseye/main armhf mosquitto-clients armhf 2.0.11-1 [110 kB] Fetched 715 kB in 0s (1,817 kB/s) Selecting previously unselected package libcjson1:armhf. (Reading database ... 72206 files and directories currently installed.) Preparing to unpack .../0-libcjson1_1.7.14-1_armhf.deb ... Unpacking libcjson1:armhf (1.7.14-1) ... Selecting previously unselected package libdlt2:armhf. Preparing to unpack .../1-libdlt2_2.18.6-1+deb11u1_armhf.deb ... Unpacking libdlt2:armhf (2.18.6-1+deb11u1) ... Selecting previously unselected package libev4:armhf. Preparing to unpack .../2-libev4_1%3a4.33-1_armhf.deb ... Unpacking libev4:armhf (1:4.33-1) ... Selecting previously unselected package libmosquitto1:armhf. Preparing to unpack .../3-libmosquitto1_2.0.11-1_armhf.deb ... Unpacking libmosquitto1:armhf (2.0.11-1) ... Selecting previously unselected package libwebsockets16:armhf. Preparing to unpack .../4-libwebsockets16_4.0.20-2_armhf.deb ... Unpacking libwebsockets16:armhf (4.0.20-2) ... Selecting previously unselected package mosquitto. Preparing to unpack .../5-mosquitto_2.0.11-1_armhf.deb ... Unpacking mosquitto (2.0.11-1) ... Selecting previously unselected package mosquitto-clients. Preparing to unpack .../6-mosquitto-clients_2.0.11-1_armhf.deb ... Unpacking mosquitto-clients (2.0.11-1) ... Setting up libmosquitto1:armhf (2.0.11-1) ... Setting up libev4:armhf (1:4.33-1) ... Setting up libcjson1:armhf (1.7.14-1) ... Setting up mosquitto-clients (2.0.11-1) ... Setting up libdlt2:armhf (2.18.6-1+deb11u1) ... Setting up libwebsockets16:armhf (4.0.20-2) ... Setting up mosquitto (2.0.11-1) ... Created symlink /etc/systemd/system/multi-user.target.wants/mosquitto.service → /lib/systemd/system/mosquitto.service. Processing triggers for libc-bin (2.31-13+deb11u5) ...


armbian@sbcspg:~/devel/fledge$ pip install modbus_cli Defaulting to user installation because normal site-packages is not writeable Requirement already satisfied: modbus_cli in /home/armbian/.local/lib/python3.9/site-packages (0.1.8) Requirement already satisfied: colorama in /home/armbian/.local/lib/python3.9/site-packages (from modbus_cli) (0.4.6) Requirement already satisfied: umodbus in /home/armbian/.local/lib/python3.9/site-packages (from modbus_cli) (1.0.4) Requirement already satisfied: pyserial~=3.4 in /usr/local/lib/python3.9/dist-packages (from umodbus->modbus_cli) (3.5)

[notice] A new release of pip is available: 23.0 -> 23.0.1 [notice] To update, run: python3 -m pip install --upgrade pip


armbian@sbcspg:~/devel/fledge$ ./.local/bin/modbus 192.168.30.42:502 300 Parsed 0 registers definitions from 1 files 300: 33 0x21^C

armbian@sbcspg:~/devel/fledge$ cd

armbian@sbcspg:~$ ./.local/bin/modbus 192.168.30.42:502 300 Parsed 0 registers definitions from 1 files 300: 33 0x21 Parsed 0 registers definitions from 1 files 0: 0 0x0 1: 256 0x100 33: 0 0x0 300: 34 0x22 Traceback (most recent call last):

 File "/home/armbian/./.local/bin/modbus", line 109, in <module>
   main()
 File "/home/armbian/./.local/bin/modbus", line 102, in main
   connect_to_device(args).perform_accesses(parse_accesses(args.access, definitions, args.byte_order), definitions).close()
 File "/home/armbian/.local/lib/python3.9/site-packages/modbus_cli/modbus_tcp.py", line 64, in perform_accesses
   access.print_values(definitions)
 File "/home/armbian/.local/lib/python3.9/site-packages/modbus_cli/access.py", line 83, in print_values
   logging.info('{}: {} {}'.format(label, value, self.present_value(value, presenter, definitions)))
 File "/home/armbian/.local/lib/python3.9/site-packages/modbus_cli/access.py", line 93, in present_value
   presentation.append(definitions.presenters[presenter][value])

KeyError: ':' ^C


https://github.com/fledge-iot/fledge-south-modbustcp/pull/26/files

Riavviare south plugin disable/enable per via grafica.


You can think about this This Technical Note (TN) as an evolution of the article "MISC-TN-021: SBCSPG and ThingsBoard IoT". The use case described here is a real-world application based on the same elements:

The application is to monitor robotized DAVE Embedded Systems' ATEs like the one shown here.

Implementation[edit | edit source]

The implementation is suitable for a production environment. Unlike what we did for this TN, in this case the ThingsBoard IoT platform was installed on the cloud, specifically on an AWS EC2 instance running Ubuntu Linux. The following diagram shows the complete solution.

ATE monitoring SBCSPG ThingsBoard.png

Technically, the gateway can communicate with the ATE using different physical links and protocols. In the example under discussion, the physical link is Ethernet and the protocol is Modbus/TCP. The gateway retrieves periodically some data regarding the robotic arm used to move the device under test (DUT). These data are exposed by the PLC governing the arm and are documented in detail here.

ThingsBoard IoT configuration[edit | edit source]

To install ThingsBoard IoT platform on an EC2 instance, these instructions were followed.

ThingsBoard IoT gateway configuration[edit | edit source]

To run this esample, the most important module to configure was the Modbus connector. The following box shows the resulting configuration file needed to poll some variables of the arm's joints (namely temperatures and currents).

armbian@sbcspg:~$ cat /etc/thingsboard-gateway/config/modbus.json
{
    "master": {
      "slaves": [
        {
          "host": "192.168.30.42",
          "port": 502,
          "type": "tcp",
          "method": "socket",
          "timeout": 35,
          "byteOrder": "BIG",
          "retries": true,
          "retryOnEmpty": true,
          "retryOnInvalid": true,
          "pollPeriod": 5000,
          "unitId": 1,
          "deviceName": "UR5",
          "sendDataOnlyOnChange": true,
          "connectAttemptTimeMs": 5000,
          "connectAttemptCount": 5,
          "waitAfterFailedAttemptsMs": 300000,
          "timeseries": [
            {
              "tag": "base_joint_temperature_deg_C",
              "type": "16int",
              "functionCode": 3,
              "objectsCount": 1,
              "address": 300
            },
            {
              "tag": "shoulder_joint_temperature_deg_C",
              "type": "16int",
              "functionCode": 3,
              "objectsCount": 1,
              "address": 301
            },
            {
                "tag": "base_joint_current_mA",
                "type": "16int",
                "functionCode": 3,
                "objectsCount": 1,
                "address": 290
            },
            {
                "tag": "shoulder_joint_current_mA",
                "type": "16int",
                "functionCode": 3,
                "objectsCount": 1,
                "address": 291
            },
            {
                "tag": "elbow_joint_current_mA",
                "type": "16int",
                "functionCode": 3,
                "objectsCount": 1,
                "address": 292
            },
            {
              "tag": "wrist1_joint_current_mA",
              "type": "16int",
              "functionCode": 3,
              "objectsCount": 1,
              "address": 293
            },
            {
                "tag": "wrist2_joint_current_mA",
                "type": "16int",
                "functionCode": 3,
                "objectsCount": 1,
                "address": 294
            },
            {
                "tag": "wrist3_joint_current_mA",
                "type": "16int",
                "functionCode": 3,
                "objectsCount": 1,
                "address": 295
            }
          ]
        }
      ]
    }
  }

Dashboards[edit | edit source]

ThingsBoard IoT allows to create easily custom dashboards to visualize data. At this link such a dashboard is available showing some temperatures and currents of the arm's joints.