[vc_row][vc_column][vc_column_text]An analog-to-digital converter (abbreviated ADC, A/D or A to D) is a device that converts a continuous physical quantity (usually voltage) to a digital number that represents the quantity’s amplitude.
The conversion involves quantization of the input, so it necessarily introduces a small amount of error. Instead of doing a single conversion, an ADC often performs the conversions (“samples” the input) periodically. The result is a sequence of digital values that have converted a continuous-time and continuous-amplitude analog signal to a discrete-time and discrete-amplitude digital signal.
[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column width=”1/1″][vc_tour][vc_tab title=”The main performance parameters of ADC” tab_id=”1394445612-1-87″][vc_column_text]
The resolution of the converter indicates the number of discrete values it can produce over the range of analog values. The resolution determines the magnitude of the quantization error and therefore determines the maximum possible average signal to noise ratio for an ideal ADC without the use of oversampling. The values are usually stored electronically in binary form, so the resolution is usually expressed in bits. In consequence, the number of discrete values available, or “levels”, is assumed to be a power of two. For example, an ADC with a resolution of 8 bits can encode an analog input to one in 256 different levels, since 28 = 256. The values can represent the ranges from 0 to 255 (i.e. unsigned integer) or from −128 to 127 (i.e. signed integer), depending on the application.
Quantization error is the noise introduced by quantization in an ideal ADC. It is a rounding error between the analog input voltage to the ADC and the output digitized value. The noise is non-linear and signal-dependent.
In an ideal analog-to-digital converter, where the quantization error is uniformly distributed between −1/2 LSB and +1/2 LSB, and the signal has a uniform distribution covering all quantization levels, the Signal-to-quantization-noise ratio (SQNR) can be calculated from
Where Q is the number of quantization bits. For example, a 16-bit ADC has a maximum signal-to-noise ratio of 6.02 × 16 = 96.3 dB, and therefore the quantization error is 96.3 dB below the maximum level. Quantization error is distributed from DC to the Nyquist frequency, consequently if part of the ADC’s bandwidth is not used (as inoversampling), some of the quantization error will fall out of band, effectively improving the SQNR. In an oversampled system, noise shaping can be used to further increase SQNR by forcing more quantization error out of the band.
These errors are measured in a unit called the least significant bit (LSB). In the above example of an eight-bit ADC, an error of one LSB is 1/256 of the full signal range, or about 0.4%.
[/vc_column_text][/vc_tab][vc_tab title=”Parts list” tab_id=”1394445612-2-81″][vc_column_text]1. 1 x pcDuino V2
2. 1 x Linker Potentiometer
3. 1 x Linker Base
4. 1 x Linker cable[/vc_column_text][/vc_tab][vc_tab title=”Wiring Diagram” tab_id=”1394445834194-2-10″][vc_column_text][/vc_column_text][/vc_tab][vc_tab title=”Test Run” tab_id=”1394445835553-3-2″][vc_column_text]
Before we can start, we need to obtain the python library for pcDuino from http://www.github.com/pcduino/python-pcduino.
(1) Create a new directory in the Sample folder named linker_led, then copy adc file adc_test in adc to the directory linker_led :
$mkdir linker_potentiometer $cd linker_potentiometer $cp /home/ubuntu/python-pcduino/Samples/adc_test/adc ./ -rf
(2) Create a new file linker_potentiometer.py in the linker_potentiometer directory , enter the following test code :
import time from adc import analog_read linker_potentiometer = 2 def delay(ms): time.sleep(1.0*ms/1000) def setup(): print "read channel ADC2 value ,the V-REF = 3.3V" delay(3000) def loop(): while(1): value = analog_read(linker_potentiometer) voltage = (value * 3.3)/4096 print ("value = %4d"%value) print ("voltage = %4.3f V" %voltage) print "----------------------------" delay(100) setup() loop()
(3) Run the code and show the results :