Research and implementation of oversampling technology based on stm32F1

Publisher:朱雀Latest update time:2017-09-12 Source: eefocusKeywords:stm32F1 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Problem statement: 
In the 2016 TI Cup Electronic Design Competition, Question G, a simple electronic scale, one of the requirements is as follows: 
Write the picture description here

It can be calculated that the accuracy required by this question is 
(500-5)/0.01=49500

However, the built-in ADC of stm32F1 has only 12-bit accuracy, which means that it can collect a maximum of 2 to the 12th power of data (2^12=4096), which obviously does not meet the requirements of the question. Through oversampling technology, the required accuracy can be achieved.

2 Extraction of oversampled data

Write the picture description here 
Note: The p here is the additional p bits of precision required

Assuming p=1, 4^1=4 data need to be collected. Assuming that the 4 data are 
1101 
, 1100 
, 1011, 
and 1010,  respectively
, R represents the number of sampling bits. Here, R=4. 
The sum of the four data is 101110 (R+2p=6, so a 6-bit data is obtained after accumulation). 
Then shift the 6-bit data right by 1 bit (p=1), and you can get 10111 (R+p=5). This value is the sampling result with 1-bit accuracy improved.

3 Prerequisites for oversampling 
(1) There must be some noise in the input signal. The noise must be white noise with power evenly distributed throughout the useful frequency band. 
(2) The amplitude of the noise must be large enough to affect the input signal so that the ADC conversion result can randomly flip at least 1 bit. Otherwise, all input signals will convert to the same value, and the decimation operation on these values ​​will not improve the accuracy.

Note: Here you can refer to the link for some articles "Research and Implementation of Oversampling Technology Based on STM32"

4. Program Implementation 
Write the picture description here

In my own program, I did not implement it completely according to the reference material. My program:

    while (1)
    {

        ADC_ConvertedValueLocal =(float) ADC_ConvertedValue/4096*3.3; //Read the AD conversion value, the variable ADC_ConvertedValue here is the AD conversion value
        printf("\r\n The current AD value = %d \r\n", ADC_ConvertedValue); 
        printf("\r\n The current AD value = %f V \r\n",ADC_ConvertedValueLocal); 

    for(h=0;h<10;h++)
        { //The outermost loop here is to print the converted value 10 times in a row for easy observation
            for(j=0;j<500;j++)
            { for(i=0;i>8; // Shift right by 8 bits to get 12 bits of precision
                        Adctemp4=Adctemp4>>4; // right shift 4 bits to get 16 bits of precision
                    //printf("16λ¾«¶ÎΪ£º%d\n",Adctemp4);
                    //printf("12λ¾«¶ÈΪ£º%d\n",Adctemp8);
                    Adctemp=0; sum=sum+Adctemp4;
            }
            adcaverage=sum/500; //Take the 16-bit precision value 500 times, that is, take the average value of multiple samples
            sum=0; printf("adcaverage=%d\n",adcaverage); //Print out the average value of 500 consecutive values ​​with 16-bit precision
    } 
    Delay(0xffffee);  
    }123456789101112131415161718192021222324252627282930313233

5 Notes 
(1) In the program, the sampling frequency of ADC is 9MHz. Obviously, the sampling frequency is too high in the sampling of electronic scales. You can choose to reduce the ADC sampling frequency to further improve the accuracy. 
(2) For more details, please refer to an article in Baidu Library, "Research and Implementation of Oversampling Technology Based on STM32". This article has a good analysis. I also basically wrote the program according to the ideas of this article. This blog is just my own experience. Please take care of the poor writing.

The website of "Research and Implementation of Oversampling Technology Based on STM32" 
is: 
http://wenku.baidu.com/link?url=5r_i7r38zSqDF0-cQlWqSBp64UHeXmPKAMGgnKk4u-FYkYdzgltG5btIFz6x0Wyi_8Q8MzoRdo4AHVhGs9MN4fxigSqJUC3O1XPjzefCdeC

  • top

  • 0

  • Step on


Keywords:stm32F1 Reference address:Research and implementation of oversampling technology based on stm32F1

Previous article:Partial mapping and complete mapping of STM32 serial port
Next article:Using while loop in stm32 causes program to freeze

Recommended ReadingLatest update time:2024-11-16 13:00

STM32F1 uses I/0 to simulate the I2C interface
Compared with the hardware I2C interface, the use of simulated timing will inevitably lead to some declines in real-time performance and transmission speed, but the I2C bus itself is not a very fast bus (according to relevant information, the highest speed is 400KHZ), and it does not need to have very high real-time p
[Microcontroller]
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号