STM32 AD sample Voltage calculation formula

Source: Internet
Author: User

When using the STM32 ADC for the detection voltage must be back to the calculation of the voltage value, in order to obtain more efficient voltage, there are now the following three ways:

You get the result that the voltage value on your current ad pin is converted to a number relative to 3.3V and 4096.
If you get the ad result is ADC_DR this variable, they have the following relationship:


adc_dr/Current Voltage value = 4096/3300 MV If you want the current voltage value in the reverse process, you can calculate it as follows:
unsigned long Voltage;
Voltage = ADC_DR;

---Assume that the ad results you get are stored in the ADC_DR variable;
Voltage = (Voltage * 3300)/4096; ----you get the correct voltage result, Unit is MV

As a general rule of efficiency, I will numerator myself:
Voltage = (Voltage * 825)/1024; ----you get the correct voltage result, Unit is MV

and further, the efficiency will be higher:
Voltage = (Voltage * 825) >>10; ----you get the correct voltage result, Unit is MV

STM32 AD sample Voltage calculation formula

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.