Today I was reading the datasheet and refrence manual of STM32. As others, I think we should use the power creativeness which god has gifted us to have an accurace ADC. :) Here are the datasheet and reference manual of STM32:
So we should consider two aspects of ADC to have an accurace ADC. Hardware and software. Ok let's take a look at datasheet. I think we just should read the datasheet because it apears there is nothing about havaing an accurate ADC.(Am I right?)
There is a figure(fig 58) that tells us many things. At first we have two components out of MCU. "Rain" and "Cparasitic".
Then we should put these between MCU and the line that we are supposed to measure. Am I right? or maybe I interprate this figure incorrectly and these two are because of impedance and capacitance of line and this figure tells us another thing that we don't know. If my first suppostion is correct, so we must find out what resistor and capacitor we should choice.
First off let's check out the datasheet more. From table 59 we see that this resistor have a max value. It's 50kOhm. Why? How they say it? In the next page there is an equation named "Equation 1: Rain max formula". Ok, as the discription tells us, we can determine the maximum external impedance(Rain). The equation:
There are five parameters we should find and put in this equation to calculate the max value.
Radc : To determine this, we can use table 59. The max value for Radc is 1kOhm and I think we can use this value for every case. Fadc: We determine this when we are configuring the clock for ADC and it's pre-determined.
Cadc: Just like Radc, we can use table 59 to determine the max value for this parameter. It's 8pF.
N : Is it bit resolution? should we always take it 12?
Ts: Again, we should use table 59. It's range is 1.5 to 239.5 Am I right?
Ok, let's use this equation and do an example: Assumptions:
And after calculation, this is what I get = -0.9986 A negetive number? why? There are a table below the discription of this equation. table 60. Rain max for Fadc=14MHz . For Ts=1.5 Rain is 0.4kOhm and I expect to get a value close to this but what I get so far is a negetive value.
A question, I still don't know, should we put a capacitor as Cparasitic between the pin of MCU and the line that we must measur? or it's the capacitance between the source of our line and our MCU and it just affects on the measurment and we should reduce Fadc. indeed it's a question to me.
Okay, let's talk about this part. If you take a look at figure 57 (ADC accuracy characteristics) you can see there are five error that I think we can remove them by software approachs.
But how to remove them? I've an idea to remove EO and EG errors. This is my approach: If we take a look at the graph accuratly, we know that there are two curves. An ideal and an actual. Everything we must do is to coincide the actual curve on the ideal one. Assume that the both curves are linear. Then we have a function X=EG*x+EO
To find EO we can connect iuput pin to ground to find the value of EO and put it in the function.
To find EG, after adding EO to x, we must find the slope of the actual curve. Then we take two sample and use this relation to find the slope. S=(Y2-Y1)/(X2-X1) and then EG=1-S
Now using X=EG*x+EO we removed these two error.
What's your opinion about my approach? is it correct? Do you have any idea to remove ET and ED and EL?
And also please answer to the question that I asked in the above passage.