Alcohol content detector (development of wireless alcohol concentration detector)

In food industry, brewing industry, petrochemical and industrial and mining enterprises, environmental detection, public security traffic management, public utilities and other fields and occasions of national economic production and people's work and life, it is often necessary to detect the concentration of alcohol gas in a specific environment to ensure the environmental safety of factories and enterprises and the safety of people's lives and property [1-4]. For example, monitoring the alcohol concentration in alcohol production workshops and petrochemical plants can avoid fire and explosion accidents in factories; Monitoring the alcohol concentration in industrial and mining enterprises can avoid vicious accidents such as alcoholism among workers; Detecting the alcohol content in the driver's body can prevent the driver from drunk driving and reduce the occurrence of vicious traffic accidents. Therefore, the development of alcohol gas concentration detector has very broad reality and potential market demand, which is of great significance. Due to the sensor performance, circuit design, data processing algorithm and other reasons, the traditional alcohol gas detector has some outstanding problems, such as low gas selectivity, poor anti-interference performance, low intelligence, complicated instrument operation, and inability to save and adjust data in real time [3-4]. In view of this, the author designed and developed a wireless intelligent alcohol concentration detector, which made up for the shortcomings and deficiencies of traditional alcohol detection instruments.

1 system overall scheme

The alcohol concentration detector consists of a transmitter and a receiver, and its principle block diagrams are shown in Figure 1 and Figure 2 respectively. The transmitter mainly includes six parts: alcohol concentration sensor and A/D conversion circuit, STC90C52RC single chip microcomputer, concentration threshold setting and sound alarm circuit, voice broadcast circuit, liquid crystal display circuit and wireless transceiver circuit. The receiver consists of wireless transceiver circuit, STC90C52RC single chip microcomputer, data interface communication circuit and upper computer.

2 system hardware circuit design

2. 1 sensor circuit and A/D conversion circuit

TGS2620 is a semiconductor gas sensor produced by FIGARO Company in Japan, which can detect the alcohol concentration in gas. It has the characteristics of high sensitivity, low power consumption, long service life and low cost [5-6]. The circuit connection is shown in Figure 3, where RH is the heater resistance, which is 83 8 Ω at room temperature; RS is the sensor resistance, and the mathematical relationship between its resistance and the concentration of reducing gas is as follows:

By detecting VRL, the gas concentration c can be determined.

In the circuit, the operational amplifier OP07 is connected in the form of voltage follower, which isolates the sensor from the subsequent circuit and reduces the influence of power supply fluctuation and external factors on the sampled data. ICL7660 is a low-power polarity inversion power converter produced by MAXIM Company, which is used to convert +5 V power supply into -5 V power supply for OP07. Among them, CC2 adopts 10 μF tantalum capacitor, which has small leakage and low dielectric loss and improves power conversion efficiency. TLC 1549 is a 10 bit resoluTIon successive approximation ADC chip produced by ti company. It has the functions of automatic sample and hold, calibration of conversion range according to proportional range, anti-noise interference and so on, and the maximum total error of full range is only 1 LSB.

2.2 LCD display, threshold setting and sound alarm circuit

16×2 character LCD module DM- 162 displays alarm threshold and alcohol concentration value. In order to reduce the number of I/O ports and simplify the circuit structure, indirect control (4-bit data bus) is adopted, and the interface circuit is shown in the upper part of Figure 4. During initialization, a 28H instruction code needs to be written to convert the 8-bit bus into the 4-bit data interface mode. The pins BLA, BLK and VL are the positive electrode, negative electrode and display contrast adjusting end of the LCD backlight, respectively, and RS and E are the register selection end, read/write signal line and enable end, respectively.

