Design of Digital Frequency Meter Based on TMS320F2812

Publisher:DazzlingSpiritLatest update time:2010-06-23 Source: 单片机与嵌入式系统应用 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Frequency refers to the number of times a periodic phenomenon is repeated per unit time, and it is mathematically the reciprocal of time. The precise measurement of time frequency has promoted the development of science, and the development of science has in turn raised the measurement of time frequency to a new level. Especially in recent decades, the measurement accuracy of frequency and time has reached a very high level, far exceeding the measurement accuracy of all other physical quantities. Its main application areas include navigation and communication, as well as space technology, industrial production, transportation, scientific research, astronomy and metrology.
In order to meet the requirements of modern technology development, new frequency meters all use single-chip microcomputers for data processing. In this way, software replaces complex hardware circuits, simplifying the structure of the instrument and enhancing its functions. This paper presents a simple frequency measurement method based on TMS320F2812 (F2812 for short) DSP. This method effectively utilizes the capture function of the on-chip external event manager of F2812 to capture and count at the effective level transition edge of the measured signal. The circuit is mostly implemented by software settings, with simple calculation, good real-time performance and high measurement accuracy.
1 Measurement method
Commonly used frequency measurement methods include direct frequency measurement, direct period measurement and multi-cycle measurement. Although the direct frequency measurement method has higher accuracy in the high frequency band, it has lower accuracy in the low frequency band, while the direct period measurement method is just the opposite. The multi-cycle measurement method is to input the measured signal and the standard signal into two counters respectively. Its actual gate time is not a fixed value, but an integer multiple of the period of the measured signal. Therefore, the counting error of ±1 Hz generated when counting the measured signal is eliminated, and its accuracy is only related to the gate time and the standard frequency. Therefore, this design adopts the multi-cycle measurement method as a specific implementation plan.
2 System Design
2.1 System Hardware Design
The overall block diagram of the hardware system is shown in Figure 1. The measured signal first passes through the limiting amplifier, DC bias, and shaping circuit to be converted into a 0-3.3 V square wave signal, and then enters the DSP, using its timer and capture unit to achieve frequency measurement. After the measurement is completed, on the one hand, the relevant parameters can be set by the keyboard to display the measurement results on the LCD, and on the other hand, the measurement results can be transmitted to the PC through RS-232 to display the measurement results. In addition, in order to improve the reliability of the system, a self-calibration circuit is added, that is, before the measurement, a 1 MHz standard pulse signal can be generated through the software setting and sent to the input end of the signal conditioning module to detect whether the measurement result is correct, thereby achieving the purpose of self-calibration.
This design uses the TMS320F2812 DSP of Texas Instruments (TI) as the core processing unit. F2812 is a high-speed, high-precision industrial control DSP chip launched by TI in recent years. It has a fast computing speed, a working clock frequency of 150 MHz, an instruction cycle of less than 6.67 ns, and low power consumption (core voltage 1.8 V, I/O port voltage 3.3 V). It adopts the Harvard bus structure and has powerful operating capabilities; peripheral devices include 3 32-bit CPU timers, 16-channel 12-bit A/D converters, serial peripheral interfaces (SPI), 2 serial communication interfaces (SCI), etc. Its on-chip peripheral time manager contains 2 modules (EVA and EVB), each of which includes 2 general timers, 3 full comparison/PWM units, 3 capture units and 1 orthogonal encoding pulse circuit. This design mainly uses 2 general timers (T1 and T2), 2 capture units (CAP1 and CAP3) in EVA, and 1 general timer (T3) in EVB. The specific measurement principle is shown in Figure 2.
First, set the T3 comparison value (preset gate time is 0.012 8 s), set the T1 comparison value to 1, and enable CAP1. Then enable T1, and when it receives a full cycle of the measured signal, it can generate a comparison output, and at the same time generate a comparison interrupt, read the stack value of CAP1 (that is, the initial value of T2 t2_1), clear the overflow times of T1 and T2, and enable CAP3 and T3. Finally, when the T3 timing ends, with the help of the D flip-flop, when the next rising edge of the measured signal arrives, the comparison output of T1 is cut off, and PDPINTA will be set at the same time, and then the overflow times tlofcount and t2ofcount of T1 and T2 are recorded, and the stack value of CAP1 (that is, the final value t2_2 of T2) and the stack value of CAP3 (that is, the final value tl_2 of T1) are read. Calculate the frequency from the obtained data, and disable T1, T2, CAP1 and CAP3. The frequency calculation formula is:
Note: The capture time base of CAP1 is T2, the capture time base of CAP3 is T1, and the standard frequency signal is 8 divided by the 150 MHz clock frequency.
2.2 System software design
The main monitoring program is the general scheduler of the entire software system, which controls the orderly operation of the program. After the system is powered on or reset, the main program first calls the initialization subroutines of each module, mainly including GPIO initialization, PIE initialization, EV initialization and SCI initialization. After the system initialization is completed, the main program starts CPU_Timer0, enables the overflow interrupts of T1 and T2, starts CAP1, sets the comparison value of T1 to 1, waits for T1CINT to be set, and starts measuring the frequency. In order to reduce the random errors generated during the measurement process, the measured results are averaged. CPU_Timer0 is used to generate a certain time period (0.6s). After the end of this period (CPU_Timer0 interrupt flag is set), the measurement results recorded in this period are averaged. At this time, if the host computer sends a receive request, the corresponding data is transmitted to the PC for display. Then, the timer and capture unit are reinitialized to enter the next round of measurement. The main monitoring program flow is shown in Figure 3.
Part of the source code for frequency measurement is as follows:
3 Error analysis and test results
3.1 Quantization Error
Assume that the frequency of the measured signal is Fx, its true value is Fxe, and the standard frequency is Fs. In a measurement, the preset gate time is T′, Tpr is the actual gate time, the count value of the measured signal is Nx, and the count value of the standard frequency signal is Ns.
The start and stop time of Fx counting is triggered by the rising edge of the signal. Within the T′ time, the count Nx of Fx is error-free, and the count Ns of Fs is assumed to differ by N pulses, that is, |△et|≤n.
Since Fx/Nx=Fs/Ns, Fxe/Nx=Fs/(Ns+△et), according to the relative error formula:
Therefore, the following conclusions can be drawn:
①Relative measurement error has nothing to do with the frequency of the measured signal.
②Increasing T' or increasing Fs can increase Ns, reduce measurement errors, and improve measurement accuracy. In this design, the preset gate time limits the minimum measurement accuracy.
③ The n in the error analysis is mainly determined by the time required for the hardware to cut off T1PWM, which is a small integer constant. If the preset gate time Tpr = 0.012 8 s, then
Even if n is a small integer constant other than 1, the accuracy can still be maintained within one hundred thousandth, and can be further improved as the preset gate time is appropriately extended.
3.2 Principle error of measurement and standard frequency error
The measurement principle is similar to the multi-cycle synchronous measurement principle. The main principle error comes from the low-level jump generated by the D trigger to cut off T1PWM when the measurement is about to end, so that it generates a jump of the rising edge captured by CAP1 and CAP3 at the same time. This period of time is mainly determined by the reaction time of the D trigger. During the measurement process, this part of the error can be overcome by appropriately increasing the time of the preset gate. At the same time, considering the high-speed clock frequency inside the DSP, this will not significantly increase the measurement time, but it achieves the purpose of weakening the influence of this error and increasing the measurement accuracy.
The standard frequency error is △Fs/Fs. Because the crystal is very stable, the standard frequency error can be calibrated, and the high-speed clock frequency inside the DSP has been appropriately divided, so the calibrated standard frequency error can be ignored compared to the quantization error.
3.3 Test Results
A function signal generator (Tektronix AFG3010; accuracy 0.000 1%) is used to generate a square wave signal, and the frequency is measured with the designed frequency meter to find the error. The measurement accuracy of this frequency measurement system can reach 0.01%. According to the error analysis, the maximum error of the system occurs when the preset gate time just fills an integer number of measured signals, that is, when the frequency is 78.125 Hz or its integer multiple, so these points are selected for testing. The actual test data is listed in Table 1.
4 Conclusion
This article focuses on the design of the digital frequency meter, the hardware composition, and the software design of the communication between the host computer and the slave computer using the Modbus protocol. Features include:
① In terms of frequency measurement principle, due to the use of multi-cycle measurement principle, the ±1 counting error generated when counting the measured signal is eliminated, and its accuracy is only related to the gate time and the standard frequency, overcoming the shortcomings of traditional frequency measurement method or cycle measurement method, and realizing wide range and high-precision frequency measurement. At the same time, due to the existence of preset gate time, it is ensured that when the measured frequency switches back and forth between frequency bands, the system responds sensitively and has good following performance.
② In terms of the overall design of the system, the internal resources of the F2812 DSP are fully utilized, that is, the timer and capture unit in the event manager are used to complete the frequency measurement; the PWM output is used to realize the design of the self-test circuit; and the serial communication module is used to complete the communication between the upper and lower computers. In terms of the display of the measurement results, RS232 is used, and the communication protocol adopts the Modbus protocol to realize the communication between the lower and upper computers, and the measurement results are displayed in the upper computer.
This article only discusses how to measure the frequency of a single-channel signal. For multi-channel signals, you can first pass them through an AND gate, use software to determine which signal is which, and then use this design method to measure. The error problem caused by this situation needs further discussion, and this article only gives a preliminary exploration.
Reference address:Design of Digital Frequency Meter Based on TMS320F2812

