Hardware | SDU-CHINA - iGEM 2023

Hardware

2023 SDU-CHINA


  • Introduction

About a glucose automatic monitoring and supplementation system based on human-computer interaction!

We designed an automatic glucose monitoring and replenishment system based on STM32, which can accurately and promptly replenish glucose. This feeding system can anticipate changes in glucose concentration through modeling, preventing the glucose level from dropping too low! The system also offers a visual display of the glucose signals, providing an intuitive understanding of the concentration levels! Moreover, the feeding system can connect to our custom-designed software via a WIFI module, enabling cloud-based control!

Fig.1

  • 01 Design Background

Currently, there is a problem of excessive labor costsin the production process of biodegradable plastics. The manufacturing process of biodegradable plastics requires the use of specific microorganisms to degrade the plastic materials. These microorganisms need to be cultivated and maintained under specific environmental conditions, including regular supplementation of glucose and other nutrients to maintain their optimal growth state, which requires specialized personnelfor monitoring and operation. Microorganisms require energy during the process of degrading plastics, and glucose is a commonly used energy supplement. Regular supplementation of glucose is necessary to maintain the microorganisms' good growth. In addition to the above reasons, there may be other factors contributing to the excessive labor costs, such as equipment maintenance and cleaning, quality control, and other related tasks. All these factors require human involvement, thereby increasing the labor costsin the production process.

In this control system,precise control of the glucose supplementation is achieved through microcontroller hardware control, based on the requirements of the microorganisms. This avoids situations of excessive or insufficient glucose supply, optimizing resource utilization, reducing waste, and improving production efficiency and economic benefits.Additionally, monitoring through an app software reduces the need for manual intervention and monitoring,thereby reducing labor costs and workload, and improving work efficiency.

Fig.2 Fig.2

  • 02 Project Design

  • A. General Design

The core of this system is the STM32F103RCT6 microcontroller, which consists of a power module, motor driver module, OLED display module, WIFI module, and glucose detection module. The power module includes a 12V battery and a voltage regulator module, which provides power to the motor driver module and the microcontroller. The motor driver module uses the BTN7971 high-power driver chip to form an H-bridge driver module, which works in conjunction with the STM32 core board to control the operation of the DC motor and achieve PWM software speed control. The motor speed is controlled by changing the duty cycle, and the glucose supplementation rate is controlled through PID control algorithm, achieving closed-loop control of the motor. The WIFI module uses ESP8266, which communicates with the main controller via serial communication to provide feedback information and enable precise control of glucose supplementation based on the requirements of the microorganisms.

In this control system, the battery voltage is continuously monitored in real-time using a voltage meter controlled by a microcontroller. The amount of glucose supplementation is precisely controlled based on the needs of microorganisms, avoiding situations of excessive or insufficient supply. The sensor current is amplified through an amplification circuit and then input into the microcontroller via an A/D conversion module. After data processing by the microcontroller, the glucose content in the fermentation tank is displayed on an OLED screen, and the motor driving the glucose supplementation is controlled based on the glucose content to ensure timely supplementation. Additionally, the data is uploaded to an IoT platform through an ESP8266 WIFI module, allowing real-time monitoring of the glucose content in the fermentation tank through a mobile app. This system reduces the need for manual intervention and monitoring, thereby lowering labor costs and reducing labor intensity, while improving work efficiency.

Fig.2

  • B. The Hardware Circuit Design

The hardware circuit of this design adopts a modular design approach, with the STM32F103RCT6 microcontroller as the main control chip. It consists of a power module, motor driver module, OLED display module, WIFI module, and glucose detection module.


  • (1) Main Control Board

The main control boardintegrates the minimum system of the microcontroller. The main control board is connected to the peripheral modules using ribbon cables and power lines, ensuring a stable connection. The main control board is equipped with user buttons, LEDs, OLED displays, and other components for monitoringthe system's operating status. The main board also has a wireless serial port interface, allowing easy connection to a computer for remote viewing of system status information and online debugging.

schematic-of-mainboard-circuit
Fig.1 |schematic-of-mainboard-circuit
schematic-of-mainboard-circuit

  • (2) Power Module

