In the application of measurement and control systems such as intelligent instruments, network communications, and process control, it is often necessary to accurately measure the frequency (or period) of pulse signals. The commonly used method is to use the measured signal as a gate signal, and a standard frequency signal as a filling pulse, and count the standard frequency signal within the gate period. How to compress the data storage capacity is the main problem to be solved in this paper.
1. Time-frequency parameter measurement based on single-chip microcomputer system
When using a single-chip microprocessor to measure the signal frequency (period), timer T0 works in counting mode, timer T1 works in timing mode, T1 sends a fixed frequency pulse (time stamp) to the outside, and T0 counts the time stamp. The measured pulse signal generates an external interrupt control signal, sends an interrupt request to the CPU, and the CPU responds to the interrupt. In the interrupt service program, the count value of T0 is read into the data memory. After the data transfer is completed, T0 is reset, and the count is restarted to start a new cycle measurement. The measurement principle is shown in Figure 2.
2 Linear Address Conversion
The microcontroller reads the count value into the memory, which means that each measured period value Ti is stored in the memory in chronological order. In this way, each measured Ti must be stored in one unit regardless of whether it is the same or not, and as the average frequency of the measured signal and the measurement time t increase, the required storage capacity will increase, that is:
Storage capacity M = f·t
If the average frequency of the measured signal is f=10kHz, then the storage capacity required for 1 second is about 10KB, and the storage capacity required for 10 seconds is about 100KB. Obviously, the RAM in the microcontroller cannot meet the requirements. Even if the external memory is expanded, it should not be too large, and there will be certain limitations.
But in fact, many of the measured Ti are the same. If the same Ti value is stored in one unit, the storage capacity can be greatly compressed. To this end, the linear transformation method can be used to convert each Ti into a unit address value according to formula (1), and add 1 to its content to indicate that there is already a Ti value. Finally, the content Ni of the unit indicates that there are Ni identical Ti values in the measurement.
Storage address = start address + kTi (1)
Where: Starting address - the storage unit address corresponding to Ti=0, which can be set arbitrarily according to the selected microcontroller model. [page]
k=1, indicating that the Ni value corresponding to Ti is stored in 2 bytes.
so:
Storage capacity M = maximum storage address - starting address value = kTimax (2)
Therefore, when using linear address conversion, the storage capacity is determined by the maximum period Timax of the measurement. And when the Ti value is measured by counting, if the counting time stamp period is tc, the Ti value measured by the counter is actually the number of tc contained in Ti. In this way, the storage capacity can be rewritten as:
Storage capacity M = Timax/tc (assuming k = 1) (3)
If the measured Timax=10ms, when tc=4μs is set, M=2.5KB; if you want to further compress the storage capacity, you can increase tc, such as when tc=8μs, M1.25MB, which can meet the requirements of limited storage capacity.
When the single-chip microcomputer performs linear address conversion, it uses the timer counting method to measure each Ti value, and then uses the interrupt service subroutine to perform address conversion according to formula (1), converts the Ti value into an address unit number, and adds 1 to the unit content. If one sampling is specified as measuring n Ti values, then after n Ti values are sampled, the period probability distribution curve reflecting the frequency fluctuation of the measured pulse as shown in Figure 3 is directly stored in the unit starting from the starting address of the memory. In Figure 3, Ni is the number of times the period Ti appears in the n pulse periods of one sampling, Nmax is the maximum value in Ni, and Tnmax is the corresponding period value.
The above data processing method not only ensures the amount of information in data sampling but also saves storage space. It more realistically reflects the changes in the signal during the sampling period. [page]
3. Compression of storage capacity and guarantee of measurement accuracy
Although the above data processing method can compress the storage space by increasing the time scale tc, it may increase the relative error Δ of the test. The maximum relative error Δmax appears at the low end of the measurement interval Timin:
Δmax=tc/Timin (4)
Considering the test error, substituting (4) into (3), the storage capacity can be expressed as:
Storage capacity M = (1/Δmax) · (Timax/Timin) (5)
This formula shows that when considering the test error, to compress the storage capacity, the measurement interval must be compressed. If the measurement range is set to 50μs~10ms, the calculated value of the measurement interval is:
(Timax/Timin)=(100ms/50μs)=20
If Δmax is set to ≤ 0.01, then M ≥ 20KB.
Therefore, in order to compress the storage capacity to about 2KB and make Δmax ≤ 0.01, the measurement interval should be compressed to less than 20.
If the entire measurement range is divided into several intervals and each interval is tested at a different time scale, the requirements of Δmax≤0.01 and storage capacity of 2 to 3KB can be met.
The above calibration is completed by software. The method adopted is to first measure once with a larger time scale (called rough measurement), then find the Tnmax value corresponding to Nmax from the probability distribution curve, compare it with the interval calibration limit coefficient, determine the time constant of timer T1 according to the interval it is in, and output the corresponding time scale pulse. After automatic calibration, re-measure with a new time scale (called fine measurement), and the period probability distribution curve obtained by fine measurement is used as the basis for calculation and control.
The software process of data acquisition is shown in Figure 4.
With the continuous improvement of the main frequency of single-chip microcomputers and the widespread application of DSP technology, favorable conditions have been created for the high-precision measurement of time-frequency parameters. The storage capacity compression method proposed in this paper aims to provide a new way to solve the problem of accuracy and data storage capacity, especially for unstable frequency signals with a certain degree of discreteness. This method has been applied and verified in many data acquisition and control systems, and has achieved good results.
Previous article:A hardware implementation of a three-MCU system
Next article:Using single chip microcomputer to realize in-system programming of CPLD
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!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- 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
- Foreign engineers thought drone motors were too heavy, so they made a PCB motor
- Why does a computer become slow when not used for a long time?
- Tektronix 2260B-800-4 Programmable High Voltage Voltage Test Experience
- Qorvo Launches World's Smallest 20-Watt Single-Chip Programmable Motor Control and Drive Solution for Brushless DC Motors
- 21 "Wanli" Raspberry Pi car - motor control learning (4-wheel speed control)
- Award-winning live broadcast: Microchip&avnet series live broadcast first collection
- IP Set Top Box
- HGI HC32A460 series function comparison chart
- How to start power supply design
- EEWORLD University ---- Machine Learning