<img src="https://secure.leadforensics.com/799478.png" style="display:none;">
Skip to content

MQTT for Manufacturing: Material and Order Tracking

<span id="hs_cos_wrapper_name" class="hs_cos_wrapper hs_cos_wrapper_meta_field hs_cos_wrapper_type_text" style="" data-hs-cos-general-type="meta_field" data-hs-cos-type="text" >MQTT for Manufacturing: Material and Order Tracking</span>

I’m excited to dive into a topic that has transformed the way we track and execute orders in manufacturing: MQTT. This technology not only enhances real-time tracking of materials but also allows for seamless communication across production lines. I’ll be drawing from my experience at Lynden Door, where I helped develop an in-house MES (Manufacturing Execution System) solution. Let's dive in!

What is MQTT?

First off, let’s clarify what MQTT is. MQTT stands for MQ Telemetry Transport. It’s a lightweight messaging protocol that allows devices to communicate with each other through a central server known as a broker.

MQTT (1)

 

Quick Facts About MQTT:

  • It has a Lightweight Protocol which makes it ideal for low-bandwidth, high-latency networks.

  • It uses a Publish-Subscribe Model where devices can publish messages to a topic and subscribe to receive messages from that topic.

  • It has a Reliable Transport Protocol via TCP for reliable message delivery and packet error checking. This is mainly with the QoS levels that have to deal with MQTT.
    • The 3 Levels of Quality of Service (QoS) are:

      • QoS 0: Message is sent without client confirmation.

      • QoS 1: Message is sent with the client confirming at least once.

      • QoS 2: Message is sent with client confirmation required.

  • The commonly used Communication Ports are:
    • 1883 (standard unencrypted)
    • 8883 (standard SSL encrypted)

In the real-world example below, we’ll see how MQTT can be utilized for real-time tracking of materials throughout a manufacturing plant, allowing operators to dynamically adjust materials and order information.

 

Door Manufacturing & My Journey into MQTT

Before joining Vertech, I worked at Linden Door, a door manufacturing company, where we built an in-house MES solution. We created two prototype programs:

  1. A Trim Line that processes doors.
  2. A Paint Line that finishes those doors.

Our Goal for MQTT 

Our primary goal in implementing MQTT in our manufacturing plant was to provide real-time material tracking. This allows operators to adjust materials and order data seamlessly, and makes sure that changes propagate throughout the system.

We wanted to realize the following 3 benefits:

  1. Real-Time Tracking: Monitoring materials throughout the manufacturing process.

  2. Dynamic Communication: Enabling production lines to communicate with each other.

  3. Independent Operation: Allowing each production line to function as an edge gateway, even without a central gateway.

Ideally, product information from the trim line would be sent to the paint line via MQTT when a stack of doors was transferred between lines. This information would then be relayed to the MES system for production planning.

Our Toolkit

We decided to design the solution completely in-house with open-source tools and languages like Python and Vanilla JavaScript to make it easy for future programmers to modify and enhance. 

Before I get into the project demo, I'll show you a few key features of MQTT that we used to make this a success.


The Power of MQTT Over WebSockets

 In our application, we utilized MQTT over WebSockets for real-time two-way communication.

What are WebSockets?

WebSockets are a communication protocol that allows for full duplex communication over a TCP connection. It uses HTTP for an initial connection and negotiates for an upgrade to a single, long-term connection. This allows web-based applications to act as MQTT devices, enabling features like in-browser barcode scanning. For instance, an operator can scan a barcode in the browser, and that data is sent to the MES system via MQTT, facilitating real-time data updates without polling a server.

MQTT over WebSockets

MQTT as a Message Bus

MQTT serves as a message bus (or message broker) for Inter-Process Communication (IPC). IPC is crucial for programs to share data and synchronize activities. Common types of IPC used in computer science are semaphores, which are data flags used between programs, shared memory, pipes, and internal message queues. 

IPC (2)

As mentioned earlier, MQTT allows programs to share data using a subscription method. One program can publish data while another subscribes to it, allowing for real-time reactions to changes. This plug-and-play approach enables various applications, from web-based systems to embedded devices, to communicate effectively. So, applications can disconnect and reconnect, and they'll still get the same data if it's retained. (In our application, most of the MQTT topics were set to be retained data.)

MQTT also allows for programs with different infrastructures to communicate. Infrastructures such as web-based applications using MQTT over WebSockets, application-based applications such as MES systems, and line-based supervisory systems, which we'll get to in a bit. Embedded applications, like barcode scanners, scales, and sensors, can then be programmed to connect to that MQTT broker.

Benefits of Using MQTT for IPC:

  • Real-Time Data Sharing: One program can publish data while others react to it in real-time.

  • Plug-and-Play Approach: Different applications can subscribe to the broker server and receive the same data, even if they disconnect and reconnect later.

  • Cross-Infrastructure Communication: MQTT allows programs of different infrastructures—web-based, application-based, and embedded—to communicate seamlessly.

 