The power supply section mainly consists of an 8V to 5V DC-DC buck module, a 3.3V voltage regulator module, and an independent servo adjustable power circuit. The main control board includes an STM32 as the core controller, an LM2596, and an Ams1117-3.3 to provide stable 5V and 3.3V powerto the microcontroller, sensors, and other peripheral modules. The peripherals and microcontroller can be powered by either a 5V or 3.3V linear power supply. The 5V power supply not only powers the microcontroller but also supplies power to an Ams1117-3.3. The LM2596S is chosen as the 5V power supply chip, and its performance is fully capable of meeting the power requirements of all components. The schematic diagram of the power module is shown below.

voltage-regulator-module
Fig.2 | Voltage Regulator Module

  • (3) Motor Driver Module

The motor driver board utilizes two BTN7971 half-bridge driver chips to form an H-bridge circuit, offering the advantages of simplicity and high integration , making it reliable and convenient. The driver chips are isolated from the main controller using a 74HC244, which improves the load capacity of the main controller's IO and prevents unstable voltages caused by motor operation from adversely affecting the main controller's performance.

Since the motor in this design is relatively lightweight and does not have strict requirements for the output current of the motor driver, the driver circuit is composed of two BTN7971 chips to form an H-bridge circuit. By controlling the direction of current flow, the motor can be driven in both forward and reverse directions. The average output power of the motor can be adjusted by controlling the duty cycle of the input PWM signal, thereby achieving control over the motor's speed.


  • (4) WIFI Module

The Bluetooth app communicates with the microcontroller remotely through a WiFi module. The microcontroller and the WiFi module communicate via serial communication. In the circuit connection, the TX and RX pins of the ESP8266 module are connected to the STM32 microcontroller. AT commands are used to check if the ESP8266 module is functioning properly. The working mode of the ESP8266 module is configured, and the STA (Station) mode is selected. The serial communication functionality of the STM32 microcontroller is configured to enable data exchange with the ESP8266 module, allowing for sending and receiving data based on the requirements.

wifi-module wifi-module
Fig.3 | WIFI Module

  • (5) Glucose Sensor Module

First, the analog input is a current input, which is converted to a voltage input through a small resistor. Then, it is amplified and converted into a voltage signal suitable for the microcontroller to receive. Based on the digital value changes of the voltage signal, the PID algorithm is applied to achieve precise glucose content compensation.

amplifier-circuit-diagram
amplifier-circuit-diagram
Fig.4 | Amplifier Circuit Diagram

glucose-sensor-module
Fig.5 | Glucose Sensor Module

  • C. Software Design

  • (1) PID Control Algorithm
pid-control-algorithm
Fig.6 | PID Control Algorithm

The PID control algorithmis a widely used control method in the field of automatic control. It is based on proportional, integral, and derivative actions. It generates control actions based on the deviation between the setpoint and the feedback value to reduce the deviation and improve system performance. The PID algorithm is known for its simplicity, stability, and ease of tuning, making it suitable for situations where the target system and control object model are not well understood or where parameters cannot be obtained.

The PID control algorithm consists of three components: proportional control,integral control, and derivative control. Proportional control immediately generates control action based on the deviation signal of the control system to reduce the deviation. Integral control is mainly used to eliminate steady-state error and improve the system's steady-state accuracy. Derivative control calculates the rate of change of the deviation and can suppress deviation variations and introduce early corrective action before the deviation becomes too large, thus speeding up the system's response and adjustment speed.

The result of the PID control algorithm is the linear combination of the proportional, integral, and derivative components of the deviation signal. Since the algorithm is a closed-loop control system, a feedback loop using sensors is required to obtain the deviation signal between the setpoint and the feedback value.


  • (2) Motor Control

To achieve closed-loop control of the motor speed,wireless serial communication is used to establish communication between the upper computer and the microcontroller. The SerialPlot software is used to observe the waveform of the target speed and the speed measured by the encoder. By comparing the two waveforms, the time required for the speed to reach stability and the degree of oscillation can be observed, which helps in adjusting the PID parameters of the motor for better performance.

