Summary

Data Communication Based on MQTT in a Polymer Extrusion Process

Published: July 15, 2022
doi:

Summary

This work proposes a flexible method for data communication between a film extrusion system and monitoring devices based on a message protocol called Message Queuing Telemetry Transport (MQTT).

Abstract

This work aims at building a flexible data communication structure for a polymer processing machine by employing a publisher-subscriber based protocol called Message Queuing Telemetry Transport (MQTT), which is operated over TCP/IP. Even when using conventional equipment, processing data can be measured and recorded by various devices anywhere through an Internet communication. A message-based protocol allows flexible communication that overcomes the shortcomings of the existing server-client protocol. Multiple devices can subscribe to the processing data published by source devices. The proposed method facilitates data communication between multiple publishers and subscribers. This work has implemented a system that publishes data from the equipment and additional sensors to a message broker. The subscribers can monitor and store the process data relayed by the broker. The system has been deployed and run for a film extrusion line to demonstrate the effectiveness.

Introduction

In the wave of the 4th industrial revolution, the acquisition and monitoring of various processing data have become important tasks1. In particular, improving the manufacturing process using process data and establishing efficient operation plans will be an important goal of all manufacturing facilities2,3. Downtime can be greatly reduced if an alarm can be sent out of the factory or if predictive maintenance can be performed in time4. Recently, many efforts have been made for data analyses in polymer processes5,6. However, it is not easy to conduct these tasks due to the difficulties in acquiring such data from the existing systems7. The hierarchical structure of the control and instrumentation makes the data acquisition and communication difficult.

First of all, it is not possible to obtain data from different machines with different manufacturing dates. It is difficult to realize communication between different machines since this requires interoperability between different fieldbuses in proprietary formats. In this way, communication methods and data formats are kept private. This helps one easily maintain data security but keeps users dependent on the machine builder for the services and future developments. The recent control computers including human-machine interface (HMI) attached to polymer processing machines are mostly Windows-based these days but are loaded with software created in a proprietary development environment. It is possible to use programmable logic controllers (PLCs) from different companies to communicate with the sensors or actuators, but in many cases, the upper supervisory control and data acquisition (SCADA) system is dependent on the control computers8. This practice has caused numerous protocols, fieldbuses, and control systems to compete in the market. Although this complexity has been alleviated little by little over time, many types of fieldbuses and protocols are still in active use.

On the other hand, communication between control devices and SCADA has been standardized by the Open Platform Communications United Architecture (OPCUA)9. Moreover, communication between SCADA and the Manufacturing Execution System (MES) has also been mainly made through OPCUA. In such a tight hierarchical structure, it is not easy to freely extract data for process monitoring and analysis. Usually, data has to be extracted out of the SCADA or MES10. As mentioned earlier, these systems are vendor-specific, and the data formats are rarely open. As a result, the data extraction requires substantial support from the original information technology/operational technology (IT/OT) solution vendors. This can hinder data acquisition for monitoring and analysis.

In a film extrusion line, the control PC is supervised by a SCADA system11. The SCADA system is operated by a computer program that cannot be easily modified. The computer program might be editable, but the editing is quite expensive and time-consuming. To easily monitor and analyze the processing data, the data should be accessible from any location. To monitor the processing data away from the site, the computer program should be capable of streaming the processing data to the Internet12. Moreover, an open free method reduces the expenses for the data acquisition13. This approach allows data analysis to be performed even in small factories that cannot afford to invest in commercial IT solutions14.

In this study, a message protocol based on the publisher-subscriber model is employed. The Message Queuing Telemetry Transport (MQTT) is an open and standard protocol that enables messaging between multiple data providers and consumers15. Here, we propose a system that acquires, transmits, and monitors data using MQTT for existing manufacturing facilities. The system is tested in a film extrusion line to verify the performance. The data from the original controller are transmitted to an edge device via the Modbus protocol. Then, the data is published to the broker. In the meantime, two Raspberry Pis publish the measured temperatures and illuminance to the same broker. Then, any device on the Internet can subscribe to the data, followed by monitoring and recording it as shown in Figure 1. The protocol in this work shows how the whole procedure can be done.

Protocol

1. Broker installation

