Drunk driving is an important cause of traffic accidents, which brings great harm to people's lives and life safety. In order to prevent motor vehicle drivers from driving after drinking, the on-site real-time inspection of the alcohol content in human breath has received increasing attention. Aiming at the problem of long recovery time of existing alcohol sensors, this system successfully realizes rapid alcohol concentration detection by calculating the slope, shortens the detection interval time, and greatly improves the efficiency of alcohol detection.
1 Overall structure of alcohol concentration detector
The alcohol concentration detector consists of a single-chip microcomputer, an alcohol sensor, a signal conditioning circuit, a voice alarm module, a TFTLCD display module, a communication module, a power amplifier module, etc. The structural block diagram is shown in Figure 1. Since the voice alarm module and the TFTLCD display module have high requirements for the processing speed and processing data volume of the single-chip microcomputer, and the alcohol detection reaction speed is fast and the real-time performance is high, the STM32 series single-chip microcomputer of ST Company is used as the main control end. ME3-C2H5OH electrochemical gas sensor has the advantages of low power consumption, high precision, high sensitivity, wide linear range, strong anti-interference ability, excellent repeatability and high stability.
2 Hardware Design
2.1 Design of MCU and its peripheral interface
The MCU adopts low-power and high-speed industrial-grade chip STM32F103VET6. The STM32 series is based on the ARM Cortex-M3 core designed for embedded applications requiring high performance, low cost and low power consumption. The STM32F103 is an "enhanced" series with a clock frequency of 72MHz, 512KB ROM, 64KB RAM, 80 common I/O ports, 8 timers/counters, 3 SPI, 2 I2C buses, 3 UARTs, 1 USB, 1 CAN bus and other communication ports. It has 2 I2S audio ports, 1μs dual 12-bit ADC, 4 Mbps UART, 18Mbps SPI, 18 MHz I/O flip speed, and internally integrates excellent safety clock mode, low-power mode with wake-up function, internal RC oscillator, embedded reset circuit, etc., which fully meet the design requirements of this alcohol concentration detector.
The power supply circuit uses LM2596 as the primary voltage conversion chip to provide 5 V voltage to power the peripheral modules, and uses AMS-3.3 as the final voltage conversion chip to provide 3.3 V voltage to power the STM32. The output current of this chip can reach 1 A, the input voltage regulation rate is less than 0.2%, the load regulation rate is less than 0.4%, and the output voltage is stable.
The watchdog circuit uses the system μP monitoring chip IMP706 produced by IMP Company of the United States. IMP706 can generate a reset signal during power-on, power-off or manual operation. The device contains a 1.6 s watchdog timer and a 4.4 V power supply voltage monitor. In addition, IMP706 also has a 1.25 V threshold power failure alarm circuit, which can be used to detect battery voltage and non-5 V power supply.
2.2 Alcohol sensor
The ME3-C2H5OH alcohol sensor works according to the electrochemical principle. It uses the electrochemical oxidation process of the gas to be tested on the working electrode potential in the electrolytic cell. The current generated by the electrochemical reaction of the gas to be tested is proportional to its concentration and follows Faraday's law. The concentration of the gas to be tested can be determined by detecting the magnitude of the current. The detection and processing circuit of the ME3-C2H5OH sensor is shown in Figure 2. The sampling voltage is obtained by the sampling resistor R1 in response to the alcohol concentration in the exhaled gas of the subject, and the sampling voltage is amplified through the op amp negative feedback amplifier circuit. The RT in the circuit is a thermal resistor, which is used to offset the temperature drift and ensure a constant amplification factor. The amplified voltage signal is sent to the ADC of the STM32, and the data after A/D conversion is analyzed and processed. Finally, the alcohol concentration is calculated to determine whether the subject is drinking. The judgment result is voice prompted by the voice chip, and then the concentration value is displayed on the LCD.
Figure 3 shows the sensitivity, response recovery and output signal characteristics of the alcohol sensor, and Figure 4 shows the concentration linear characteristic curve. It can be seen from Figures 3 and 4 that the ME3-C2H5OH type electrochemical element has high sensitivity, fast response speed, small zero drift, and this element is linear. Therefore, the use of this type of electrochemical element to detect alcohol concentration values has high accuracy and fast response.
2.3 Voice Alarm Module
The XF-S4040-CN Chinese speech synthesis chip is a brand-new Chinese speech synthesis chip designed based on the InterSound4.6 Chinese speech synthesis system and launched by Anhui University of Science and Technology iFlytek Information Technology Co., Ltd. The chip can receive commands and text to be synthesized through the asynchronous serial port (UART) and I2C bus interface, and directly synthesize it into speech output. It is mainly aimed at mid-to-high-end application fields, providing a set of speech synthesis solutions with excellent speech synthesis effects and extremely small size. The circuit of the speech synthesis module is shown in Figure 5.
The XF-S4040-CN Chinese speech synthesis chip is designed for embedded applications and has the ability to synthesize any Chinese text and English letters. The main features of this chip are high naturalness of synthesized speech, simple and convenient control interface, and powerful adjustable functions. The operation command format is as follows. [page]
The operation routine based on the serial port is as follows:
2.4 The power amplifier module
TDA7266 is a dual-channel audio stereo amplifier, packaged in the form of MULTI-WATT, specially designed for high-quality audio amplifier circuits of music equipment and color TVs. The voice signals of the left and right channels output by the voice alarm module enter the TDA7266 amplifier through the potentiometer to amplify the voice signals. The potentiometer is used to adjust the volume. After amplification, two audio signals are output, and these two channels are connected to two speakers respectively.
The TDA7266 amplifier circuit is simple and has good sound effects, so it is widely used in high-quality audio amplification. The amplifier module circuit is shown in Figure 6.
2.5 Communication module
When the communication distance is required to be from tens of meters to thousands of meters, the RS-485 serial bus is widely used. RS-485 uses a combination of balanced transmission and differential reception, so it has the ability to suppress common-mode interference. In addition, the bus transceiver has high sensitivity and can detect voltages as low as 200 mV, so the transmission signal can be recovered thousands of meters away. The RS-485 interface bus allows up to 128 transceivers to be connected, that is, it has multi-station capabilities, so that users can easily establish a device network using a simple RS-485 interface. In this design, it is precisely considering that the data of the alcohol concentration detector may be transmitted back to the computer host terminal, requiring a relatively long transmission distance and low signal distortion, so RS-485 communication is selected.
2.6 TFTLCD display module
When the alcohol concentration detector is in use, it is necessary to display the alcohol concentration value and alarm information. At the same time, it is also necessary to enter the preset value of the alcohol concentration alarm point to set the range of the alcohol concentration alarm. Therefore, this design uses TFTLCD to display the alcohol concentration value. TFTLCD has a touch function and can be used to input the preset value of alcohol concentration.
TFTLCD uses a 260,000-color TFTLCD screen with a resolution of 320×240, which can realize a friendly human-machine interface display. TFTLCD uses ILI9320 produced by Ilitek, which can communicate with the microcontroller through multiple parallel communication methods. The TFTLCD screen has a resistive touch screen, which is controlled by pressure sensing. The ADS7846 produced by TI is used as the touch screen control chip. ADS7846 integrates a 12-bit successive approximation A/D converter with a conversion frequency of 125 kHz. When in use, ADS7846 obtains the X and Y
coordinates of the contact position through two A/D conversions, communicates with STM32 through the SPI bus, and completes the input of control information.
3 Software Design
3.1 Overall Software Design
After the system is initialized, the value of the alcohol concentration sensor is first collected, and do...while() is used to wait for the sensor to initialize until the optimal state, otherwise it will wait. After the sensor is initialized, it enters the cycle detection mode. When someone blows, it can be detected according to the range of slope changes, and then it can be judged whether the person is drinking. When alcohol gas is detected, the conductivity of the sensor will increase with the increase of gas concentration, resulting in an increase in the voltage of the voltage divider resistor connected to the sensor. The 7th channel of the A/D interface of the microcontroller will collect this voltage. When the voltage value increases to a certain extent, that is, when the alcohol concentration reaches the set value, the flag position will be set to the drinking state; if the voltage decreases, that is, the alcohol concentration is zero, the flag position is in the normal state. According to the above two different states, the buzzer, voice module and LED indicator light will give different alarms. The microcontroller continuously performs timed A/D conversion, and performs filtering and comparison in the conversion end interrupt. The difference between the two A/D measurement values is the rate of change of the voltage, that is, the required slope value. This value is compared with the slope range value set before, so as to judge whether the person being tested is drinking. The LCD will always filter and average the collected values for dynamic display.
3.2 Slope Algorithm Design
The design of the slope algorithm mainly uses the timing A/D conversion resources of the microcontroller. According to the previous description, it is necessary to calculate the slope of the voltage change, that is, the range of voltage change within a certain period of time. The timing A/D conversion function can easily achieve this requirement.
Figure 7 is the A/D conversion interrupt program flow chart. In the main program, corresponding operations can be performed according to the flag bit set by this interrupt, such as voice playback control, buzzer alarm, LED flashing, etc.
Conclusion
This article introduces in detail the design method of alcohol concentration detector based on STM32. The detector has the advantages of high precision, high sensitivity, friendly human-computer interaction, intelligent voice alarm, and easy to carry. It can be used in various occasions where human alcohol content needs to be detected, especially for the detection of drunk driving, and has broad application prospects.
Previous article:Design of DDS Signal Source in Quartz Crystal Test System
Next article:Energy spectrum nuclear well logging instrument based on embedded system
Recommended ReadingLatest update time:2024-11-17 00:51
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- EEWORLD University Hall----TI Smart Speaker and Sound Bar- Audio Session
- Several issues about switching power supply
- The CC2540 transmit power is not enough (for example, not enough to 0dbm). How can this be solved? The impedance is already 50 ohms.
- "Smart Sensor Design", a reference book for sensor development and design
- I would like to ask a question about circuit design.
- Cadence creates a new component
- TMS320F28335 SVPWM source program
- A professor said that due to the needs of safety and stability, 8-bit microcontrollers are used on satellites. Is this true?
- Battle of MicroPython Forks
- Commodore 64 emulator for STM32F429 Discovery