Based on the observations, if the motor speed reaches the target value slowly, exhibits significant overshoot, and has some degree of jitter, the PID parameters can be adjusted to improve the performance. Increasing the proportional (P) value, decreasing the integral (I) value, and increasing the derivative (D) value can help in overcoming dead zones and achieving fast and stable glucose content compensation.

By fine-tuning the PID parameters, the motor can accurately and quickly reach the desired glucose content compensation, overcoming slow response, overshoot, and jitter.


  • 03 Pin Configuration
Chart 1 | Pin Configuration
Pin Function Description
PA2 USART2_TX Receiver WIFI signal
PA3 USART2_RX Sending control instruction
PC7 TIM8_CH2 Motor control
PB6 TIM4_CH1 Encoder
PC5 ADC12_IN15 Sensor

  • 04 Testing And Debugging Process

  • A. Testing Plan

  • (1) Hardware Testing

To test the motor, connect the motor driver module to the motor under test. Use a signal source to simulate an MCU output with an amplitude of 3.3V and a frequency of 10kHz PWM signal. Connect this signal to the control terminal of the motor driver module. By continuously adjusting the duty cycle of the PWM signal, observe and record the motor's speed.

Start by setting the duty cycle of the PWM signal to a low value, such as 10%. Observe the motor's speed and record it. Gradually increase the duty cycle in steps, such as 20%, 30%, and so on, and observe and record the corresponding motor speeds at each step. Continue this process until reaching a duty cycle of 100%.

By analyzing the recorded data, you can observe the relationship between the duty cycle of the PWM signal and the motor's speed. This information can be used to determine the appropriate duty cycle for achieving the desired motor speed in your application.


  • (2) Software Testing

To ensure stable PWM waveform output from the MCU, use an oscilloscope to observe the output waveform. Connect the oscilloscope probe to the PWM output pin of the MCU and adjust the settings on the oscilloscope to display the waveform accurately. This will allow you to verify the stability and quality of the PWM signal generated by the MCU.

For closed-loop control of the motor speed, establishb wireless serial communication between the upper computer and the microcontroller. Use SerialPlot software to observe the waveforms of the target speed and the speed measured by the encoder. Compare the two waveforms to observe the time required for the speed to reach stability and the degree of oscillation. This will help in fine-tuning the PID parameters of the motor for better performance.Based on the observations, if the motor speed reaches the target value slowly, exhibits significant overshoot, and has some degree of jitter, you can improve the performance by ncreasing the proportional (P) value, decreasing the integral (I) value, and increasing the derivative (D) value . This will help the motor overcome dead zones and achieve fast and stable glucose content compensation.By adjusting the PID parameters, the motor can overcome slow response, reduce overshoot, and minimize jitter, ultimately achieving precise and stable glucose content compensation.


  • B. Test Conditions And Instruments

Testing Conditions:After multiple checks, the simulated circuit and the hardware circuit must be identical to the system schematic, and thorough inspections should be conducted to ensure that there are no errors. The hardware circuit should be guaranteed to be free of soldering defects.

Testing Conditions:SDS2352X Plus Oscilloscope, SDG2122X Function/Arbitrary Waveform Generator, SDM3055X-E Digital Multimeter, SPD3303X DC Power Supply.


  • C. Testing Results And Analysis

  • (1) Testing results in different situations
Chart 2 | Testing result
Glucose Content Testing result
Excessive Effective
Normal Effective
Bit Effective
Very few Effective

  • (2) Results Analyses

After multiple adjustments of PID parameters and algorithm optimization, this system has shown good testing results for different glucose concentrations. It can achieve accurate and rapid glucose supplementation.


  • Vision of the future

The current project is based on an STM32 microcontroller and has successfully achieved regulation of glucose concentration in a fermentation tank. To further enhance and improve the system, we plan to expand the control range to include key parameters such as temperature, pH value, and dissolved oxygen. Additionally, we intend to replace the control system with a more suitable industrial production Programmable Logic Controller (PLC). Furthermore, we have designed a stirring system that utilizes a Rockwell PLC in conjunction with a variable frequency drive (VFD) to control the motor.

pid-control-algorithm