A method for realizing sampling frequency synchronization with strong real-time performance

Publisher:MindfulBeingLatest update time:2006-05-07 Source: 电子技术应用 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

    Abstract: This paper analyzes the impact of power frequency changes on the digital measurement accuracy of calculating the effective value of electricity and the reasons for the sampling frequency error. The method of using the high-speed input interface of the microcontroller Intel80C196 and the software timer to implement sampling frequency tracking is given. Hardware circuit structure and software block diagram.

    Keywords: Sampling frequency synchronous microcontroller

With the development of computer technology, automatic power devices such as power meter relay protection are becoming more and more intelligent. Most of these devices use AC sampling. Most of the AC sampling process is: the voltage (or current) from the secondary circuit of the system is sent to the appropriate voltage of the A/D through the secondary PT (or CT), etc., and then the CPU controls the A/D to sample at a certain rate. The frequency is converted from analog to digital to obtain discrete sampling data. After discrete Fourier transform (DFT), the effective value of the fundamental wave and each harmonic value are calculated to realize other functions. The DFT calculation process is as follows:

    If a discrete sampling system samples N samples per cycle, the effective value, real part effective value, and imaginary part effective value of its fundamental voltage (or current) are:

Where N——the number of sampling points per week;

     Xn——The nth sample value.

    The condition that the above calculation can accurately express the effective value is that the N sampling points of each weekly wave are evenly distributed in each power frequency cycle. However, in power automatic devices, the sampling frequency is mostly accomplished by setting the frequency division coefficient of the CPU timer. The clock source of the timer is determined by the crystal oscillator of the CPU system, and the sampling frequency is fixed. However, even if the sampling frequency that meets the above calculation requirements has been calculated based on the accurate power frequency (50Hz), because the frequency of the power system changes, and during the detection of fault recording devices and relay protection device products, It is necessary to assess the response of the device when the frequency changes. For example, in the relevant national testing standards, it is necessary to check the response of the wave recording device under low-frequency conditions. Therefore, data collected according to a fixed sampling frequency will inevitably have errors in the calculation results, which may cause a decrease in measurement accuracy or malfunction of the automatic device.

    1 The impact of frequency changes on calculated values

     The frequency here refers to both the sampling frequency and the power frequency of the power system, because changes in either of them will affect the calculation of the effective value after sampling. Assume that the sampling frequency is fixed at 1kHz (that is, corresponding to a 50Hz signal with 20 sampling points per wave), the effective value of the signal is 60V, corresponding to an equal-amplitude input quantity with a frequency of 46 to 54Hz, refer to formulas (1) and (2) , (3) Carry out full-cycle Fourier filtering for calculation, and the relative error of the results is shown in Table 1.

    Obviously, changes in frequency have a greater impact on calculating the effective value. The reason for this problem is that the N sampling points of each weekly wave are not evenly distributed in each power frequency cycle. To solve this problem, the "parameter self-optimization equal-interval synchronous sampling method" is given in the literature [1]. It should be said that this method is very suitable for slow instrument detection devices. However, because the calculation process is relatively complex, and the number of sampling points and frequency of each wave are changing, the timeliness requirements are high, and the discrete sampling data cannot be processed in a background processing device (such as a power system dynamic recording device), which cannot meet the requirements. Therefore, when the accuracy meets the requirements, only one of the methods can be used: fix the number of sampling points, adjust the sampling interval in a timely manner according to the timely power frequency cycle measured by the microcontroller. At present, a considerable number of power automatic devices use Intel80C196 microcontroller as the CPU. This article uses Intel80C196 as an example to introduce the method of implementing sampling frequency tracking.

    2 Hardware circuit composition and implementation principle

    Considering that the frequency of the system does not change very quickly, in order to adjust the sampling frequency in a timely manner as the system power frequency changes, we can first measure the count value Tc corresponding to the previous cycle of the system frequency (in units of the timer clock cycle of the microcontroller system , the same below), and then calculate the count value Tsj of each sampling interval in a timely manner according to the number of sampling points per week (N):

  Interval count value: 

    Then sampling with Tsj as the period can achieve timely tracking of the sampling frequency. In order to realize this process, the circuit structure shown in Figure 1 is planned to be used: the A-phase voltage from the bus voltage transformer is step-down isolated by a small PT, low-pass filtered, shaped into a square wave by a zero comparator, and sent through an optocoupler. Go to the high-speed input interface HSI.0 of Intel80C196, use the rising edge of the square wave to trigger the high-speed input interrupt, and measure the count value Tc of each power frequency cycle. After analysis and calculation by the microcontroller, the sampling interval Tsj is obtained through equation (4). Set the software timer interrupt with Tsj as the time interval. Perform data acquisition control, etc. in the software timer interrupt to complete timely tracking of the sampling frequency.

          3 Software process

    When designing software, you should make full use of the features of the 80C196 microcontroller: high-speed input (HSI) interface and software timer. The former is used to detect the rising edge of the square wave after shaping, and uses high-speed input interrupts to measure the system cycle. The latter is used to generate a software timer interrupt with a calculated timely sampling interval Ts as a period for A/D acquisition control.

    The software consists of two parts: the main program, the high-speed input (HSI) interrupt program and the HS0 software timer interrupt. The flow charts are shown in Figures 2 to 4.

    The main program mainly completes initialization and other application functions. During initialization, the default count value Td of the sampling time interval should be set. It is mainly used when the frequency of the power system cannot be measured correctly due to abnormal power used for frequency measurement. This default value is used as the sampling interval count Tsc, that is, Tsj = Td. The calculation method of this default value can refer to the following example:

    Assume that the system frequency is 50Hz (that is, the period is 20000μs);

    The number of sampling points per week is 20;

    The system crystal oscillator of 80C196 is 16MHz, and using timer 1 as the time base, the counting period is 1μs, see literature [2].

    Then the time between sampling points is:

