1. Problem statement:
In the 2016 TI Cup Electronic Design Competition, Question G, a simple electronic scale, one of the requirements is as follows:
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
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
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
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
- Popular Resources
- Popular amplifiers
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
- Automotive electronics such as car chargers and wireless chargers
- 220V AC to 18V DC
- DSPF28335 Study Notes
- Anyone know what component this is?
- 【AT-START-F425 Review】-Recording the use of CAN communication
- HDI blind hole design, did you notice this detail?
- EEWORLD University Hall----Design of DC power supply system for battery testing equipment
- This is a brain teaser - hypotenuse, leg, chord, even Pythagorean theorem
- Should the PCB trace angle not be 90°? — PCB Layout Tips
- Problems with serial programming of STC89C51RC microcontroller