<aside> <img src="/icons/map-pin_gray.svg" alt="/icons/map-pin_gray.svg" width="40px" /> In midterm, there’s usually a question dedicated just for analog to digital converter, so we will cover it in this section.
</aside>
An analog to digital converter (ADC) converts electrical voltage to a digital value. This was briefly introduced in lab 3.
Figure 12.1 The A/D conversion process.
The process is described in the figure above, but the main takeaway you want to get from this section is the following:
An ideal ADC should demonstrate the linear input/output relationship — i.e. a straight line shown in the left.
Figure 12.2 An ideal A/D converter output characteristic.
However, the issue is that it requires the use of an infinite number of bits to represent the conversion result. If you need more clarification, refer to the example below.
An alternative would be to have a low reference and high reference voltage. Such that there exists a minimum change in voltage for it to change the output code level.
Figure 12.3 Output characteristic of an ideal n-bit A/D converter.
This is defined as the resolution for an $n$-bit ADC from the range of $0\ V$to $V_{\textrm{DD}}$.
$$ \frac{V_{\textrm{DD}}}{2^n} $$
Note that the HCS12 specifically only allows for 8-bit or 10-bit A/D conversions.
As mentioned, an A/D converter needs a low reference voltage $V_{\textrm{RL}}$ and a high reference voltage $V_{\textrm{RH}}$ to perform the conversion. The ADC provides an $n$-bit code. Typically, a question may ask you determine the voltage $V_{\textrm{k}}$ given the digital code of $k$.
<aside> <img src="/icons/help-alternate_gray.svg" alt="/icons/help-alternate_gray.svg" width="40px" /> The value of $k$ is the just decimal equivalent of the possible output codes in a $n$-bit ADC. So, for a 10-bit ADC, the range of $k$ is from $0$ to $1024$ in decimal.
</aside>
We can do so, by using the following formula to determine this voltage:
$$ V_{\textrm{k}} = V_{\textrm{RL}} + \bigg(\frac{k}{2^n}\bigg)(V_{\textrm{RH}} - V_{\textrm{RL}}) $$
<aside> <img src="/icons/help-alternate_gray.svg" alt="/icons/help-alternate_gray.svg" width="40px" /> This formula can actually be derived using linear interpolation if you know it, so it’s not necessarily needed to memorize.
$$ \frac{y - y_0}{x - x_0} = \frac{y_1 - y_0}{x_1 - x_0} $$
In this case, we set $y$ as our voltage and $x$ as our output code value. Equivalently, it becomes,
$$ \frac{V_{\textrm{k}} - V_{\textrm{RL}}}{k - 0} = \frac{V_{\textrm{RH}}- V_{\textrm{RL}}}{2^n - 0} $$
</aside>
In most cases, $V_{\textrm{RL}} = 0\ V$ and $V_{\textrm{RH}} = V_{\textrm{DD}}$, thus simplifies to:
$$ V_{\textrm{k}} = \bigg(\frac{k}{2^n}\bigg)V_{\textrm{DD}} $$
Refer to example below, which was a question from a previous midterm.