Selection of ADC

KeithWalker

Joined Jul 10, 2017
596
The microcontroller does not read the ADC output into memory as a 12 bit byte. It handles the output as it would any unsigned integer. It is not limited to 8 bit values.
Regards,
Keith
 

MrChips

Joined Oct 2, 2009
19,914
I visited on this page https://www.pantechsolutions.net/microcontroller-tutorials/how-to-interface-spi-adc-with-8051-development-board

microcontroller is 8 bit and ADC is 12 bit

My question are

Do they send 8 bit or 12 bit data when both are communicated?

I think only 8 bit data If so, what is the use of using 12 bit instead of 8 bit ?
Your post triggers a number of valid questions with corresponding answers.

The first answer is: It depends on the actual ADC and its 12-bit interface. You have to look at the datasheet of the specific ADC and read how the ADC communicates with the MCU. For the MCP3202 in question, data is transmitted via the SPI 12 bits at a time. It is also possible to communicate with this ADC in multiple 8-bit transfers. If your MCU does not support SPI, you can "bit-bang" your own 12-bit SPI.

The next question is: What is the point of 12-bit ADC when the MCU is only 8 bits?
8-bit computers are not limited to manipulating 8 bits. Any 8-bit computer can perform 8, 16, 32, 64-bit arithmetic (or any number of bits) by using multiple bytes and registers.

Finally: Why choose the 8051 interfaced to MCP3202 when there are so many MCUs with built-in ADC?
Almost every low end MCU from Atmel, PIC, TI, and every MCU manufacturer have MCUs with embedded ADC.
 

JohnInTX

Joined Jun 26, 2012
3,940
You can find one answer in the code in the article if you take the time to look:
C:
/* --- read ADC result 12 bit -------- */ AdcResult=0;

for(i=0;i<12;i++)
{
ADC_CLK=1; k++;k++;
/// delay about 2 uS 
AdcResult<<=1; 
AdcResult=AdcResult | (ADC_DO & 0x01);
ADC_CLK=0; k++;k++;
/// delay about 2 uS
}
 

Thread Starter

champ1

Joined Jun 4, 2018
112
Your post triggers a number of valid questions with corresponding answers.
There are many types of ADCs available in the market like 8 bit, 10 bit, 12 bit, 16 bit

What is meaning of resolution in terms of ADC ?

Does it mean that the adC is 12 bits, then its resolution will be 12 bit

12 ADC range is -2048 to 2047

volt = (adcValue*5.00)/2047; //12bit resolution, 5vReference

With this formula we are calculating the voltage, what is the use of it ?
 

MrChips

Joined Oct 2, 2009
19,914
The number of bits will determine how finely you can divide your voltage range. This tells you the resolution.

12-bit ADC = 4096 steps
For 5V reference, 1 step = 5V/4096 = 1.22mV resolution

Resolution and accuracy are not the same thing.

Most ADCs in MCUs will only convert positive voltages, for example, 0-5V if the reference voltage is 5V.
When the ADC outputs a value of adcValue, for a 12-bit unipolar ADC the digitized voltage is

voltage = adcValue * reference / 4096
 

Thread Starter

champ1

Joined Jun 4, 2018
112
The number of bits will determine how finely you can divide your voltage range. This tells you the resolution.

voltage = adcValue * reference / 4096
let's assume
  1. ADC range (-2048 to 2047 )
  2. reference voltage (5V)
  3. Resolution with 5V reference ( 1.22mV )
  4. Raw ADC value 2040, 1024 , 500

volt = (Raw ADC *5 )/2047;

Raw ADC value 2040, 1024 , 500

volt = (adcValue *5 )/2047;

= ( 2040 * 5 )/2040
= 10200 / 2040
= 5 V

volt = (1024 * 5)/2047
= 5120 /2047
= 2.5 V

volt = ( 500 * 5)/2040
= 2500 / 2040
= 1.22 V


Do we get 5, 2.5 and 1.2 V at the output of ADC chip ?
 

MrChips

Joined Oct 2, 2009
19,914
let's assume
  1. ADC range (-2048 to 2047 )
  2. reference voltage (5V)
  3. Resolution with 5V reference ( 1.22mV )
  4. Raw ADC value 2040, 1024 , 500

volt = (Raw ADC *5 )/2047;

Raw ADC value 2040, 1024 , 500

volt = (adcValue *5 )/2047;

= ( 2040 * 5 )/2040
= 10200 / 2040
= 5 V

volt = (1024 * 5)/2047
= 5120 /2047
= 2.5 V

volt = ( 500 * 5)/2040
= 2500 / 2040
= 1.22 V


