For a 16 bit ADC with a -10V to +10V analog input range I have read the following:
The resolution \$ \text{delta} = \dfrac{20V}{2^{16}} \$
16 bit 0000000000000000 corresponds to decimal 0 and this means the voltage read by the ADC is between -10V to -9 999.695V.
Similarly 16 bit 1111111111111111 corresponds to decimal 65535 and this means the voltage read by the ADC is between +9 999.695V to +10 000.
But I have couple of questions here where I get confused:
1-) If the ADC samples a voltage of +9 999V, will it register as 65535 or 65534?
2-) How about 32767 and 32768? Do they both represent OV? It seems to me 32767 is registered if the voltage is between -20/2^16V and 0V; and 32768 is registered if the voltage is between +20/2^16V and 0V. Is that correct. If so it means for 0V there are two steps unlike other voltage readings.
3-) Is the resolution \$ \dfrac{20V}{2^{16}} \$ or \$ \dfrac{20V}{2^{16}-1} \$?
EDIT:
I plotted in Python quantization of a sinusoid for a 3 bit ADC.
Which plot below represents better a 3-bit ADC converter quantizing a 10V 1Hz sinusoid input in this case sampled at 512Hz rate:
3 is the number of bits.
Below call it Plot 1, the number of levels are odd i.e (2^3)-1:
And below call it Plot 2, the number of levels are even i.e 2^3:
Which one above represents an ADC quantization better?
EDIT 2:
In response to Dirceu Rodrigues Jr and the transfer function he provided in his answer, I tried to plot it in Python (3 bit ADC for -10 to +10V input versus binary code in decimal):
import numpy as np
import matplotlib.pyplot as plt
#ANALOG SIGNAL:
va = np.linspace(-10, 10, 10000 ) #Analog input from -10V to +10V
fs_p = 10.0
fs_n = -10.0
#DIGITAL OUTPUT CODE:
n=3 #ADC resolution
vd = ((va - fs_n) / (fs_p - fs_n)) * (2**n) #Transfer function
vd = (vd).astype(int) #output code
plt.plot(va, vd,'.b')
plt.plot(va, vd,'-g')
plt.xlabel('Va (Analog input)')
plt.ylabel('Vd (Output code)')
plt.show()
plt.grid()
Here is the output: