Share this

Application of Raspberry Pi in the Electrical Control System of Horizontal Centrifuge Wastewater Treatment Unit

2026-04-06 05:32:18 · · #1

The Raspberry Pi GPIO extension RS485/GPIO module enables bidirectional communication with the frequency converter via the Modbus protocol to control a wastewater treatment device. It not only implements all the functions of a traditional PLC control system but also enables Internet of Things (IoT) functionality, while significantly reducing overall costs.

Keywords: Raspberry Pi; PLC; Centrifuge

1. Introduction

Figure 1. Raspberry Pi with expansion module and fan.

The Raspberry Pi 3B features a 1.2GHz 64-bit quad-core ARM Cortex-A53 CPU, a processor rarely found in other IoT devices. This powerful processor gives the Raspberry Pi strong data processing capabilities, enabling smooth execution of multi-threaded tasks. It integrates Wi-Fi and Bluetooth chips, facilitating wireless network connectivity and IoT deployment. Furthermore, it provides 40-pin GPIO, four USB 2.0 ports, and other interfaces, allowing for easy feature expansion. The Raspberry Pi's official default operating system is Linux, and its software repository contains over 350,000 packages. Currently, approximately 6 million Raspberry Pis are running worldwide. These hardware and software advantages provide strong support for the new products described below.