NOTE: To monitor and record processing data via the Internet, a computer system that relays the data should be prepared. The system should be accessible from both the publishers and the subscribers as shown in Figure 2. Thus, it needs to have a public IP address that is known prior to any communication. An open MQTT broker called Eclipse Mosquitto is installed on the system13.

  1. Connect a computer to the Internet giving a public IP address. Give the address in the IP setting of the operating system.
  2. Install a broker software such as Eclipse Mosquitto on the computer. Download the installation file using a browser and execute it.
  3. Test the broker with a test program such as MQTT Lens. Download MQTT Lens using a browser and install it. Then, ensure published messages are subscribed.

2. Main publisher preparation

NOTE: This computer publishes the machine data via MQTT over TCP to the broker. Legacy data should be interpreted and repackaged to be sent out.This can be usually done by RS485 or Ethernet. The connection at the hardware level should be verified depending on the bus type. The extrusion machine sends out the data via Modbus through an Ethernet port.

  1. Physically place a computer in the machine site and set it up as the main publisher.
    NOTE: Although not obligatory, an industrial computer was selected in this work.
  2. Install Python3 on the computer. Download the installer file using a browser and execute it.
  3. Install PyModbus16. Download the installer file using a browser and execute it.
  4. Examine the extrusion controller with HMI controlling the machine and connect the extrusion controller to the main publisher.
  5. Fully identify the data and the corresponding address in the Modbus protocol from the machine using a Modbus tool such as ModbusPoll or QModMaster. Ensure the sent machine data are shown in the corresponding cells of the Modbus tool.
  6. Write a Python code on the publisher PC that retrieves the data from the extrusion controller.
    NOTE: Here is a code example:
    from pyModbusTCP.client import ModbusClient
    client = ModbusClient(host="192.168.1.***", port=***, unit_id=***)
    client.open()
    ExtrusionData = str(client.read_holding_registers(1000, 58))
  7. Merge additional data streams from other devices via PCIe, USB, RS232, and RS485.
    NOTE: This is straightforward. Once an additional data string is obtained, simply add the data to the existing data stream, which is done by the following code:
    ExtrusionData += AdditionalData
  8. Import the paho.mqtt.client after installing paho-mqtt by pip install paho-mqtt17.
  9. Implement the code to connect and publish data to the broker.
    NOTE: Refer to the following code example:
    url="117.xx.xxx.xx"; port = 1883; username = "****"; password = "xxxxx"; topic = "Extruder"
    mqttc = mqtt.Client()
    mqttc.username_pw_set(username,password)
    mqttc.connect(host=url, port=port)
    mqttc.loop_start()
    ExtrusionData = str(client.read_holding_registers(1000, 58))
    Pub1= mqttc.publish(topic, ExtrusionData))
    Pub1.wait_for_publish()

3. Additional publisher preparation

NOTE: This computer also publishes the machine data via MQTT over TCP to the broker. Sometimes, additional measurement that cannot be done on the main publisher is required. Internet of Things (IoT) devices such as Raspberry Pi and Arduino can take the role. In this work, Raspberry Pi was employed for temperature data and illuminance data. The procedure is similar to protocol section 2.

  1. Place a Raspberry Pi near the sensor location.
    NOTE: Since the wiring distance is limited, the Raspberry Pi cannot be placed very far from the measurement location. However, as the vicinity of the extruder is very hot, the device needs to be placed at least 1 m away from the measurement location.
  2. Install Python3 on the Raspberry Pi by the following commands in the command line:
    sudo apt update
    sudo apt install Python3 idle3
  3. Implement the code to acquire the sensor data. The sensor data can be transmitted via I2C or GPIO.
    NOTE: Refer to the following code example for additional temperature data via GPIO:
    from max6675 import MAX6675
    cs_pin1 = 24; clock_pin1 = 25; data_pin1 = 18
    cs_pin2 = 9; clock_pin2 = 11; data_pin2 = 19
    units = "C"
    thermocouple1 = MAX6675(cs_pin1, clock_pin1, data_pin1, units)
    thermocouple2 = MAX6675(cs_pin2, clock_pin2, data_pin2, units)
    T1 = thermocouple1.get()
    T2 = thermocouple2.get()
  4. Import paho.mqtt.client.
  5. Reuse the code in section 2 to connect and publish data to the broker.

4. Subscriber's setup

