In this paper, the basic principle of the accuracy of the microcontroller digital converter (ADC) is studied, and the feasibility of the STM32 microcontroller core is analyzed. At the same time, whether the over-sampling technology can be tested by STM32 microcontroller technology through the research data, it is concluded that the use of over-sampling technology can effectively reduce the micro-control of STM32.
The burden of the processor in the device greatly improves the accuracy of its own analog-to-digital converter. The sampling process of analog-to-digital converter is to convert continuous analog signals into limited numbers, in which each number represents the information acquired by the sampling. In the process of quantization, appropriate quantitative analysis should be delineated according to the location of data, for example, 12-bit data represents 212 quantization levels, and 14-bit data represents 214 quantization levels. Sample values of the same level can be classified into one type and given a quantization value. The analog signal of the converter is continuous. The difference between the quantized result and the actual analog value is called error (eq), or quantized noise.
Assuming that the quantization noise is white noise, the average noise power can be obtained by calculating the quantization error in the same way. Sampling value obtained by 4P over-sampling rate is processed by summation and average calculation, but it can’t simply add and divide the sampling value of 4p. The filtering effect of this method is very low. For example, the sampling value of R bit is still R bit after the average of precision, and can’t be improved. Accuracy of sampling. When extracting the over-sampled data, the value of R 2p bit can be obtained by adding up the values of 4P sampling data.
By shifting P units to the right, the value of R P bit can be obtained. At this time, the number is the final result of sampling which improves the precision after P bit. The successful implementation of oversampling technology is preconditioned and can not work well in any time. Generally, to improve the accuracy of sampling by using oversampling technology is to satisfy the following two conditions: first, there must be some white noise in the input signal of the controller, and the average distribution of power should be in the sampling technology. Second, the amplitude of white noise should have enough influence on the input noise or signal, so that the converted signal of ADC can be randomly converted into that, if not, thermostatic element the values of the input signal will be the same, so that the extraction results can not improve the accuracy of oversampled data. If one bit can not be reversed, it is necessary to input some noise artificially in the incoming signal. The frequency of noise can not be linearly related to the input signal. At the same time, it is necessary to ensure that the conversion results with ADC can be randomly reversed between the quantified values of apricot forest. The STM32 microcontroller is equipped with 12-bit ADC, which has 16-bit input signal channels. Through the existence of sampling sequence registers, these channels of ADC can be sampled in any order.
The self-contained ADC usually completes the request of DMA again after each sampling. If the corresponding DMA channel has been occupied, the oversampled value can be transmitted directly through the DMA to large SRAM without interference from the CPU. STM32 microcontrollers are embedded with eight 16-bit timers.
These timers have the following modes: obtaining comparison, input-output comparison, PWN or monopulse operation. Timer arrangement can be set to the same clock size as CPU, so that the timing can be accurately carried out.
In order to use oversampling technology smoothly, the design software code of STM32 microcontroller system should be monitored to observe whether the system meets the requirements of oversampling conditions. In the process of conditional testing, the signal with a frequency of 50 Hz is input, and the sampling rate is controlled to at least 100 Hz according to Nyquist’s law. In such a sampling frequency, the input signals of ADC 0.0000V, 1.7000V and 3.4000V are brought to the microcontroller.
At the same time, the down-sampling values are directly transmitted to the computer without processing, and then the data observed by Excel software are used. If the noise input signals in the system can be flipped one or two times, the noise distribution is regarded as random. It can also be regarded as white noise. This result has met the requirement of oversampling technology, and it does not need artificially created signals to transmit, thus causing white noise. The software system design of STM32 microcontroller mainly includes two aspects: initialization of system function and interrupt processing. In the design of system initialization, it is mainly aimed at the initialization management of ADC, CPU clock and DMA timer of STM32. In order to improve their accuracy to four bits, the incoming signal must be controlled at least at 25.6 kHz oversampling frequency. The CPU clock of STM32 microcontroller should be set to 56 MHz and the clock of ADC should be set to 8 coefficients. At the same time, 242 ADC clock cycles should be set through time conversion.
The sampling rate of ADC can reach 29 kHz, which can meet the requirement of oversampling technology frequency and effectively avoid the time of occupying CPU of microcontroller. The timer of the microcontroller is set to each 10ms to generate the interrupt, which can start the DMA transmission while interrupting, and the source device of the transmission is set to the register of the analog-to-digital converter. After the transmission of the code is completed, the 256 sampling values in the process are summated by interrupt processing program, and a 12-bit oversampled value can be obtained by the right-shifting eight-bit processing.
The oversampled value is the result of mean filtering, which is used as the reference of the oversampled result. If you move 4 bits to the right, you can get a 16-bit oversampled value, which is the final result of sampling. You can display the two kinds of data by computer. The over-sampling technology based on STM32 can effectively solve the problem of low accuracy of ADC brought by STM32 microcontroller, improve the accuracy of over-sampling results, reduce the use of external expensive ADC controller, and improve work efficiency. However, this oversampling technology has certain limitations, and has certain impact on CPU, but the overall effect is very ideal.