You are on page 1of 8

# Experiment No:

## Aim: Data acquisition and analysis using PC.

Part List :
1. OASIS ARM7( TITAN) BOARD
2. RS232 Serial cable
3. 9 Volt DC Power Supply
4. Triton IDE
Theory

## Analog-to-digital converter (ADC)

Electrical Symbol

## An analog-to-digital converter is a device which converts continuous signals to

discrete digital numbers. It means the conversion of an input analog voltage to a digital
number which is proportional to the magnitude of the voltage or current.
ADC Pin Description (LPC2148)

• Step 1: Configuring the ADC Power and ADC Port Pin Select the pin
function (PINSEL)
It is a set of registers that we can use to indicate exactly which function we would
like each pin to perform.
For example: If ADC0.1 is used for your application then corresponding Pin no.
and port pin is 13 and P0.28 respectively. To activate port pin as ADC input
PINSEL0 must be used. (PINSEL0 = 0x01000000)
To configure the A/D Converter, need to pass a specific 32-bit value to the
appropriate ADCR. This 'control register' manages the configuration of A/D
converter
Format of ADC Control Register

SEL: Channel Selection Bits
To select ADC0 Channel 1 (ADC0.1) set the appropriate bit in SEL.
SEL = 0000 0010
CLKDIV: ADC Clock selection
For example: Fosc = 12 MHz
PLL: M=5 and P =2 (Set by startups)
CCLK = Fosc X M = 12MHz x 5 = 60 MHz
PCLK = Fosc/4 = 15 MHz by setting VPBDIV = 0x00 (Default Value)
ADC Clock = PCLK/ (CLKDIV Value + 1) (Max. 4.5 MHz)
Desired ADC Clock is 3.0 MHz
Therefore
CLKDIV = (PCLK/ADC Clock) – 1
CLKDIV = (15x106 / 3x 106 ) – 1
CLKDIV = (4)10 = (0000 0100)2
CLKS :
These three bits are used to indicate the range of values used when converting
analog data. You can set the 'precision' of the results from 3-bits (values from 0-7)
up to 10-bits (values from 0-1023), depending on your requirements. To get the
maximum 10-bit 'range', we would provide the following value to the CLKS field:
CLKS = 000
PDN : Since we want to convert data right away, we could tell the ADC to go out
of power-down mode (its default value) by setting this bit to 1
START: To start the ADC conversion immediately
START = 0x001
 STEP 3: READING THE STATUS OF A/D CONVERSION
The A/D Status register allows checking the status of all A/D channels
simultaneously. The DONE and OVERRUN flags appearing in the ADDRn
register for each A/D channel are mirrored in ADSTAT. The interrupt flag (the
logical OR of all DONE flags) is also found in ADSTAT.
 STEP 4: READING THE CONVERSION RESULTS
Each ADC channel has its own dedicated data register (ADDR0..7) that we canuse
to 'read' the results of the analog to digital conversion, as well to check whether
the current conversion is complete or not. Also there is global data register which
will give the result of latest channel A/D conversion. The 32-bit value has the
following format:
A/D Channel Data Register (ADDR0 to ADDR7)

## DONE (Bit 31)

This bit is set to 1 when an A/D conversion is complete. Foraccurate results, you
need to wait until this value is 1 before readingthe RESULT bits. (This value is
cleared when you read this register.)
OVERRUN (Bit 30)
This value will be 1 if the results of one or more conversionswere lost when
converting in BURST mode. (As with DONE, this bitwill be cleared when you
RESULTS (Bits 15..6)
If DONE is 1 (meaning the conversion is complete), these 10 bits will contain a
binary number representing the results of ADC conversion. It works by measuring
the voltage on the analog input pin divided by the voltage on the Vref pin. Zero
means that the voltage onthe analog input pin was less than, equal to or close to
GND (Vssa),and 0x3FF (or 0011 1111 1111) indicates that the voltage on the
analog input pin was close to, equal to or greater than the voltage on the Vref pin.
Anything value between these two extremes will be returned as a 10-bit number
(between 0 and 1023).
CHN (Bits 26:24)
These bits contain the channel from which the RESULT bits were converted (e.g.
000 identifies channel 0, 001 channel 1...).
Procedural Algorithm:

## 1. Select the GPIO for ADC conversion.

2. Set the ADCR Register with Channel 2, Clock 4Mhz, Burst Mode, 11 clocks per
10 bit and start conversion.
3. While the data bit is 1 , data is been received in ADDR and is collected inadc data
(6-16 ) bits .
4. This data is been moved to the first 10 bits.
5. Convert this data in to temperature by scaling ,and print the output
onHyperTerminal.
Procedure:
1. Connect 9 V DC Power supply to the OASIS TITAN Board.
2. Connect the Board with the COM port of the PC using the serial cable.
3. Generate .hex file using Triton IDE.
5. Put the board in RUN mode and you can observe the output.
Source Code:
#include<LPC22xx.h>
#include<board.h>
int main(void)
{
*PINSEL1 = *PINSEL1 & 0XFCFFFFFF;
*PINSEL1 = *PINSEL1 | 0X01000000;
//AD conversion is operational, start conversion
*ADCR = 0X01210302; // Channel 1 , Clock 4Mhz, Burst Mode, 11 clocks per 10 bit ,
//AD conversion is operational, start conversion
while(1)
{