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.
[1]Yan Jundao.Non-contact measurement and control of temperature inside rotating objects[J].Journal of China Textile University,1982,(2).
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
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
- Easy-to-use nine-channel RGB LED driver
- [Application development based on NUCLEO-F746ZG motor] 10. Parameter configuration - GPIO port configuration
- Connection between Bluetooth module HC-05 and 51 microcontroller
- Flexible vibration plate machine operation demonstration diagram
- IO cannot be set to 0
- Tips to Avoid Detours in NIOS II SOPC Development
- A newbie wants to control a stepper motor and ask for guidance
- Summarizing the experience of the big guys, how to learn STM32? (Entry, Advanced)
- Summary of basic knowledge points of C language
- CC2640R2F Chinese data sheet download -TI Bluetooth MCU