Design of Intelligent Fire Extinguishing Car based on STM32 Single Chip Microcomputer

In view of the accidental fire in flammable and explosive warehouses and large petrochemical enterprises in the market, in order to reduce casualties and property losses as much as possible, this paper designs a high-pressure water-spraying intelligent fire-fighting car system. The system uses STM32 single chip microcomputer as the main controller and uses reflective photodetector RPR-220 diode to track and avoid obstacles. In the process of driving, the fire-fighting intelligent car along the designed route, through the infrared photoelectric sensor induction light source to detect the specific position of the flame, the algorithm can be used to design the tracking fire extinguishing, and drive the motor pump to spray water in this mode. relative to the fan fire extinguishing can effectively control the second occurrence of the fire source, so as to complete the fire fighting operation. Through the actual test and experiment, the intelligent fire extinguishing car can complete the corresponding functions quickly and smoothly in different modes.


Introduction
With the continuous improvement of my country's urbanization and the rise of a large number of petrochemical companies and large factories, it is difficult for the staff to detect in time when a common fire occurs, which leads to more and more serious disasters [1]. For this reason, a smart device was developed to monitor the hidden dangers of fire in real time, which greatly reduces the risk of property loss for the enterprise and more effectively controls the casualties of personnel [2]. In this article, an intelligent fire extinguishing system is designed with an intelligent fire fighting vehicle as a carrier. In order to prevent the recurrence of a second fire, the system uses a water pump spray device to replace the original fan module, which greatly improves the timeliness of fire extinguishing. By planning the overall design of the trolley, hardware circuit design, programming of program codes, and comprehensive debugging of software and hardware, the intelligent fire truck can realize automatic obstacle avoidance, flame detection, tracking fire extinguishing, ultrasonic distance measurement, infrared remote control fire extinguishing and other functions to adapt to different fires The needs of the environment [3].

The overall design of the intelligent fire fighting car system
The overall structure of the intelligent fire-fighting car system designed in this paper is shown in figure 1. The system mainly includes power module, main control module, motor drive module, tracking module, ultrasonic obstacle avoidance module and fire extinguishing module.
Among them, the main control module is the core of the whole system, which can send and receive data from each module at the same time. After processing and analysis, it sends corresponding commands to drive and control each module.
It can be seen from Figure 1 that the main controller is directly connected to the motor drive, and can directly drive the 4 wheel motors through the level signal control output to realize the direction change and advance and retreat control of the mobile platform of the smart fire truck, and an installation under the chassis The RPR-220 reflective photoelectric sensor can allow the smart fire truck to follow the prescribed black line. In addition, an ultrasonic detection module is designed and installed in the system, which can detect the position information of obstacles in the case of complicated smoke, and judge the forward, backward, steering, and stop of the smart car. When the intelligent fire fighting vehicle is driven by the motor, the detection signal obtained through the fire extinguishing module is converted into an electrical signal and transmitted to the single-chip microcomputer for processing. When a fire source is detected at the location, the main controller sends a level signal to drive the micro water pump device Fire sprinkler [5].

Main controller unit
The main controller unit in the system is the core part of the intelligent fire truck, which integrates the task of sending and receiving instructions to control internal and external modules. The main chip selection is the STM32F103 processor, which is a 32-bit microcontroller based on the ARM Cortex-M core STM32 series, with a program memory capacity of 64KB, a working voltage (VDD) of 2 ～ 3.6V, and a high-performance RISC core. It has internal resources such as a 12-bit analog-to-digital converter, PWM timer, and high-speed embedded memory. The chip has fast processing speed, low power consumption, low cost, and has abundant internal and external resources.

Power module
The power module is responsible for supplying power to the development board and peripheral devices. The system uses 2 rechargeable lithium batteries in series as the battery. There are 2 regulated power supplies in the system, 3.3V for the CPU and 5.5V for other peripheral devices. 5. The 5V voltage regulator module is shown in Figure 2, and the circuit uses a switching regulator chip LM7805CV; 3. The 3V voltage regulator module is shown in Figure 3 and uses a switching regulator chip AMS1117. LM7805CV is the most commonly used voltage regulator chip, the output current reaches 1.5A, no external compensation components are needed, and the built-in current limiting circuit greatly improves the stability of the power supply output; AMS1117 is a positive low-dropout regulator, Its output voltage is 3.3V.  Control the motor drive direction as shown in Table 1.

Ultrasonic obstacle avoidance module
Both the transmitting and receiving ends of the ultrasonic wave adopt the HC-SR04 module, as shown in Figure 4. The module includes a control circuit, ultrasonic transmitter and receiver. Trigger distance measurement through the IO interface TRIG, give at least 10μs high-level signal, the module automatically sends 8 40kHz square waves, and automatically detects whether there is a signal return, once an echo signal is detected, it will output a reverberation signal. The pulse width is proportional to the measured distance. From this, the distance can be calculated from the time interval between the transmitted signal and the received echo signal.

