Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - digital frequency meter
digital frequency meter
Taking TMS320F28 12 DSP chip as the control unit, the equal precision measurement is realized by using the rich software resources of DSP 28 12 without any gating devices. According to the number of high-frequency standard pulses in each gate-gate time and the number of known measured signals, the frequency of the measured signals is obtained, and then the final result is obtained through multiple averages.

Keywords: digital frequency meter; Equal precision measurement; No children after death.

* This work won the first prize in the proposition group of Dezhou Instruments C2000 DSP Grand Prix in 2008, and was supported by Hefei University of Technology's innovative experiment plan for college students in 2008.

Significance and overview of the work

With the rapid development of microelectronics and computer technology, the principle, function, accuracy and automation level of various electronic measuring instruments have changed greatly, especially after the birth of DSP technology, electronic measuring technology has entered a new era. In recent years, DSP has gradually become the basic device of various electronic devices, the sunrise industry with the most development potential in 2 1 century, and even known as the revolutionary standard bearer in the information and digital age. In electronic measurement technology, frequency is one of the most basic parameters, which is closely related to many electrical parameters and non-electrical measurement. For example, many sensors convert some non-electric quantity into frequency to measure, so the measurement of frequency is more important. Digital frequency meter is an instrument that displays the frequency of the measured signal digitally. The measured signal can be sine wave, square wave or other periodically changing signals.

High-speed integrated circuits and large-scale integrated circuits are widely used in digital frequency meters, which makes the instrument smaller, lower in power consumption and higher in accuracy and reliability. The traditional frequency meter is gradually replaced by the new digital frequency meter because of its large measurement error and narrow range. The equal precision frequency meter based on DSP has the advantages of accurate measurement, high precision, convenient use and low price, and will be widely used.

The simple digital frequency meter designed by us can measure the frequency with equal accuracy in a wide range without using any gating devices. In the range of 0.5 Hz ~10 MHz, the maximum relative error of square wave measurement is less than 2e-6, and that of sine wave measurement is less than 3.5e-5. The results are displayed on the computer through RS232 communication, and the data can be monitored conveniently.

scheme design

General introduction

The traditional equal-precision frequency measurement method uses gating devices to generate gating signals, which realizes the synchronization between the actual gating signals and the measured signals and eliminates the error of one pulse generated by counting the measured signals. Its schematic diagram is shown in figure 1.

Figure 1 Traditional Equal Precision Measurement Principle

The counting gate time is controlled by hardware. When the preset gate signal (i.e., the gate setting signal) is at a high level, the reference signal counter CNT 1 and the measurement signal counter CNT2 are not started, but start counting at the same time when the rising edge of the measurement signal arrives. When the preset signal is low, the two counters will not be closed immediately, but will also be closed after the rising edge of the measured signal arrives. Therefore, the actual gating time is an integer multiple of the period of the measured signal, thus realizing the synchronization of gating and the measured signal. But the actual door-to-door time is not fixed, which is related to the frequency of the measured signal. In addition, whether using counter or single chip microcomputer, it is always inseparable from the door control device when achieving equal precision measurement.

Based on the abundant software resources of DSP, this design completes the equal precision measurement of the frequency of the measured signal through judgment and processing. There is no need for any gating device in hardware, which simplifies the circuit. The system block diagram is shown in Figure 2. The signal processing part takes TMS320F28 12 DSP chip as the control and measurement core. The signal conditioning part mainly completes signal amplification, shaping and limiting; The standard frequency signal is generated by a 30MHz active crystal oscillator as a high-frequency standard filling pulse; The communication with the upper computer is realized through the SCI module of DSP, and the results are displayed on the upper computer.

Figure 2 System Block Diagram

Frequency/period measurement

When measuring the frequency and period of the measured signal, the equal precision measurement is based on the jump of the output level of the T 1PWM pin when the DSP comparison matches the turn-on and turn-off of the gate-gate signal. Because the comparison and matching occur at the rising edge of the measurement signal, the synchronization between the gate-gate time and the measurement signal is realized. The schematic diagram is shown in Figure 3.

