How to Implement Predictive Maintenance Faster in Industry 4.0

Implementing Predictive Maintenance with Raspberry Pi

Industry 4.0 is making its way into the world of mechanical engineering. The growing interconnectivity of machines allows, with the help of sensors, to record an equipment’s status in real-time. The resulting data sets enable companies to proactively plan the maintenance of their machinery and equipment. For this, they include, for example, changes in noise, speeds, temperatures, currents and voltages, or vibrations in their analysis. This so-called ‘predictive maintenance’ replaces the usual reactive and preventive approaches and offers many advantages.

Figure 1 – MCC 152 DAQ HAT

Predictive maintenance makes it possible to determine the best time for performing the work, and it reduces downtime and lowers the toll associated with unplanned outages, thereby improving profitability. It also makes it practicable to schedule work on a machine at a time when its unavailability will cause the least disruption. Hidden defects in products can be identified early on, too. Overall, predictive maintenance can help to optimize equipment operation, to increase reliability, and to reduce energy consumption and thus cost. These benefits apply not only to the manufacturing industry, but to a variety of areas, such as aviation or rail transport, or in the drive trains of wind or steam turbines.

However, a predictive maintenance system has high hardware requirements: The sensors need special converter inputs, and there must be sufficient memory and computing power available. To get reliable condition information, a huge amount of different data must first be collected, digitized, and transmitted. Then, these data sets have to be stored and analyzed. In the end, the probabilities of the occurrence of certain events need to be determined. This includes the extraction of condition indicators, the characteristics whose change in behavior safely predicts an imminent malfunction.

Environmental parameters like humidity and temperature need to be monitored in addition to the condition of the machinery. “Big Data” techniques such as edge computing are a good solution for this. Additionally, it requires state-of-the-art sensor technology for data acquisition and a modern IT infrastructure for storing, distributing, and analyzing the collected information.

The sensors used should be customized to the various process parameters to be observed; sometimes simple voltage and current sensors are the right choice while others require temperature, airflow, or viscosity measurements, and so on. The processing power must also match the amount of data to be evaluated, as does the storage (memory) capacity and the connectivity to further systems.

Why Raspberry Pi?

Several predictive maintenance equipment manufacturers rely on a Raspberry Pi when it comes to computing at the edge. This small single-board computer (SBC), developed and supported by the Raspberry Pi Foundation, was originally created to enable people to pick up computing and digital making skills. but it soon found its way into industrial applications as well. It has a wealth of communication interfaces like WLAN, Bluetooth, USB, or LAN, and also supports microSD Flash cards, offering good storage possibilities. Its CPU is based on different Arm cores, with the Raspberry Pi 3 using an Arm Cortex-A53 and the Raspberry Pi 4 using an Arm Cortex-A72 core. With its 40-pin general purpose input-output (GPIO) expansion connector, developers can add extra functionalities through boards plugged on top of the Raspberry Pi.

How Do HATs Work?

The Raspberry Pi Foundation provides a specification of what they call “HAT”, Hardware Attached on Top. Besides specifying the mechanical dimension, the details given there enable the main board’s bootloader to automatically detect and identify an attached HAT-compatible board at startup, and then to autoconfigure the GPIOs and the board’s drivers.This auto-identification is achieved by reserving two pins on the 40-pin header (ID_SD and ID_SC), which connect to a mandatory I2C EEPROM on the module.

This EEPROM holds the manufacturing information, as well as the GPIO setup and a stripped-down Device Tree, allowing the Linux-based operating system to load the drivers required. The EEPROM structure starts with a HEADER, containing 4 bytes of signature (“R-Pi”), the data format version, the total number of ATOMs in the memory and the total length of the EEPROM data in bytes.

Three ATOMs are required: ATOM1 with the vendor information, ATOM2 holding the GPIO map, and ATOM3 with the Device Tree information. The bootloader reads all these details and makes them available to user programs through the “/hat” node of the Device Tree. This way, applications do not have to access the EEPROM directly. A HAT can only be called “HAT compatible” if the module follows these rules. Doing so is not obligatory, but boards not following it cannot be named HATs. While the original specification does not imply that HATs can be stacked, this is possible if they are designed carefully, e.g., if their GPIOs do not conflict.


Examples of stackable HATs are the data acquisition (DAQ) modules from Measurement Computing Corporation (MCC, available on Digilent’s site), which are used in many industries and applications. Their uses range from laboratory setups, such as a neuromuscular biomechanics test system, over remote installations in the wind energy sector, to IoT and OEM solutions for energy and machine condition monitoring and predictive maintenance.