20000μs/20=1000μs

    The default count value for the sampling interval is:

Td=1000μs/1μs=1000

    The high-speed input interrupt program first reads the current high-speed input count value Tnew, calculates the difference from the last count value Told, and obtains the appropriate power frequency cycle Tc, and then judges the value range of Tc to confirm the validity of the value. When judging the effectiveness of Tc, you can refer to the following method: consider the frequency fluctuation range of the general system, such as the corresponding Tc range of 45 to 55 Hz and determine it by the difference between the two measured values ​​(because the normal system frequency cannot mutate). Finally, use equation (4) and consider the 20 state cycles required to enter the interrupt program to calculate the timely sampling interval Tsj.

    After entering the HS0 software timer interrupt, the first thing to do is to preset the time Tsj for the next interrupt. Then perform the control of A/D conversion and other processing required for each sampling interval. It should be noted that since the software timer interrupt priority is higher than the high-speed input interrupt, the sampling control will not be affected by the high-speed input interrupt. In addition, the A/D control here can be the on-chip A/D inside the 80C196, or it can control the extended A/D. It depends on actual needs.

    The sampling frequency synchronization method proposed in this article has been successfully used in the microcomputer power fault recorder and RTU automatic device we developed. The measured results of using sampling frequency tracking in the oscilloscope are shown in Table 2. Although the calculation result error is larger than that of the method in literature [1], it is all within the allowable range of general device errors (<0.5%). It can effectively offset the impact of power system frequency changes on the device measurement accuracy. Therefore, it can meet the general requirements. Instrumentation requirements. It has the characteristics of simple tracking and adjustment and strong timeliness, and is a relatively practical method. Automatic devices using other CPUs can use similar principles to achieve synchronous tracking of sampling frequencies.

Reference address:A method for realizing sampling frequency synchronization with strong real-time performance

Previous article:Low-illumination CCD image acquisition and noise preprocessing
Next article:Accuracy analysis of virtual test system

Latest Test Measurement 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号