A Time Difference Ultrasonic Flowmeter and Its Simplified Algorithm

Vortex flowmeter has been widely used in many industries because of its advantages of strong medium adaptability, no moving parts, and simple structure. The traditional vortex flowmeter adopts the analog signal processing method, which has poor anti-interference ability, and generally uses 4-20mA analog output. Require.
Aiming at the problems existing in the low flow rate measurement and signal output of the vortex flowmeter, a vortex flowmeter with PROFIBUS-DP interface based on multi-processor technology was developed.

1 Overall system design
The overall design of the system is mainly divided into four parts: analog signal preprocessing circuit, control and transmission circuit, digital signal processing circuit and PROFIBUS-DP interface circuit from the perspectives of anti-interference, low power consumption and bus interface. The basic structure of the system is shown in Figure 1. The dual-core technology based on the combination of single-chip microcomputer and DSP can give full play to the powerful control function of MSP430 and the powerful data processing capability of DSP to solve the anti-interference problem of vortex flowmeter and improve the real-time and reliability of the system. The ultra-low power consumption DSP and single chip microcomputer in similar products are selected, and the system peripheral chip with low power consumption is selected; the high integration of the MSP430 single chip microcomputer and the powerful function of the HPI interface of the DSP are fully utilized, eliminating the need for an external 12-bit A/D and user interface. It is used to store the Flash ROM of the DSP program to reduce the power consumption of the system. SPC3 integrates the complete protocol of PROFIBUS-DP physical layer and data link layer, which provides an inexpensive configuration solution for the bus interface of the vortex flowmeter. The realization of the whole system is simple and convenient, which not only saves the cost, but also reduces the volume.

2 System hardware design
2.1 Analog signal preprocessing circuit
The analog signal preprocessing circuit includes charge amplifier, differential amplifier and anti-aliasing filter. The analog signal preprocessing circuit processes the collected charge signal in three aspects through an analog circuit with an operational amplifier as the main body: the charge amplifier at the input stage converts the alternating charge signal output by the piezoelectric detection element of the vortex sensor into a voltage signal ; Amplify the amplitude of the alternating signal through the amplification function of the differential amplifier and other stage circuits; realize the anti-aliasing filtering before the signal ADC (analog-to-digital conversion) through the anti-aliasing filter.
2.2 Control and transmission circuit
The control and transmission circuit takes the ultra-low power consumption MSP430F149 microcontroller as the core, and realizes functions such as parameter setting, data acquisition, data transmission, and display. The 12-bit A/D integrated in MSP430F149 realizes high-precision real-time data acquisition, and the rich external interface realizes the functions of keyboard operation, HPI simulation sequence, LCD display and external communication. This powerful control function is replaced by the DSF method.
2.3 Digital signal processing circuit
The digital signal processing circuit takes DSP as the core and MSP430 as the auxiliary circuit. The DSP selects TMS320C5416 (5416 for short), which is a 16-bit fixed-point general-purpose DSP chip with flexible operation, high speed and low power consumption. It can meet the requirements of large amount of calculation and real-time performance of the system. The data of the DSP comes from the data collected by the 12-bit A/D of the single-chip microcomputer. The high-speed communication between the DSP and the single-chip microcomputer is carried out through the host interface (HPI). When the DSP receives the data of the vortex signal, the frequency estimation method based on DFT is adopted. Digital signal processing is performed on the signal, and the processed result is sent back to the microcontroller. Figure 2 shows the connection diagram of the DSP and the HPI interface circuit of the single-chip microcomputer.
Apply the HPI interface to the Bootloader of the DSP, that is, store the program of the DSP in the Flash of the MCU (there is no program memory in the DSP), and when the system starts, write the program from the MCU to the RAM of the DSP through the HPI port in the way of Bootloader. In the middle of the process, start the DSP, so that the DSP starts normal signal processing, which saves a piece of FlashROM used to store programs for the DSP; The data is then transmitted to the RAM of the DSP through the HPI interface, the DSP processes the data again, and the processed result is sent back to the microcontroller, thereby saving a piece of A/D and reducing power consumption.
2.4 PROFIBO-DP communication interface circuit
MSP430F149 is a microcontroller without external expansion bus. When it interfaces with SPC3, it can allocate some I/O ports as the address, data and control bus interface of SPC3 in Intel mode. The interface timing is realized by programming software.
MAP430F149 manages communication affairs as a processor unit, and SPC3 protocol chip completes data conversion and sending and receiving functions. When SPC3 selects Intel chip mode and works in synchronous mode, the internal address latch and decoding circuit work, so the lower 8-bit address line of the CPU is directly connected to SPC3 without going through the 573 latch (the lower 8-bit address line is connected to the 8-bit address line. The data line is time-sharing and shared transmission line), and the P4 port is multiplexed as A/DBUS. The high-order 8-bit address lines of the CPU are directly connected to AB0-AB7 of SPC3, and must be 00000XXX (X means both 0 and 1 signals). Here, AB3~AB10 of SPC3 are grounded, and AB0~AB2 are connected to P1.6, P1.4, and P1.5 of the single-chip microcomputer, which are used as AB8~AB10 address lines. At this time, the input pin XCS of the chip selection signal does not work, and it is connected to a high level; the address latch signal ALE works, and it is connected to the processor P1.7. The CPU and SPC3 exchange data through the dual-port RAM of SPC3. The dual-port RAM of SPC3 should allocate addresses uniformly in the CPU address space, and the CPU regards this piece of RAM as its own external RAM.
Because MSP430F149 uses low power supply voltage 3.3 V to supply power, while SPC3 uses 5 V to supply power, it is necessary to consider the coexistence of 3 V logic system and 5 V logic system in hardware design. In order to avoid damage to components and loss of data, two dedicated SN74LVCC4245A level conversion chips are used here, which are bidirectional I/O level converters with an 8-bit width; the interrupt signal X/INT is divided by a simple resistor. The method is connected to P1.0.
The four pins used for serial communication when the SPC3 is connected to the transceiver are XCTS, RTS, TXD and RXD. XCTS is the clear to send input signal pin of SPC3, which means that SPC3 is allowed to send data, and the low level is valid, and it is always connected to the low level here. RTS is the output enable terminal of the SPC3 request to send signal receiver transmitter. RXD and TXD are serial receive and transmit ports, respectively. In order to improve the anti-interference of the system, the internal circuit of SPC3 must be electrically isolated from the physical interface. Here, the HCPL7721 high-speed optocoupler with a rate of up to 25 Mb/s is adopted, and the transceiver adopts sN75ALS176, which is sufficient for the application of this system.