Tracking unit module
The black line tracking module of the intelligent fire truck uses the RPR-220 reflective photoelectric sensor, which has low power consumption, high sensitivity and strong anti-interference ability. In order to achieve the desired effect of tracking, the test points are set in a darker environment, and some black tracks are arranged on the ground. It can be seen from the internal structure diagram of the sensor that the photoelectric sensor is made of the infrared emitting diode on the left and the infrared receiving tube on the right. The infrared diodes at the 1, 2 ends emit infrared light, which is reflected back by the white ground to be received by the 3 and 4 infrared receiving tubes. When infrared is received, 3 and 4 are turned on. The actual test circuit is shown in Figure 5. When the car is running, the infrared transmitting end emits infrared light, and the receiving end receives the light reflected from the ground. The infrared receiving transistors at the 3 and 4 ends are cut off, and then a high voltage is output after the 3 pin of the RPR-220. level. When the smart fire truck is running on the black track normally, the receiver tube cannot receive the reflected infrared light, and it outputs a low level. When the smart fire truck deviates from the black track during driving, the ground receiving tube will receive the light reflected from the white ground and output a high level.
As shown in Figure 6, the received signal data is input to the LM339 four-voltage comparator as a differential. If a black line is detected, the 3 pin of the RPR-220 will output a voltage to compare with the reference voltage. If the RPR-220's If the voltage of pin 3 is larger than the reference voltage, pin 2 of LM339 will output a low level. On the contrary, if the black line is not detected, the 2 pin of LM339 outputs a high level. Figure 6. LM339 differential data processing principle diagram

Fire extinguishing unit module
The design of the fire extinguishing unit is relatively simple. The module is mainly composed of an infrared flame detector, a relay, and a miniature water pump. The flame detector is made of light-sensitive components for flames. As shown in Figure 7, the strength of the flame is detected, and the sensed signal is transmitted to the intelligent fire detection vehicle through the controller.
The flame probe of the flame sensor that can distinguish the electronic signal can be used to detect the location of the fire source or sense the wavelength For the fire source in the range of 760～ 1100nm, the interface of the detector board can be directly connected to the IO port of the single-chip microcomputer. When the flame detector detects the flame and reaches the threshold set by the potentiometer, the upper green indicator light will be lit, DO The digital switch output is low level; otherwise, the indicator light is off. The intelligent fire truck of the system uses a water pump to spray water to extinguish the fire, and a photoelectric isolator is combined with a triode to control the interruption of the relay, and the intermediate relay controls the switch of the water pump. In the specified area, when the infrared flame detector detects the position of the flame, the intelligent fire truck starts to spray water to complete the fire-fighting related operations.

Figure 8. System flow chart
After the hardware design and installation are completed, the program needs to be written and burned. The overall language of the smart fire truck is C++, Keil4 is used in the compilation software, and the MCUISP tool is used to download the program through the STM32 serial port. After the smart fire truck completes the code programming, the module is initialized after the power is turned on, and the system clock setting, delay function, timer interrupt, motor drive, tracking signal interface, and fire control interface are initialized. After the module is initialized, the program enters the working cycle, that is, the trolley enters the automatic judgment mode, and follows the set black line track to avoid obstacles. When a fire source is detected, the water pump is turned on to extinguish the fire. After completion, the cycle is performed again for detection. When the trolley is in remote manual fire extinguishing, if a fire source is detected, it will enter the state of waiting for the button to extinguish the fire. The system flow is shown in Figure 8. Figure 9. Trolley obstacle avoidance diagram The 3-way ultrasonic module installed in the intelligent fire fighting vehicle has obtained the information of the obstacle. When the obstacle is found to be obstructing the forward direction, the control unit receives the target information to avoid it in time and move on. The specific locations of the obstacles are directly in front of the trolley, front left and front right, as shown in Figure 9. The input is the distance DF between the ultrasound and the obstacle in front and the distance DS between the ultrasound and the obstacle on both sides, and the output is the linear velocity VO and the steering angle change WO.

Obstacle avoidance algorithm design
According to design of the obstacle avoidance algorithm, the fuzzy language is expressed as DS={big right, small right, zero, big left, small left}={RL,RS,ZE,LL,LS}, as shown in Figure 10a, DS takes The value interval is quantified as [-2, 2], the obstacle distance DS on the left side of the design is positive, and the right side is negative [8]. The DF membership function is shown in Figure  10b, expressed in fuzzy language as DF={Small, Medium, Large}={Small, Medium, Large}, the DF value interval is quantized as [0, 2]; the WO value is quantified In the interval [-30, 30], the fuzzy language is expressed as WO={small right, big right, middle right, zero, small left, big left, middle left}={RS, RB, RM, ZE, LS, LB }, where the left turn is negative and the right turn is positive.

Fire extinguishing program design
Two fire sources are inserted in the prescribed track, and the smart car finds the positions of the left and right fire sources through infrared flame sensors. The fire extinguishing process is shown in Figure 10. In order to improve the accuracy of fire extinguishing, the car needs to face the fire source, otherwise the fire source is likely to be difficult to extinguish [9]. In this case, the smart car needs to judge the strength of the two fire sources, if the left side is strong , The car will turn left 45°, otherwise turn right 45°. After each turn, the smart car will move closer to ensure the accuracy of the fire. After aiming at the fire source and waiting for 0.5s, turn on the water pump to extinguish the fire. After 5s, read the information to confirm whether the fire source is extinguished. If it does, turn off the water pump and move on to find other fire sources.

System software design
The smart car designed in this paper uses the STM32F103 single-chip microcomputer as the main control core to control the peripheral motor drive, ultrasonic, sensor and other modules. After many debugging and test verifications, it successfully realized autonomous tracking, obstacle avoidance, fire detection, etc. Function, can be put into market application after slight improvement. The intelligent fire extinguishing trolley is suitable for fire prevention in large warehouses, flammable and explosive factories and large petrochemical enterprises, and has certain practical value for improving production safety.