MQTT as a Data Cache

In our MES, MQTT also acted as a data cache for each production line. Each line maintained a local database to store its current status, while MQTT provided a temporary cache for real-time updates. This setup allowed different production lines to access information about neighboring lines, enabling them to adjust their operations accordingly.

For instance, if a neighboring line is detected as stalled, upstream lines can halt production to prevent bottlenecks. This real-time visibility is crucial for maintaining efficiency in a manufacturing environment.

mqtt data cache

Displaying Important Information

MQTT can also be used to display critical information to operators. For example, we utilized MQTT to show line status on overhead display screens, which included:

  • Upcoming products for the line

  • Current line status and status of line cells

  • Alerts for any issues on the line

  • Real-time product location
  • Operator instructions
  • Supervisory calculated statistics like line rate, OEE data, downtime and sensor status

This information can be easily displayed on a webpage using MQTT over WebSockets, allowing operators to stay informed without needing to pull data from servers constantly.

 

Using MQTT for Supervisory Control (SCADA)

What is a supervisor?

 
A supervisor is a central controller that provides edge MES functions and “supervises” line operations.
 

Supervisor Key Tasks:

  • Gathers data from gateway MES about products and creates line product states.
  • Sends “triggers” to the line PLCs depending on the product data and PLC states.
  • Allows operators to make data modifications and override machine operations.

In our manufacturing setup, each production line acted as an edge device while still being part of the overall MES system. Each line had a supervisory system that oversaw operations and instructed PLCs (Programmable Logic Controllers) based on sensor triggers and product data.

Example Supervisor Workflow:

  1. Stack Transfer: A stack of doors is offloaded from the trim line to the paint line and stops at a sensor.

  2. Barcode Scanning: An operator scans the barcode, which sends the data to the supervisory system.

  3. Data Query: The supervisory system queries the MES for product information

  4. Operator Confirmation: The operator confirms the information popup, enters any corrections, and saves MES data.

  5. Item Creation: The supervisor creates that item in the system and saves that item to the database. It then publishes that information out to MQTT, saying this item was just added to the infeed. This allows neighboring lines and the MES to see the updated information.

  6. Item Triggers Sensor: As the item moves through the line, it triggers a cell sensor which causes the PLC to stop and ask the supervisor what it should do next. 
  7. PLC Receives Instructions such as painting the stack a certain color, squeezing the stack (lining them up), or diverting to another cell if there are defects.

supervisor workflow


So, using this supervisory system example, we can see that there are many different layers that contribute to a single paint line. Each line has a supervisory engine, which contains the state engine that listens for PLC triggers and activates associated functions, as well as doing barcode scanning, getting product information from the MES and publishing the current line seed to the MQTT.

paintline supervisory control logic map

So it is basically just a big giant loop that's listening for events from the PLC, from barcode scanning, or any MQTT messages. And then, when it receives those commands, it sends that into a callback into a separate thread. This workflow ensures that all lines are aware of each other’s statuses, allowing for adjustments in throughput and preventing bottlenecks.

Independence and Resilience in MQTT Line Connections

One of the standout features of this MQTT-driven system is its independence. Since each line has its own independent MQTT broker and supervisory system, each production line can operate without connecting to the central gateway, allowing for continued operations even during network outages.

This independence allows the lines to adapt to changes in neighboring lines. Lines can subscribe to neighboring line states and relay that information to the operators. The central MES gateway can also subscribe to each line and store the line states in a central database for use in OEE and MES calculations (see image below).

For example, let's say there's a line that's down. The upstream line can stop the conveyor because it can see via MQTT that the next line is down and unable to receive any instructions. So it stops production at this conveyor line, creates an alert or diverts product to another line. 

(Note: This is similar to Ignition Edge Gateway and provides a non-Ignition approach if needed.)

 MQTT line connections

Fallback Options:

In case of a loss of network connectivity, there are fallback options available.

  • Manual Control - Operators can manually control the line via supervisory control and input MES data into the line. 

  • Store and Forward - Data is cached locally at the MQTT broker and forwarded to the central gateway once the connection is restored.

Ultimately, line independence leads to better operational stability and smoother operations.

MQTT Demo

Alright let's get into a demo of the actual system we developed. Check out my video below:

 

 

MQTT and The Future of Manufacturing

MQTT-driven order tracking and execution continues to transform the manufacturing landscape. By enabling real-time communication, dynamic adjustments, and independent operations, this technology is paving the way for more efficient and responsive manufacturing processes.

If you’re interested in implementing a similar system in your manufacturing plant, consider exploring MQTT and WebSockets as viable solutions. The benefits of real-time tracking and execution are immense, and the potential for increased efficiency is undeniable.

And if you're interested in learning more about Vertech's bulletproof MES and SCADA solutions for manufacturing, you can read more here:

Read More About Manufacturing