NOTE: Any devices on Internet may receive the processing data via the broker. The data is processed and visualized also by a Python code. In case the development is difficult, available applications such as MQTT Client in Google Play and MQT Tool in the App Store can be employed. Since the implementation of the user interface is quite lengthy, the details are not described here. Also note that existing applications such as MQT Tool in App Store can receive the data.

  1. Engage a device for subscription to the Internet. Ensure a physical cable connection and then execute a ping to the broker IP on the command line (e.g., ping 117.xx.xxx.xx).
  2. Install a suitable Python environment depending on the device and the OS. For example, install Pydroid3 on an android device instead of Python3 from the Google Play.
  3. Import both paho.mqtt.client and paho.mqtt.subscribe to connect to and receive data from the broker.
    NOTE: Refer to the following code example:
    import paho.mqtt.client as mqtt
    import paho.mqtt.subscribe as subscribe
    url="117.xx.xxx.xx"; port = 1883; username = "****"; password = "xxxxx"; topic = "Extruder"
    mqttc.username_pw_set(username, password)
    mqttc.connect(host=url, port=port)
    mqttc.subscribe(topic, 0)
    mqttc.loop_start()
    Sub1 = subscribe.simple(topic, hostname=url)
    ExtruderData = Sub1.payload.decode("utf-8")
  4. Build a user interface as required using PyQT5.
    NOTE: This part is very lengthy and focuses on graphical representation of the received data rather than communication. The corresponding code is provided as supplementary data.
  5. Display the incoming data on the GUI by executing the built code.

5. Data logging

NOTE: The processing data can be written in a database while monitoring. In this work, a lab-scale database was chosen. The data are connected onto a Microsoft Access file to easily write and retrieve from a user computer. In addition, a table can be instantly built by a query to analyze data in a spreadsheet such as Microsoft Excel.

  1. Select a subscriber device to record the data.
  2. Import pyodbc by executing "pip install pyodbc" on the command line for the Python code to access the database as shown in Figure 318.
  3. Send a query to the database by the Python code for recording the processing data. Refer to the Python code in Figure 3 for the method.
  4. Send a query to the database for retrieval of the recorded data.
    NOTE: A code example for data retrieval is given below:
    import pyodbc
    x for x in pyodbc.drivers() if x.startswith('Microsoft Access Driver')]
    conn_str = (
    r'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};'
    r'DBQ=C:Usersdata_analysisdb1.accdb;'
    )
    cnxn = pyodbc.connect(conn_str)
    crsr = cnxn.cursor()
    for table_info in crsr.tables(tableType='TABLE'):
    print(table_info.table_name)
    sql = """
    SELECT * FROM Process_Condition
    """
    crsr = cnxn.execute(sql)
    for row in crsr:
    RetrievedData = pd.read_sql(sql, cnxn)
    crsr.close()
    cnxn.close()

6. Deployment

NOTE: If all the devices can be connected to the Internet, the setup is simple. However, to secure the machine side data, the publishers can be in the intranet only. In this case, the broker can be a gateway to the Internet. To be so, the broker should be equipped with two ethernet adaptors, one of which must have a public IP address. After all the items are developed, the codes should be deployed onto each device as shown in Figure 4. The mode of connection, wired or wireless, is not important, but it has to be secured so that each device should be able to access the broker. This means the broker can act as a gateway on the border between the intranet and the Internet for security purposes. Of course, even if all the devices are exposed to the Internet, there is no problem from a communication point of view.

  1. Connect the extrusion controller, the main publisher, and the additional publishers to the Intranet port via ethernet.
  2. Connect one ethernet port of the broker to the intranet and the other to the Internet.
  3. Connect subscribers to the Internet by repeating step 4.1 for all of them.

7. Execution

NOTE: To test the whole system, we started the extrusion line and ran all the Python codes and Mosquitto.

  1. Start the extrusion process. On the HMI of the machine, set the temperatures and turn on the heater by touching the button on the HMI screen. Once the required temperature is reached, start the screw rotation to extrude the polymer melt.
  2. Turn on all the computers, start the broker software on the broker device by the command "net start mosquitto", and then run the Python codes to monitor and record the processing data as needed.
    NOTE: The order of step 7.1 and step 7.2 can be reversed. The Python codes can be executed simply by typing "python3 xxxxx.py" on the command line followed by pressing Enter. Add this command to the start-up programs to avoid typing the command every time the device reboots.

