ADCs acts as a bridge between the ANALOG real world and digital world of controllers. ADC converts analog voltage into a digital number which can be understood and proceed by controller. Let us understand this with an example.

LPC 2148 operates on 3.3V supply. If we use 10 bit ADC, 3.3V correspondences to 2^10=1023.Ā Half of 3.3V= 1.65V can be represented by 512, 0V as digital value 0 and so on.

Before proceeding further, let us first understand few basic concepts related to ADC.

1.Ā Ā Resolution:

Analog voltage will be converted into a digital number. Number of bits required to store the digital number let sayĀ __n__Ā bits is known as resolution. If a digital number is represented with n bits, the maximum value is 2^{n}. So for 10 bit ADC resolution is 10 bit and maximum value is 2^{10}=1023.

2.Ā Ā Step size

Minimum voltage which can be distinguished by controller is known as step size.

Step size= Maximum Voltage/ 2^{n}Ā where n= resolution

For LPC 2148, Maximum voltage=3.3V and n=10

So step size=3.3/1023= 0.0032258064 V = 3.23 mv (Approx.)

Voltage between 0 and 3.23 mV will be identified as same for controller. This identifies the accuracy of ADC.

3.Ā Ā Conversion time

Converting analog voltage into a digital will not be done immediately. It will take few mili-seconds. Higher the resolution, higher is the conversion time.

So now, let us start with ADC of LPC 2148. First let us have quick look at features of it.

Ā·Ā Ā Ā Ā Ā Ā Ā Ā LPC 2148 has two inbuilt ADC modules known as ADC0 and ADC1.

Ā·Ā Ā Ā Ā Ā Ā Ā Ā Maximum resolution of ADC is 10 bit. It is configurable by programming.

Ā·Ā Ā Ā Ā Ā Ā Ā Ā ADC0 has 6 channels

Ā·Ā Ā Ā Ā Ā Ā Ā Ā ADC1 has 8 channels

Ā·Ā Ā Ā Ā Ā Ā Ā Ā Both ADC supports maximum clock frequency of 4.5 MHz (Operating frequency decides the conversion time)

Pins required for ADC are as follows.

There are various registers associated with ADC0 and ADC1. Commonly user registers are ADC Control Registers (AD0CR & AD1CR) and ADCGR- ADC Global data register.

Let us understand all registers one by one.

The most important register for ADC is ADCR. Let us see the functions of each bit of this register.

Another important register is AD0GR and AD1GR. Bits of this register are as follows.

Result of the conversion is stored in A/D Data register which has following structure.

Steps for programming:

1.Ā Ā Configure input pin as analog input pin for ADC

2.Ā Ā Select channel of ADC

3.Ā Ā Start conversion

4.Ā Ā Wait till conversion is done

5.Ā Ā Read data of ADC Conversion output

6.Ā Ā Convert number into separate digits like 512 as separate 5,1 and 2

7.Ā Ā Display digits on LCD

8.Ā Ā Repeat above steps

[/nextpage]

## Leave a Reply