The alcohol concentration threshold setting and sound alarm circuit are shown in the lower part of Figure 4. When the setting key S 1 is pressed, enter the threshold setting interface (the initial threshold is 500 ppm), and then press S2 or S3 to increase or decrease the threshold in steps of 20 ppm. After the threshold is set, write the addresses of the first sector 2000H and 200 1H of the 5 KB EEPROM on the STC90C52RC microcontroller, so that the system does not need to be reset. If the alcohol concentration value is greater than the threshold, set the P0.7 port line to a low level, and the triode 8550 drives the buzzer to give an alarm.

2.3 Voice Broadcasting Circuit

Use the ISD2560 voice recording and playback integrated chip of Winbond Company to play the alcohol concentration value, and the circuit is shown in Figure 5. The microphone is differentially connected to the MIC terminal and MIC REF terminal of the on-chip preamplifier to eliminate noise and improve the input * * * mode rejection ratio. Speakers are connected in the form of double-ended output, and the output power is four times that of single-ended use. The P2 port, P3.0 port and P3. 1 port lines of the single chip microcomputer are connected with the address lines A0~A9 respectively, which are used to set the starting address of the voice segment stored in the 480 KB EEPROM of ISD2560 chip (the address is 0H~257H). Both recording and playback functions start from this starting address, and the address of the information segment is automatically increased during recording. The voice information that this system needs to input in ISD2560 includes: the current alcohol concentration values are zero, one, two, three, four, five, six, seven, eight, nine, ten and one hundred. As the voice recording and playback time of ISD2560 is 60 s, it can record and play 180 Chinese characters according to the calculation of 3 Chinese characters per second, which meets the broadcasting requirements. In addition, the working mode [7-8] (address: 300H~3FFH) of ISD2560 can be configured through P3.0, P3. 1 and P2.0~P2.6 ports. P3.4~P3.6 ports are used to control chip selection, chip switching and recording/playback mode selection respectively. P3.2 port is used to judge whether the memory space of the chip is full or whether the information storage overflows. Because the mark is automatically inserted at the end of each information segment during recording, when the mark is encountered during playback, a negative pulse with a width of about 12.5 ms is generated. Before playing another recording, use P3.3 port to detect the rising edge of this pulse to avoid discontinuous voice playing.

2.4 Wireless transceiver circuit

The system uses the single chip wireless transceiver chip nRF24L0 1 produced by NORDIC Company, which works in the ISM band of 2.4 ~ 2.483 5 GHz, to complete the transmission and reception of wireless data. The highest transmission rate of nRF24L0 1 is 2 Mb/s, and the circuit is shown in Figure 6. The voltage stabilizing chip lm1117-3.3 V converts the 5 V input voltage into 3.3v to supply power to nRF24L0 1. The interface between nRF24L0 1 and MCU is four-wire SPI, and pins CSN, SCK, MOSI and MISO are chip select enable line, clock line, data input line and data output line of SPI respectively. IRQ is an interrupt signal line (active low), which is connected to the external interrupt pin of single chip microcomputer. The single chip microcomputer mainly communicates with nRF24L0 1 through this interface line to judge whether the data reception and data transmission are completed. CE is the RX/TX mode selection line of the chip. IREF is the reference current input terminal and is grounded through a 22kω resistor. Pins ANT 1 and ANT2 provide balanced RF output for the antenna, and a single-ended impedance output of 50 Ω is obtained through a simple RF network matching circuit. The network matching circuit prevents harmonics in the transmitting mode and suppresses local oscillation leakage in the receiving mode. The VDD_PA pin outputs a voltage of 1.8 V to supply power to the on-chip power amplifier.

2.5 data interface communication circuit

The communication between the receiving computer and the single chip microcomputer is completed by the serial USB interface integrated circuit CH340T, as shown in Figure 7. CH340T supports USB 1. 1 or USB2.0/USB3.0 communication, with emulation interface, can upgrade peripheral serial devices, support common MODEM contact signals, support IRDA standard SIR infrared communication, and provide RS23RS48RS422 interface and other functions. CH340T has built-in independent transceiver buffer, which supports simplex, half-duplex and full-duplex asynchronous serial communication, and the communication baud rate is 50 b/s ~ 2 MB/s. In Figure 7, the sending pin TXD of CH340T chip is reversely connected with a diode 1N400 1 to prevent this pin from injecting current back into the microcontroller. Add a 300 Ω current-limiting resistor on the receiving pin RXD to prevent the single chip microcomputer from re-injecting current into CH340T; Thereby preventing another chip which does not need power supply from continuing to work due to current backflow.