Representative Results

It has been found that the data shown in the HMI and measured by the Raspberry Pis were monitored and recorded in the subscribers as shown in Figure 5. As presented in the video, the processing data are logged into the database.

Figure 1
Figure 1: Outline of the data transmission using the MQTT protocol. The broker relays the message from the publishers to the subscribers. The publishers in this diagram are the main publisher and the additional publisher (Raspberry Pi). The main publisher is directly connected to the extrusion machine to receive the data. The number of subscribers is not limited as long as the network capacity allows. The subscribers can republish the data to other subscribers to record it in a database such as Microsoft Access. Please click here to view a larger version of this figure.

Figure 2
Figure 2: Data flow by publication, brokerage, and subscription in a film extrusion line. The processing data is published by the physical systems represented in the upper left box. For the subscriber, a Python code creating a graphic user interface is written based on PyQt5 to display the received data on the screen. Please click here to view a larger version of this figure.

Figure 3
Figure 3: Recording the subscribed data to an MS Access file via ODBC. To establish a connection to Microsoft Access, the ODBC was employed. The Python code using the pyodbc is written for the connection, which allows logging and analysis by transmitting queries generated by users. Please click here to view a larger version of this figure.

Figure 4
Figure 4: Deployment of the whole system. The broker device in building 2 requires two ethernet ports, one to the intranet and the other to the Internet. For security, the publishers are connected to the intranet, while the subscribers are connected to the Internet. The broker requires a public IP address to be accessed outside the campus. As a result, any devices on the Internet can subscribe to the published data. Please click here to view a larger version of this figure.

Figure 5
Figure 5: Running the data monitoring system while operating the film extrusion line. The processing data can be monitored during the extrusion operation (lower right) once the entire system has been deployed. The data shown in the HMI (upper right) are published outside. After the broker has been started, the codes in the publisher and subscriber devices should be executed. Then, the data flows begin as planned in the system. Using the incoming data, the filmed extrusion line can be monitored and displayed (lower left). Please click here to view a larger version of this figure.

Supplementary Data. Please click here to download this File.

Discussion

By following the protocol presented, the processing data can be monitored and recorded without expensive IT solutions such as the MES. The IoT technologies can make it easier to acquire and deliver data from conventional machines. It has been shown that the message-based protocol, MQTT, successfully serves as a platform for data communication for polymer processing lines. Moreover, additional data can be flexibly measured and transmitted together. The additional publishers employed in this work were the Raspberry Pis. Notably, they can be further protected by housing them in industrial Raspberry Pi enclosures to ensure robust operation under harsh conditions. The subscribers can be any device anywhere with any operating system. The subscriber device can receive only the necessary data by selecting the topic to subscribe. This work has shown that the MQTT together with the IoT devices enables data monitoring for a polymer processing line without great difficulty. Modern industrial communication architectures tend to deviate from pyramid architectures such as the Purdue model, and the proposed method also shows that this trend is justified.

By implementing the software using Python, the code could be reused for various platforms19. Consequently, the devices with different platforms could take part in publishing and subscribing the processing data. Moreover, a lot of coding load could be reduced by importing several prebuilt codes such as PyModbus, pyodbc, paho.mqtt, and PyQT5. Since the development regarding MQTT was simple and straightforward, there was not much difficulty in debugging. However, it took considerable effort to bring the processing data from the legacy controller to the publisher device. If the data format and protocol are not clearly known, the data packet should be analyzed carefully. Also, the cyber security issue should be examined to prevent unwanted data leakage.

A large factory with many machines still might need the conventional MES-based data acquisition, probably using OPCUA communication. In such cases, investment in the IT system can be made without too much risk. However, for small factories with tight budgets, the proposed model is a promising alternative20. Thus, the MES and IoT are expected to coexist and develop for a considerable period of time. In addition to the polymer processes such as injection molding and extrusion, this approach can be applied to any manufacturing processes that require data communication.

Disclosures

The authors have nothing to disclose.

Acknowledgements

This study was supported by the Research Program funded by the SeoulTech (Seoul National University of Science and Technology).

Materials

