how do you convert an ADC digitized numeric value (0...255 for 8 bit) to a voltage, i.e. how do you figure out what voltage does this number represents ?
you should use an 8bit DAC ( Digital to Analog Converter ). It has 8 inputs for the 8 bits to convert, one input for a reference voltage Vref and inputs for the power supply. The analog output voltage is a proportion of a reference voltage and the proportion based on the digital word applied.
i.e. Vout = Vref * [ 2^(b0) + 2^(b1) + ... + 2^(b7)], where b0, b1, .. , b7 are the bits of the digital word applied.
There is confusion about ADC or DAC. In some sources, it is said there are 2n-1, in some sources it is said there are 2n discrete levels. Let’s finish this confusion.
ADC (Analog to Digital Converter)
For example; if we have 3-bits ADC and an analog sensor with the measuring range of 0 to 1 Volt. How will we convert this voltage to digital number? What will be the minimum voltage value that we can detect (means resolution)?
Answer:
23=8 and maximum number for 3-bits in binary system is (111)2 = 7. But there are 8 different numbers starting from 0 to 7. So there will be 8 different numbers for the voltage span of the sensor.
The voltage span is 1-0=1 V
1V/8=0.125 V (The minimum voltage value we can detect with the given sensor.)
e.g. ADC’s output will be 0 (000)2 while the sensor’s voltage is 0 to 0.124 V. When it comes to 0.125 V, it will become 1 (001)2. It can be understood easily from the graph.
DAC (Digital to Analog Converter)
Same considerations are valid for DAC also. You must divide the voltage number to bit number.
When we look at the above example;
1V/8=0.125V
e.g. Digital number 5 (binary 101) will produce 0.625 V (5*0.125V).
When we come to 8 bit; there will be 28=256 (0...255) discrete levels for an analog signal. So you must divide the voltage value to 256.
For example; if the analog sensor’s voltage measuring range is 0-5 V. What will be the DAC’s output for the digital number of 33?
5/256= 0.01953125 V (resolution-1 bit digital variation’s voltage response)