Do we get 5, 2.5 and 1.2 V at the output of ADC chip ?
An analog-to-digital converter converts voltage to a number.
You do not get volts at the output. You get a number such as 2040, 1024, 500 as in your example.
(Watch your denominator. For 12-bit unipolar ADC, the denominator is 4096.)
 

Thread Starter

champ1

Joined Jun 4, 2018
112
An analog-to-digital converter converts voltage to a number.
You do not get volts at the output. You get a number such as 2040, 1024, 500 as in your example.
I am confused because 2040, 1024, 500 are numbers and microcontroller doesn't deal with number it only deal with voltage signal 5V or 0 V

What would be temperature value for 2040, 1024, 500 values ?
 

MrChips

Joined Oct 2, 2009
19,914
I am confused because 2040, 1024, 500 are numbers and microcontroller doesn't deal with number it only deal with voltage signal 5V or 0 V

What would be temperature value for 2040, 1024, 500 values ?
Now you are discussing something totally different.
Do you understand the difference between analog and digital?

Let us get down to basics.

A digital logic circuit operating on 5V supply only understands two things, 0V and 5V.
In reality, there has to be a voltage threshold which we will call Vth so that any voltage below Vth is considered FALSE and any voltage above Vth is considered TRUE. Instead of using the binary values FALSE/TRUE we will use 0/1.
(btw - This is a 1-bit ADC.)

A computer works with 0/1. Nothing else. Period.
A computer can work with any collection of 0 and 1, for example 10101010, or 10010111.
The computer knows nothing about 123 or 456.

How much of this do you understand?
 

Thread Starter

champ1

Joined Jun 4, 2018
112
How much of this do you understand?
Yes i understand Each ADC value has a binary sequence

2040 = 0111 1111 1000 it mans ADC will send 0111 1111 1000 binary sequence to microcontroller

Now you are discussing something totally different.
Actually, I did not understand how the temperature can be calculated from the ADC value. Each ADC value will represent the temperature

http://exploreembedded.com/wiki/Reading_Temperature_with_AVR_ADC

I was reading this page but do not understand how they are calculating the temperature
 

MrChips

Joined Oct 2, 2009
19,914
It doesn't matter what physical parameter you are measuring so long as you know the conversion from that parameter to voltage.
In the case of LM35 it is given that the transfer characteristics are 10mV per °C.
Hence 1V = 100°C

Multiply voltage by 100 to convert from voltage to °C.
 

Thread Starter

champ1

Joined Jun 4, 2018
112
It doesn't matter what physical parameter you are measuring so long as you know the conversion from that parameter to voltage.
In the case of LM35 it is given that the transfer characteristics are 10mV per °C.
Hence 1V = 100°C

Multiply voltage by 100 to convert from voltage to °C.
In the case of LM35 temperature value for Raw ADC value 2040, 1024 , 500

volt = (adcValue *5 )/2047;

= ( 2040 * 5 )/2040
= 10200 / 2040
= 5 V

5 volt * 100 = 500 C

volt = (1024 * 5)/2047
= 5120 /2047
= 2.5 V

2.5 * 100 = 250 c

volt = ( 500 * 5)/2040
= 2500 / 2040
= 1.22 V

1.22 * 100 = 122 C

Are my calculations correct ?
 

Thread Starter

champ1

Joined Jun 4, 2018
112
Why are you dividing by 2040 and not 2048 or 4096?
its typeof mistake in editing calculation

The temperature may be in minus or may be plus -2048 to 2047

-2048 to 2047

Raw ADC value 2040, 1024 , 500

volt = (adcValue *5 )/2047;

= ( 2040 * 5 )/2047
= 10200 / 2047
= 4.98 V

4.98 volt * 100 = 498.290 C

volt = (1024 * 5)/2047
= 5120 /2047
= 2.5 V

2.5 * 100 = 250 c

volt = ( 500 * 5)/2047
= 2500 / 2047
= 1.22 V

1.22 * 100 = 122 C
 

KeithWalker

Joined Jul 10, 2017
596
Does it mean that the adC is 12 bits, then its resolution will be 12 bit
12 ADC range is -2048 to 2047
volt = (adcValue*5.00)/2047; //12bit resolution, 5vReference
With this formula we are calculating the voltage, what is the use of it ?
An ADC only measures voltage from zero to its reference voltage. If the reference of a 12 bit ADC is +12 volts, It will measure form 0 to +12 volts (not -12 to + 12) in steps from 0 to 4095 which gives it a resolution of 12/4095 = 2.93 mV. The accuracy of the value will depend on the accuracy of the reference voltage, the linearity of the ADC and the temperature stability of the measuring circuitry.
Regards,
Keith
 
Top