Edge Device Adavantech UNO 420 Intel Atom E3815 Fanless
Film Extrusion Machine EM Korea Not Available For production of 450 mm film
Pydroid IIEC Not Available Android Devices
Python3 Python Software Foundataion Not Available Windows, Linux
Raspberry Pi 4 CanaKit Not Available Standard Kit

References

  1. Shafiq, S. I., Szczerbicki, E., Sanin, C. Proposition of the methodology for Data Acquisition, Analysis and Visualization in support of Industry 4.0. Procedia Computer Science. 159, 1976-1985 (2019).
  2. Dilda, V., et al. Manufacturing: Analytics unleashes productivity and profitability. McKinsey & Company. , (2017).
  3. Ismail, A., Truong, H. L., Kastner, W. Manufacturing process data analysis pipelines: A requirements analysis and survey. Journal of Big Data. 6, 1 (2019).
  4. Nwanya, S. C., Udofia, J. I., Ajayi, O. O. Optimization of machine downtime in the plastic manufacturing. Cogent Engineering. 4 (1), 1335444 (2017).
  5. Zhou, T., Song, Z., Sundmacher, K. Big data creates new opportunities for materials research: A review on methods and applications of machine learning for materials design. 공학. 5 (6), 1017-1026 (2019).
  6. Rousopoulou, V., Nizamis, A., Thanasis, V., Ioannidis, D., Tzovaras, D. Predictive maintenance for injection molding machines enabled by cognitive analytics for Industry 4.0. Frontiers in Artificial Intelligence. 3, 578152 (2020).
  7. Mamo, F. T., Sikora, A., Rathfelder, C. Legacy to Industry 4.0: A Profibus Sniffer. Journal of Physics: Conference Series. 870, 012002 (2017).
  8. Figueroa-Lorenzo, S., Añorga, J., Arrizabalaga, S. A role-based access control model in Modbus SCADA systems. A centralized model approach. Sensors. 19 (20), 4455 (2019).
  9. Schleipen, M., Gilani, S. -. S., Bischoff, T., Pfrommer, J. OPC UA & Industrie 4.0 – Enabling technology with high diversity and variability. Procedia CIRP. 57, 315-320 (2016).
  10. Nițulescu, I. -. V., Korodi, A. Supervisory control and data Acquisition approach in node-RED: Application and discussions. IoT. 1, 76-91 (2020).
  11. Perez-Lopez, E. SCADA systems in the industrial automation. Tecnología en Marcha. 28 (4), 3-14 (2015).
  12. Andersen, D. L., Ashbrook, C. S. A., Karlborg, N. B. Significance of big data analytics and the internet of things (IoT) aspects in industrial development, governance and sustainability. International Journal of Intelligent Networks. 1, 107-111 (2020).
  13. Kashyap, M., Sharma, V., Gupta, N. Taking MQTT and NodeMcu to IOT: Communication in Internet of Things. Procedia Computer Science. 132, 1611-1618 (2018).
  14. . Mythbusting the MES. Systema Available from: https://www.systema.com/blog/mythbusting-the-mes (2021)
  15. Yeh, C. -. S., Chen, S. -. L., Li, I. -. C. Implementation of MQTT protocol based network architecture for smart factory. Proceedings of the Institution of Mechanical Engineers, Part B: Journal of Engineering Manufacture. 235 (13), 2132-2142 (2021).
  16. Parian, C., Guldimann, T., Bhatia, S. Fooling the master: Exploiting weaknesses in the Modbus protocol. Procedia Computer Science. 171, 2453-2458 (2020).
  17. Mishra, B., Kertesz, A. The use of MQTT in M2M and IoT systems: A survey. IEEE Access. 8, 201071-201086 (2020).
  18. . pyodbc 4.0.34 Available from: https://pypi.org/project/pyodbc/ (2021)
  19. Ayer, V., Miguez, S., Toby, B. Why scientists should learn to program in Python. Powder Diffraction. 29 (2), 48-64 (2014).
  20. Boyes, H., Hallaq, B., Cunningham, J., Watson, T. The industrial internet of things (IIoT): An analysis framework. Computers in Industry. 101, 1-12 (2018).

Play Video

Cite This Article
Kim, J. H., Moon, S. H., Ryu, J. S., Kim, S. K. Data Communication Based on MQTT in a Polymer Extrusion Process. J. Vis. Exp. (185), e63717, doi:10.3791/63717 (2022).

View Video