3 System software design
3.1 The software design of the microcontroller part
The task of the one-chip computer part is to complete parameter setting, data sampling, Bootloader for DSP, data display, data transmission and so on. The program is designed in accordance with the modular design idea, and is mainly divided into four modules: data sampling program, HPI communication program, liquid crystal display program, and remote transmission program. The main program flow chart is shown in Figure 4.
3.2 Software design of DSP part
First, make the DSP work in the Bootloader state of HPI mode, and prepare to receive the program code transmitted by the microcontroller. After the program transmission is completed, the Bootloader state ends, and the DSP enters normal work. Street signal data, after receiving the data, digital signal processing is performed on the received data, and the processing result is sent back to the single-chip microcomputer through the HPI port. The software design flow chart of the DSP part is shown in Figure 5.
3.3 Software design of SPC3 part
The SPC3 communication module program adopts a structured and modular approach, including four parts: the main program, the interrupt module, the subprogram module and the program header file. The flow chart of the main program of the communication interface is shown in Figure 6. The initialization of SPC3 in the main program is very important, and it is related to whether it can work normally. The initialization process is as follows: reset the watchdog, set the SPC3 to allow interrupts, write the slave identification number and address, set the mode register, set the diagnostic buffer, parameters, configuration buffer length, set the address buffer length, and calculate the length of each buffer. The pointer and the pointer of the auxiliary buffer determine the pointer of the input and output buffer according to the data length of the input and output.

4 Conclusion
Aiming at the shortcomings of the traditional vortex flowmeter, a set of low-power digital vortex signal processing system is constructed by combining the powerful control function of the single-chip microcomputer with the powerful computing power of the DSP and its low power consumption. The power consumption is reduced and its accuracy in the field environment is improved. And designed the communication interface of PROFIBUS-DP bus to realize long-distance data transmission. In addition, it is equipped with a liquid crystal display module, which provides a friendly man-machine interface. The system provides a reference for the independent development of fieldbus instruments, and has broad market application prospects.


Post time: 26-01-22