3 system software design

3. Software design of1lower computer

The program development and debugging of the lower computer are carried out in the integrated development environment of Keil μVision4, including the software design of transmitter and receiver.

3. Software design of1.1transmitter

The software flow of the transmitter is shown in Figure 8. After the microcontroller is powered on, the system is initialized, and the internal system variables of the microcontroller and external devices such as TLC154DM-16ISD2560, nRF24L0 1 are initially set. Then delay about 5 minutes to preheat the sensor TGS2620 to ensure the normal operation of the sensor; After the program is initialized, the system enters the monitoring state. If you press the alarm threshold setting key, enter the alarm limit setting mode; If the record key is pressed, the recording mode is entered; Then start A/D conversion to obtain the sampling data, and get the measured alcohol concentration value after filtering, scale conversion and system error correction. Compare this value with the alarm threshold, and if the result is "greater than" or "equal to", start the buzzer sounding program to give an audible alarm, prompting that the alcohol concentration exceeds the standard; Then the value is displayed on the DM- 162 LCD module in real time; Finally, it is judged whether the playback key is pressed. If pressed, search the storage address of the corresponding voice information in ISD2560 according to the alcohol concentration value and start playing; After playback, the value is sent by the sender of nRF24L0 1 to the receiver. After sending, collect, display and send a new round of alcohol concentration data.

The transmitter software preprocesses the A/D sampling data by anti-pulse interference average filtering method [9]. Its principle is: continuously sample k times, then compare these k sampled data, remove the maximum and minimum values, and calculate the arithmetic average of the remaining K-2 data as the effective sampling value. This method combines the advantages of median filtering method and arithmetic average filtering method, which can not only eliminate the pulse interference, but also eliminate the sampling value deviation caused by occasional pulse interference. In order to speed up the calculation, the digital filter is designed with K= 10.

In order to improve the real-time performance of the system, the software adopts piecewise linear interpolation method [10- 1 1] for scale transformation. The process is as follows: (1) According to the calibration curve of sensor TGS2620, divide the curve into non-equidistant segments (when the curvature changes greatly (slightly) and the sampling point spacing is small (greatly)), and select the coordinates (VRLi, ci) of each segment (I = 0, 1, ..., m). Where: (2) Calculate the slope ki of the fitted straight line between adjacent sampling points = (ci+1-ci)/(vrli+1-vrli) (i = 0,1,…, m-1); (3) storing m groups of coordinate data (VRLi, Ci) and the corresponding slope ki in the second sector (address: 2200H~23FFH) of the on-chip EEPROM; (4) Every time a voltage value VRL is collected, the EEPROM table is queried to find out the interval (VRLi, Ci)~(VRLi+ 1, Ci+ 1) where VRL is located, and the interval (VRLi, Ci) and ki data are taken out, and the linear interpolation formula C=Ci+ki(VRL-VRLi) is used.

Substitute the collected n sampling data (xi, yi) into equation (5) to get the values of coefficients a and b, and store them in the memory unit of the single chip microcomputer. In the system measurement, the corrected alcohol concentration value Y can be obtained by substituting the converted alcohol concentration measurement value X into the error correction equation y=ax+b, thus eliminating the system error.

3. 1.2 receiver software design

The software flow of the receiver MCU is shown in Figure 9. After the receiver is powered on, the program initializes nRF24L0 1 and serial port, and then enters the monitoring scene. When nRF24L0 1 receives a complete frame of alcohol concentration data, it will immediately send it to the upper computer through the serial port. The data interaction between MCU and PC at the receiving end adopts asynchronous communication mode. Independent baud rate, the serial port protocol is set as: baud rate 9 600 b/s, 8 data bits, 1 stop bit, no check bit.