Five different HATs are available, designed especially for test and measurement applications. The MCC 118 and MCC 128 are voltage measurement HATS with eight channels for single point or waveform measurements. While the MCC 118 features eight single-ended inputs with a resolution of 12 bits, the MCC 128 provides either eight single-ended or four differential inputs with a resolution of 16 bits. The MCC 152 has two 12-bit analog voltage outputs and eight 5 V or 3.3 V digital I/O-channels with a CMOS input threshold.

Figure 2 – MCC 172 Block Diagram

The other two HATs offer special interfaces: The MCC 134 thermocouple measurement HAT has four isolated inputs for temperature sensors and is equipped with a 24-bit analog-to-digital converter (ADC) and a cold-junction compensation to detect broken or disconnected thermocouples. The MCC 172 IEPE (Integrated Electronics Piezoelectric) measurement HAT, on the other hand, is designed for IEPE sensors such as force or pressure sensors, accelerometers, and microphones. It has two channels, each one having a 24-bit analog-to-digital converter with a maximum sampling rate of 51.2 kSamples/s. It supports synchronous ADC conversions across multiple modules.

All MCC HATs are designed so that up to eight boards of the same or different types can be stacked onto a single Raspberry Pi, providing developers with a high flexibility to create multi-function, Raspberry-Pi-based measurement and data logger solutions.

Figure 3 – MCC’s Portfolio of Different HATs

Library Support

MCC has tested its DAQ HATs with all Raspberry Pi models having a 40-pin GPIO header and running Raspberry Pi OS. They are incompatible with the original Raspberry Pi 1 A or B, as these come with a 26-pin header. They also shouldn’t be operated together with any other HATs, or devices which use the SPI interface of the Raspberry Pi, like serial LCDs, as the MCC DAQ HATs use the SPI port themselves for communication. The data sheets of the HATs contain more information about the pins used on the 40-pin GPIO connector, as they vary between the different HATs.

MCC provides comprehensive open-source software libraries for its HATs. These libraries support C and C++, as well as Python 2.7 and Python 3.7 as programming languages and include in-depth API (Application Programming Interface) and hardware documentation. Users can download the libraries from GitHub for free and install them easily on the Raspberry Pi with the shell script supplied.

Both libraries are organized in a way that they provide global functions/methods for the DAQ HAT boards attached to the system and board-specific functions/classes, allowing the software developer to access the full functionality of each board type.

Global functions allow the listing of attached HATs and providing information about them, as well as some interrupt functions. Board specific functions comprise open and close functions (e.g., mcc172_open()), read and write functions, functions for calibration and configuration, as well as other functions for information and application-specific tasks. An example of the latter is the function mcc172_a_in_scan_start(), which starts a hardware-paced analog input data capture. The C/C++ functions and the Python classes share the same names, which simplifies switching between the two programming languages. Both libraries support the concurrent operation of multiple MCC DAQ HATs.

Example Project Using the DAQ HAT Library

To create a C/C++ program, users need to include the header files in their source code and point the compiler and the linker to the respective installation paths of the header files and the library. For a Python program, it suffices to import the Python package “daqhats”.

The MCC DAQ HAT library also comes with several example programs in C/C++ and Python that developers can peruse to learn more about the library and the boards. One of them is a console-based example that reads and displays values from the modules. Other examples offer a user interface, like a data logger written in C/C++, or a Web server written in Python. Some boards also come with an IFTTT (If This Than That) web-based service that interacts with apps and hardware to automate various functions. This example reads some analog values from the modules and writes the data to a Google Sheets spreadsheet. The user can then remotely monitor this spreadsheet from his Google Drive.

Figure 4 – Webserver example for the MCC 172 DAQ HAT

How You Can Benefit From DAQ HATs

With this ready-made soft- and hardware, customers can focus on the processing and analysis of their data instead of the data acquisition. This way, systems can be created and deployed faster and at a lower cost.

The Texas-based IoT-company Thinaer, for example, used the MCC 172 IEPE HAT and the MCC 134 thermocouple HAT stacked on top of a Raspberry Pi to collect and analyze vibration and temperature data of their customer’s various machinery. Employing the MCC libraries for the data acquisition together with the off-the-shelf boards allowed Thinaer to concentrate on the analytics and anomaly detection for the predictive maintenance. Furthermore, the MCC DAQ HATs fitted easily into their existing system enclosure, removing the need for its redesign, saving time and money.

Figure 5 – Using the Raspberry Pi + MCC DAQ HAT


One Comment on “How to Implement Predictive Maintenance Faster in Industry 4.0”

  1. I’ve reviewed the MCC 172 HAT last month for an element14 road test. Also to review predictive maintenance capabilities, in combination with LabVIEW.

Leave a Reply

Your email address will not be published.