MQTT protocol overview

MQTT is a standard messaging protocol for the Internet of Things. It is designed as a very lightweight publish/subscribe messaging, which is very suitable for connecting remote devices with a small code footprint and network bandwidth. The MQTT protocol has the following characteristics:

  • lightweight and efficient. : MQTT client is very small and requires less equipment resources. The MQTT message header is very small, which can optimize the network bandwidth.
  • Two-way communication : MQTT allows message transfer from device to cloud and cloud to device.
  • Reliable message delivery : MQTT has 3 defined service quality levels: 0-at most once, 1-at least once, 2-exactly once. The reliability of message delivery can be guaranteed according to business scenarios.
  • supports unreliable networks : Many IoT devices are connected via unreliable cellular networks. MQTT's support for persistent sessions reduces the time it takes to reconnect the client and the broker.
  • Security : MQTT allows you to easily encrypt messages with TLS and authenticate clients using modern authentication protocols such as OAuth.

Today, MQTT is widely used in industries such as automobiles, manufacturing, telecommunications, oil and gas.

This series of articles will explain in detail how the MQTT protocol plays a role in the actual application scenarios of various industries.

Current industrial PLC data acquisition

PLC, the programmable logic controller, is the core equipment in the field of industrial automation and is widely used in various industrial fields. Since the advent of PLC, it has been showing strong vitality and rapid growth. In 2020, the sales volume of the global PLC market has reached the level of tens of billions of RMB.

The German industry defines the widespread application of PLC in the production process automation process as "Industry 3.0", which represents the promotion and application of various types of CNC machine tools, industrial robots and other stand-alone automation equipment in the production process. The ubiquitous sensors, PLCs, intelligent control systems, and communication facilities form an intelligent network through ICT technology to enable interconnection between people, people and machines, machines and machines, and services and services. This is "Industry 4.0 The core meaning of "". People, things, and data are reengineered through the Internet of Things technology, from a stand-alone intelligence upgrade to the intelligence of the interconnection of all things.

The realization of the Internet of Everything in the industrial scene cannot be separated from the data collection of industrial automation equipment. Among them, there are as many as dozens of industrial field bus protocols commonly used by PLCs. In addition, each major PLC manufacturer basically has its own private bus protocol. Due to the wide variety of fieldbuses, traditional industrial PLC data collection is generally carried out by deploying an edge gateway on the device side: the edge gateway is used to unify various protocols, and then the PLC data collection and aggregation are forwarded to the IoT platform , In this way, data interconnection between devices is realized.

当前的工业 PLC 数据采集.png

However, the data collection method based on the edge gateway has the following shortcomings:

  • Need to deploy edge gateway hardware and perform software configuration, which requires additional costs.
  • The data collection frequency of edge gateways can only reach the second level, and most of the data formats reported by edge gateways to the IoT platform cannot be modified.
  • Communication problems between the PLC and the edge gateway will result in missing data collection and will not be able to provide effective data support for advanced applications.

New trend: PLC integration with MQTT protocol

With the rapid development of the Internet of Things, big data, and artificial intelligence, automation manufacturers are also accelerating their IoT strategies and launching their own IoT and digital solutions. As the mainstream Internet of Things protocol, the MQTT protocol has become the focus of attention of various automation equipment manufacturers. In order to accelerate the realization of the interconnected industrial Internet of Things, major manufacturers have begun to integrate the MQTT protocol in the PLC to facilitate the collection of PLC data.

Take several mainstream manufacturers as examples:

  • Siemens has encapsulated the MQTT client function into a PLC library file. Through Siemens S7-1200 and S7-1500, data reporting based on the MQTT 3.1.1 protocol can be realized, and the PLC and MQTT message server can be easily connected.
  • Beckhoff Germany launched the TF6701 IOT communication library, through the MQTT protocol, PLC data can be directly sent to the public cloud IoT platform and MQTT message server ; TF6701 also supports the encapsulation of PLC data into json format to complete data reporting , To realize the unification of the data format in the OT and IT fields.

PLC 集成 MQTT 协议.png

Image source: https://infosys.beckhoff.com

  • The PLCnext open control platform launched by Phoenix. The operating system adopts the RT-Linux system. In addition to the traditional PLC programming functions, it also supports C, Java, Python, JS and other high-level language programming, so that the PLC can flexibly connect to the Internet of Things through the MQTT SDK platform.

One net to the end: MQTT empowers industrial data application scenarios

So in actual industrial scenarios, what are the advantages of the combination of MQTT protocol and PLC in data acquisition?

Streamline resource allocation and make collection more convenient

