CN101706299A - Coriolis mass flow transmitter based on DSP - Google Patents
Coriolis mass flow transmitter based on DSP Download PDFInfo
- Publication number
- CN101706299A CN101706299A CN200910185560A CN200910185560A CN101706299A CN 101706299 A CN101706299 A CN 101706299A CN 200910185560 A CN200910185560 A CN 200910185560A CN 200910185560 A CN200910185560 A CN 200910185560A CN 101706299 A CN101706299 A CN 101706299A
- Authority
- CN
- China
- Prior art keywords
- dsp
- data
- frequency
- signal
- signals
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000004422 calculation algorithm Methods 0.000 claims abstract description 68
- 238000001914 filtration Methods 0.000 claims abstract description 24
- 230000003044 adaptive effect Effects 0.000 claims abstract description 18
- 230000003750 conditioning effect Effects 0.000 claims abstract description 13
- 230000003321 amplification Effects 0.000 claims abstract description 6
- 238000003199 nucleic acid amplification method Methods 0.000 claims abstract description 6
- 239000003990 capacitor Substances 0.000 claims description 57
- 238000004364 calculation method Methods 0.000 claims description 32
- 238000012545 processing Methods 0.000 claims description 31
- 238000005070 sampling Methods 0.000 claims description 29
- 238000000034 method Methods 0.000 claims description 28
- 230000006870 function Effects 0.000 claims description 26
- 238000005259 measurement Methods 0.000 claims description 18
- 101100162020 Mesorhizobium japonicum (strain LMG 29417 / CECT 9101 / MAFF 303099) adc3 gene Proteins 0.000 claims description 13
- 230000005540 biological transmission Effects 0.000 claims description 13
- 238000006243 chemical reaction Methods 0.000 claims description 12
- 238000012935 Averaging Methods 0.000 claims description 8
- 230000002093 peripheral effect Effects 0.000 claims description 7
- 238000003491 array Methods 0.000 claims description 6
- 101100434411 Saccharomyces cerevisiae (strain ATCC 204508 / S288c) ADH1 gene Proteins 0.000 claims description 5
- 101150102866 adc1 gene Proteins 0.000 claims description 5
- 239000012530 fluid Substances 0.000 claims description 5
- 239000000463 material Substances 0.000 claims description 5
- 239000004973 liquid crystal related substance Substances 0.000 claims description 4
- 238000007781 pre-processing Methods 0.000 claims description 4
- 101150042711 adc2 gene Proteins 0.000 claims description 3
- 230000000694 effects Effects 0.000 claims description 3
- 238000000691 measurement method Methods 0.000 claims description 3
- 101100156949 Arabidopsis thaliana XRN4 gene Proteins 0.000 claims description 2
- 101100215777 Schizosaccharomyces pombe (strain 972 / ATCC 24843) ain1 gene Proteins 0.000 claims description 2
- 238000002474 experimental method Methods 0.000 claims description 2
- 230000003071 parasitic effect Effects 0.000 claims description 2
- 230000003068 static effect Effects 0.000 claims description 2
- 230000001629 suppression Effects 0.000 claims description 2
- 230000001360 synchronised effect Effects 0.000 claims 2
- 102100030891 Actin-associated protein FAM107A Human genes 0.000 claims 1
- 101001063917 Homo sapiens Actin-associated protein FAM107A Proteins 0.000 claims 1
- 101150016871 LTI6B gene Proteins 0.000 claims 1
- 101100370098 Saccharomyces cerevisiae (strain ATCC 204508 / S288c) TOR2 gene Proteins 0.000 claims 1
- 238000007493 shaping process Methods 0.000 claims 1
- 238000001514 detection method Methods 0.000 abstract description 3
- 230000008569 process Effects 0.000 description 18
- 238000012546 transfer Methods 0.000 description 12
- 238000010586 diagram Methods 0.000 description 8
- 230000008859 change Effects 0.000 description 5
- 230000007423 decrease Effects 0.000 description 5
- 239000011324 bead Substances 0.000 description 4
- 230000000903 blocking effect Effects 0.000 description 4
- 238000012937 correction Methods 0.000 description 4
- 238000005516 engineering process Methods 0.000 description 4
- 230000004044 response Effects 0.000 description 4
- 102100024061 Integrator complex subunit 1 Human genes 0.000 description 3
- 101710092857 Integrator complex subunit 1 Proteins 0.000 description 3
- 238000004891 communication Methods 0.000 description 3
- 239000013078 crystal Substances 0.000 description 3
- 230000001186 cumulative effect Effects 0.000 description 3
- 125000004122 cyclic group Chemical group 0.000 description 3
- 238000013461 design Methods 0.000 description 3
- 238000012544 monitoring process Methods 0.000 description 3
- 238000004088 simulation Methods 0.000 description 3
- 108010076504 Protein Sorting Signals Proteins 0.000 description 2
- 238000013475 authorization Methods 0.000 description 2
- 230000035772 mutation Effects 0.000 description 2
- 238000001228 spectrum Methods 0.000 description 2
- 238000012360 testing method Methods 0.000 description 2
- 239000002699 waste material Substances 0.000 description 2
- NAWXUBYGYWOOIX-SFHVURJKSA-N (2s)-2-[[4-[2-(2,4-diaminoquinazolin-6-yl)ethyl]benzoyl]amino]-4-methylidenepentanedioic acid Chemical compound C1=CC2=NC(N)=NC(N)=C2C=C1CCC1=CC=C(C(=O)N[C@@H](CC(=C)C(O)=O)C(O)=O)C=C1 NAWXUBYGYWOOIX-SFHVURJKSA-N 0.000 description 1
- 102100030147 Integrator complex subunit 7 Human genes 0.000 description 1
- 101710092890 Integrator complex subunit 7 Proteins 0.000 description 1
- 101150051106 SWEET11 gene Proteins 0.000 description 1
- 230000002159 abnormal effect Effects 0.000 description 1
- 230000005856 abnormality Effects 0.000 description 1
- 230000001010 compromised effect Effects 0.000 description 1
- 230000008878 coupling Effects 0.000 description 1
- 238000010168 coupling process Methods 0.000 description 1
- 238000005859 coupling reaction Methods 0.000 description 1
- 238000009795 derivation Methods 0.000 description 1
- 238000000605 extraction Methods 0.000 description 1
- 230000005669 field effect Effects 0.000 description 1
- 238000009499 grossing Methods 0.000 description 1
- 230000036039 immunity Effects 0.000 description 1
- 238000011423 initialization method Methods 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 238000013507 mapping Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000000737 periodic effect Effects 0.000 description 1
- 238000003672 processing method Methods 0.000 description 1
- 238000004904 shortening Methods 0.000 description 1
- 230000008054 signal transmission Effects 0.000 description 1
- 238000010183 spectrum analysis Methods 0.000 description 1
- 230000002277 temperature effect Effects 0.000 description 1
- 230000009466 transformation Effects 0.000 description 1
- 230000005514 two-phase flow Effects 0.000 description 1
Images
Landscapes
- Measuring Volume Flow (AREA)
Abstract
本发明涉及流量检测领域,为一种基于DSP的科氏质量流量变送器,包括放大滤波电路、模数转换器1、模数转换器2、电压基准源、电压跟随器、电流源、差分放大器、模数转换器3、模拟驱动模块、数字信号处理器DSP最小系统、外扩SRAM、外扩EEPROM、人机接口、4~20mA电流输出及脉冲输出、电源模块以及软件。模拟驱动模块激励科氏质量流量传感器内部的激振器,使流量管以固有频率振动。位于流量管两侧的两个磁电式传感器输出两路正弦波信号,两路信号经两路参数相同的调理电路放大、滤波后分别被两个相同型号的模数转换器同时采样并转换为数字量,通过DSP的两个多通道缓冲串口送入DSP。DSP采用数字滤波消除信号的噪声,自适应格型陷波滤波器计算频率,再采用计及负频率的DTFT算法计算相位差,最终得到质量流量。
The invention relates to the field of flow detection, and is a DSP-based Coriolis mass flow transmitter, including an amplification filter circuit, an analog-to-digital converter 1, an analog-to-digital converter 2, a voltage reference source, a voltage follower, a current source, a differential Amplifier, analog-to-digital converter 3, analog drive module, digital signal processor DSP minimum system, externally expanded SRAM, externally expanded EEPROM, man-machine interface, 4-20mA current output and pulse output, power supply module and software. The analog drive module excites an exciter inside the Coriolis mass flow sensor, causing the flow tube to vibrate at its natural frequency. The two magnetoelectric sensors located on both sides of the flow tube output two sine wave signals. The two signals are amplified and filtered by two conditioning circuits with the same parameters. After being sampled and converted into The digital quantity is sent to the DSP through two multi-channel buffered serial ports of the DSP. DSP uses digital filtering to eliminate signal noise, adaptive lattice notch filter to calculate frequency, and then uses DTFT algorithm considering negative frequency to calculate phase difference, and finally obtains mass flow rate.
Description
技术领域technical field
本发明涉及流量检测领域,为一种基于DSP的科氏质量流量变送器,特别是一种采用数字滤波对信号进行滤波、自适应格型陷波滤波器计算信号频率,再采用计及负频率的DTFT算法计算相位差的科氏质量流量计信号处理系统和模拟驱动系统。The invention relates to the field of flow detection, and is a DSP-based Coriolis mass flow transmitter, in particular, a digital filter is used to filter the signal, an adaptive lattice notch filter is used to calculate the signal frequency, and then a negative The frequency of the DTFT algorithm is used to calculate the phase difference of the Coriolis mass flowmeter signal processing system and the analog drive system.
背景技术Background technique
科里奥利质量流量计(以下简称为科氏质量流量计)可以直接测量质量流量,是当前发展最为迅速的流量计之一,具有广阔的应用前景。科氏质量流量计由两部分组成,一是传感器部分,包括磁电式速度传感器、激振器和温度传感器,二是变送器,包括信号调理、处理部分和驱动部分。就信号调理和处理部分来说,要求其精确地测量来自两个流量(磁电式速度)传感器信号的相位差,并跟踪其频率的变化。国外率先将数字信号处理技术和数字信号处理器(DSP)应用于科氏质量流量计中。The Coriolis mass flowmeter (hereinafter referred to as the Coriolis mass flowmeter) can directly measure the mass flow rate. It is one of the most rapidly developing flowmeters and has broad application prospects. The Coriolis mass flowmeter is composed of two parts, one is the sensor part, including the magnetoelectric speed sensor, exciter and temperature sensor, and the other is the transmitter, including the signal conditioning, processing part and driving part. As far as the signal conditioning and processing part is concerned, it is required to accurately measure the phase difference of the signals from the two flow (magnetoelectric speed) sensors and track changes in their frequency. Foreign countries take the lead in applying digital signal processing technology and digital signal processor (DSP) to Coriolis mass flowmeters.
(1)基于离散傅里叶变换的方法(1) Method based on discrete Fourier transform
美国Micro Motion公司用离散傅里叶变换(DFT)处理科里奥利质量流量计的输出信号(Paul Romano.Coriolis mass flow rate meter having a substantially increased noise immunity.US Patent No.4934196,Jun.19,1990),用TMS系列的数字信号处理器(DSP)作为二次仪表的处理核心。当非整周期采样时,DFT的计算误差不能满足仪表精度的要求,为此,提出了粗测、细测和频率跟踪的思路。但是,对其中的一些关键技术没有披露。例如,当频率变化时,如何采集过零点,等。合肥工业大学参考其思路,研制了采用DFT的、基于ADSP系列的DSP的信号处理系统,解决了美国专利中没有说明的技术难点,并在细测和频率跟踪方面做了改进(徐科军,于翠欣等.科氏质量流量计数字信号处理系统,发明专利,专利号:ZL 00108414.3,申请日:2000.4.30.,授权公告日:2002.12.4.)。American Micro Motion company uses discrete Fourier transform (DFT) to process the output signal of Coriolis mass flow meter (Paul Romano.Coriolis mass flow rate meter having a substantially increased noise immunity.US Patent No.4934196, Jun.19, 1990), using the TMS series digital signal processor (DSP) as the processing core of the secondary instrument. When non-full-period sampling is performed, the calculation error of DFT cannot meet the requirements of instrument accuracy. Therefore, the ideas of rough measurement, fine measurement and frequency tracking are proposed. However, some key technologies are not disclosed. For example, when the frequency changes, how to collect zero-crossing points, etc. Hefei University of Technology developed a DFT-based signal processing system based on the ADSP series DSP with reference to its ideas, which solved the technical difficulties not described in the US patent, and made improvements in fine measurement and frequency tracking (Xu Kejun, Yu Cuixin et al. Coriolis mass flowmeter digital signal processing system, invention patent, patent number: ZL 00108414.3, application date: 2000.4.30., authorization announcement date: 2002.12.4.).
(2)基于信号幅值的方法(2) Method based on signal amplitude
日本富士公司(Yoshimura Hiroyuki.Phase difference measuring apparatus for measuringphase difference between input signals.European patent application,EP0791807A2,27.08.1997;Yoshimura Hiroyuki.Phase difference measuring apparatus andflowmeter thereof.European patent application,EP 0702212A2,20.03.1996)对来自科氏质量流量计中两个传感器的信号进行放大,同时将这两个信号送入差动放大器,得到两个传感器的信号之差。多路转换器将这三个信号顺序送入模数转换器,送入DSP做DFT,计算出两个传感器信号的相位差,并从中选一个信号作为参考,去补偿各个传输通道特性差异所造成的误差。此方法的问题是:两个传感器信号的相位差很小(一般小于4度),故差动放大器的幅值很小,极易受到噪声干扰;补偿方法耗时太多,因为计算一次相位差需要采集6路信号。日本富士公司(Yoshimura Hiroyuki.Phase difference measuring apparatus for measuringphase difference between input signals.European patent application,EP0791807A2,27.08.1997;Yoshimura Hiroyuki.Phase difference measuring apparatus andflowmeter thereof.European patent application,EP 0702212A2,20.03.1996)对The signals from the two sensors in the Coriolis mass flowmeter are amplified, and the two signals are sent to the differential amplifier at the same time to obtain the difference between the signals of the two sensors. The multiplexer sends these three signals to the analog-to-digital converter sequentially, and sends them to the DSP for DFT to calculate the phase difference of the two sensor signals, and select one signal as a reference to compensate for the difference in the characteristics of each transmission channel. error. The problem with this method is: the phase difference of the two sensor signals is very small (generally less than 4 degrees), so the amplitude of the differential amplifier is very small, and it is very susceptible to noise interference; the compensation method takes too much time, because the calculation of the phase difference once Need to collect 6 signals.
(3)基于自适应线性增强的方法(3) Method based on adaptive linear enhancement
1996年9月10日授予H.V.Derby等人的美国专利US-5555190以及1998年8月12日授予的中国专利CN-1190461A中设计了一个基于DSP的数字信号处理系统.在DSP中采用了自适应线性增强(ALE)技术和装置,准确地确定振动流管之间的频率和相位关系,从而更精确地确定流经质量流量计的质量流量.Derby的专利有两个实施例,每一个实施例信号处理环节都由三部分组成:多抽一滤波、频率估计/线性增强和相位差计算.两实施例的多抽一部分采用(8∶1和6∶1两级抽取),相位差计算采用改进的Goertzel算法.两实施例只是频率估计/线性增强部分有所不同,第一个实施例的ALE是通过同时对两参数估计的自适应陷波滤波器(ANF)来实现的,第二个实施例使用了四个自适应陷波滤波器,在左信道和右信道分别串联两个陷波滤波器.Derby的专利的缺点是:对第一实施例,对两参数进行估计增加了算法的复杂性;第二实施例中采用两个级联的ANF,算法的复杂程度比第一实施例更高,而且,由于第二级的ANF是以第一级的ANF为基础的,只有在第一级收敛后第二级才会收敛,因此对于频率变化较大的情况下,收敛速度反而降低.同时,相位差计算部分采用的Goertzel算法,用定点实现时有可能发生溢出.A DSP-based digital signal processing system was designed in the US patent US-5555190 granted to H.V.Derby et al. on September 10, 1996 and the Chinese patent CN-1190461A granted on August 12, 1998. Adaptive Linear Enhancement (ALE) technique and apparatus to accurately determine the frequency and phase relationship between vibrating flow tubes to more accurately determine mass flow through a mass flow meter. Derby's patent has two embodiments, each of The signal processing link is composed of three parts: multi-decimation-filtering, frequency estimation/linear enhancement and phase difference calculation. The multi-decimation part of the two embodiments adopts (8:1 and 6:1 two-stage extraction), and the phase difference calculation adopts improved The Goertzel algorithm. The two embodiments are only different in the frequency estimation/linear enhancement part. The ALE of the first embodiment is realized by the adaptive notch filter (ANF) of the two parameter estimates simultaneously, and the second implementation The example uses four self-adaptive notch filters, and two notch filters are connected in series respectively in the left channel and the right channel. The shortcoming of Derby's patent is: for the first embodiment, the estimation of two parameters increases the complexity of the algorithm property; in the second embodiment, two cascaded ANFs are used, and the complexity of the algorithm is higher than that of the first embodiment, and, since the second-level ANF is based on the first-level ANF, only the first The second stage will converge after the first stage converges. Therefore, when the frequency changes greatly, the convergence speed will decrease instead. At the same time, the Goertzel algorithm used in the phase difference calculation part may overflow when it is implemented with fixed points.
针对这些问题,合肥工业大学设计了一种信号处理方法和装置,兼顾频率跟踪的精度和算法收敛速度,又不明显增加算法的复杂程度,而且用定点实现时不易溢出(徐科军,徐文福.基于AFF和SGA的科氏质量流量计数字信号处理系统,发明专利,专利号:ZL03108944.5,申请日:2003.4.4.,授权公告日:2005.3.23.)。信号处理环节由三部分组成:多抽一滤波、频率估计/线性增强和相位差计算。频率估计/线性增强部分采用漏斗型(Funnel)滤波器。滤波器有两个设计参数,对零极点进行了更强的限制,阶次也比同级的ANF高。在相位差计算部分采用更易于定点实现的、且非常适合于时变正弦信号的滑动Goertzel算法。但是,SGA算法的收敛过程还是较长,跟踪精度不够高,达不到科氏质量流量计精度要求;同时,用于实际系统时,计算量大,不易实时实现。In response to these problems, Hefei University of Technology designed a signal processing method and device, which takes into account the accuracy of frequency tracking and the convergence speed of the algorithm, without significantly increasing the complexity of the algorithm, and it is not easy to overflow when implemented with fixed points (Xu Kejun, Xu Wenfu. Coriolis mass flowmeter digital signal processing system based on AFF and SGA, invention patent, patent number: ZL03108944.5, application date: 2003.4.4., authorization announcement date: 2005.3.23.). The signal processing link consists of three parts: multi-decimation-filtering, frequency estimation/linear enhancement and phase difference calculation. The frequency estimation/linear enhancement part adopts the funnel type (Funnel) filter. The filter has two design parameters, which impose stronger restrictions on the zero and pole points, and the order is higher than that of the ANF of the same level. In the phase difference calculation part, the sliding Goertzel algorithm, which is easier to implement at fixed points and is very suitable for time-varying sinusoidal signals, is adopted. However, the convergence process of the SGA algorithm is still long, and the tracking accuracy is not high enough to meet the accuracy requirements of the Coriolis mass flowmeter; at the same time, when used in an actual system, the calculation amount is large and it is difficult to implement in real time.
发明内容Contents of the invention
本发明为了解决上述问题,采用以下技术方案:基于DSP的科氏质量流量变送器包括放大滤波电路、模数转换器1、模数转换器2、电压基准源、电压跟随器、电流源、差分放大器、模数转换器3、模拟驱动模块、数字信号处理器DSP最小系统、外扩静态随机存取存储器(SARAM)、外扩EEPROM(电可擦可编程只读存储器)、人机接口、4~20mA电流输出及脉冲输出、电源模块以及软件模块。模拟驱动模块激励科氏质量流量传感器内部的激振器,使流量管以固有频率振动。位于流量管两侧的两个磁电式传感器输出两路正弦波信号,两路信号经两路参数相同的调理电路放大、滤波后分别被两个相同型号的模数转换器同时采样并转换为数字量,通过DSP的两个多通道缓冲串口送入DSP。DSP采用数字滤波消除信号的噪声,自适应格型陷波滤波器计算频率,再采用负频率修正的离散时间傅里叶变换(DTFT)算法计算相位差,最终得到质量流量。In order to solve the above problems, the present invention adopts the following technical solutions: the Coriolis mass flow transmitter based on DSP includes an amplification filter circuit, an analog-to-
本发明专利的优点是:提高相位差计算精度,缩短收敛时间,用DSP研制出工业界可以接受和应用的系统,实时实现数字信号处理算法。The advantages of the patent of the present invention are: improving phase difference calculation accuracy, shortening convergence time, developing a system acceptable and applicable in the industry with DSP, and realizing digital signal processing algorithms in real time.
附图说明Description of drawings
图1为本发明系统的硬件总体框图。Fig. 1 is the overall block diagram of the hardware of the system of the present invention.
图2为本发明系统的信号调理、采集部分基准源。Fig. 2 is the reference source of the signal conditioning and acquisition part of the system of the present invention.
图3为本发明系统的模拟驱动。Fig. 3 is a simulation drive of the system of the present invention.
图4为本发明系统的信号调理、采集电路。Fig. 4 is the signal conditioning and acquisition circuit of the system of the present invention.
图5为本发明系统的温度补偿电路。Fig. 5 is a temperature compensation circuit of the system of the present invention.
图6为本发明系统的DSP最小系统。Fig. 6 is the DSP minimum system of the system of the present invention.
图7为本发明系统的外扩存储器及DSP启动方式选择。Fig. 7 is the selection of the externally expanded memory and the DSP startup mode of the system of the present invention.
图8为本发明系统的液晶和键盘电路。Fig. 8 is the liquid crystal and keyboard circuit of the system of the present invention.
图9为本发明系统的脉冲输出。Figure 9 is the pulse output of the system of the present invention.
图10为本发明系统的4~20mA电流输出。Fig. 10 is the 4-20mA current output of the system of the present invention.
图11为本发明系统的软件总体框图。Fig. 11 is an overall software block diagram of the system of the present invention.
图12为本发明系统的主监控程序流程图。Fig. 12 is a flow chart of the main monitoring program of the system of the present invention.
图13为本发明系统的INT1.4中断示意图。Fig. 13 is a schematic diagram of the INT1.4 interrupt of the system of the present invention.
图14为本发明系统的INT7.1与INT7.2中断示意图。Fig. 14 is a schematic diagram of INT7.1 and INT7.2 interrupts of the system of the present invention.
图15为本发明系统的信号采集传输过程示意图。Fig. 15 is a schematic diagram of the signal acquisition and transmission process of the system of the present invention.
图16为本发明系统的DMA中断服务程序流程图。Fig. 16 is a flow chart of the DMA interrupt service program of the system of the present invention.
图17为本发明系统的循环长数组。Fig. 17 is the cyclic long array of the system of the present invention.
图18为本发明系统的算法处理流程图。Fig. 18 is a flow chart of the algorithm processing of the system of the present invention.
图19为本发明系统的自适应格型陷波算法的流程图。Fig. 19 is a flow chart of the adaptive lattice notch algorithm of the system of the present invention.
图20为本发明系统的负频率修正的DTFT算法流程图。Fig. 20 is a flow chart of the DTFT algorithm for negative frequency correction of the system of the present invention.
图21为本发明系统的平均模块流程图。Fig. 21 is a flow chart of the averaging module of the system of the present invention.
图22为本发明系统的分段示意图。Fig. 22 is a schematic diagram of the segments of the system of the present invention.
图23为本发明系统的PWM波输出流程图。Fig. 23 is a flow chart of PWM wave output of the system of the present invention.
具体实施方式Detailed ways
本发明系统硬件框图如图1所示。本发明系统由科里奥利质量流量传感器(包括磁电式速度传感器A、磁电式速度传感器B、激振器、电阻温度传感器RTD)、放大滤波电路、模数转换器ADC1、模数转换器ADC2、电压基准源、电压跟随器、电流源、差分放大器、模数转换器ADC3、模拟驱动模块、数字信号处理器DSP最小系统、外扩SARAM、外扩EEPROM、人机接口、4~20mA电流输出及脉冲输出、电源模块组成。本发明系统按功能分为多个电路板,最主要的是模拟板和数字板,前者包括传感器信号调理及采集电路、模拟驱动电路和温度补偿电路;后者包括DSP最小系统及外扩存储器等。The hardware block diagram of the system of the present invention is shown in Fig. 1 . The system of the present invention consists of a Coriolis mass flow sensor (including a magnetoelectric speed sensor A, a magnetoelectric speed sensor B, an exciter, a resistance temperature sensor RTD), an amplification filter circuit, an analog-to-digital converter ADC1, an analog-to-digital conversion ADC2, voltage reference source, voltage follower, current source, differential amplifier, analog-to-digital converter ADC3, analog drive module, digital signal processor DSP minimum system, external expansion SARAM, external expansion EEPROM, man-machine interface, 4 ~ 20mA Composed of current output, pulse output, and power module. The system of the present invention is divided into a plurality of circuit boards according to functions, the most important ones are analog boards and digital boards, the former includes sensor signal conditioning and acquisition circuits, analog drive circuits and temperature compensation circuits; the latter includes DSP minimum systems and externally expanded memory, etc. .
本发明系统工作过程为:模拟驱动模块激励科里奥利质量流量传感器(以下简称科氏传感器)内部的激振器,使流量管以固有频率振动。位于流量管两侧的两个磁电式传感器输出两路正弦波信号,两路信号经两路参数相同的调理电路放大、滤波后分别被两个相同型号的ADC1和ADC2同时采样并转换为数字量,通过DSP的两个多通道缓冲串口McBSP口送入DSP计算两路信号相位差。DSP采用多抽一、自适应格型陷波滤波器对信号进行数字滤波,再采用计及负频率的DTFT算法计算相位差。流体温度影响流量管角弹性模量,从而影响测量值,所以需进行温度补偿。产生恒定电流流经科氏传感器内部温度传感器Pt100,Pt100两端电压经差分放大器放大后,被ADC3采样并转换为数字量送入DSP进行温度补偿的相关计算。将相位差转换为质量流量并加入温度补偿,将最终值在LCD上显示,并配有4~20mA电流输出及脉冲输出。The working process of the system of the present invention is as follows: the analog driving module excites the vibrator inside the Coriolis mass flow sensor (hereinafter referred to as the Coriolis sensor), so that the flow tube vibrates at a natural frequency. Two magnetoelectric sensors located on both sides of the flow tube output two sine wave signals, and the two signals are amplified and filtered by two conditioning circuits with the same parameters, and then they are simultaneously sampled and converted into digital by two ADC1 and ADC2 of the same model. The amount is sent to the DSP through two multi-channel buffered serial ports McBSP of the DSP to calculate the phase difference of the two signals. DSP adopts multi-pump and self-adaptive lattice notch filter to digitally filter the signal, and then uses DTFT algorithm considering negative frequency to calculate the phase difference. Fluid temperature affects the flow tube angular modulus and thus the measured value, so temperature compensation is required. A constant current is generated to flow through the internal temperature sensor Pt100 of the Coriolis sensor. After the voltage at both ends of the Pt100 is amplified by the differential amplifier, it is sampled by ADC3 and converted into a digital quantity and sent to the DSP for temperature compensation calculation. Convert the phase difference into mass flow and add temperature compensation, and display the final value on LCD, and it is equipped with 4-20mA current output and pulse output.
图2为信号调理、采集部分电压基准源。U10为基准源,其输出再经运放U11组成的电压跟随器,提高电流输出能力。C32、C33为输入、输出滤波电容;电容C37与U10内部电阻构成RC滤波器,对输出进行滤波;电容C34、C35、C36为输出滤波电容;C30、C38为退耦电容。Figure 2 shows the signal conditioning and acquisition part of the voltage reference source. U10 is the reference source, and its output passes through the voltage follower composed of operational amplifier U11 to improve the current output capability. C32 and C33 are input and output filter capacitors; capacitor C37 and the internal resistance of U10 form an RC filter to filter the output; capacitors C34, C35 and C36 are output filter capacitors; C30 and C38 are decoupling capacitors.
图3为模拟驱动电路。输入信号LP+经U16A、R31、R34构成的同相放大器放大后,送至由U16B、C51、R29、R27、C47、R26构成的带通滤波器滤波,R32、C55用于吸收U16B输出信号中的尖脉冲,电容C48、C50、C52、C53为退耦电容。U16B输出信号一路经U18B、R43、R46构成的同相放大器放大后送至模拟乘法器U19的一个输入端Y1;另一路送至整流电路,整流电路由U17A、U17B、R28、R30、R35、R36、R33、C56、D1、D2组成,将输入的交流信号整流为直流信号,其值与交流信号幅值成正比,电容C49、C54为退耦电容。整流电路输出TPE送至增益控制电路,增益控制电路由U18A、电阻R37、R39、R44、电位器W1、电容C65组成,其输出W随输入的增大而减小,反之亦然;电容C57、C62为退耦电容。U18A的输出送至模拟乘法器U1的另一个输入端X1,U19输出为X1与Y1的乘积。增益控制电路控制X1,就能控制U19的输出,当LP+减小时,X1增大;当LP+增大时,X1减小,达到稳定U19输出的目的。R38、R41为限流电阻,C58、C60、C64、C66为退耦电容。C61、R40、R42构成隔直电路,隔直后的信号经U20A、R45、R47构成的同相放大器放大,C59、C63为退耦电容,未使用的运放U20B接成跟随器并将输入接地。U20A输出TPM送至由U21B、U21A及外围器件构成的带振动过强保护的放大电路,以避免驱动电压过大造成传感器损坏。整流电路输出TPE接至U21A反相输入端,当TPE小于由电阻R50、电位器W2设定得值时,U21A的输出接近正电源电压,P沟道结型场效应管Q1导通,电阻R48与R55并联到地,放大倍数为6倍;反之,当TPE大于电阻R50、电位器W2的设定值时,U21A的输出接近负电源电压,Q1截止,放大倍数为1,起到了保护传感器的作用。电阻R52、电容C75对输入信号TPE滤波,R51为限流电阻,U21B、R49、R48、R55构成同相放大器,C73、R54为隔直电路,对输入信号TPM隔直,电容C67其滤波作用,电容C68、C70、C74、C76为退耦电容。U21B输出信号经C72、R53构成的隔直电路后,再经U22、R56、R57构成的功率放大器将电压放大2倍并提高输出功率后驱动激振器,电容C69、C71、C77、C78为退耦电容。Figure 3 is an analog drive circuit. After the input signal LP+ is amplified by the non-inverting amplifier composed of U16A, R31, R34, it is sent to the band-pass filter composed of U16B, C51, R29, R27, C47, and R26 for filtering, and R32 and C55 are used to absorb the peak in the output signal of U16B Pulse, capacitors C48, C50, C52, and C53 are decoupling capacitors. One output signal of U16B is amplified by the non-inverting amplifier composed of U18B, R43, and R46, and then sent to an input terminal Y1 of the analog multiplier U19; Composed of R33, C56, D1, and D2, the input AC signal is rectified into a DC signal, and its value is proportional to the amplitude of the AC signal. Capacitors C49 and C54 are decoupling capacitors. The output TPE of the rectifier circuit is sent to the gain control circuit. The gain control circuit is composed of U18A, resistors R37, R39, R44, potentiometer W1, and capacitor C65. The output W decreases with the increase of the input, and vice versa; the capacitor C57, C62 is a decoupling capacitor. The output of U18A is sent to the other input terminal X1 of the analog multiplier U1, and the output of U19 is the product of X1 and Y1. When the gain control circuit controls X1, it can control the output of U19. When LP+ decreases, X1 increases; when LP+ increases, X1 decreases to stabilize the output of U19. R38 and R41 are current limiting resistors, and C58, C60, C64 and C66 are decoupling capacitors. C61, R40, R42 constitute a DC blocking circuit, the signal after DC blocking is amplified by the non-inverting amplifier composed of U20A, R45, R47, C59, C63 are decoupling capacitors, and the unused operational amplifier U20B is connected as a follower and the input is grounded. The output TPM of U20A is sent to the amplifying circuit with over-vibration protection composed of U21B, U21A and peripheral devices to avoid sensor damage caused by excessive driving voltage. The output TPE of the rectifier circuit is connected to the inverting input terminal of U21A. When TPE is less than the value set by the resistor R50 and the potentiometer W2, the output of U21A is close to the positive power supply voltage, the P-channel junction field effect transistor Q1 is turned on, and the resistor R48 Connect R55 to the ground in parallel, and the magnification is 6 times; on the contrary, when TPE is greater than the set value of resistor R50 and potentiometer W2, the output of U21A is close to the negative power supply voltage, Q1 is cut off, and the magnification is 1, which protects the sensor effect. Resistor R52 and capacitor C75 filter the input signal TPE, R51 is a current-limiting resistor, U21B, R49, R48, and R55 form a non-inverting amplifier, C73 and R54 are DC blocking circuits, which block DC input signal TPM, and capacitor C67 has a filtering effect. C68, C70, C74, and C76 are decoupling capacitors. The output signal of U21B passes through the DC blocking circuit composed of C72 and R53, and then the power amplifier composed of U22, R56 and R57 amplifies the voltage by 2 times and increases the output power to drive the exciter. coupling capacitance.
图4是传感器信号调理、采集电路。信号RP+、RP-以差分形式接至U2输入端,经仪用放大器U2放大后送至由运放U3A及外围电阻、电容构成的二阶低通滤波器滤波后,再经R7、U4构成的限幅保护电路送入ADC U1的输入端。通过R8、R9将输入信号RP+、RP-接成差分形式,R2设置U2的放大倍数,C2、C6、C12、C14为退耦电容,R5、R6、R1、R12、C5、C10与运放U3A构成二阶低通滤波器,C3、C9、C11、C13为退耦电容,电容C90用来滤除U1中高频开关器件产生的高频干扰。Figure 4 is the sensor signal conditioning, acquisition circuit. The signals RP+ and RP- are connected to the input terminal of U2 in a differential form, amplified by the instrument amplifier U2, and sent to the second-order low-pass filter composed of the operational amplifier U3A and peripheral resistors and capacitors, and then filtered by the second-order low-pass filter composed of R7 and U4. The clipping protection circuit feeds into the input of ADC U1. The input signals RP+ and RP- are connected into a differential form through R8 and R9, R2 sets the amplification factor of U2, C2, C6, C12, and C14 are decoupling capacitors, R5, R6, R1, R12, C5, and C10 are connected to the operational amplifier U3A Constitutes a second-order low-pass filter, C3, C9, C11, and C13 are decoupling capacitors, and capacitor C90 is used to filter out high-frequency interference generated by high-frequency switching devices in U1.
U1为差分输入ADC1,信号接至AIN0(6脚),另一输入端AIN1(7脚)接2.5V基准源;U1所需基准取自外部2.5V基准源,VREF(4脚)接2.5V基准,VREFN(3脚)接地;U1的数据传输接口与DSP的多通道缓冲串口McBSP口连接:时钟SCLK(18脚)接MCLKXA,数据输入DIN(17脚)接MDXA,数据输出DOUT(16脚)接MDRA,片选CS接MFSXA,其中串联的电阻R3、R4、R10与U1相应管脚输入寄生电容构成RC低通滤波,滤除尖峰脉冲;控制管脚DRDY、SYNC接至DSP的GPIO口;电容C7、C8为滤波电容,电容C1、C4、C15、C17为退耦电容。U1 is a differential input ADC1, the signal is connected to AIN0 (pin 6), and the other input terminal AIN1 (pin 7) is connected to a 2.5V reference source; the reference required by U1 is taken from an external 2.5V reference source, and VREF (pin 4) is connected to 2.5V Reference, VREFN (pin 3) is grounded; the data transmission interface of U1 is connected to the multi-channel buffer serial port McBSP of DSP: the clock SCLK (pin 18) is connected to MCLKXA, the data input DIN (pin 17) is connected to MDXA, and the data output DOUT (pin 16) ) is connected to MDRA, chip selection CS is connected to MFSXA, in which the serial resistors R3, R4, R10 and the corresponding pin input parasitic capacitance of U1 form an RC low-pass filter to filter out spikes; the control pins DRDY and SYNC are connected to the GPIO port of DSP ; Capacitors C7 and C8 are filter capacitors, and capacitors C1, C4, C15 and C17 are decoupling capacitors.
另一路信号LP+、LP-经过相同原理和结构的调理电路送到与U1相同型号的ADC2U6中,不再赘述.U1、U6的时钟采用相同的时钟源一外部有源晶振U9.U9产生的时钟经施密特触发器U5以提高驱动能力,然后分两路送至U1和U6时钟输入管脚,磁珠L1、电容C29对电源滤波,电容C31和电阻R25用于滤除时钟信号中的高频尖脉冲,电阻R11亦是用于滤除尖脉冲.The other signal LP+, LP- is sent to the ADC2U6 of the same model as U1 through the conditioning circuit of the same principle and structure, and will not be described again. The clocks of U1 and U6 use the same clock source-the clock generated by the external active crystal oscillator U9.U9 The Schmitt trigger U5 is used to improve the driving ability, and then sent to the U1 and U6 clock input pins in two ways. The magnetic bead L1 and the capacitor C29 filter the power supply, and the capacitor C31 and the resistor R25 are used to filter out the high voltage in the clock signal. Frequency spikes, resistor R11 is also used to filter out spikes.
图5为温度补偿电路。传感器内的温度传感器为Pt100。恒流源加到Pt100上,经差分放大后送至ADC3采样并转换为数字量送至DSP。Pt100接至图中RTD+和RTD-处,U23、R61、U24、R58、R59、R67、Q2、Q3产生恒流源流经Pt100。R62和TP1用于测试、校准,可断开Pt100并短接TP1以进行测试及校准。Pt100两端电压经U26A、U26B、R64、R63、R65组成的差分放大器放大后,送至差分输入的ADC3U25输入端AIN+(3脚)和AIN-(4脚)。R70、C88及R71、C89分别构成RC低通滤波器;电容C80、C87为滤波电容;R60、U27及R66、U29分别构成限幅保护电路;U25所需基准源由U28提供,C85、C86为输入输出滤波电容,C84与U25内部电阻构成RC滤波器,对U28输出进行滤波。U25数字接口与DSP的SPI口连接,时钟SCLK(1脚)接SPICLKA,片选CS(2脚)接SPISTEA,数据输入DIN(10脚)接SPISIMOA,数据输出DOUT(9脚)接SPISOMIA。电容C79、C81、C82、C83为退耦电容。Figure 5 shows the temperature compensation circuit. The temperature sensor inside the sensor is Pt100. The constant current source is added to Pt100, and after differential amplification, it is sent to ADC3 for sampling and converted into digital quantity and sent to DSP. Pt100 is connected to RTD+ and RTD- in the figure, U23, R61, U24, R58, R59, R67, Q2, Q3 generate a constant current source and flow through Pt100. R62 and TP1 are used for testing and calibration, you can disconnect Pt100 and short-circuit TP1 for testing and calibration. The voltage at both ends of the Pt100 is amplified by the differential amplifier composed of U26A, U26B, R64, R63, and R65, and then sent to the differential input ADC3U25 input terminals AIN+ (3 pins) and AIN- (4 pins). R70, C88, R71, and C89 respectively constitute an RC low-pass filter; capacitors C80 and C87 are filter capacitors; R60, U27, R66, and U29 respectively constitute a limiting protection circuit; the reference source required by U25 is provided by U28, and C85 and C86 are The input and output filter capacitors, C84 and U25 internal resistors form an RC filter to filter the output of U28. The U25 digital interface is connected to the SPI port of the DSP, the clock SCLK (pin 1) is connected to SPICLKA, the chip select CS (pin 2) is connected to SPISTEA, the data input DIN (pin 10) is connected to SPISIMOA, and the data output DOUT (pin 9) is connected to SPISOMIA. Capacitors C79, C81, C82, and C83 are decoupling capacitors.
图6为DSP最小系统,包括晶振、JTAG、退耦电容等。主要使用了DSP(U1)的SPI、McBSP及多个通用输入输出管脚(GPIO),还外扩了RAM,未使用的管脚均做了妥善处理。U2为有源晶振,为DSP提供时钟,磁珠L3、电容C34对电源滤波,C35、R7滤除时钟信号中的尖峰脉冲;DSP U1的142脚和25脚为功能管脚,复位时需分别置于有效和无效的状态,R1、R4为上拉电阻;DS2为DSP工作指示灯,R22为限流电阻;U1的57脚接的电阻R3为偏置电流提供通路,U1的55脚、56脚为内部ADC基准输出,需并联电容C27、C26到地;P1为JTAG接口,R2、R5、R6均是手册中要求接的下拉、上拉电阻;磁珠L1隔离数字3.3V和模拟3.3V,磁珠L2隔离数字1.9V和模拟1.9V;电容C1~C25、C28~C33为退耦电容。Figure 6 shows the minimum DSP system, including crystal oscillator, JTAG, and decoupling capacitors. The SPI, McBSP and multiple general-purpose input and output pins (GPIO) of the DSP (U1) are mainly used, and the RAM is also expanded, and the unused pins are properly handled. U2 is an active crystal oscillator, which provides clock for DSP, bead L3 and capacitor C34 filter the power supply, C35 and R7 filter out the peak pulse in the clock signal; pin 142 and pin 25 of DSP U1 are functional pins, which need to be reset separately In the valid and invalid states, R1 and R4 are pull-up resistors; DS2 is the DSP work indicator light, R22 is the current limiting resistor; the resistor R3 connected to pin 57 of U1 provides a path for the bias current, and pins 55 and 56 of U1 The pin is the internal ADC reference output, and capacitors C27 and C26 need to be connected in parallel to the ground; P1 is the JTAG interface, and R2, R5, and R6 are the pull-down and pull-up resistors required in the manual; the magnetic bead L1 isolates digital 3.3V and analog 3.3V , Magnetic bead L2 isolates digital 1.9V and analog 1.9V; capacitors C1~C25, C28~C33 are decoupling capacitors.
图7为DSP外扩存储器及DSP启动方式选择。U4为外扩RAM,与DSP连接时,其地址线、数据线均可打乱,片选CS(6脚)接DSP的XZCS7n,WE(17脚)接XWE0n,OE接XRDn,C47、C48为退耦电容。U5为外扩EEPROM,与DSP的GPIO口连接,C46为退耦电容,R14为下拉电阻;电阻R13、R18、R15、R19、R16、R20、R17、R21与地址线XA15、XA14、XA13、XA12连接,R18、R19、R20、R21是否焊接到PCB上决定DSP的启动方式。Figure 7 shows the selection of DSP external memory expansion and DSP startup mode. U4 is an external expansion RAM. When connecting with DSP, its address line and data line can be disrupted. Chip select CS (pin 6) is connected to XZCS7n of DSP, WE (pin 17) is connected to XWE0n, OE is connected to XRDn, C47 and C48 are decoupling capacitor. U5 is an external expansion EEPROM, connected to the GPIO port of DSP, C46 is a decoupling capacitor, R14 is a pull-down resistor; resistors R13, R18, R15, R19, R16, R20, R17, R21 and address lines XA15, XA14, XA13, XA12 Connection, whether R18, R19, R20, and R21 are soldered to the PCB determines how the DSP starts.
图8为液晶及键盘电路。P1为液晶接口,串联D1将3.3V电源电压降低以满足液晶的供电要求,P1的第4脚为地,第1、2和3脚分别为片选、时钟和数据输入脚,与DSP的GPIO相连,由于电平与DSP电平不匹配,电阻R2~R8构成分压电路以匹配电平;P3为键盘接口,第5脚为地,其余与DSP的GPIO相连,电阻R1、R4、R9、R10为限流电阻,电容C1、C2、C3、C4用于硬件去抖动,系统掉电时,D2、D3、D4、D5为电容上电荷的释放提供通路。Figure 8 is the LCD and keyboard circuit. P1 is the liquid crystal interface, and D1 in series reduces the 3.3V power supply voltage to meet the power supply requirements of the liquid crystal. The 4th pin of P1 is the ground, and the 1st, 2nd and 3rd pins are the chip selection, clock and data input pins respectively, and the GPIO of the DSP Connected, because the level does not match the DSP level, the resistors R2~R8 form a voltage divider circuit to match the level; P3 is the keyboard interface, the fifth pin is the ground, and the rest are connected to the GPIO of the DSP. The resistors R1, R4, R9, R10 is a current-limiting resistor. Capacitors C1, C2, C3, and C4 are used for hardware debounce. When the system is powered off, D2, D3, D4, and D5 provide paths for the release of charges on the capacitors.
图9为脉冲输出电路.当输入信号PulseIn为高电平时,Q4导通,U1导通,Q2截止,Q1、Q3截止,输出PulseOut为低电平;当PulseIn为低电平时,Q4截止,U1截止,Q2基极电压被D1、D2箝位在1.4V,Q2导通,电阻R8、R3上产生压降,导致Q1、Q3导通,输出PulseOut为高电平,其电压值等于(R6+R10)或(R7+R9)上的压降,而这又与电阻R1、R8、R3、R4有关.电阻R11为基极限流电阻,R5为光耦U1输入端限流电阻,R2为U1输出端上拉电阻,D1、D2为箝位二极管,电阻R1、R8、R3、R4决定流经R1的电流大小,从而决定脉冲输出高电平的电压值,电阻(R6+R10)和(R7+R9)上的压降即为脉冲高电平的电压值,电容C1、C2、C3为退耦电容.Figure 9 shows the pulse output circuit. When the input signal PulseIn is high level, Q4 is turned on, U1 is turned on, Q2 is turned off, Q1 and Q3 are turned off, and the output PulseOut is low level; when PulseIn is low level, Q4 is turned off, and U1 At the end, the base voltage of Q2 is clamped at 1.4V by D1 and D2, Q2 is turned on, and a voltage drop occurs on resistors R8 and R3, resulting in Q1 and Q3 being turned on, and the output PulseOut is high, and its voltage value is equal to (R6+ The voltage drop on R10) or (R7+R9), which is related to resistors R1, R8, R3, and R4. Resistor R11 is the base current-limiting resistor, R5 is the current-limiting resistor at the input of optocoupler U1, and R2 is the output of U1 End pull-up resistors, D1 and D2 are clamping diodes, resistors R1, R8, R3, and R4 determine the magnitude of the current flowing through R1, thereby determining the voltage value of the pulse output high level, resistors (R6+R10) and (R7+ The voltage drop on R9) is the voltage value of the pulse high level, and capacitors C1, C2, and C3 are decoupling capacitors.
图10为4~20mA输出电路。U3为DAC,流量计算值(数字量)经U3转换为模拟电压送至U2输入,U2将电压转换为4~20mA电流输出。R2、U4为U3提供电压基准源,C5、C6为退耦电容。U2的12脚输出10V电压;Q3增加其电流输出能力;U1为LDO,提供3.3V电源;C3、C2为滤波电容;R1决定U2输入电压与输出电流的关系;电容C4使电路稳定;Q1、Q2与U2内的运放组成电压/电流转换电路;电容C1为退耦电容。Figure 10 is a 4 ~ 20mA output circuit. U3 is a DAC, and the flow calculation value (digital quantity) is converted into an analog voltage by U3 and sent to U2 for input, and U2 converts the voltage into a 4-20mA current output. R2 and U4 provide voltage reference source for U3, and C5 and C6 are decoupling capacitors. U2's
本发明专利的软件工作流程为:The software workflow of the patent of the present invention is:
(1)系统上电后,一方面模拟驱动电路产生驱动信号来激励科氏流量计的振动,另一方面DSP完成系统各个部分的初始化,然后启动并同步两路ADC的采样转换。(1) After the system is powered on, on the one hand, the analog drive circuit generates a drive signal to stimulate the vibration of the Coriolis flowmeter; on the other hand, the DSP completes the initialization of each part of the system, and then starts and synchronizes the sampling conversion of the two ADCs.
(2)数据转换好后,通过GPIO产生中断;中断服务程序将转换的结果传送到两路多通道缓冲串口McBSP的接收管脚上,之后启动直接存储器存取(DMA)传输,在不打扰CPU工作的情况下,将McBSP的接收管脚上的数据通过DMA传输到内部存储空间的临时数组中;当临时数组放满后,产生两个DMA接收中断,中断服务程序将两个临时数组中的数据存放到外部SARAM中的两个循环缓冲数组中。(2) After the data is converted, an interrupt is generated through GPIO; the interrupt service program transfers the converted result to the receiving pins of the two-way multi-channel buffered serial port McBSP, and then starts direct memory access (DMA) transmission without disturbing the CPU In the case of work, the data on the receiving pin of McBSP is transferred to the temporary array in the internal storage space through DMA; when the temporary array is full, two DMA receiving interrupts are generated, and the interrupt service routine transfers the data in the two temporary arrays Data is stored in two circular buffer arrays in the external SARAM.
(3)到外部循环数组中取500点新的连续的数据,判断信号的大小,如果信号很小,则表示驱动还没有稳定,继续等待;若信号大于设置的数值,则可以开始调用算法模块。(3) Take 500 points of new continuous data from the external loop array, and judge the size of the signal. If the signal is small, it means that the drive is not stable, and continue to wait; if the signal is greater than the set value, you can start calling the algorithm module .
(4)对两路500点数据信号滤波进行预处理,滤除噪声提高增强信号质量;然后,对两路滤波后的信号调用自适应格型陷波滤波器来分别估计两路传感器信号的基频,然后对两路信号的频率值取平均,得到信号基频瞬时值,对频率进行平均处理,并设置一个比较范围,得到的平均频率值变化幅度在比较范围内则不更新频率值,如果超出范围则更新频率,这样就可以得到稳定而精准的频率值,结合系数即可以得到瞬时密度值;最后调用负频率修正的DTFT算法来计算两路信号的相位差,并对结果进行平均,结合频率值得到时间差,进而结合设定的仪表系数,得到瞬时流量值。(4) Preprocess the two channels of 500-point data signal filtering, filter out the noise and improve the quality of the enhanced signal; then, call the adaptive lattice notch filter on the two channels of filtered signals to estimate the basis of the two channels of sensor signals respectively frequency, and then average the frequency values of the two signals to obtain the instantaneous value of the fundamental frequency of the signal, average the frequency, and set a comparison range. If the frequency exceeds the range, the frequency is updated, so that a stable and accurate frequency value can be obtained, and the instantaneous density value can be obtained by combining the coefficient; finally, the DTFT algorithm with negative frequency correction is called to calculate the phase difference of the two signals, and the results are averaged, combined with The time difference is obtained from the frequency value, and combined with the set meter coefficient, the instantaneous flow value is obtained.
(5)读取温度传感器信号转换为温度值,根据被测流量计的材质得到相应的温度补偿系数,对瞬时流量进行温度补偿。(5) Read the temperature sensor signal and convert it into a temperature value, and obtain the corresponding temperature compensation coefficient according to the material of the measured flowmeter, and perform temperature compensation on the instantaneous flow rate.
(6)通过CPU定时器定时1s产生中断,在中断服务程序中累加瞬时流量得到累积流量;同时,置位输出结果标志位。(6) Generate an interrupt at regular intervals of 1s through the CPU timer, and accumulate the instantaneous flow in the interrupt service program to obtain the accumulated flow; at the same time, set the output result flag bit.
(7)得到测量结果后,TMS320F28335一方面通过LCD将累积流量、密度、温度等测量值显示出来;另一方面根据得到的瞬时流量通过DA或ePWM模块向外输出相应的4~20mA电流以及PWM脉冲,以便上位机或者其他二次仪表计数。(7) After obtaining the measurement results, the TMS320F28335 displays the measured values such as cumulative flow, density, and temperature through the LCD on the one hand; on the other hand, according to the obtained instantaneous flow, it outputs the corresponding 4-20mA current and PWM through the DA or ePWM module. Pulse, so that the upper computer or other secondary instruments can count.
(8)最后查询键盘标志位是否置位,若置位调用键盘服务子程序,若没有,重复2-8的过程对流量进行实时测量。(8) Finally check whether the keyboard flag is set, if set, call the keyboard service subroutine, if not, repeat the process of 2-8 to measure the flow in real time.
本发明系统中数字信号处理系统的主要任务是对实时采样数据进行相应的数字信号处理算法,以完成流量测量,并利用硬件资源,编写相应的程序进行功能扩展,满足用户对仪表提出的要求.本发明系统除了测量流量,还需具备脉冲输出、电流输出、仪表系数设定和人机接口(即键盘功能和LCD显示)等功能.此外,为保证系统正常运行,在系统中加入了错误检测、故障复位功能.因此,整个数字信号处理系统的功能较多,软件设计复杂.为了便于系统的设计和维护,软件设计采取模块化设计方案,将完成特定功能或者类似功能的子程序组合成功能模块,然后由一个主监控程序统一调用,当然这些功能模块之间也可以互相调用,中断模块处理一些特殊事件,可打断主程序的执行.软件总体框图如图11所示,主要包括初始化模块、信号采集模块、算法模块、中断模块、结果输出模块、人机接口模块、EEPROM操作模块、错误模块以及看门狗复位模块.每一个功能模块一般都包含一个头文件和一个函数文件,从而使软件便于管理和移植.The main task of the digital signal processing system in the system of the present invention is to perform corresponding digital signal processing algorithms on real-time sampling data to complete flow measurement, and use hardware resources to write corresponding programs to expand functions to meet user requirements for instruments. In addition to measuring flow, the system of the present invention also needs to have functions such as pulse output, current output, instrument coefficient setting and man-machine interface (ie keyboard function and LCD display). In addition, in order to ensure the normal operation of the system, an error detection system is added to the system , Fault reset function. Therefore, the entire digital signal processing system has many functions, and the software design is complex. In order to facilitate the design and maintenance of the system, the software design adopts a modular design scheme, and the subroutines that complete specific functions or similar functions are combined into functions Module, and then called by a main monitoring program. Of course, these functional modules can also call each other. The interrupt module handles some special events and can interrupt the execution of the main program. The overall block diagram of the software is shown in Figure 11, mainly including the initialization module , signal acquisition module, algorithm module, interrupt module, result output module, man-machine interface module, EEPROM operation module, error module and watchdog reset module. Each function module generally includes a header file and a function file, so that The software is easy to manage and transplant.
图12的是系统主监控流程。主监控程序是整个信号处理系统的总调度程序,调用各个模块中的子程序,实现仪表所要求的功能。它是一个死循环程序,系统一上电,主监控程序自动运行,进入不断计算和处理的循环中。基本过程为:系统上电后,立即进行初始化;初始化后,开启ADC转换采样数据,然后调用计算模块,对信号采样序列采用信号处理算法进行处理,计算出传感器信号频率以及两路的相位差、时间差;然后,根据所设定的仪表系数,计算瞬时流量和累积流量;并对结果进行平均处理,以及对瞬时流量和累积流量进行温度补偿;接下来调用系统输出模块,根据计算出的瞬时流量,向外发送相应的脉冲量和标准的4~20mA的电流;完成输出后,主监控程序查询键盘操作标志位进行相应的处理,最后返回,重新开始进行信号处理、计算流量和输出信号,不断循环。Figure 12 is the main monitoring process of the system. The main monitoring program is the general dispatcher of the entire signal processing system, which calls the subroutines in each module to realize the functions required by the instrument. It is an endless loop program. Once the system is powered on, the main monitoring program runs automatically and enters a cycle of continuous calculation and processing. The basic process is: after the system is powered on, initialize it immediately; after initialization, turn on the ADC to convert the sampling data, and then call the calculation module to process the signal sampling sequence with a signal processing algorithm to calculate the sensor signal frequency and the phase difference between the two channels, time difference; then, according to the set instrument coefficient, calculate the instantaneous flow and cumulative flow; and average the results, and perform temperature compensation on the instantaneous flow and cumulative flow; then call the system output module, according to the calculated instantaneous flow , send out the corresponding pulse amount and the standard 4-20mA current; after the output is completed, the main monitoring program queries the keyboard operation flag bit for corresponding processing, and finally returns to start signal processing, flow calculation and output signal again, and continuously cycle.
本发明系统上电以后首先要需要对各个模块的软硬件资源进行初始化后才能进入正常的流量测量过程。该模块负责系统内可编程器件和软件资源的初始化,主要包括DSP芯片TMS320F28335初始化、外部可编程器件初始化、中断配置初始化以及软件资源初始化等。After the system of the present invention is powered on, the software and hardware resources of each module need to be initialized before entering the normal flow measurement process. This module is responsible for the initialization of programmable devices and software resources in the system, mainly including the initialization of DSP chip TMS320F28335, the initialization of external programmable devices, the initialization of interrupt configuration and the initialization of software resources, etc.
TMS320F28335的初始化主要包括系统时钟初始化和系统用到的TMS320F28335内部集成功能模块的初始化,如看门狗、系统外部接口XINTF、增强型PWM模块中ePWM1a、定时器、直接存储器访问DMA模块、多通道缓冲串口McBSP模块、Flash存储器以及通用数字复用口GPIO等。The initialization of TMS320F28335 mainly includes system clock initialization and initialization of TMS320F28335 internal integrated function modules used by the system, such as watchdog, system external interface XINTF, ePWM1a in enhanced PWM module, timer, direct memory access DMA module, multi-channel buffer Serial port McBSP module, Flash memory and general digital multiplexing port GPIO, etc.
外部可编程器件初始化包括两路采集流量传感器信号的ADC芯片以及一路采集温度传感器信号的ADC3芯片的初始化、LCD初始化。ADC芯片的初始化主要是芯片工作模式等控制字的写入。LCD初始化则包括:控制引脚初始化、写模式命令字和初始化显示内容等。The initialization of external programmable devices includes the initialization of two ADC chips for collecting flow sensor signals, the initialization of ADC3 chip for collecting temperature sensor signals, and the LCD initialization. The initialization of the ADC chip is mainly the writing of control words such as the working mode of the chip. LCD initialization includes: control pin initialization, write mode command word and initialization display content, etc.
中断配置初始化包括PIE控制寄存器初始化、中断向量表初始化以及系统中用到的中断进行映射等。Interrupt configuration initialization includes PIE control register initialization, interrupt vector table initialization, and interrupt mapping used in the system.
软件资源初始化主要是用于各个模块的全局数据结构、数组、参数等的初始化。软件中有些数据需要不断的使用,应配置成全局变量;另外,模块之间共享的数据,也应配置成全局变量形式。根据初始化方式的不同,全局变量的初始化主要分为两类:一类是通过EEPROM来进行初始化,主要是仪表参数和标定的固定偏差等;另一类则是直接复制初始化,主要包括反映系统工作状态的状态变量和为了减少程序计算量、方便程序调用的常数变量等。Software resource initialization is mainly used for initialization of global data structures, arrays, parameters, etc. of each module. Some data in the software needs to be used continuously and should be configured as global variables; in addition, data shared between modules should also be configured as global variables. According to the different initialization methods, the initialization of global variables is mainly divided into two categories: one is to initialize through EEPROM, mainly the fixed deviation of instrument parameters and calibration, etc.; the other is to directly copy and initialize, mainly including reflecting system work State variables and constant variables to reduce program calculations and facilitate program calls, etc.
TMS320F28335内部采用一个集中化的外设中断扩展控制器PIE来处理所有片内外设和外部引脚中断的优先级以及中断的响应,这些中断被分为12组,每组有8个中断复用一个CPU级中断即INT1-INT12,这12个核心级中断优先级固定且是可屏蔽的.本系统采用了两个核心CPU级中断:INT1和INT7.INT1.4是一个外设中断源,来自采集两路传感器信号的ADC之一,表示两路ADC转换数据完成,如图13所示,两路ADC的Ready信号接至DSP的GPIO8和GPIO10上,由于本系统的要求,必须同时启动两路ADC转换,且两路ADC配置相同,因此转换数据的时间一致,这样Ready信号应该同时有效,为了简便,采取一路ADC的Ready信号通过GPIO口发送中断请求,如果在中断配置初始化中映射了该中断,且PIE,CPU中断都使能,CPU就会响应该中断,在中断服务程序中查询判断另一路ADC的Ready信号是否有效,如果有效就执行下一步,如果无效,可以继续等待,但是如前面所述两路ADC动作一致,不会等太长的时间,这样既减少了中断的数目,同时查询也不会浪费CPU时间,确保两路ADC转换好的的信号都及时得到转移的,同时也提高了系统的效率.由于ADC采集两路传感器信号是本系统工作的第一步,所以在外设中断中,该中断应该具有最高优先级,因此映射到CPU的INT1.TMS320F28335 internally adopts a centralized peripheral interrupt expansion controller PIE to handle the priority and interrupt response of all on-chip peripherals and external pin interrupts. These interrupts are divided into 12 groups, and each group has 8 interrupts to multiplex one CPU-level interrupts are INT1-INT12. These 12 core-level interrupts have fixed priorities and are maskable. This system uses two core CPU-level interrupts: INT1 and INT7. INT1.4 is a peripheral interrupt source, which comes from the acquisition One of the ADCs of the two sensor signals indicates that the conversion data of the two ADCs is completed. As shown in Figure 13, the Ready signals of the two ADCs are connected to GPIO8 and GPIO10 of the DSP. Due to the requirements of this system, the two ADCs must be started at the same time Conversion, and the configuration of the two ADCs is the same, so the time to convert the data is the same, so the Ready signal should be valid at the same time. For simplicity, the Ready signal of one ADC is used to send an interrupt request through the GPIO port. If the interrupt is mapped in the interrupt configuration initialization, And PIE, CPU interrupt is enabled, the CPU will respond to the interrupt, inquire in the interrupt service program to determine whether the Ready signal of the other ADC is valid, if it is valid, execute the next step, if it is invalid, you can continue to wait, but as mentioned above The above-mentioned two ADCs act in the same way and will not wait too long, which not only reduces the number of interrupts, but also does not waste CPU time for querying, ensuring that the signals converted by the two ADCs are transferred in time, and also improves Improve the efficiency of the system. Since the ADC collects two sensor signals is the first step of the system, so in the peripheral interrupt, the interrupt should have the highest priority, so it is mapped to the INT1 of the CPU.
INT1.7来自于CPU定时器Time0的周期中断触发,用于定时计算累计流量、换算瞬时流量对应的PWM波的频率值、换算瞬时流量对应的DAC输出的电压值、并置位输出标志位,为调用输出模块做准备。由于该中断主要用于总流量的计算,因此为确保结果的正确性,优先级也必须较高,因此采用CPUTime0定时器,可以映射到CPU的INT1。INT1.7 comes from the periodic interrupt trigger of CPU timer Time0, which is used to regularly calculate the accumulated flow, convert the frequency value of the PWM wave corresponding to the instantaneous flow, convert the voltage value of the DAC output corresponding to the instantaneous flow, and set the output flag. Prepare to call the output module. Since the interrupt is mainly used for the calculation of the total flow, the priority must be higher to ensure the correctness of the result, so the CPUTime0 timer is used, which can be mapped to the INT1 of the CPU.
系统中一些实时性要求不高的定时处理没有分配处理器,而是采用延迟函数进行软件定时,这样便于实现。例如定时键盘扫描、定时LCD刷新、定时读取温度值、设置模式下的LCD数码管的定时闪烁以及GPIO模拟产生SPI的通信时序等。INT7.1和INT7.2由DMA传输通道1和传输通道2的中断组成。如图14所示,两路DMA用于对DSP的多通道缓冲串口McBSP接收的两路ADC采样转换的科氏传感器信号进行传输,DMA在不打扰CPU的情况下将数据传送到内部RAM中的ping_buffer或pong_buffer缓冲数组中,当缓冲数组满时就会产生DMA接收中断,在中断服务程序中修改DMA传送地址以及将已满的ping_buffer或pong_buffer中的数据读取到外部SARAM中的长的循环缓冲数组中供算法调用。因为整个数字信号处理系统必须保证输入信号的实时、连续以及正确性,采用TMS320F28335的DMA传输便可以实现将大量的实时数据正确转移,而不降低CPU的工作效率。DMA接收中断的优先级要低于ADC中断。In the system, some timing processes with low real-time requirements are not assigned processors, but delay functions are used for software timing, which is easy to implement. For example, timing keyboard scanning, timing LCD refresh, timing reading temperature value, timing flickering of LCD digital tube in setting mode, and GPIO simulation generating SPI communication timing, etc. INT7.1 and INT7.2 are composed of interrupts of
信号采集模块包括两个部分:科氏传感器信号数据采集和温度传感器信号采集。传感器信号数据采集主要用于检查科氏的频率、两个通道的相位差,采集过程分为采集传输过程和信号读取过程。The signal acquisition module includes two parts: Coriolis sensor signal data acquisition and temperature sensor signal acquisition. The sensor signal data acquisition is mainly used to check the Coriolis frequency and the phase difference of the two channels. The acquisition process is divided into the acquisition transmission process and the signal reading process.
科里奥利质量流量计的数字信号处理是以两路传感器的信号为研究对象的,两路信号要求必须同时采样,且要求将实时采样的数据连续保存下来供数字信号处理算法调用去计算流量值。为了能及时保存大量的数据,采用了如图15所示的信号采集和传输的过程。The digital signal processing of the Coriolis mass flowmeter is based on the signals of two sensors. The two signals must be sampled at the same time, and the real-time sampled data must be continuously saved for the digital signal processing algorithm to calculate the flow rate. value. In order to save a large amount of data in time, the process of signal acquisition and transmission as shown in Figure 15 is adopted.
由于本系统对算法精度要求非常高,因此必须选取一款性能优越的ADC。本系统选择的是两个ADC来分别采样两个传感器信号,该ADC是一款低噪声、Δ∑型的24位ADC,性能能够满足我们的算法的要求,且具有SPI串行接口,便于与DSP传送数据。本系统应用两路多通道缓冲串口McBSP与两路AD通讯。Because this system has very high requirements on the accuracy of the algorithm, it is necessary to select an ADC with superior performance. This system chooses two ADCs to sample two sensor signals respectively. The ADC is a low-noise, Δ∑-type 24-bit ADC whose performance can meet the requirements of our algorithm, and has an SPI serial interface, which is easy to communicate with DSP transfers data. This system uses two multi-channel buffered serial ports McBSP to communicate with two ADs.
配置好ADC后,两路ADC就开始同步转换了,单个数据转换好后通过GPIO8产生中断(通过一个ADC的DRDY脚产生一个中断,在该中断服务程序中查询另一个AD的DRDY信号),中断服务程序中为McBSPa口与b口接收数据提供时钟,两路24位采样数据就会到达McBSPa口与b口的接收寄存器中,高位接收在DRR2中,低位在DRR1中,以32位整形数据保存在McBSP的接收缓冲器中,如果这时候利用McBSP产生两路中断让CPU读取数据的话,CPU利用率太低,采样频率2kHz,500ms就要中断一次读取数据,CPU根本没有将大部分的时间用于算法以及其他系统功能上,这样根本无法实现整个系统.因此我们选择了McBSP的DMA传输功能,在不打扰CPU的情况下将数据及时传送到内部RAM中,而不会丢失或覆盖采样数据,提高CPU的利用率.After the ADC is configured, the two ADCs start to convert synchronously. After the single data is converted, an interrupt is generated through GPIO8 (an interrupt is generated through the DRDY pin of one ADC, and the DRDY signal of another AD is queried in the interrupt service program). In the service program, the clock is provided for the data received by the McBSPa port and the b port, and the two 24-bit sampling data will arrive at the receiving registers of the McBSPa port and the b port. In the receiving buffer of McBSP, if McBSP is used to generate two interrupts to let the CPU read data at this time, the CPU utilization rate is too low, the sampling frequency is 2kHz, and the reading data will be interrupted once every 500ms. Time is spent on algorithms and other system functions, so that the whole system cannot be implemented at all. Therefore, we chose the DMA transfer function of McBSP to transfer the data to the internal RAM in time without disturbing the CPU, without losing or overwriting samples Data, improve CPU utilization.
28335中有的DMA可为ADC、McBSP、ePWM、XINTF以及SARAM服务,因此需要指定DMA中断为McBSPa/b的接收中断。Some DMAs in 28335 can serve ADC, McBSP, ePWM, XINTF and SARAM, so it is necessary to specify the DMA interrupt as the receiving interrupt of McBSPa/b.
注意,配置DMA必须在配置McBSP以及AD之前。这样,McBSP接收寄存器一旦有数据就会自动开始DMA传输,分别将两路信号数据传送到DSP内部RAM的指定地方pingL_buffer与pingR_buffer(buffer大小为40点)中,当buffer放满时两路DMA传输分别产生中断,DMA中断服务程序中有两个任务:一,修改buffer地址为pongL_buffer与pongR_buffer(buffer大小仍为40点)(若为pong_buffer,地址修改为ping_buffer,交替使用),防止AD采样数据丢失;二,将两路数据从放满数据的内部buffer中读出,放入位于外扩SARAM的较长的循环数组中,并记录该循环数组的头指针、尾指针以及新数据的长度,为算法取数据做准备。DMA中断服务程序流程图如图16所示。Note that configuring DMA must be done before configuring McBSP and AD. In this way, once the McBSP receiving register has data, it will automatically start DMA transmission, and transfer the two signal data to the designated places pingL_buffer and pingR_buffer (buffer size is 40 points) in the DSP internal RAM respectively. When the buffer is full, the two channels of DMA transmission Generate interrupts respectively. There are two tasks in the DMA interrupt service program: 1. Modify the buffer address to pongL_buffer and pongR_buffer (buffer size is still 40 points) (if it is pong_buffer, modify the address to ping_buffer and use it alternately) to prevent the loss of AD sampling data ; Two, read out the two-way data from the internal buffer full of data, put it into a longer circular array located in the externally expanded SARAM, and record the head pointer, tail pointer and the length of the new data of the circular array, as The algorithm takes the data and prepares it. The flowchart of DMA interrupt service program is shown in Figure 16.
信号读取是指从外部SARAM中的循环长数组channel_signal中读取连续数据的过程,循环长数组的结构如图17所示,该数组设置了三个标志,即头指针Top_pointer、尾指针Tail_pointer、新数据长度(所谓新数据就是指还没有用于信号处理算法的采样数据)Newda_len。Signal reading refers to the process of reading continuous data from the cyclic long array channel_signal in the external SARAM. The structure of the cyclic long array is shown in Figure 17. The array is set with three flags, namely the head pointer Top_pointer, the tail pointer Tail_pointer, The length of the new data (the so-called new data refers to the sampling data that has not been used in the signal processing algorithm) Newda_len.
DMA中断服务程序将buffer中数据放入循环数组时,Top_pointer++,Newda_len++这样Newda_len记录了已有的采样数据,在主程序中判断Newda_len的长读,当有500点数据时,就从循环数组中取500点数到signalLCH[500]及signalRCH[500]中并转换整型数据到浮点型数据,为调用算法做准备,此时,取一点出来,Tail_pointer++,取完数据后即调用算法程序进行计算流量,500点算完后Newda_len-500,进入下一轮循环。可以看出,头指针Top_pointer用于表示有数据写入循环数组中,尾指针Tail_pointer用于表示有数据读出循环数组中,新数据长度Newda_len用于表示有效的可用于算法的数据。When the DMA interrupt service program puts the data in the buffer into the circular array, Top_pointer++, Newda_len++, Newda_len records the existing sampling data, and judges the long read of Newda_len in the main program. When there are 500 points of data, it takes them from the circular array. Transfer 500 points to signalLCH[500] and signalRCH[500] and convert integer data to floating-point data to prepare for calling the algorithm. At this time, take a point out, Tail_pointer++, and call the algorithm program to calculate the flow after taking the data , Newda_len-500 after the calculation of 500 points, enter the next cycle. It can be seen that the head pointer Top_pointer is used to indicate that there is data written into the circular array, the tail pointer Tail_pointer is used to indicate that there is data read out of the circular array, and the new data length Newda_len is used to indicate valid data that can be used for the algorithm.
如果Newda_len>Sum_len,即表示存放数据速度比取出数据速度快,数据没来得及取出便被覆盖了,此时表明取出数据做算法消耗时间过长,算法来不及算,需要简化算法或者降低采样频率,此时就产生了溢出错误,标记overflow_error置位,对错误的处理是重新初始化循环长数组,使Top_pointer=Rail_pointer即可,同时还需改进算法或者降低采样频率。If Newda_len>Sum_len, it means that the speed of storing data is faster than the speed of fetching data, and the data will be overwritten before it can be fetched in time. At this time, it means that fetching data takes too long to do the algorithm, and the algorithm is too late to calculate. It is necessary to simplify the algorithm or reduce the sampling frequency. When an overflow error occurs, the flag overflow_error is set, and the error handling is to re-initialize the loop long array, so that Top_pointer=Rail_pointer, and it is necessary to improve the algorithm or reduce the sampling frequency.
温度信号采集是直接在模拟信号输入调理电路后通过ADC3采样转换成数字量的。ADC3是一款低功耗的、缓冲的24位Δ∑型ADC,且采用SPI方式通信,通过DSP上的SPI模块口来实现数据传递与控制。由于流量管介质的温度在一定时间内变化不大,温度信息实时性要求并不高,因此没必要采取很高的SPI通信速率,我们配置ADC3工作在单个转换模式下,即开启AD转换,ADC3转换好一个数据后就变为关闭休眠状态,直到CPU查询DOUT/RDY有效并且有空来取数,重新唤醒ADC3后就可以转化下一个数据了。这样系统就可以在需要温度信息的时候去读取温度传感器信号,避免采集实时数据带来的资源浪费。ADC3的采样速率比较低,同时,可以用一个延时软件函数来定时去读取温度,唤醒ADC3去转换下一个数,这样就可以固定时间去更新温度信息了。The temperature signal acquisition is converted into digital quantity through ADC3 sampling directly after the analog signal is input into the conditioning circuit. ADC3 is a low-power, buffered 24-bit ΔΣ-type ADC, and uses SPI communication, and realizes data transmission and control through the SPI module port on the DSP. Since the temperature of the flow tube medium does not change much within a certain period of time, the real-time requirements for temperature information are not high, so it is not necessary to adopt a high SPI communication rate. We configure ADC3 to work in a single conversion mode, that is, to enable AD conversion. ADC3 After converting a piece of data, it becomes closed and dormant until the CPU checks that DOUT/RDY is valid and is free to fetch data. After reawakening ADC3, the next data can be converted. In this way, the system can read the temperature sensor signal when temperature information is needed, avoiding the waste of resources caused by collecting real-time data. The sampling rate of ADC3 is relatively low. At the same time, a delay software function can be used to read the temperature regularly, and wake up ADC3 to convert the next number, so that the temperature information can be updated at a fixed time.
算法模块内包含了系统所进行的大部分数值运算子程序,主要有信号预处理、估计传感器信号的基频、计算两路信号的相位差和时间差、对结果进行平均处理、瞬时流量计算、流量的温度补偿。整个算法模快的处理流程如图18所示。The algorithm module contains most of the numerical operation subroutines performed by the system, mainly including signal preprocessing, estimating the fundamental frequency of sensor signals, calculating the phase difference and time difference of two signals, averaging the results, calculating instantaneous flow, flow temperature compensation. The processing flow of the entire algorithm module is shown in Figure 18.
信号预处理指对采集的传感器信号进行滤波,滤除不必要的频率成分为后面的算法打基础。信号预处理分两种情况:一种是,对于Δ∑型ADC来说,由于AD本身以很高的采样频率1.92MHz采样,之后内部带有滤波平均的处理,因此以2kHz传送到DSP的数字量噪声已经比较低了,所以,软件滤波只需滤掉较高成分频率即可,简单的FIR低通滤波即可满足后续算法的要求;另一种是,对于其他AD或者音频处理芯片Codec来说,则需要使用多抽一滤波器,即为了增强对噪声的抑制,先用16kHz较高的采样频率对科氏流量计的输出信号进行采样,然后用多抽一滤波器进行抗混叠滤波和抽取,一般需采用两级多抽一滤波才能达到较好的效果,并且抽取之后减少了数据量,提高信号质量的同时没有增加后续的计算负担。如果实际应用时信号中存在其他的频率的干扰,通过分析信号的频谱可以设计陷阱深度和宽度可调的陷波器来具体处理实际中的干扰,提高整个算法的抗干扰能力。Signal preprocessing refers to filtering the collected sensor signals to filter out unnecessary frequency components to lay the foundation for subsequent algorithms. There are two cases of signal preprocessing: one is, for the ΔΣ ADC, since the AD itself samples at a very high sampling frequency of 1.92MHz, and then has filtering and averaging processing inside, the digital data transmitted to the DSP at 2kHz The amount of noise is already relatively low, so software filtering only needs to filter out higher component frequencies, and simple FIR low-pass filtering can meet the requirements of subsequent algorithms; the other is, for other AD or audio processing chip Codec In other words, you need to use a multi-pump filter, that is, in order to enhance the suppression of noise, first use a higher sampling frequency of 16kHz to sample the output signal of the Coriolis flowmeter, and then use a multi-pump filter for anti-aliasing filtering And decimation, generally need to use two more decimation and one filter to achieve better results, and after the decimation, the amount of data is reduced, and the signal quality is improved without increasing the subsequent calculation burden. If there are other frequency interferences in the signal in actual application, a notch filter with adjustable trap depth and width can be designed by analyzing the frequency spectrum of the signal to specifically deal with the actual interference and improve the anti-interference ability of the entire algorithm.
数字滤波公式为:The digital filtering formula is:
x(n)=(b0u(n)+b1u(n-1)+…bmu(n-m)-a1x(n-1)-…-akx(n-k))/a0(1)x(n)=(b 0 u(n)+b 1 u(n-1)+...b m u(nm)-a 1 x(n-1)-...-a k x(nk))/a 0 (1)
式中,u和x分别代表采样得到的原始信号序列和数字滤波之后的信号序列,{b0,…,bm,a0,…,ak}为滤波器系数,m和k为滤波器的阶数。滤波器系数可根据现场状况,通过系统面板进行设置。In the formula, u and x represent the original signal sequence obtained by sampling and the signal sequence after digital filtering respectively, {b 0 ,..., b m , a 0 ,..., a k } are filter coefficients, m and k are filter coefficients of order. The filter coefficient can be set through the system panel according to the site conditions.
经过预处理的信号就可以调用自适应格型陷波滤波来估计信号的基频了,由于科氏质量流量计两个流量管的不一致性,导致两路传感器信号存在偏差,为了提高计算相位差的精度,对两路信号分别经过两个不同的自适应格型陷波滤波器,分别估算两路信号的频率,然后在平均得到一个折中的频率值传递给后面的算法。The preprocessed signal can call the adaptive lattice notch filter to estimate the fundamental frequency of the signal. Due to the inconsistency of the two flow tubes of the Coriolis mass flowmeter, there is a deviation in the two sensor signals. In order to improve the calculation of the phase difference The accuracy of the two signals is passed through two different adaptive lattice notch filters to estimate the frequencies of the two signals respectively, and then a compromised frequency value is obtained on average and passed to the subsequent algorithm.
格型IIR陷波器是由全极点和全零点两个格型滤波器级联而成,其传递函数如式(2)所示。The lattice IIR notch filter is formed by cascading two lattice filters with all poles and all zeros, and its transfer function is shown in formula (2).
H1(z)贡献为整个格型陷波器的极点部分,相当于AR模型,而H2(z)则贡献为整个格型IIR陷波器的零点部分,是一个格型FIR滤波器。为了减少计算负担,通过将零点固定在单位圆上,使得只调整一个参数就能达到自适应陷波的目的。将零点固定在单位圆上,即令k1=1,k0在经过一段时间自适应后收敛到-cosω,ω是信号的归一化频率,α决定陷阱的宽度,其自适应算法如下式(3)到式(10)所示。H 1 (z) contributes to the pole part of the entire lattice notch filter, which is equivalent to the AR model, while H 2 (z) contributes to the zero part of the entire lattice IIR notch filter, which is a lattice FIR filter. In order to reduce the computational burden, the zero point is fixed on the unit circle, so that only one parameter can be adjusted to achieve the purpose of adaptive notch. Fix the zero point on the unit circle, that is, let k 1 =1, k 0 converges to -cosω after a period of self-adaptation, ω is the normalized frequency of the signal, α determines the width of the trap, and its adaptive algorithm is as follows ( 3) to formula (10).
D(n)=λ(n)D(n-1)+2(1-λ(n))s2(n-1) (5)D(n)=λ(n)D(n-1)+2(1-λ(n))s 2 (n-1) (5)
C(n)=λ(n)C(n-1)+(1-λ(n))s(n-1)[s(n)+s(n-2)] (7)C(n)=λ(n)C(n-1)+(1-λ(n))s(n-1)[s(n)+s(n-2)] (7)
其中,是k0(n)的估计值,是经过平滑处理后的值,γ=0.5,y(n)-x(n)即为去除噪声后的增强信号。由于科氏流量计流体的密度反映为频率的变化,所以需要及时跟踪流体信号变化的频率,通过大量的仿真研究,发现通过调整ρ和λ的终值,适当地加大陷波器陷阱的宽度,也能够在保证精度的同时实现对频率变化的跟踪,如式(11)和式(12)所示。in, is an estimate of k 0 (n), yes The value after smoothing, γ=0.5, y(n)-x(n) is the enhanced signal after removing the noise. Since the density of the Coriolis flowmeter fluid is reflected as a change in frequency, it is necessary to track the frequency of the fluid signal change in time. Through a large number of simulation studies, it is found that by adjusting the final values of ρ and λ, the width of the trap trap can be appropriately increased. , can also realize the tracking of frequency changes while ensuring the accuracy, as shown in equations (11) and (12).
ρ(n)=0.98-0.195×0.99(n-1) (11)ρ(n)=0.98-0.195×0.99 (n-1) (11)
λ(n)=0.98-0.05×0.99(n-1) (12)λ(n)=0.98-0.05×0.99 (n-1) (12)
自适应格型陷波算法的流程图如图19所示。注意,格型陷波滤波是有滤波功能的,能够得到只有信号频率的增强信号,但是由于两路信号使用的两个IIR型滤波器,增强信号中的相位已经改变了,所以在后续算法中并没有使用增强信号,自适应格型陷波只用于估计信号频率。The flowchart of the adaptive lattice notch algorithm is shown in Figure 19. Note that the lattice notch filter has a filtering function and can obtain an enhanced signal with only the signal frequency. However, due to the two IIR filters used by the two signals, the phase in the enhanced signal has changed, so in the subsequent algorithm No boost signal is used, adaptive lattice notch is only used to estimate the signal frequency.
自适应格型陷波算法可用于跟踪变化的频率,且跟踪速度快,跟踪精度高,整个算法的计算量较小,一路自适应格型滤波得到一点频率值的时间为10.5μs,跟踪精度优于0.01%。并且调整参数的终值以及变化步长即可调整格型跟踪频率的速度和精度,这样,该算法可以灵活应用于突变、骤变的信号,比如两相流、批料流等应用。The adaptive lattice notch algorithm can be used to track the changing frequency, and the tracking speed is fast and the tracking accuracy is high. The calculation amount of the whole algorithm is small. The time for one channel of adaptive lattice filtering to obtain a frequency value is 10.5μs, and the tracking accuracy is excellent. at 0.01%. And by adjusting the final value of the parameters and changing the step size, the speed and accuracy of the grid pattern tracking frequency can be adjusted. In this way, the algorithm can be flexibly applied to sudden and sudden changes in signals, such as two-phase flow, batch flow and other applications.
在得到DTFT_omega频率值之后,连同500点信号数据传递到DTFT算法模块中,计算两路信号的相位差。对于平稳流量信号来说,我们认为一定时间内比如选择2s时间内的4000点数据基本保持不变,从第一个采样点开始不断增加数据长度来计算指定频率处的傅里叶系数,4000点后重新开始计算,防止数值的溢出。同时由于DTFT收敛有一个过程,所以4000点中我们只保存后面2500点的数据用于后面的平均处理。同时,为了提高计算精度,对得到的相位差进行负频率的修正。After the DTFT_omega frequency value is obtained, it is passed to the DTFT algorithm module together with 500 points of signal data to calculate the phase difference between the two signals. For a steady flow signal, we believe that within a certain period of time, for example, the data of 4000 points within 2s remains basically unchanged, and the data length is continuously increased from the first sampling point to calculate the Fourier coefficient at the specified frequency, 4000 points Then restart the calculation to prevent the overflow of the value. At the same time, because there is a process of DTFT convergence, we only save the data of the next 2500 points among the 4000 points for the subsequent average processing. At the same time, in order to improve the calculation accuracy, a negative frequency correction is performed on the obtained phase difference.
基于DTFT频谱分析的相位差测量方法在计算相位差时忽略了频谱中的负频率成分。当信号频率很低或采样点数较少时,负频率成分的影响显著增大,导致DTFT递推算法的相位差测量精度明显下降,甚至无法测量。这也是滑动Goertzel算法在计算相位差时存在较长的收敛过程的主要原因之一。为此,采用一种负频率修正的DTFT递推算法来测量相位差,其推导公式如式(13)至式(23)所示。The phase difference measurement method based on DTFT spectrum analysis ignores the negative frequency components in the spectrum when calculating the phase difference. When the signal frequency is very low or the number of sampling points is small, the influence of the negative frequency component is significantly increased, resulting in a significant decrease in the phase difference measurement accuracy of the DTFT recursive algorithm, or even impossible measurement. This is also one of the main reasons why the sliding Goertzel algorithm has a long convergence process when calculating the phase difference. To this end, a negative frequency correction DTFT recursive algorithm is used to measure the phase difference, and its derivation formula is shown in formula (13) to formula (23).
s1(t)=A1cos(2πf0t+θ1) (13-1)s 1 (t)=A 1 cos(2πf 0 t+θ 1 ) (13-1)
s2(t)=A2cos(2πf0t+θ2) (13-2)s 2 (t)=A 2 cos(2πf 0 t+θ 2 ) (13-2)
s1(n)=A1cos(ωt+θ1) (14-1)s 1 (n)=A 1 cos(ωt+θ 1 ) (14-1)
s2(n)=A2cos(ωt+θ2),n=0,1,...,N-1,ω=2πf0/fs (14-2)s 2 (n)=A 2 cos(ωt+θ 2 ), n=0, 1, ..., N-1, ω=2πf 0 /f s (14-2)
c1=sinα1sinα2cos(α1-α3)+sinα3sinα4cos(α4-α2) (18)c 1 = sinα 1 sinα 2 cos(α 1 -α 3 )+sinα 3 sinα 4 cos(α 4 -α 2 ) (18)
c2=sinα1sinα2sin(α1-α3)-sinα3sinα4cos(α4-α2) (19)c 2 = sinα 1 sinα 2 sin(α 1 -α 3 )-sinα 3 sinα 4 cos(α 4 -α 2 ) (19)
c3=sinα1sinα2sin(α1-α3)+sinα3sinα4sin(α4-α2) (20)c 3 =sinα 1 sinα 2 sin(α 1 -α 3 )+sinα 3 sinα 4 sin(α 4 -α 2 ) (20)
c4=sinα1sinα2cos(α1-α3)-sinα3sinα4cos(α4-α2) (21)c 4 =sinα 1 sinα 2 cos(α 1 -α 3 )-sinα 3 sinα 4 cos(α 4 -α 2 ) (21)
归纳起来,计及负频率影响的DTFT递推算法的计算步骤如下:To sum up, the calculation steps of the DTFT recursive algorithm considering the influence of negative frequency are as follows:
(1)求出ω的估计值由格型陷波滤波器估计频率;(1) Calculate the estimated value of ω Estimate frequency by lattice notch filter;
(2)应用DTFT递推算法(如式(15)所示)分别计算s1(n)和s2(n)在处的DTFT,求出tanφ1和tanφ2, (2) Apply DTFT recursive algorithm (as shown in formula (15)) to calculate s1(n) and s2(n) in DTFT at the place, find tanφ1 and tanφ2,
(3)由N求出m1~m4,并同tanφ和tanφ一起代入式(25),求得相位差和时间差。(3) by N finds m1 ~ m4, and substitutes into formula (25) together with tanφ and tanφ, obtains phase difference and time difference.
(4)当应用于实际系统时,随着N的不断增加,DTFT递推算法亦存在数值溢出的问题,因此需对采样点数设置最大值,超过最大值将所有变量清零重新计算,由于本发明专利的相位差测量方法在计算时收敛很快,因此重新计算带来的影响很小。通过实验发现,将最大值设置为2000时既能收敛到很高的精度,又能满足实时要求,当相位差发生变化时能很快跟踪上。(4) When applied to the actual system, with the continuous increase of N, the DTFT recursive algorithm also has the problem of numerical overflow. Therefore, it is necessary to set the maximum value for the number of sampling points. If the maximum value is exceeded, all variables are cleared and recalculated. Due to this The phase difference measurement method of the invention patent converges quickly during calculation, so the impact of recalculation is very small. Through experiments, it is found that when the maximum value is set to 2000, it can not only converge to a high precision, but also meet the real-time requirements, and can quickly track when the phase difference changes.
计及负频率影响的DTFT算法与滑动Goertzal算法在原理上是一致的,均通过不断增加计算序列的长度,实现指定频率处的傅里叶系数的快速计算,考虑到科式流量计相位差计算的实时性要求,需每采样一点计算一次傅里叶系数,DTFT的递推算法计算量要比滑动Goertzal算法小,且能很快收敛,具很高的计算精度.The DTFT algorithm and the sliding Goertzal algorithm, which take into account the influence of negative frequency, are consistent in principle. They both realize the fast calculation of the Fourier coefficient at the specified frequency by continuously increasing the length of the calculation sequence. Considering the calculation of the phase difference of the Corian flowmeter Due to the real-time requirements, the Fourier coefficient needs to be calculated every sampling point. The recursive algorithm of DTFT has a smaller calculation amount than the sliding Goertzal algorithm, and can converge quickly, with high calculation accuracy.
整个算法流程图如图20所示。The flow chart of the whole algorithm is shown in Figure 20.
为了防止数据统计变异性对相位差结果的影响,必须对若干个结果进行平均。科氏流量计在小流量的时候信号较弱,信噪比降低,信号质量比较差,DTFT计算得到的相位差波动比较大,必须采取平均措施,以便输出稳定的相位差值。To prevent the statistical variability of the data from affecting the phase difference results, several results must be averaged. The signal of Coriolis flowmeter is weak when the flow rate is small, the signal-to-noise ratio is reduced, and the signal quality is relatively poor. The phase difference calculated by DTFT fluctuates relatively large, and averaging measures must be taken in order to output a stable phase difference value.
我们采取下面的加权平均方法来对结果进行后里:We adopt the following weighted average method to rearrange the results:
式中,λ为加权平均的遗忘因子,大小接近1,即相当于个点数在平均。λ值小的话,表示平均的点数少,当相位差发生变化时,算法的响应速度会很快,但是由于平均点数少,数据的波动克服能力小,反之,如果λ值取小的话,表示平均的点数增加,这样可以很好的克服数据的波动性,输出平稳的结果,但如果流量出现突变,这时需要计算那么多点才能反映流量的变化,这仍会造成测量误差,因此还需采取设置门限值的方法来解决。设置一个相位差突变门限phase_limit,如果连续计算出N个相位差值波动幅度都超过了phase_limit,则对这N个相位差值和之后算出的结果平均,而前面的值都不参加平均,从而快速的反应流量变化。N一般取5至10,理论上,门限phase_limit选择的越小对微小突变越敏感,但实际中门限值也不能取太小,因为本身DTFT算法就会在一定范围内波动。平均模块的具体流程图如图21所示。In the formula, λ is the weighted average forgetting factor, which is close to 1, which is equivalent to points on average. If the value of λ is small, it means that the number of average points is small. When the phase difference changes, the response speed of the algorithm will be very fast, but because of the small number of average points, the ability to overcome data fluctuations is small. On the contrary, if the value of λ is small, it means that the average The number of points increases, which can well overcome the volatility of the data and output a stable result, but if the flow rate changes suddenly, so many points need to be calculated to reflect the change of the flow rate, which will still cause measurement errors, so further measures are needed Set the threshold method to solve it. Set a phase difference mutation threshold phase_limit. If the fluctuation range of N phase difference values calculated continuously exceeds the phase_limit, then the N phase difference values and the subsequent calculated results are averaged, and the previous values do not participate in the average, so as to quickly Response to flow changes. N generally ranges from 5 to 10. In theory, the smaller the threshold phase_limit is, the more sensitive it is to small mutations. However, in practice, the threshold value should not be too small, because the DTFT algorithm itself will fluctuate within a certain range. The specific flow chart of the averaging module is shown in Figure 21.
科里奥利质量流量计的性能会受环境的影响,其中温度的影响较为突出,温度的变化会引起质量流量计对流量、密度的测量误差,在实际高精度使用场合中必须考虑温度效应,并对质量流量进行温度补偿。The performance of the Coriolis mass flowmeter will be affected by the environment, and the influence of temperature is more prominent. The change of temperature will cause the measurement error of the mass flowmeter on the flow and density. In the actual high-precision use occasions, the temperature effect must be considered. And temperature compensation for mass flow.
流量计中的敏感管材料的弹性模量是随温度变化而变化的,一般认为材料的弹性模量的温度系数是确定的,可以适时检测温度利用计算机进行数字补偿。我们选取的流量计一次仪表敏感管材料为316L,根据资料流量斜率温度系数为5.41%/100℃。每2s输出一个瞬时流量,读取当下的温度值,根据温度得到补偿系数即可,瞬时流量的求取以及温度补偿如式(4)所示。The elastic modulus of the sensitive tube material in the flowmeter changes with the temperature. It is generally believed that the temperature coefficient of the elastic modulus of the material is determined, and the temperature can be detected timely and digitally compensated by the computer. The material of the primary instrument sensitive tube of the flowmeter we selected is 316L, and the temperature coefficient of the flow rate slope is 5.41%/100°C according to the data. Output an instantaneous flow every 2s, read the current temperature value, and get the compensation coefficient according to the temperature. The calculation of the instantaneous flow and temperature compensation are shown in formula (4).
系统输出模块即远程信号发送操作模块,包含两个子操作,分别是4~20mA电流输出操作和脉冲输出操作。The system output module is the remote signal transmission operation module, which includes two sub-operations, namely 4-20mA current output operation and pulse output operation.
4~20mA电流输出的基本原理为:由于28335的1个SPI模块已被占用,所以使用内部通用GPIO口来模拟SPI时序向DA7513转换器发送12位串行数据,由D/A完成数字量到模拟电压量转换,再通过一个V/I变换电路,将电压量转换为4~20mA电流量.因此,4~20mA电流输出软件操作为:根据瞬时流量估计结果向DA7513写入相应数据即可.估计电压公式如式(5)和式(6)所示.The basic principle of 4-20mA current output is: since one SPI module of 28335 has been occupied, the internal general-purpose GPIO port is used to simulate the SPI timing to send 12-bit serial data to the DA7513 converter, and the digital quantity is transferred to the DA7513 converter by D/A. The analog voltage is converted, and then through a V/I conversion circuit, the voltage is converted into a 4-20mA current. Therefore, the 4-20mA current output software operation is: write the corresponding data to the DA7513 according to the instantaneous flow estimation result. The estimated voltage formula is shown in formula (5) and formula (6).
PWM输出功能是由DSP的ePWM模块中一路PWM的比较输出功能来实现的,输出脉冲范围为10Hz-5kHz。由于科里奥利质量流量计可直接给出流体质量,所以PWM波输出脉冲的个数对应质量,本系统可测量的流速范围为1g/s-500g/s,那么要求1s输出PWM脉冲个数为1-500个即1个脉冲代表1g,也就是说PWM脉冲频率为1Hz-500Hz,由于28335PWM模块可输出最小频率为8.9Hz(150000000/2/128/65536),因此将PWM脉冲频率扩大10倍,即10个脉冲代表1g,脉冲频率变为10Hz-5kHz。The PWM output function is realized by the comparison output function of one PWM in the ePWM module of DSP, and the output pulse range is 10Hz-5kHz. Since the Coriolis mass flowmeter can directly give the mass of the fluid, the number of PWM wave output pulses corresponds to the mass. The flow rate range that this system can measure is 1g/s-500g/s, so the number of PWM pulses output in 1s is required It is 1-500, that is, one pulse represents 1g, that is to say, the PWM pulse frequency is 1Hz-500Hz. Since the 28335PWM module can output a minimum frequency of 8.9Hz (150000000/2/128/65536), the PWM pulse frequency is expanded by 10 times, that is, 10 pulses represent 1g, and the pulse frequency becomes 10Hz-5kHz.
由于算法计算的瞬时流量为浮点数,需取整换算周期寄存器和比较寄存器的值,取整会导致周期寄存器的值增加,进而有可能导致每输出一个PWM脉冲时会多计一个TBCLK,为了保证最后PWM不多输出一个脉冲,要求1s累加的TBCLK的个数小于比较寄存器值,即要求fPWM<PRD/2,频率具体分段如图22所示。Since the instantaneous flow calculated by the algorithm is a floating-point number, it is necessary to round to convert the values of the period register and the comparison register. Rounding will cause the value of the period register to increase, which may cause an extra TBCLK to be counted every time a PWM pulse is output. In order to ensure Finally, PWM does not output more than one pulse, and the number of TBCLK accumulated in 1s is required to be less than the comparison register value, that is, f PWM <PRD/2 is required, and the specific frequency division is shown in Figure 22.
为了尽量减少整数截断对输出PWM脉冲个数造成的影响,设置了中间变量middle_fre用于累加本次PWM频率值和上次频率值取整后丢掉的小数部分,然后对middle_fre取整即得到本次输出PWM的频率值,所以,PWM输出函数流程图如图23所示。In order to minimize the impact of integer truncation on the number of output PWM pulses, an intermediate variable middle_fre is set to accumulate the current PWM frequency value and the fractional part lost after rounding the previous frequency value, and then round up middle_fre to obtain this time Output the frequency value of PWM, so the flow chart of PWM output function is shown in Figure 23.
系统扩展了256×16大小的EEPROM型号为93LC66,用来保存测量结果和仪表系数以及其他一些需要掉电保存的数据。通过DSP上的多功能复用GPIO口模拟串行时序对EEPROM来进行数据读写和控制,典型的写数据的时间为10ms,因此读写EEPRM用于两种场合:第一:用于系统初始化中的全局变量初始化;第二:与键盘合作,用于保存键盘设置的参数以及要保存的结果数据。The system expands the EEPROM model 93LC66 with a size of 256×16, which is used to save the measurement results, instrument coefficients and other data that need to be saved when the power is turned off. Through the multi-function multiplexing GPIO port on the DSP to simulate the serial timing to read, write and control the data of EEPROM, the typical data writing time is 10ms, so reading and writing EEPRM is used in two occasions: first: for system initialization The global variable initialization in; the second: cooperate with the keyboard to save the parameters set by the keyboard and the result data to be saved.
在配置好EEPROM的GPIO口后,在写数据之前,应该先发送控制字写使能,如果写入一个固定地址数据,最好先擦除该地址上原来的数据,然后指定8位地址、16位数据,写入要保存的数据,读取的时候,同样需要指定地址。本系统中需要保存三种数据:仪表系数K、零点固定偏差φ、要保存的累计流量Q。并给三种数据分配了固定的地址。在读写EPROM过程中关键是数据格式的转化,写入数据时需要把浮点数转化为32位的整型数据,读取数据时又需要把32位整形数据转化为浮点型数据。After configuring the GPIO port of the EEPROM, before writing data, you should first send the control word write enable. If you write data at a fixed address, it is best to erase the original data on the address first, and then specify the 8-bit address, 16 Bit data, write the data to be saved, and also need to specify the address when reading. Three kinds of data need to be saved in this system: instrument coefficient K, zero point fixed deviation φ, accumulated flow Q to be saved. And assign a fixed address to the three kinds of data. The key in the process of reading and writing EPROM is the transformation of the data format. When writing data, the floating-point number needs to be converted into 32-bit integer data, and when reading data, the 32-bit integer data needs to be converted into floating-point data.
在仪表开始工作时,需要通过键盘来设置仪表系数K和零点固定偏差φ,此时需要将两个参数保存,程序开始运行进入初始化阶段时,需要把这两个数据读出赋给相应的变量,然后开始算法过程,整个测量过程是不需要使用EEPROM操作的,测量完成后查询是否保存累计流量标志,如果标志置位,则需要写该结果数据到EEPROM的指定地址中。When the instrument starts to work, it is necessary to set the instrument coefficient K and zero point fixed deviation φ through the keyboard. At this time, the two parameters need to be saved. When the program starts to run and enters the initialization stage, these two data need to be read out and assigned to the corresponding variables. , and then start the algorithm process, the entire measurement process does not need to use EEPROM to operate, after the measurement is completed, query whether to save the accumulated flow flag, if the flag is set, you need to write the result data to the specified address of the EEPROM.
在测量过程中可能会出现一些异常,比如测量结果超出范围、数组越界、数据覆盖等等的情况,为了便于监测这些错误同时也为了方便调试,在系统软件中加入了错误模块,用来标记和记录程序执行过程中产生的异常情况.错误模块的设置非常简单,设置一个全局变量用于记录错误代码,以及使用宏定义一些错误代码标志和错误处理接口函数.这样其他模块只要包含错误模块后,如果发生错误,就可以调用宏定义函数报告错误状况,并置位错误标志,这样就可以清楚的知道运行中是否出现错误以及出现了哪类错误,便于监测和调试.错误模块只负责记录错误信息,对于错误的处理还需要各个模块中的具体函数去处理.There may be some abnormalities during the measurement process, such as measurement results out of range, array out of bounds, data coverage, etc. In order to facilitate monitoring of these errors and facilitate debugging, an error module is added to the system software to mark and Record the abnormal conditions generated during the execution of the program. The setting of the error module is very simple. Set a global variable to record the error code, and use macros to define some error code flags and error handling interface functions. In this way, other modules only need to include the error module. If an error occurs, you can call the macro definition function to report the error status and set the error flag, so that you can clearly know whether there is an error and what type of error occurred during operation, which is convenient for monitoring and debugging. The error module is only responsible for recording error information , the error handling also needs specific functions in each module to handle.
系统的人机接口模块由LCD和键盘组成,用于实现仪表测量结果的就地显示和仪表参数的修改。其软件实现包括LCD操作子程序和键盘处理的子程序。The man-machine interface module of the system is composed of LCD and keyboard, which is used to realize the local display of the instrument measurement results and the modification of the instrument parameters. Its software implementation includes LCD operation subroutines and keyboard processing subroutines.
Claims (9)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN2009101855608A CN101706299B (en) | 2009-11-20 | 2009-11-20 | A Coriolis Mass Flow Transmitter Based on DSP |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN2009101855608A CN101706299B (en) | 2009-11-20 | 2009-11-20 | A Coriolis Mass Flow Transmitter Based on DSP |
Publications (2)
Publication Number | Publication Date |
---|---|
CN101706299A true CN101706299A (en) | 2010-05-12 |
CN101706299B CN101706299B (en) | 2011-03-30 |
Family
ID=42376536
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN2009101855608A Active CN101706299B (en) | 2009-11-20 | 2009-11-20 | A Coriolis Mass Flow Transmitter Based on DSP |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN101706299B (en) |
Cited By (18)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101881947A (en) * | 2010-05-26 | 2010-11-10 | 北京航空航天大学 | Coriolis mass flow meter full digital closed-loop system |
CN103245386A (en) * | 2013-04-10 | 2013-08-14 | 温州新蓝科技有限公司 | Coriolis flowmeter and information processing technology thereof |
CN103528634A (en) * | 2013-10-23 | 2014-01-22 | 山东大学 | Coriolis mass flow meter cloud transmission digital signal processing device and method |
WO2014067059A1 (en) * | 2012-10-30 | 2014-05-08 | 西安东风机电有限公司 | Digital drive method and system of coriolis flow meter |
WO2014110724A1 (en) * | 2013-01-16 | 2014-07-24 | Nestec S.A. | Vibration monitoring system for a liquid food producing apparatus |
CN104011511A (en) * | 2011-12-23 | 2014-08-27 | 大陆汽车有限责任公司 | Sensor system |
CN104019850A (en) * | 2013-03-02 | 2014-09-03 | 山西太钢不锈钢股份有限公司 | Method for measuring volume flow rate of fluid |
CN105203169A (en) * | 2014-06-26 | 2015-12-30 | 微动公司 | Transmitter and method for transmitting sensor signals in transmitter |
CN105865555A (en) * | 2016-05-24 | 2016-08-17 | 合肥工业大学 | High temperature-resisting simulation driving circuit for Coriolis mass flow meter |
CN106525267A (en) * | 2016-12-16 | 2017-03-22 | 山东金洲科瑞节能科技有限公司 | Bus type temperature measuring device |
CN107084770A (en) * | 2016-02-14 | 2017-08-22 | 高准有限公司 | Signal pickup circuit, transmitter, the method for flowmeter and pickoff signals |
CN107102586A (en) * | 2017-05-24 | 2017-08-29 | 西北工业大学 | A kind of coriolis mass flowmeters amplitude control method |
CN107806909A (en) * | 2017-09-13 | 2018-03-16 | 南京农业大学 | A kind of impulse type cereal flow transducer signal acquisition and processing apparatus |
CN110709676A (en) * | 2017-06-02 | 2020-01-17 | 恩德斯+豪斯流量技术股份有限公司 | Sensor for measuring the mass flow of a flowable medium |
CN111006731A (en) * | 2019-12-10 | 2020-04-14 | 海默潘多拉数据科技(深圳)有限公司 | Intelligent oil well flow measuring method based on multiphase flowmeter |
CN111566457A (en) * | 2017-11-14 | 2020-08-21 | 恩德斯+豪斯流量技术股份有限公司 | Measuring device with at least one curved measuring tube for determining a measured value of the mass flow of a medium according to the coriolis principle |
CN114828370A (en) * | 2022-03-18 | 2022-07-29 | 合肥工业大学 | Self-adaptive phase difference calculation method for plasma density measurement |
CN117268512A (en) * | 2023-11-23 | 2023-12-22 | 青岛鼎信通讯科技有限公司 | Consistency optimization method suitable for ultrasonic water meter |
-
2009
- 2009-11-20 CN CN2009101855608A patent/CN101706299B/en active Active
Cited By (25)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101881947A (en) * | 2010-05-26 | 2010-11-10 | 北京航空航天大学 | Coriolis mass flow meter full digital closed-loop system |
US9541434B2 (en) | 2011-12-23 | 2017-01-10 | Continental Automotive Gmbh | Sensor system |
CN104011511A (en) * | 2011-12-23 | 2014-08-27 | 大陆汽车有限责任公司 | Sensor system |
WO2014067059A1 (en) * | 2012-10-30 | 2014-05-08 | 西安东风机电有限公司 | Digital drive method and system of coriolis flow meter |
CN104040301A (en) * | 2012-10-30 | 2014-09-10 | 西安东风机电有限公司 | Digital drive method and system of coriolis flow meter |
WO2014110724A1 (en) * | 2013-01-16 | 2014-07-24 | Nestec S.A. | Vibration monitoring system for a liquid food producing apparatus |
CN104019850A (en) * | 2013-03-02 | 2014-09-03 | 山西太钢不锈钢股份有限公司 | Method for measuring volume flow rate of fluid |
CN103245386A (en) * | 2013-04-10 | 2013-08-14 | 温州新蓝科技有限公司 | Coriolis flowmeter and information processing technology thereof |
CN103528634A (en) * | 2013-10-23 | 2014-01-22 | 山东大学 | Coriolis mass flow meter cloud transmission digital signal processing device and method |
CN105203169A (en) * | 2014-06-26 | 2015-12-30 | 微动公司 | Transmitter and method for transmitting sensor signals in transmitter |
CN107084770A (en) * | 2016-02-14 | 2017-08-22 | 高准有限公司 | Signal pickup circuit, transmitter, the method for flowmeter and pickoff signals |
CN105865555A (en) * | 2016-05-24 | 2016-08-17 | 合肥工业大学 | High temperature-resisting simulation driving circuit for Coriolis mass flow meter |
CN105865555B (en) * | 2016-05-24 | 2018-08-24 | 合肥工业大学 | A kind of high temperature resistance analog drive circuit of Coriolis mass flowmeter |
CN106525267A (en) * | 2016-12-16 | 2017-03-22 | 山东金洲科瑞节能科技有限公司 | Bus type temperature measuring device |
CN107102586A (en) * | 2017-05-24 | 2017-08-29 | 西北工业大学 | A kind of coriolis mass flowmeters amplitude control method |
CN110709676A (en) * | 2017-06-02 | 2020-01-17 | 恩德斯+豪斯流量技术股份有限公司 | Sensor for measuring the mass flow of a flowable medium |
CN107806909A (en) * | 2017-09-13 | 2018-03-16 | 南京农业大学 | A kind of impulse type cereal flow transducer signal acquisition and processing apparatus |
US11378432B2 (en) | 2017-11-14 | 2022-07-05 | Endress+Hauser Flowtec Ag | Measuring device having at least one bent measuring tube for determining a mass flow measured value of a medium according to the Coriolis principle |
CN111566457A (en) * | 2017-11-14 | 2020-08-21 | 恩德斯+豪斯流量技术股份有限公司 | Measuring device with at least one curved measuring tube for determining a measured value of the mass flow of a medium according to the coriolis principle |
CN111566457B (en) * | 2017-11-14 | 2022-06-03 | 恩德斯+豪斯流量技术股份有限公司 | Measuring device with at least one curved measuring tube for determining a measured value of the mass flow of a medium according to the coriolis principle |
CN111006731A (en) * | 2019-12-10 | 2020-04-14 | 海默潘多拉数据科技(深圳)有限公司 | Intelligent oil well flow measuring method based on multiphase flowmeter |
CN114828370A (en) * | 2022-03-18 | 2022-07-29 | 合肥工业大学 | Self-adaptive phase difference calculation method for plasma density measurement |
CN114828370B (en) * | 2022-03-18 | 2024-04-19 | 合肥工业大学 | An adaptive phase difference calculation method for plasma density measurement |
CN117268512A (en) * | 2023-11-23 | 2023-12-22 | 青岛鼎信通讯科技有限公司 | Consistency optimization method suitable for ultrasonic water meter |
CN117268512B (en) * | 2023-11-23 | 2024-02-09 | 青岛鼎信通讯科技有限公司 | Consistency optimization method suitable for ultrasonic water meter |
Also Published As
Publication number | Publication date |
---|---|
CN101706299B (en) | 2011-03-30 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN101706299B (en) | A Coriolis Mass Flow Transmitter Based on DSP | |
CN101451864A (en) | Improved low power consumption two-wire system vortex shedding flowmeter | |
CN101782407B (en) | Digital vortex street/precession flowmeter powered by battery | |
CN108020282B (en) | Coriolis mass flowmeter signal processing method based on complex coefficient filtering | |
CN102128656B (en) | Slightly bent Koch mass flow meter digital signal processing method and system | |
CN106154816B (en) | A kind of punctual method of automatic device high-precision | |
CN100470207C (en) | Two-wire vortex flowmeter | |
CN104375006B (en) | A kind of Fast synchronization phase amount correction method | |
CN103528634B (en) | A kind of coriolis mass flowmeters cloud transmission digital signal processing device and method | |
CN203720285U (en) | Online electric power quality monitoring device | |
CN104914304A (en) | Electric energy accurate measurement method and electric energy accurate measurement device under fluctuating load | |
CN102176112A (en) | Method for achieving accurate clock timing by arranging RTC (real time clock) in MCU (micro control unit) | |
CN200993665Y (en) | Small digitalized prase-comparing measuring device | |
CN101162479A (en) | Design method of electric energy quality monitoring application-specific integrated circuits based on soft nucleus CPU technology | |
CN109061259A (en) | A kind of intelligent electric energy meter analysis of metering error method, metering device and intelligent electric energy meter | |
CN109005002A (en) | Sensing data processing unit, sensing system and the method for determining reduced parameter in the scope of the sensing system | |
CN109709393A (en) | Device based on time domain signal frequency stability measurement | |
CN101363746B (en) | Fluid vibration type effusion meter self-adapting FFT power spectrum analysis and signal processing method | |
CN1268659A (en) | Ke's mass flowmeter digital signal processing system | |
CN104937504A (en) | Quartz electronic watch high-precision timekeeping method | |
CN107687875A (en) | A kind of magnetic vortex street flowmeter for measuring gassiness the flow of conductive liquid | |
CN117007861A (en) | FPGA-based spectrum analysis system and method | |
CN106501605A (en) | One kind is than phase device | |
CN103018557A (en) | Normalization master-slave type harmonic wave and inter-harmonic wave real-time analysis method | |
CN107167196A (en) | A kind of Ke's mass flowmeter digital drive system based on FPGA |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
TR01 | Transfer of patent right | ||
TR01 | Transfer of patent right |
Effective date of registration: 20221101 Address after: 325600 291 weft seventeen Road, Yueqing Economic Development Zone, Wenzhou, Zhejiang Patentee after: Goldcard Smart Group Co.,Ltd. Address before: Tunxi road in Baohe District of Hefei city of Anhui Province, No. 193 230009 Patentee before: Hefei University of Technology |