Sine Wave Distortion Control Based on Single Chip Microcomputer Technology

Publisher:Meilin8888Latest update time:2012-02-08 Source: 仪表技术 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1 Sine wave distortion

Suppose the generated sine wave is A, its power is P, and the harmonic components it contains are A1, A2, ...An, and their corresponding powers are P1, P2, ...Pn, then the sine wave distortion r is defined as: The

magnetically coupled non-contact temperature sensor we developed relies on sine waves to transmit signals non-contactly. The frequency of the sine wave represents a certain temperature value, so there are high requirements for the distortion of the sine wave emitted by the sine wave generator. Because the existence of its harmonic components (even if filtered) is enough to produce a non-existent temperature value, resulting in erroneous measurement and erroneous control.

The distortion of a sine wave can be measured using a "sine wave distortion meter"

.

The working principle of the single-chip microcomputer sine wave generator using the table lookup method is as follows:

(1) Sampling the sine signal, assuming that the number of sampling points for one cycle of the sine wave is N. See formula (1)

where n = 0, 1, ... N-1.
Considering that the value range of the sine function is from -1 → 0 → +1, they are converted into fixed-point unsigned values ​​for storage. If the number of bits M stored is 8, then the value of formula (1) is transferred, see formula (2).

In this way, the value range of the sine function is -1 → 0 → +1, and the stored 8-bit (i.e. M) binary data is 0 → 128 → 255 (in decimal). Sample formula (2) in sequence to obtain X (n), n = 0, 1, ... N-1, a total of N data, forming a sine data table, which is solidified in the EPROM.

(2) Write a table lookup program, take out data from the beginning to the end, and then convert it into analog quantity from the D/A chip output, and a complete sine wave will be generated. Suppose it takes at least ts to take each data from the table and output it from the D/A chip, then the time required to output a complete sine wave is TM, and TM = ts*N.

(3) The table lookup procedure is repeated over and over again to achieve continuous sinusoidal wave output.

3. The influence of the number of sampling points N on the distortion

The microcomputerized sine wave generator uses N sinusoidally changing values ​​to drive the D/A chip to generate a "sine wave". The minimum time required for each output point X (n) is ts, so the time required for a complete sine wave (i.e. one cycle) is TM, and TM = ts * N. At this time, the highest frequency of the sine wave is Assuming that

the compiled subroutine ts is about 1μs, if N is 200, then fmax , that is, if the frequency f of the output sine wave is required to be greater than 4998Hz, N can only be less than 200. Therefore, a qualitative conclusion can be drawn: the larger N is, the smaller the distortion of the sine wave, but the sine minimum limit fmax also decreases.

This article proposes a concept of "waveform accuracy" R for digital sine waves. R is defined as:

The reasons for defining "waveform accuracy" R are as follows:

The microcomputerized sine wave is to take out the value in the sine wave table, and generate a step-shaped analog sine wave by D/A output. Obviously, the data value in the sine wave table directly affects the shape of the step-shaped sine wave. "Waveform accuracy" R is a description of the quality of the sine wave table data, which should be equivalent to the description of "distortion" for analog sine waves.

According to the rule of ideal sampling, the sampling time interval between data points X(n) is constant, that is, ts above, that is, the X(n) sequence is the sampling value of N points uniformly distributed on the sine wave in time. Since N is finite, these points cannot form a smooth sine wave, but have a drop ΔR, and ΔR = X(n) - X(n-1), and its size reflects the roughness of the curve (corresponding to the distortion). The slope of the sine wave changes the most at n = 0, so ΔRmax = X(1) - X(0). Using the concept of relative error, we can get the "waveform accuracy" R. The following formula (4) is used to quantitatively calculate the waveform accuracy R200 and R100 of N = 200 and N = 100 respectively:

Obviously, R200 < R100, and the step-shaped sine wave of N = 200 is closer to the smooth theoretical value than that of N = 100.

4 The influence of quantization error on sine wave distortion

For the sampling value X(n) of the sine wave, it must be represented by a finite bit (M bit) binary value. There is a quantization error between it and the theoretical sine value. The existence of the quantization error directly affects the distortion of the sine wave, because the sampling value X(n) does not actually fall on the theoretical sine value curve, and the difference between the two is the quantization error. Obviously, the larger M is, the smaller the quantization error is, and the closer X(n) is to the theoretical sine value, so the actual sine wave distortion is also smaller. As for the quantitative calculation of the influence of the quantization error on the sine wave distortion, this article will not expand on it. The conclusion is:

The value of M should be consistent with the word length of the D/A chip. When the selected D/A chip has an 8-bit word length, its data pins D0 to D7 also have a total of 8 bits, and the number of bits M stored in the sine data table should also be 8 bits, so that there is a one-to-one correspondence between bits when data is transmitted. At this time, it is meaningless to use 12 or 16 bits to store the sine table.

5 Summary

In order to make the microcomputerized sine wave generator produce high-quality sine waves, the following aspects can be paid attention to during design:

(1) Increase the crystal oscillator frequency of the microcontroller as much as possible, and make the subroutine for sampling the D/A output as concise as possible, so that the running time ts is reduced and the upper frequency limit fmax of the high-quality sine wave can be increased;
(2) Under the condition of meeting the highest frequency, take N as large as possible, that is, the number of sampling points in the sine table is as large as possible, so as to reduce the distortion of the actual sine wave generated;
(3) Based on cost considerations, choose a D/A chip with fast conversion speed and large word size, which will reduce the quantization error and thus reduce the distortion.

References

[1]Yan Jundao.Non-contact measurement and control of temperature inside rotating objects[J].Journal of China Textile University,1982,(2).

Reference address:Sine Wave Distortion Control Based on Single Chip Microcomputer Technology

Previous article:Realization of Serial Communication between PC and MCU under Windows Environment
Next article:Using microprocessor monitoring circuit to improve the reliability of single chip computer system and power failure protection circuit

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号