Previous article:Design of a two-dimensional code reader based on TMS320DM642
Next article:Software simulation of asynchronous communication of BF561 SPORT port

Recommended ReadingLatest update time:2024-11-16 19:39

Bayer format image preprocessing based on FPGA+DSP technology
Real-time processing of high-resolution images has been widely used and developed in the fields of communications, medicine, military, aerospace, information security, etc. In the process of real-time image processing, the data volume of the lower-level image preprocessing is large, the calculation is simple, but the
[Embedded]
Bayer format image preprocessing based on FPGA+DSP technology
Design of portable power quality analyzer based on DSP+ARM
  With the expansion of national industrial scale and the development of science and technology, the load structure of power grid has changed greatly. On the one hand, the massive growth of nonlinear, impact and unbalanced loads has deteriorated the power quality; on the other hand, with the development of information
[Embedded]
Design of portable power quality analyzer based on DSP+ARM
Discussion on the key to extend battery life in DSP system--DC/DC regulator
Introduction A long-standing challenge for designers of MP3 players, personal media players, digital cameras, and other portable consumer applications is to achieve high performance and low power consumption. These battery-powered systems typically use an embedded digital signal processor (DSP) that is used at maximu
[Power Management]
Discussion on the key to extend battery life in DSP system--DC/DC regulator
Integrated tools improve design and verification automation of embedded DSP systems
The traditional design process of embedded DSP system usually consists of two stages: from concept to algorithm and from algorithm to product. Usually these two stages are independent of each other and completed by different design teams. In the traditional design process, manual conversion and connection between the
[Embedded]
Digital filter design based on DSP C54x
Preface In an actual application system, there are always various interferences. When using DSP for digital signal processing, the signal can be extracted from the noise, that is, a mixed source of noise and signal is sampled, and then passed through a digital filter to filter out the noise and extract useful signals
[Analog Electronics]
Research on ECG Monitoring System Based on TMS320LF2407A DSP
introduction With the development of society and the improvement of people's living standards, people pay more and more attention to health, but with the improvement of living standards, the incidence of cardiovascular diseases continues to rise. Especially in recent years, with the aggravation of social aging,
[Industrial Control]
Research on ECG Monitoring System Based on TMS320LF2407A DSP
Detailed introduction on how to use DSC (DSP) to control AC inverter system
What is DSC? Simply put: DSP+MCU=digital signal control (DSC) Microchip's dsPIC digital signal controller has both the high performance of a 16-bit flash microcontroller and a digital signal processor ( The dsPIC digital signal controller with 16-bit microcontroller as the core not only has powerful peripherals an
[Power Management]
Detailed introduction on how to use DSC (DSP) to control AC inverter system
Design of hierarchical distributed management system based on DSP chip
1 Overview 1.1 Background Digital signal processors (DSPs) are generally used to run core data processing algorithms, but in some special environments, DSPs must be used to manage the core chip of the control unit. This paper presents a hierarchical distributed image processing system, in which
[Embedded]
Latest Embedded Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号