Research and Design of Infrared Remote Control and Self-balancing Car Based on STM32

Shiyao Cui, Peng Su, Zhenhua WangAdvances 2015 · DOI

Abstract

This paper introduces the design of an infrared remote-controlled self-balancing car utilizing the STM32 as the master control chip. The system employs an MPU6050 sensor to acquire real-time attitude data, which is then processed using a Kalman filter algorithm and data fusion techniques. A PID control algorithm calculates the PWM duty cycle to drive the motors, enabling the car to maintain balance while performing maneuvers such as moving forward, backward, and turning via infrared commands.

Introduction

The two-wheeled self-balancing car is a classic "inverted pendulum" problem in control theory. Characterized by inherent instability, multivariable inputs, and high non-linearity, it serves as a rigorous benchmark for real-time control systems. Unlike traditional four-wheeled vehicles, this platform must continuously modulate motor output to maintain an upright posture. This research details the development of a functional prototype that achieves autonomous balance and precise maneuverability.

System Architecture and Hardware Integration

The system's core is the STM32F103C8T6 microcontroller (ARM Cortex-M3), chosen for its 72MHz clock speed, which is essential for high-frequency control loops.

Hardware block diagram showing the integration of the STM32 controller, MPU6050 sensor, and L298N motor driver.

As illustrated in the hardware architecture, the STM32 interfaces with several critical modules:

  • MPU6050 Motion Sensor: A 6-axis device providing raw accelerometer and gyroscope data.
  • L298N Motor Drive: Translates PWM signals into high-current power for the DC motors.
  • Infrared Module: Decodes NEC protocol signals for user-driven directional control.
  • Voltage Regulator: Converts the 12V power source into stable levels for the logic circuits.

Control Strategy

Stability is achieved through a combination of sophisticated state estimation and a multi-layered PID control loop.

State Estimation via Kalman Filtering

Raw sensor data presents a trade-off: accelerometers are stable in the long term but noisy due to vibrations, while gyroscopes are smooth but suffer from long-term drift. The system implements a Kalman filter to fuse these sources, providing an optimal estimate of the car's actual tilt angle and angular velocity.

Triple-Layer PID Control

To ensure both balance and positional stability, the controller employs a three-part PID strategy:

  1. Angle Control ($Kp$): The primary loop for maintaining vertical balance.
  2. Speed Control ($Kd$): Dampens oscillations and manages the velocity of the motors.
  3. Displacement Control ($Ki$): Prevents the robot from drifting away from its starting position when no commands are received.

Experimental Results and Parameter Tuning

Physical testing confirmed the system's efficacy, with the robot maintaining its position with a displacement error of less than 3cm. A significant portion of the development involved tuning the PID parameters to find the "sweet spot" between responsiveness and stability.

Table of PID parameter debugging results (Form 1) illustrating the system's response to different gain values.

As shown in the debugging table, improper tuning leads to failure: a $Kp$ of 80 caused violent shaking ("overstrike"), while a $Kp$ of 40 resulted in a sluggish response. The optimal configuration was identified as $Kp=60, Ki=0.02, Kd=1$.

Conclusion

This project successfully demonstrates a stable self-balancing vehicle using an STM32-based architecture. While the current model relies on human input via infrared, future iterations could integrate ultrasonic or LIDAR sensors for autonomous obstacle avoidance, transforming the platform into a fully autonomous mobile robot.

Summary updated

Abstract

This paper introduced a design of infrared remote and self-balancing car.STM32 is master control chip on this system. Infrared remote control devices serve as the control devices. Firstly, the MPU6050 sensor acquire data of the car's attitude. Then, using Kalman filter algorithm and Data fusion technology process the data. After fusion processing, using the PID algorithm calculate the duty cycle of PWM to control the current electromotor. Finallythe car can selfbalance, move forward, move back, turn left and turn right.
BibTeX
@inproceedings{cui2015research,
  author = {Shiyao Cui and Peng Su and Zhenhua Wang},
  title = {{Research and Design of Infrared Remote Control and Self-balancing Car Based on STM32}},
  booktitle = {Advances},
  year = {2015},
  doi = {10.2991/isrme-15.2015.265},
}
Figure