3.2 Software design of upper computer

The user interface of the upper computer is developed by the general object-based programming language Microsoft Visual Basic 6.0, which realizes the reception, display and storage of alcohol concentration data. The software uses serial communication control MSComm. MSComm control is an ActiveX control provided by Microsoft for serial communication programming under Windows. By programming the properties and events of the control, serial communication can be easily realized. The serial communication protocol is exactly the same as the receiving end. The program flow of the upper computer software is shown in figure 10.

4 system testing

In order to test the measurement performance of this system, a standard alcohol solution is prepared with anhydrous alcohol and purified water according to a certain volume ratio. See table 1 for the test results. Where: the unit ppm=μg/mL represents the alcohol content in 1 mL alcohol solution. From the measurement results, it can be seen that the test data covers the range of the sensor, and the maximum relative error of the test is less than 2%, which is better than similar design products [3-5].

In order to obtain the maximum error-free communication distance between the transmitter and receiver of the instrument, the error rate (critical interval) of nRF24L0 1 is tested outdoors, and the results are shown in Table 2. Among them, the error rate per meter is1the average value calculated after 0 tests. It can be seen that the transmission distance of nRF24L0 1 can reach 100 m, which is slightly higher than RFID, ZIGBEE and Bluetooth wireless communication technologies [12].

5 Main technical indicators

The main technical indicators of this instrument are as follows: (1) measuring range: 50 ~ 5000 ppm;; ; (2) Sensitivity (sensor resistance change rate): 0.3 ~ 0.5; (3) Measurement accuracy: ≤ 2%; (4) Transmission distance: ≤100m; (5) Working power supply: DC+5V; ; (6) Working environment temperature:-40℃ ~+70℃; (7) Relative humidity of working environment: 0 ~ 85% RH.

6 concluding remarks

In this paper, an alcohol concentration detector based on STC90C52RC microcontroller, TGS2620 alcohol sensor and nRF24L0 1 wireless communication chip is designed and developed. The instrument has been put into practical production in a small brewery in Chengdu. The field work shows that the system runs normally and works reliably. The system has the advantages of high gas selectivity, high sensitivity, good stability, high intelligence, long communication distance, low power consumption, strong anti-industrial interference ability and high cost performance. The instrument can be used in food processing industry, industrial and mining enterprises, petrochemical industry, environmental detection and protection, social utilities, aerial workers, public security traffic management (such as drunk driving, traffic police law enforcement) and other occasions that need on-site detection or wireless telemetry of alcohol gas concentration, and has broad market application prospects and high promotion value.

refer to

Li Haitao. Remote vehicle-mounted intelligent monitoring system for drunk driving based on QNX [J]. Application of electronic technology, 2014,40 (8):136-139.

Song Xiaoyu, Gao Guowei, Li Shichuan, et al. Design of alcohol concentration detection system based on single chip microcomputer [J]. Sensor World, 2017,23 (8):18-23.

Lu and Tao Dajin. Design of alcohol concentration detector based on single chip microcomputer [J]. Microcomputer and its application, 2014,33 (22): 34-36.

Ge Yu. Design of vehicle-mounted alcohol detection control circuit based on GPRS/GPS [D]. Nanchang: Nanchang University, 20 10.

Zhang Zhe, Jin Tong, Chen Donghui, et al. Application of electronic nose based on air sensor array in beef freshness detection [J]. Journal of Bionics Engineering, 2008,5 (1): 67-73.

[6] Figaro Group. General information of TGS sensor [EB/OL]. (2008-04-23)[20 19-07-03]./2065 438+08 _ 05/d78-ffddd 177 E3 BCA . html

Hu Shibing, Chen

(School of Electronic Engineering, Chengdu University of Information Science and Technology, Chengdu, Sichuan 6 10225)