1 Introduction
Since frequency signals have the advantages of strong anti-interference, easy transmission, and high measurement accuracy, many non-frequency sensor signals are converted into frequency quantities for measurement and processing. Therefore, frequency measurement methods are attracting more and more attention and research.
Frequency measurement is one of the most basic measurements in the field of measurement and control systems. The most commonly used instrument for measuring signal frequency today is the frequency meter. During the measurement process, the frequency meter requires a time base signal as the time base for measuring the signal frequency. The time base signal is generally generated by a local oscillator circuit. Although quartz crystal oscillators are now commonly used, the accuracy of the time base signal cannot be guaranteed. Therefore, the measurement accuracy of the frequency meter becomes a problem. There are two traditional frequency measurement methods [1] : one is the frequency measurement method, which measures the number of repeated changes N of the measured signal within a certain time interval T, and the frequency is obtained; the other method is the period measurement method, which measures the number of standard high-frequency signals f within one cycle of the measured signal, and the measured frequency is obtained.
This paper introduces a width measurement method [2] . With the help of the photoelectric coupling principle, the AC signal is converted into a periodic pulse signal. By capturing the falling edge of the pulse signal and counting it with a timer, the period of the pulse signal can be obtained by the difference between the two counts, and the frequency of the measured AC signal can be calculated.
2 Hardware Circuit Design
The tasks completed by the hardware circuit are:
(1) The design of the analog circuit part is to convert the signal. The AC signal can be converted into a periodic pulse signal through analog devices such as a rectifier bridge and a photocoupler.
(2) The design of the digital circuit part is to detect the signal. The 16-bit timer A inside the MSP430 microcontroller has a pulse capture function, which can detect the duty cycle of the pulse signal.
Figure 1 is its basic structure diagram.
2.1 Design of analog circuit
Figure 2 shows the principle of the analog part. The following mainly describes the working principle of the circuit:
Considering that the AC signal may contain a certain amount of DC signal, and the DC signal will cause the AC waveform to move up or down, this may cause the original AC signal to have no zero point, and there is no question of zero-crossing detection or periodic pulses. Therefore, according to the actual situation of the AC signal, an appropriate capacitor should be set at the outlet of the AC signal to play a DC isolation role.
R1 and R2 are current limiting resistors to protect the voltage regulator, diode, and optocoupler behind them within the rated power consumption range. Since the AC signal source here is a 220V AC sinusoidal signal, the resistance of R1 and R2 should be relatively large and the power should be relatively large. The system uses a 1W resistor.
D1 and D2 are Zener voltage regulators, whose main function is to limit the voltage and protect the rectifier diodes of the rectifier bridge so that their reverse voltage is within the range. The voltage regulator model selected in this system is 1N4736, and its voltage regulation range is far less than the reverse withstand voltage of the rectifier diode. Figure 3 shows the terminal voltage of the voltage regulator (i.e., Vi1-Vi2 in Figure 1) waveform.
D3 is a rectifier bridge, which performs full-wave rectification on the AC power to make the current direction constant. Figure 4 shows the voltage waveform at both ends of the rectifier bridge (i.e., V1-V3 in the figure).
U2 is a photocoupler, which has two functions: signal conversion function, converting the rectified AC signal into a pulse signal; strong and weak current isolation function, which makes the strong current part and the weak current part electrically isolated, so that when the strong current part fails, the weak current circuit behind it, including the single-chip computer system, will not be damaged. The model used in this system is 4N25 , which has good switching characteristics, and its switching time can be adjusted through the base resistance. Figure 5 shows the switching characteristics of its base resistance under a given environment [3] . It can be seen from Figure 5 that when the base resistance R be is about , its comprehensive time index is the best, that is, the switching characteristics are better, so the base resistance (R5) in this system is taken.
The collector-emitter voltage (V5) waveform is shown in Figure 6.
Q1 is a transistor, and its function is to convert the pulse signal of V5 into high and low levels (0-3.3V) that can be recognized by the single-chip microcomputer. Therefore, Q1 must work in the switching state, that is, in the process of constantly switching between the saturation state and the cut-off state. The selection of the resistance values of resistors R6 and R7 in the system is mainly to make the transistor work in the switching state. Figure 7 shows several indicators of Q1 working in the switching state. The current r6[i] on R6 = Ib, the current r7[i] on R7 = Ic, V5 = Vbe, and V6 = Vce.
It can be seen from Figure 7 that the transistor works in a saturated state, and in a cut-off state, it has a good switching characteristic.
TA0 directly enters the microcontroller, and R8 is a current limiting resistor to prevent excessive current from entering the microcontroller.
2.2 Design of digital circuit
The main chip used in the system is the low-power single-chip microcomputer MSP430F449 from Texas Instruments . MSP430F449 is a powerful single-chip microcomputer in the MSP430 series. It adopts the von Neumann system, RISC instruction structure, and 16-bit arithmetic unit width. It integrates 60KB of FLASH program memory, 2KB of SRAM data memory, multiple 16-bit timer/capture/comparator, 2 serial ports, 12-bit analog-to-digital converter, JTAG program download, online debugging interface, watchdog timer, etc. 48 I/O multi-function ports, of which P1 and P2 have bit interrupt function. Therefore, this single-chip microcomputer has the characteristics of fast instruction execution speed, powerful functions, simple external circuit, low power consumption, perfect power saving management method, and is positioned for embedded system applications [4] [5] .
In this system, the main functional module of the microcontroller used is the 16-bit timer A. Its internal pulse capture has the following characteristics [6] :
(1) 16-bit counter, 4 working modes;
(2) A variety of optional counter clock sources, including slow clock, fast clock and external clock;
(3) Capture/compare registers with multiple configurable inputs and multiple configurable output units with 8 output modes;
(4) It can not only capture the time when the external event occurs, but also lock the high and low levels when the external event occurs, which brings great convenience to our design;
(5) Serial communication can be supported in hardware.
3 Software Design [7] [8] [9]
The task of software design is mainly to set the initialization of Timer A, and the software is programmed in C language. When Timer A works in capture mode, when the capture condition (trigger mode) is met, the hardware automatically writes the data in the counter TAR into the capture/compare register CCR0. Figure 8 is the system software flow chart.
In this system, the timer uses continuous counting mode and the capture method uses falling edge capture. System initialization includes the selection of system frequency fs (1MHz) and the setting of the control register of Timer A. The registers that need to be set are the control register TACTL and the capture/compare control register CCTL0. The Timer A interrupt function is triggered when a capture occurs. First, the difference between the value in CCR0 and the variable LastCCR0 is calculated. LastCCR0 is the value of register CCR0 recorded at the last capture. The initial value of CCR0 is 0. The loop is triggered five times, and the difference between the five times is saved in the array Timervalue[]. Considering that the signal does not necessarily start from zero when the counter starts counting, the actual calculation should start from the second trigger, so that four pulse periods can be calculated, and then the average pulse period is calculated. The average period is the half period of the measured AC signal, and then its frequency can be obtained. It can be expressed as:
4 Conclusion
This paper proposes a zero-crossing detection circuit, and selects electronic components with corresponding parameters according to actual needs. At the same time, the pulse capture function of the MSP430 microcontroller is used to realize the detection of the frequency of the AC signal. The system has high detection accuracy and strong real-time performance for the frequency of low-frequency AC signals, and has certain practical application value. At the same time, the zero-crossing detection circuit introduced in this paper has a wider application. By using the multi-channel PWM output unit of the capture/comparator inside the Timer A of the MSP430 microcontroller, certain control functions can be realized.
Innovation of this article: This article proposes an AC frequency detection system based on the width measurement method. This system uses zero-crossing detection and the pulse capture function of the MSP430 microcontroller. Compared with previous frequency detection systems, it is more intuitive, more accurate, and more real-time.
References:
[1] Ma Xianguo, Improvement of frequency measurement method, Chinese Journal of Scientific Instrument, 2004.8, 25(4) Supplement: 120-122
[2] Zhao Zhanke, Application of single chip microcomputer in frequency detection of frequency shift signal, Microcomputer Information, 2004, 20(2): 76-77
[3] Toshiba Corporation, Semiconductor Technical Data (4N25)
[4] Hu Dake, Principle and application of MSP430 series ultra-low power 16-bit single chip microcomputer, Beijing University of Aeronautics and Astronautics Press, 2000.6
[5] Wei Xiaolong, MSP430 series single chip microcomputer interface technology and system design examples, Beijing University of Aeronautics and Astronautics Press, 2002.11
[6] Liang Yuan, Application of MSP430 MCU TIMER_A in product design, Proceedings of the 2001 International Academic Exchange Conference on Embedded Systems and MCUs
[7] Zhang Xi, Practical C language programming for MSP430 series MCUs, People's Posts and Telecommunications Press, 2005.9
[8] Liu Liqun, Design of ultra-low power data acquisition device based on MSP430 MCU, Automation Instrumentation, 2005.4, 26(4):30-31
[9] Liu Yuhong, Mixed programming of MSP430 MCU with C language and assembly language, Microcomputer Information, 2003, 19(10):56-57
Previous article:Design of Inclination Measurement System Based on Single Chip Microcomputer
Next article:Written for the junior students who are just starting to learn microcontrollers
Recommended ReadingLatest update time:2024-11-16 17:48
- Popular Resources
- Popular amplifiers
- MSP430 series single chip microcomputer system engineering design and practice
- oled multi-chip calling program
- Microcontroller Principles and Applications Tutorial (2nd Edition) (Zhang Yuanliang)
- Getting Started and Improving MSP430 Microcontrollers - National Undergraduate Electronic Design Competition Training Course
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Showing goods + inventory
- Does anyone have a simulation circuit diagram of the LMD18200 chip?
- Digital Circuit Design with Verilog HDL.pdf
- 46% of open source maintainers are unpaid, and 26% earn more than $1,000 per year
- How to start learning analog electronics
- I would like to ask about the AMS1117 and LM2596S chips
- Why are all villains so stupid?
- Pipeline Leakage Monitor Based on Sound Waves
- See good people and emulate them, Zhu Ge is full of positive energy^_^
- [Mil MYS-8MMX] Mil MYS-8MMQ6-8E2D-180-C Unpacking Report 2 - Power on