A method for compressing storage capacity in time-frequency parameter measurement

Publisher:和谐的24号Latest update time:2012-02-20 Source: 21ICKeywords:Measurement Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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 - transformation ratio, which means that the number of Ti values ​​Ni appearing is stored in k bytes.

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.

Based on the measured storage data, the average period T = (∑Ni·Ti) / ∑Ni, or the average frequency f = 1/T can be calculated by mathematical statistics methods.

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.

Keywords:Measurement Reference address:A method for compressing storage capacity in time-frequency parameter measurement

Previous article:A hardware implementation of a three-MCU system
Next article:Using single chip microcomputer to realize in-system programming of CPLD

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号