Fig. 3 Principle of Equal Precision Frequency Measurement

The clock input of general timer T 1 selects the external timer clock. Here, the conditioned measurement signal is used as the clock input of timer T 1, and the clock input of timer T2 selects the internal CPU clock to generate high-frequency standard filling pulse. When the general timer T 1 in the on-chip EVA of F28 12 has a comparison matching event, the CMP output signal of its comparison output pin T 1 will automatically change the level state and generate PWM waves. The capture unit CAP 1 is set to capture the rising edge, and the rising edge of the PWM wave output by T 1 is captured by CAP 1. At this time, the count value of timer T2 is read, and the count value of timer T2 is also read again when the next comparison matches. By subtracting the T2CNT value twice, the number of standard filling pulses in the gate-gate time can be obtained, and then the frequency of the measurement signal can be obtained.

When comparing and matching based on DSP, the jump of output level of T 1PWM pin is used as the turn-on and turn-off of gate-gate signal. Because the comparison and matching occur at the rising edge of the measurement signal, the synchronization between the gate-gate time and the measurement signal is realized. The rising edges of two adjacent PWM waves generated by comparison and matching are respectively used as the opening and closing signals of the gate-gate signal, in which the number of signals to be measured is an integer, which is arbitrarily set by ourselves. The clock input of timer T2 selects the internal CPU clock to generate the standard filling pulse. Set the capture unit CAP 1 as rising edge capture, read the value in the stack CAPFIFO when capturing the rising edge, and then read the value in the stack when capturing the next time, and calculate the number of standard filling pulses Ny, thus ensuring that the number of Ny is not less than a certain value, that is, ensuring that the gate-gate time is longer than a certain value. Assuming that the total number of high-frequency filling pulses in the gate-gate time is not less than n now, when NY >: N, the timing period of the timer T 1 increases, that is, the value of the timer T 1 period register TIPR increases. There is a formula T 1PR+ 1=n/Ny, because n/Ny is not necessarily an integer, so a.

The basic principle of periodic measurement is exactly the same as that of frequency measurement. By measuring the signal frequency, the period of the measured signal can be obtained according to the commonly used t =1/f.

error analysis

The start and end time of timer T 1 counting is triggered by the rising edge of the signal, and there is no error in counting the measured signal within a measuring time. At this time, the counting number Ny of standard frequency pulses differs by at most one pulse, so the theoretical error is:

|d|≤ 1/Ny

Obviously, the measurement accuracy is only related to Ny. As long as the value of Ny is large enough, the accuracy can be guaranteed.

hardware design

As shown in fig. 4, the measured signal is amplified by the high-speed operational amplifier OPA2690 and shaped by the high-speed comparator TL30 16 [3]. When the comparator shapes the low-frequency sine wave signal, the edge of the output waveform has serious jitter, which affects the measurement. The solution is to add positive feedback to the comparator to accelerate the signal edge and form a hysteresis loop, which can effectively eliminate jitter. The shaped signal is clipped by high-speed Schmitt trigger SN74LVC 1G 14 and further shaped. In the measurement part, the clock input pin TCLKINA of timer T 1 on DSP28 12 chip, the comparison output pin T 1 PWM of timer T1and the input pin CAP 1 of capture unit are mainly used to complete the frequency measurement. In the communication part, MAX322 1 is selected as the RS-232 level converter, and serial communication is carried out with the upper computer through the 9-core standard RS-232 port. The serial communication sending pin SCIRXD and serial communication receiving pin SCITXD of DSP are mainly used.

Fig. 4 Hardware circuit connection diagram

software design

The software design part mainly includes the following four parts:

Initialization: configure variable parameters, system clock, PIE, EV, Flash, GPIO, etc.

Interrupt module: SCI interrupt and timer T2 and T3 overflow interrupt.

