Understand how to increase the resolution of
the ADC measurement by oversampling
Setup DAC reference voltage used by the AC as input to the ADC
Configure the ADC to have 17-bit resolution
using oversampling
Info: To increase the ADC resolution by n bits, the
signal must be oversampled by 4n samples. To achieve a 17-bit resolution,
an additional 5-bit resolution is needed, which means that the signal needs to be
sampled 45 = 1024 times. The ADC can be configured to accumulate up to
1024 samples. The accumulated result will be the sum of the 1024 samples. This
result needs to be scaled down to achieve the desired bit width by dividing by
the scaling factor. The scaling factor is given by 2n. To increase the
resolution by 5 bits, we either need to divide the result by 25 = 32 or
right shift it by 5.
At the beginning of adc_init, set up the DAC voltage reference to 2.048V by
writing:
VREF.CTRLA = VREF_AC0REFSEL_2V048_gc; /* Voltage reference for AC */
AC0.DACREF = 0xFF; /* DACREF is VREF */
Tip: The internal
reference voltage generator (DACREF) can be used to create specific voltage
references. The voltage reference VDACREF is configured through
the Analog Comparator.
Info:
The DAC voltage reference depends on the DACREF value and the
reference voltage selected in the VREF module Control
Register A and is calculated as:
Configure the MUXPOS to have the DAC reference as an input
source:
ADC0.MUXPOS = ADC_MUXPOS_DAC_gc; /*DAC from AC0*/
Configure the ADC so it can achieve 17-bit
resolution by setting ADC_SAMPLES in adc.h to the right number of samples using the
ADC_SAMPNUM macros by
writing:
#defineADC_SAMPLES ADC_SAMPNUM_ACC1024_gc
In the main()
function right shift the accumulated result to scale the result down to 17-bit
by
writing:
It
is important to take the average of the accumulated measurements before the
12-bit result is scaled up.
Verify that the solution builds with no
errors by selecting Build → Build Solution from the top menu bar in Microchip
Studio or pressing the F7 key.
Flash the device by selecting Debug →
Start without debugging for the top menu bar in Microchip Studio or
pressing the Ctrl+Alt+F5 keys.
Plot the 17-bit result and the 12-bit result
in the Data visualizer by loading the workspace
Assignment3.json.
Result: The ADC is
configured to measure the DAC reference voltage from the AC module using
oversampling to increase the resolution to 17-bit. Figure 4-1 shows the comparison between the 17-bit
and the 12-bit result. The 17-bit result is in green, while the 12-bit result is in red.
Observe that the 17-bit signal can take much smaller steps than the 12-bit
signal.Figure 4-1. Assignment 3: 17-Bit vs. 12-Bit
The online versions of the documents are provided as a courtesy. Verify all content and data in the device’s PDF documentation found on the device product page.