High precision pressure transmitter based on MSP430 single chip microcomputer
Introduction:
The output of the sensor is not only affected by the pressure, but also by other external non-target parameters, which results in the cross-sensitivity of the sensor and affects the output accuracy. In order to solve this problem, the main temperature compensation, including linear interpolation, least square method, neural network algorithm and so on. BP network method is a good method in neural network, by establishing BP network, using its ability to approximate any nonlinear function with any precision to carry out data fitting. The MSP430 is an ultra-low-power, peripheral-rich microcontroller. MSP430 was used to collect the pressure output of the sensor and the temperature value of the environment as the input sample of BP network training for off-line training, and the weight and threshold values were modified to the maximum extent. The output of the transmitter was controlled by the trained weight array and threshold array, and its structure was programmed with C language. To achieve the purpose of BP network data fusion.
1 System hardware design
1.1 Chip Selection
MSP430 single chip microcomputer is a system with high integration and high precision. It uses a streamlined instruction set and is a 16-bit high-speed processing MCU. The system runs relatively stable and has strong processing capacity. It has A wealth of peripheral modules, such as A/D module, D/A module, etc., in use to reduce the volume of peripheral space. The MSP430 series microcontroller has ultra-low power consumption and powerful data processing capability. Considering that the array needs to carry out a large number of floating point operations after BP network training, and the switching capability of its chip is very rich, the TPM microcontroller of MSP430 series is selected.
1.2 Hardware circuit design
The overall block diagram of hardware circuit design is shown in Figure 1. Pressure or hydraulic pressure acts on the front pressure sensor. The pressure sensor input the voltage signal of pressure and temperature to the amplifier, and the amplifier signal is amplified and input to the A/D conversion channel of the MCU. The single chip computer converts the voltage signal of pressure and temperature into digital quantity for processing, displays it through LED, and transmits the data to the upper computer through RS485 communication interface. The power module provides 3. At 3v and 5v voltages, the entire circuit is implemented as follows:
(1) Pressure sensor MPM280 pressure sensor, MPM280 detection circuit form Wheatstone bridge, using 1.5mA DC power supply.
(2) Power module design. MSP430 needs 3.3V voltage power supply, and other peripherals need 5V voltage power supply. The input power supply is processed by voltage transformer. Special chips LM317, TPS76950 and TPS76933 are used here. The voltage is converted to + 1v power output by the LM317, which powers the TPS7693 and TPS76950 chips, respectively, and the TPS769 33 and TPS76950 convert 10V voltage to 3.3V and 5V voltage output to the MCU and MCU peripherals.
(3) Signal amplifier circuit. The core amplifier chosen here is the IN A 121, which is A low-power, high-precision differential pressure amplifier that can operate IN both single-power and dual-power modes. After the pressure force measured by the pressure sensor is converted into the input voltage signal to pin 3 and pin 2 of INA 12 1, the amplification of the amplifier can be adjusted according to the external resistance. The amplified voltage signal is sent to the A/D conversion channel of the MCU through pin 6 ina121 to realize the amplification function.
(4) A/D conversion part. The ADC12 module of MSP430F247 single-chip microcomputer is used to realize A/D conversion directly. The MSP430F247T PM itself has A 2-channel conversion interface, and realizes A/D conversion of 2-channel analog signals of temperature and pressure through the control register of the ADC12 module. ADC12 built-in reference power supply, ADC12 analog multiplexer can time sequence conversion of temperature and pressure signals, and has the function of sampling and holding, ADC12 hardware through the setting will automatically convert the result to the corresponding register.
(5) RS-485 communication circuit and display circuit. The RS-485 communication circuit module uses a dedicated chip MAX485, and the LED display uses a driver chip SH J74A HC373.
2 System software design
The core of the system software implementation is the connection relationship between the weights and thresholds obtained by BP network training. The weights and thresholds are based on array operation and tansig incentive function for each layer of neuron output. The weights and thresholds of the neural network are obtained by training the training samples in the MATLAB neural network toolbox. The collection of training samples here is to magnify the output voltage values of pressure signals and temperature signals and input them to the single chip microcomputer. After A/D conversion, digital quantities are obtained, and the digital quantities are directly applied for off-line training to obtain the weight and threshold values of the neural network. The advantage of direct A/D value training is to reduce the voltage loss of voltage A/D conversion. The output accuracy is improved. The test samples are used to detect the trained neural network. When the requirements are met, the connection relationship between the trained weight and the threshold value is expressed in C language and transplanted to the single chip microcomputer to process signals and complete the requirements of the control algorithm.
2.1 BP network algorithm
BP network is the most widely used neural network model, it is divided into input layer, hidden layer and output layer 3 layers, the layer and the layer between the mode of full interconnection, the same layer of the unit there is no mutual connection. The input mode of forward propagation is processed layer by layer from the input layer through the hidden layer and transmitted to the output layer. If the output layer does not get the expected result, the error signal is returned along the original path and the weight of each layer is modified to be propagated in reverse phase until the error is minimal and the desired target value is finally achieved.
2.2 Collection of test samples and data processing
The equipment required for the collection of test samples are: MPM 280 pressure sensor, pressure sensor signal control circuit board, standard pressure gauge, pressure transducer high and low temperature test box, test computer, MSP430 download cable. Connect the pressure transducer to the pressure sensor test temperature box, connect the 4 wires of the pressure sensor to the pressure sensor signal control circuit board, the communication interface on the circuit board is connected to the main machine, and one end of the MSP430 lower load line is connected to the monolithic machine JTA G. The other end is connected to the host in the collection of test samples and test samples of the neural network. The work completed by the single chip machine is power-on initialization, A/D conversion of temperature and pressure, and the converted data is sent to the host through RS485 communication to display. Record the A/D sampling values of temperature and pressure, in which the reference voltage selected for the A/D sampling value is the set voltage in the chip machine 1. 5 V, the measured data are shown in Table 1.
As can be seen from Table 1: The A/D sampling value of the zero point of the original pressure sensor shifts from 223 at -40℃ to 185 at 80 ℃, and the full point shifts from 3 961 at 40℃ to 3 016 at 80 ℃. In addition, under the same pressure, the A/D sampling value of different temperature points is also different. It can be seen that there is a large temperature drift, so temperature compensation is required.
In order to test the control performance of BP network after training, sample detection of BP network is required. At this time, the data after simulation of neural network tool box is required to be reverse-normalized. The purpose of inverse normalization is to map the number between 0.05 and 0.95 output by the neural network to the desired interval value. The inverse normalization formula is
Where: P is the pseudo-output value of the neural network; P, where P is the maximum and minimum value of the pressure scaling value in the training sample under normalization; P is the final data fusion value.
2.3 Establishment and training of BP network
Open the command window interface of MATLA B, enter nntool in the main interface of neural network toolbox, and build a 4-layer BP network. The first layer is the input layer, which is composed of two neurons and is the numerical input after the normalization of the temperature and pressure A/D sampling values. The first hidden layer has five neurons, and the second hidden layer has four neurons. The output layer is a neuron, which represents the pressure output after processing, and the excitation function of each layer is the tansig function. The input and target values of normalized training samples were imported into the neural network toolbox, and the training samples were selected as 40℃, 30℃, 20℃, 10℃, 0℃, 20 qC, 30℃, 20℃, 60℃. Sample the temperature and pressure of 10 temperature points at 80℃, select the temperature and pressure A/D samples at 10℃ as the test samples, set the training parameters on the training TAB of MAIAB neural network toolbox, and click the TR AIN button for training. If the error is not minimized after the maximum training times are reached, continue training. When the training error is no longer reduced, the training is stopped, and the error at this time is 3.225 × 101, and the training times reach 2,899 times. In order to verify the effectiveness and accuracy of the neural network for temperature compensation of the sensor, the collected data is input into the neural network for detection, and the output value is reverse-normalized to obtain the fusion value. The neural network fusion values of training samples and test samples are shown in Table 2.
Table 1 Sampling values of temperature and pressure A/D
As can be seen from Table 2, when the ambient temperature ranges from -40 ℃ to 80℃, the error of BP network data fusion value is 0.08%, it can be seen that the BP network is highly accurate for temperature compensation data fusion. Check the weight and threshold of BP network in MATLAB neural network toolbox to obtain the connection relationship. The data control algorithm of the pressure sensor is realized by programming. View weights and thresholds for the Neural Network toolbox. The maximum and minimum values of each trained array and temperature and pressure A/D sampling values are programmed by c language to complete the algorithm control.
2.4 System software implementation
After BP network training, the weights and thresholds that meet the requirements of control training are obtained, and their connection relationships are programmed and transplanted to the single chip computer to complete the signal processing needs. In the whole system, the work completed by the single chip microcomputer mainly includes: power-on initialization, including the watchdog off, crystal initialization, LED and communication module initialization, etc. Perform temperature and pressure A/D conversion, including sampling frequency setting, reference voltage selection, ADC12 module setting, average data filtering, etc. The sample values of _AiD of temperature and pressure are normalized, and the maximum and minimum values of normalized temperature and pressure are the same as the maximum and minimum values selected by BP network training. The two dimensional array of temperature and pressure signals is input into the weight connection of neural network training to realize signal processing, and the output values are reverse-normalized. The anti-normalized processing signal is sent out through the LED display and through the RS-485 communication interface. Its program design flow diagram is shown in Figure 4.
3. Closing remarks
The neural network is a large-scale nonlinear system, which has the ability of self-adaptation and self-learning. Through its own data fusion, the cross-spirit sensitivity of the pressure sensor is eliminated, the temperature compensation is carried out, and the precision of the pressure sensor is improved. Experimental results show that: After off-line training of neural network, the data fitting model is obtained, and the real-time signal processing can achieve good zero point compensation characteristics and good time-drift suppression characteristics. The volume of pressure sensor is reduced by using the rich peripherals of ultra-low power MCU MSP430. The A/D values of pressure and temperature collected by MSP430 microcontroller are used for off-line training, which improves the precision of pressure sensor. The design has been made samples, meet 0. 1% accuracy required.
References:
[1] Temperature compensation of diffused silicon pressure sensor by two data fusion algorithms. Computer Measurement and Control, 2008, 16 (9) : 1363-1365
[2] Shen Jianhua. Yang Yanqin. Principle and practice of 16-bit ultra-low power single-chip microcomputer of MSP430 series. Beijing: Beijing University of Aeronautics and Astronautics Press, 2008:1-100. (in Chinese)
[3] Liu Junhua. Intelligent sensor system. Xi 'an: Xidian University Press, 2004:1-5O. (in Chinese)
[4] Cong Shuang. The theory and application of neural networks in the planar metatrab toolbox. Hefei: University of Science and Technology of China Press, 2003:55-85. (in Chinese)
[5] He Ping, Pan Guofeng, Sun Yicai, et al. RBF network model for temperature drift compensation of pressure sensor. Chinese Journal of Scientific Instrument, 2008, 29 (3) : 572-576.
[6] Zhang Yaofeng, Sun Yicai. Pressure sensor wireless data acquisition system based on BP neural network temperature compensation. Sensor World, 2008 (1) : 36-39.
[7] Wang Fuchang, Zhang Baolei, Zhang Tongqing. Neural network tool nntool and its application. Computing Machines and Modernization, 2003 (9) : 84-85.
[8] Gao Feng, Dong Haiying, Hu Yankui. Sensor cross sensitivity suppression based on BP channel network. Sensor Technology, 2005, 24 (2) : 22-26. About the Author: Zhang Jianjun, (198 31), Master candidate. His research interests are industrial automation and intelligent control.