Odor source tracking has become a significant research focus in recent years, with wide applications in daily life and industrial settings. This paper presents an intelligent odor-tracking car designed around the STC12C5A60S2 microcontroller. The system utilizes two odor sensors to detect concentration differences and determine the direction of the scent. A PID algorithm is applied to control the steering angle, enabling the vehicle to follow the odor accurately. The hardware architecture is simple and flexible, and experimental results demonstrate that the car can effectively perform odor tracking in indoor environments with time-varying airflow.
Odor tracking technology plays a crucial role in detecting harmful gas leaks and locating explosive sources. Due to its growing importance, researchers have made rapid progress in this field. With the increasing demand for smart devices in daily life, intelligent cars and robots equipped with advanced control systems are becoming more common. These autonomous agents are expected to play a vital role in both industrial and domestic applications in the future. An intelligent car is essentially a system capable of sensing its surroundings and moving purposefully, making it a form of mobile robot with wheels instead of legs, which simplifies implementation and control.
One major challenge in current intelligent scent-tracking vehicles is the long response time and poor tracking performance. This paper introduces a system where the STC12 single-chip microcontroller serves as the core control unit, allowing the car to automatically detect nearby odors and respond accordingly. The PID algorithm adjusts the servo motor to guide the vehicle along the scent trail. Experimental data show that the tracking time is significantly reduced, and the vehicle's following performance is greatly improved.
**1 Hardware System and Working Principle**
**1.1 Hardware System Design**
The smart car system (Fig. 1) consists of several key modules: power supply, control processing, sensor module, steering control, motor drive, and status display. The control unit is based on the STC12C5A60S2 microcontroller. The motor is driven by the ULN2003APC chip, using rear-wheel drive. The servo motor is directly controlled by the microcontroller, which manages front-wheel steering. Part of the circuit diagram (Fig. 2) and the board layout (Fig. 3) are shown below.
[Image: A.jpg]
[Image: B.jpg]
**1.2 Working Principle**
In this design, the car uses odor sensors to detect the concentration of the scent in two directions. The signals are sent to the ADC port of the microcontroller, which processes the data and determines the direction of the strongest odor. Based on this information, the PID algorithm controls the steering gear to adjust the vehicle’s path, guiding it toward the odor source.
[Image: C.jpg]
**2 Chip Configuration and Functions**
**2.1 Introduction to the STC12C5A60S2 Microcontroller**
The STC12C5A60S2 microcontroller features 1280 bytes of RAM, 40 general-purpose I/O ports, EEPROM, and a watchdog function. It operates at different frequencies depending on the voltage—11–17 MHz at 5V and 8–12 MHz at 3.3V. The device supports Power Down mode and can be awakened via external interrupts such as INT0/P3.2 or TxD/P3.0.
**2.2 Odor Sensor Module**
The MS5100 gas sensor is used to detect odor concentration. When powered, the metal compound inside the sensor reacts to specific odors, causing its resistance to decrease with increasing concentration. The signal is then converted into a digital value through the microcontroller’s ADC interface.
[Image: D.jpg]
**2.3 Servo Motor Module**
The servo motor is controlled using PWM signals with a period of 20 ms and pulse widths ranging from 0.5 to 2.5 ms. This allows the motor to rotate between 0° and 180°, adjusting the car’s direction accordingly.
**2.4 Motor Drive Module**
To drive the DC motor, the ULN2003 Darlington transistor array is used. It provides sufficient current and voltage to control the motor speed through PWM signals generated by the microcontroller.
**2.5 Indicator Display Module**
LEDs are used to indicate sensor readings and system status, helping users monitor the car’s operation in real time.
[Image: E.jpg]
**2.6 Power Supply Module**
A voltage regulator circuit using LM7805 and LM7806 ensures stable power supply for the microcontroller, servo, and motor. This converts the battery voltage into 5V and 6V DC, providing reliable power to all components.
[Image: F.jpg]
**3 Experiment and Results**
The main challenge in odor tracking is quickly analyzing the scent flow and accurately controlling the steering. However, due to the car’s speed and the limitations of the servo response, collisions often occur during sharp turns. To address this, the PID algorithm was implemented to improve the vehicle’s tracking performance. The formula for the PID controller is:
$$
PID_{out} = K_p \cdot e + K_i \cdot \sum e + K_d \cdot \frac{de}{dt}
$$
In C programming, the code for the PID algorithm can be written as:
```c
PID_out = (servo_P * error_history[2] // Proportional
+ servo_I * error_sum / 10 // Integral
+ servo_D * (error_history[2] - error_history[1])) // Differential
/ 10; // Convert decimal to integer for efficiency
```
This approach enhances the car’s ability to track the scent more accurately and efficiently.
**4 Conclusion**
The STC12C5A60S2 microcontroller enables accurate odor detection and efficient control of the vehicle’s movement. With proper PID tuning, the system achieves fast and precise tracking. Although the sensor’s sensitivity remains a limitation, the experiment successfully demonstrated the car’s ability to detect and follow strong odor concentrations. The integration of the PID algorithm significantly improved the vehicle’s adaptability and tracking performance, proving the effectiveness of the design.
Three Phase High Frequency Rack UPS
Three Phase High Frequency Rack-Mounted UPS,Three Phase High Frequency Rack-Mounted Online UPS
Shenzhen Unitronic Power System Co., Ltd , https://www.unitronicpower.com