Currently, most centrifuges produced in China use PLCs as the core control element of the electrical control system. If the operating data needs to be transmitted remotely, it must be connected to the external network with the help of various gateway products (such as Delta's DX2100, Xikenmai's 1149, and Huachen Zhitong's M111N). This is a typical three-layer Internet of Things architecture.

The Raspberry Pi-based electrical control system introduced in this article abandons the traditional PLC and connects the data directly to the external network. The Raspberry Pi essentially plays the dual role of controller and gateway.

2 System Architecture

Figure 2 System Block Diagram

Hardware configuration: Raspberry Pi 3B + RS485/GPIO; Inverter : Huichuan MD380 + MD38IO1; Control signals, operating status feedback signals of 10 peripheral devices and 13 sensor signals of the sewage treatment device are all connected to the I/O port of the inverter. Figure 1 is a photo of the Raspberry Pi and Figure 2 is a system diagram.

Software configuration: Linux operating system; Python 3.5 programming software; PyQt5 GUI design software; Modbus_tk communication software.

3. Research and Development Process

3.1 Overview of Code Development

The Raspberry Pi's UART serial port has three functions: ① Bluetooth communication (default) ② Control terminal debug port ③ Serial communication with other devices. However, only one function can be used at a time. In this example, the Bluetooth communication function and the control terminal function need to be turned off.

① Configure Modbus_tk communication protocol: modbus_rtu, 9600, 8N1;

②Use the command logger.info(master.execute(1, cst.READ_HOLDING_REGISTERS, 28672, 12))

Read 12 data points from the inverter starting address 7000H (here, reading from inverter #1) and store them in the log file;

③ Split the log file. Splitting means keeping some records and discarding the rest. In this example, it is saved every 2 seconds and the file name is "pzw".

④ Parsing the log file: Below is a portion of the log content from inverter #1 in the file "pzw" (inverters #2 through #5 have the same format):

2018-05-25 19:42:11, 200-->1-3-112-0-0-12-95-15

2018-05-25 19:42:11, 306-<-1-3-24-0-0-14-16-16-232-0-0-0-0-0-0-0-0-0-0-0-1-252-1-240-0-134-87-101

2018-05-25 19:42:11, 395-(0, 3600, 4328, 0, 0, 0, 0, 0, 508, 496, 134)

The first line is the read data command (read data frame) sent by the Raspberry Pi to the inverter, the second line is the data sent by the inverter to the Raspberry Pi (read response frame), and the third line is the data (this line does not contain station number information).

Analysis of the first two lines reveals: ① After removing the date and time header from each record, the first character is the inverter's station number. ② The number of characters in records containing inverter parameter values ​​is much greater than in other records. Based on these two characteristics, the following code is developed to parse the log file and ultimately obtain five strings representing the 12 inverter parameter values: b1~b5. Further processing of these strings will yield the specific data values.

withopen('pzw')asfile_object:

lines = file_object.readlines() # Read the file line by line and store the results in the table lines.

n = len(lines) # Get the length of the table

for i in range(n):

lines[i]=(lines[i])[27:]# Extract the 27th item to the end of the table and save it to the table.

iflen(lines[i])>63and(lines[i])[0]=='1': # Check the station number to determine if it is data

abc1=lines[i] # Store in table abc1

a1=abc1[7:]# Extracts the 7th item to the end of table abc1 and saves it to table a1.

b1 = a1.split('-') # Splits the string into new tables using '-' as the delimiter.

u0_00_1=str(float(int(b1[0])*256+int(b1[1]))/100)#Inverter output frequency

self.l1_1.setText(u0_00_1+'Hz') # Label display

...

u0_11_1=str((int(b1[22])*256+int(b1[23]))/4)#pt100 Left bearing temperature

self.l7_1.setText(u0_11_1+'℃')

iflen(lines[i])>63and(lines[i])[0]=='2':

.................

⑤ Main program structure

Control signals such as "start" and "stop" are non-periodic commands, while reading and processing inverter parameters are periodic commands. Therefore, the main program adopts a main thread-sub-thread structure. The process is shown in Figure 3. Two timer modules, QTimer, time each session for 0.5 seconds, thus forming a program execution process with a loop of approximately 2 seconds.

Figure 3 Main Flowchart

3.2 User Interface Design

Figure 4. Raspberry Pi user interface

The wastewater treatment device can be controlled locally or remotely via desktop: the local operation interface is shown in Figure 4; the remote operation interface is shown in Figure 5. To remotely access a Raspberry Pi running Linux from a Windows 7 system, you need to install xrdp and vncserver, set a static IP address, and then connect via remote desktop. The username is "pi" and the password is "raspberry".

Figure 5 Remote computer operation interface

3.3 IoT Application Development

The overall design concept is as follows: First, upload the data to Alibaba Cloud server (ECS service), then use PHP programming language and MySQL database to store the data on the cloud server, and finally establish an IoT data aggregation center in Ningbo as a client.

To upload data to Alibaba Cloud, the Raspberry Pi side needs to do the following: (1) Set a static IP address; (2) Build a PHP website server; (3) Compile a program (run in the background with multiple threads).

Renting cloud servers for remote data transfer is beneficial to both users and manufacturers:

① Manufacturers can monitor the actual operation of centrifuges remotely anytime and anywhere, make timely predictions of potential faults, and provide helpful suggestions to users; ② The historical data viewing and historical fault viewing functions are very useful for fault location and cause determination, which can reduce user downtime and losses caused by downtime, and effectively avoid unnecessary disputes caused by disagreements between the two parties regarding the determination of the fault cause; ③ Through the accumulation and analysis of a large amount of data, design and manufacturing defects can be discovered in a timely manner, which is conducive to manufacturers further improving product quality.

The above solution is currently in the trial stage, and there are two issues that need to be properly addressed: ① Some users are worried about the leakage of important process parameters, feeling like they are being "spyed on," and are not welcoming of it. ② The data tables displayed on the web service page provided by Alibaba Cloud cannot intuitively reflect the overall system operation status, and engineers hope to provide an interface similar to a monitoring screen.

4. Conclusions and Outlook

Reading data from one inverter takes 200ms, and from five inverters it takes 1 second. Therefore, the minimum data update rate is 1.5 seconds. To control more inverters, the data update rate will inevitably decrease, making the operation sluggish and reducing its practical value. Therefore, it is advisable to consider having two or more Raspberry Pis work together to form a Raspberry Pi cluster, thus solving the control scale problem.

The Raspberry Pi uses Modbus to communicate and control the inverter and peripheral devices connected to its I/O ports. If the project doesn't include an inverter, the Raspberry Pi wouldn't be able to function so effectively. This further demonstrates that using the Raspberry Pi in centrifuge control systems is highly economical and reasonable, solving the data connection problem while significantly reducing product costs. It should be noted that this control scheme is not only suitable for centrifuge control but is worth considering for any project involving an inverter.

The application prospects of Raspberry Pi in the centrifuge industry can be described by Figure 6. Centrifuge operation data from all over the country and even the world are gathered in the Ningbo data center through cloud servers. Engineers can monitor the equipment anytime and anywhere, and then strategic planning and decisive victory will become a reality.

Figure 6 Centrifuge Monitoring Center

References

[1] Zhang Shuangchi: A Method and Application Example of Controlling Multiple Frequency Converters Based on Modbus and Raspberry Pi, Control and Drive, 2018.4

[2] Ke Bowen: Raspberry Pi in Action, Tsinghua University Press, June 2015.

Statement: This article is copyrighted by China Transmission Network. You are welcome to reprint it, but please be sure to indicate the source and author.

Read next

CATDOLL 115CM Cici TPE (Asian Tone)

Height: 115cm Weight: 19.5kg Shoulder Width: 29cm Bust/Waist/Hip: 57/53/64cm Oral Depth: 3-5cm Vaginal Depth: 3-15cm An...

Articles 2026-02-22