After integrating the MQTT client into the PLC system, traditional automation engineers can realize the data collection and reporting of the equipment through the ladder diagram and function block diagram programming that they are good at. There is no need to purchase edge gateways, and they do not need to care about the wiring and software of the edge gateways. Configuration work.

Millisecond time stamp, more accurate data point information

In the traditional edge gateway data collection method, most gateway devices obtain PLC data through polling, and the collection accuracy can reach the second level. Based on the integration of MQTT and PLC, data points can be combined with time stamps accurate to 1 millisecond, and real-time reporting of industrial data can be achieved through the MQTT protocol. In addition, through NTP or IEEE 1588 server, all PLC devices can be synchronized to ensure that PLC devices in various production links such as smart factories and production lines have the same time reference. All types of smart devices have clock synchronization, which is a great success in the future. Data analysis and mining provide efficient data support.

Flexible configuration of data points, more uniform reporting format

In the traditional edge gateway data collection method, the gateway device reads the PLC register data through the fieldbus driver. The data point parameters need to be configured according to the PLC point data type, and then the data is reported to the MQTT server in a fixed json format. The integration of MQTT and PLC can support flexible configuration of data points in PLC, and report data in json format to realize the unification of data formats in the OT and IT fields.

Based on the above advantages, PLCs that use MQTT for data collection and data upload to the cloud have gradually been widely used in various industrial scenarios.

Comprehensive perception of massive data: predictive maintenance of transmission chain components

At present, a new round of scientific and technological revolution and industrial transformation are booming. Industrial production has gradually become the key exploration direction of artificial intelligence. The prerequisite for the development of industrial intelligence is the comprehensive real-time perception of massive data. The integration of MQTT and PLC in the industrial field completes the real-time collection of high-precision data. The combination of high-throughput and low-latency IoT messaging middleware such as EMQ X in the cloud can further realize the real-time real-time of massive industrial data. Movement, processing, analysis and storage have consolidated the underlying foundation for the application of industrial intelligence. In the wind power industry, through real-time collection of vibration data from the wind turbine drive chain status monitoring system (CMS) and wind turbine SCADA system operating data, the two are fused and analyzed to establish an early failure warning model for wind turbine drive chain components, which can provide timely warning to the core Early component failures and active preventive measures should be taken to reduce the probability of major failures of the core components of the wind turbine and avoid maintenance costs of large components and other losses.

传动链部件预测性维护.png

Improve equipment utilization: remote equipment diagnosis

Since PLC integrates MQTT, the data points of each PLC scan cycle can be packaged and sent to the MQTT message middleware EMQ X with timestamp, and the data is stored in the time series database through the built-in rule engine of EMQ X. Combined with a wealth of visualization tools, the cloud software oscilloscope function can be implemented to help engineers quickly locate field equipment faults remotely, reduce equipment downtime, and improve equipment utilization.

Decision optimization: smart dispatch of power grid

Based on the comprehensive perception of the Internet of Things, combined with data analysis and modeling in the cloud, a closed-loop decision-making optimization application will eventually be formed. The bottom-up information flow and the top-down decision flow will jointly form the core link of industrial intelligence applications. . The integration of MQTT and PLC in the industrial field does not require edge gateways and protocol conversions, realizing a true one-to-one network, and building a safe, stable, and low-latency communication link between the data center and the industrial field. In the field of new energy power generation, the low-latency communication link of MQTT directly connects to the PLC, which can quickly respond to the power grid frequency modulation and reactive power compensation commands at the dispatching layer on the power generation side, and promote the intelligent development of the power grid.

电网智能调度.png

Image source: "Industrial Internet System Architecture 2.0 Report"

It can be seen that the PLC integrated with the MQTT protocol will make the industrial data collection scene simpler and more efficient. Combined with the high-performance MQTT message middleware on the server side or in the cloud, industrial production data can be easily uploaded to the cloud and its value can be fully realized.

Copyright statement: This article is EMQ original, please indicate the source for reprinting.

Original link: https://www.emqx.com/zh/blog/mqtt-and-plc

Technical support: If you have any questions about this article or EMQ related products, you can visit the EMQ Q&A community https://askemq.com ask questions, and we will reply to support in time.

For more technical dry goods, please pay attention to our public account [EMQ Chinese Community].


EMQX
336 声望436 粉丝

EMQ(杭州映云科技有限公司)是一家开源物联网数据基础设施软件供应商,交付全球领先的开源 MQTT 消息服务器和流处理数据库,提供基于云原生+边缘计算技术的一站式解决方案,实现企业云边端实时数据连接、移动、...