Data processing module: segmentation+arithmetic average.

Output operation module: the data is transmitted to the upper computer through RS-232.

Fig. 5 is a software flow chart of measuring frequency and period, and fig. 6 is a flow chart of timer 2 overflow interrupt.

Fig. 5 Flow chart of frequency and period measurement

Fig. 6 Flow chart of timer T2 overflow interrupt

When initializing this part, the following configuration should be made: the clock input of general timer T 1 is external timer clock, and the clock input of general timer T2 is internal clock input, which is used to count the standard pulses provided by external 30MHz active crystal oscillator; The capture unit 1 is set to capture the rising edge of the PWM wave output by the T 1PWM pin, and the count value T2CNT of the timer T2 is read every time the comparison matches, which is stored in the CAP 1FIFO. During initialization, the FIFO stack state in the status register of capture unit 1 should be set to empty stack; Set the timing period of the timer T 1 to the period length of four signals to be measured, calculate the frequency of the signals to be measured by the number of standard pulses in one timing period of the timer T 1, and then segment the signals to be measured, namely, low frequency band (less than 46.875Hz) and medium frequency band (more than 46.875Hz and less than 2343.75KHz). If the signal frequency is in the middle and high frequency band, the registers of timer T 1 and timer T2 are reconfigured to change the timing period and the number of high frequency filling pulses in each gating time. Calculate the frequency and period of the next timer T 1. In addition, when comparison matching occurs for the first time, to clear the overflow times of timer T2, a flag can be set to determine whether comparison matching occurs for the first time. When the overflow time is cleared, the overflow time is recorded until the second comparison and matching occurs.

Suggestions for further improvement

The measurement error of this method mainly comes from the hardware part, and the quality of shaping circuit is directly related to the measurement accuracy. Therefore, our next step is to improve the shaping effect and anti-interference performance of the shaping circuit and reduce the error caused by signal shaping as much as possible.

Due to the saturation of DSP timer count, there is an upper limit to achieve such accuracy measurement, that is, when the frequency of the measured signal is higher than that of the high-frequency filling pulse, this method cannot achieve equal accuracy. On the basis of this scheme, the following processing can be carried out: the number of signals to be measured is fixed in the timing period of timer T 1, T 1PR can be set to 65529, and the clock of timer T2 is modified to 75MHz, thus ensuring the number of high-frequency filling pulses in each gate time, thus ensuring the accuracy of measuring the frequency and period of high-frequency signals.

However, when the clock input of the timer T 1 is selected as the external clock, the input range of the measurement signal is limited. If the range of the measured signal is to be further increased to several hundred megabytes or as high as G Hz, we can consider the method of phase measurement, set the measured signal to 360 degrees, and calculate the frequency of the measured signal according to the X-degree phase difference between the measured signal and the standard signal.

References:

1. Zhang Zhiwen, Tian Yingfeng, research on high-precision frequency measurement system based on DSP, Journal of University of Technology .2007,

27(2): 167- 170

2. Texas Instruments. Reference guide for control and interruption of TMS320C28x DSP system. Texas Instruments, July 2003

3. Organizing Committee of National Electronic Design Competition for College Students, Compilation of Winning Works of National Electronic Design Competition for College Students, beijing institute of technology press, August 2004 169-2 16.

4. Xu,,, TMS320X28 1x DSP principle and application, Beijing University of Aeronautics and Astronautics Press, 2006.

5. Zhao Yongsheng, Zu and Niu, Design of Equal Precision Frequency Meter Based on Single Chip Microcomputer, Microcomputer Information (Embedded and SOC), 2007,23 (9-2):152-154.

Similar article:

Application of DSP and CAN Bus in DC Motor Test System

Research on on-line writing method of TMS 320 VC 55 x series DSP

Design of multi-band mixed signal test system based on DSP

Using Linux and DSP/BIOS to realize dual OS signal processing technology.

Design of High Precision Digital Frequency Meter Based on TMS320F28 12