1. Introduction
Regardless of the type of signal, continuous or discrete, regular or irregular, for a computer control system, it must first be conditioned through the forward channel so that the signal can be detected by the machine: the range of high and low levels, timing coordination, whether latching is required, whether frequency division is required, etc.
Frequency signals are generally used for speed measurement, V/I measurement, phase measurement, etc., especially in industrial control. Many transmitters such as voltage, power, and travel transmitters have frequency signal or pulse signal outputs. Frequency signals have good anti-interference performance and are suitable for long-distance transmission. In addition, the interface required for frequency signals is simple and occupies less resources. Generally, it only occupies one counter interface for direct counting or one interrupt source input interface to count pulses in the interrupt service program. Of course, external counting devices can also be used to input several general I/O interfaces.
In short, the measurement of frequency signals has a flexible input method, which is of great significance to the measurement of various parameters of frequency signals. Frequency parameters mainly include period, duration of high and low levels, and duty cycle.
2. Cycle measurement
Because cycle = number of pulses/time, in order to calculate the number of pulses per unit time, a time reference must be firstly provided. If the timer of a single-chip microcomputer is used for timing, the highest frequency of the signal directly connected to the single-chip microcomputer depends on the crystal oscillator frequency. Since the high and low levels of each pulse of the measured signal must last for at least one machine cycle, its cycle must not be higher than 2 times the machine cycle; on the other hand, one machine cycle is equal to 6 state cycles, and one state cycle is equal to 2 crystal oscillator cycles. Therefore, T to be measured <= 24*T crystal oscillator.
2.1 Measurement of low-frequency signal period The wiring diagram is shown in Figure 1. The front end belongs to the signal conditioning circuit. The working principle is: use a counter and a timer to accumulate the number of pulses within the set time; another method is one timer and one interrupt port, the interrupt is triggered by the falling edge, and counting is performed in the interrupt program.
Obviously, the count value obtained by the above method will be affected by the timing error; in situations where high accuracy is required, this error can be avoided by using an external precision pulse source. That is, when using external pulses for comparative counting, there is no error caused by timing reasons. See Figure 2. At this time, the following relationship will be obtained: F to be measured * COUNT standard = F standard * CONNT to be measured
2.2 Measurement of high frequency signal period. Figure 3 is a typical circuit.
The functions of each part of this circuit are described as follows:
AD9686: Converts non-TTL level signals to TTL level and is a forward conditioning circuit.
The accumulator is a binary counter, the purpose is to divide the signal, MR is the clear terminal. Two counters with different performance are used here, namely 74LS197 and 74LS93. Among them, LS197 is a four-bit binary counter with a maximum counting frequency of 100MHz. It can be divided by 16. If the divided frequency calculated according to the main frequency of the microcontroller is still higher than the measurable frequency, it is necessary to continue dividing. Of course, the maximum operating frequency requirement of the subsequent dividing chip can be reduced. The output of each pin is:
Output of 74LS197: Output of 74LS93:
Q1: Fin divided by 2 Q2: Fin divided by 4 Q1: Fin divided by 32 Q2: Fin divided by 64
Q3: Fin divided by 8 Q1: Fin divided by 16 Q3: Fin divided by 128 Q1: Fin divided by 256
This circuit uses hardware control. When the gate position is "1", 74LS00 is turned on, and the pulse to be tested and the reference pulse enter the external hardware counter for counting at the same time. After a certain delay, the gate position is 0 and the counting stops. According to the count value at this time, we have the following relationship: COUNT to be tested/F to be tested = COUNT reference/F reference. According to needs, only the corresponding frequency division pin can be connected to the microcontroller for counting, or the I/O port can be used to read all the frequency division pins. From the structure of the circuit, we know that this circuit has the advantage of modularity.
3 Measurement of pulse high level duration
3.1 When the pulse frequency is high and the high level time of each cycle is short, in order to ensure accuracy, the time values of N high levels need to be averaged. The wiring and flow diagram are as follows:
3.2 When the pulse frequency is low, it means that the high level lasts longer. At this time, the gating method of T0 or T1 can be used for direct counting. In order to prevent counting from starting from point B in Figure 5, there are two ways to reduce the error: using software method: the signal to be measured is connected to the interrupt port through a non-gate, and the timing of the gating method is turned on in the interrupt program at the same time, thereby ensuring that counting starts from the rising edge of the pulse; hardware method can also be used to ensure that it starts from point A. This method is explained as follows. Using the JK trigger circuit of Figure 6, when the falling edge of Fin arrives, the potential at point C is high, and the potential sent to INT0 is low.
If the high level time in the above method exceeds 65535 count values, the TF0 mark should be identified to expand the counting range.
Obviously, as long as the pulse signal is inverted, we can get the measurement method of its low-level duration, which is not elaborated here.
4 Application of 8098 series microcontroller
Use the timer to count and measure the pulse width. This method is similar to the above: turn on the interrupt by detecting the pin's upward jump, and record the time value T1 at the same time; turn off the interrupt by detecting the pin's downward jump, and record the time value T2 at that moment. T2 minus T1 plus the time corresponding to the number of interrupts recorded is equal to the duration of the high level in one cycle.
The unique feature is the use of the HSI component (high-speed input channel) in 8098. Pulse signals are input through the pins, and the time of the event can be recorded in four working modes at the same time: positive jump, negative jump, positive and negative jump, and trigger every 8 positive jumps, without occupying CPU time. Since the time of the event is based on timer T1, T1 is counted once every 8 states, and each state cycle is 3 times the crystal oscillator cycle, the duration of the positive and negative levels should be greater than 12 times the crystal oscillator cycle. When the frequency is too high, the frequency can be measured by 8 divisions. When the frequency can be measured directly, the same signal can be input through two HIS pins to record the positive jump, negative jump time and the number of cycles respectively, so as to calculate the pulse cycle, positive level time, negative level time, and further calculate the duty cycle.
5 Conclusion
The key to frequency measurement with a single-chip microcomputer lies in frequency division, synchronization, and counting range. In the aforementioned method, the counting port and the external interrupt port can be used interchangeably, but the counting is implemented differently, which requires a corresponding change in the input method. By measuring the high and low potential time of the pulse signal, the duty cycle can be measured using the calculation function of the single-chip microcomputer.
Previous article:Application of TOPSwitch-FX series single chip switching power supply
Next article:Application of LCD Module DMF-50081 in Single Chip Microcomputer System
Recommended ReadingLatest update time:2024-11-16 17:40
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
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
- Recruiting hardware development engineers Annual salary: 120,000-300,000 | Experience: 3-8 years | Work location: Beijing, Chengdu, Wuhan
- Conformal Array for Radar Missile Seeker
- TMS570LS1224_GY30 light sensor driver
- Good information on clock division
- A question about the STM32L073 port A driver
- 【Gravity:AS7341 Review】Color Temperature Perception Measurement: Analysis of Three Chip Performance
- Problems with devices that measure temperature
- Huawei Science Comic: How do Bluetooth, Wi-Fi, and GNSS work together? Connectivity Chip
- InstaSPIN Brushless DC (BLDC) Lab
- [Synopsys IP Resources] How to cope with the challenges of HPC SoC development in the era of surging data volume