SlideShare a Scribd company logo
ADC in LPC2148
Aarav Soni
What is ADC ?
• Analog to Digital Conversion(i.e. ADC) , as the name suggests , is all about
converting a given analog signal into its digital form or say a digital value.
• This conversion or measurement happens in presence of a fixed and
accurate reference voltage.
• The analog signal is compared to this reference voltage and then
estimations are made to get the final measured value.
Resolution
• ADC is used to convert analog signal/voltage into its equivalent digital number so
that microcontroller can process that numbers and make it human readable.
• The ADC characterized by resolution. The resolution of ADC indicates the number
of digital values.
• In LPC2148 microcontroller we have in-built 10-bit ADC. So for 10-bit ADC
resolution is 10-bit and maximum value will be 210=1024. This means our digital
value or discrete level lies between 0 to 1023.
• There is one more term important to understand while dealing with ADC and it is
step size. Step size is the minimum change in input voltage which can be resolved
by ADC. The concept of step size is closely associated with the resolution of ADC.
ADC in LPC2148 ARM7 Microcontroller
• The ADC in LPC2148 ARM7 Microcontroller is 10-bit successive
approximation analog to digital converter.
• LPC2148 has two inbuilt ADC Modules, named as ADC0 & ADC1.
• ADC0 has 6-Channels (AD0.1-AD0.6).
• ADC1 has 8-Channels (AD1.0-AD1.7).
• ADC operating frequency is 4.5 MHz (max.), operating frequency
decides the conversion time.
• Supports power down mode.
• Burst conversion mode for single or multiple inputs.
• There are several registers associated with ADC feature but we will
mainly discussing about ADC Control Register (ADCR) & ADC Global
Data Register (ADGDR).
ADC related channels and pins
Registers of ADC in LPC2148 Microcontroller
Description of AD0CR:
A/D Global Data Register (AD0GDR)
Description of AD0GDR
ADC Operating modes in LPC2148
Software controlled mode : In Software mode only one conversion
will be done at a time. This conversion can be controlled in software.
To perform another conversion you will need to re-initiate the
process. In software mode only 1 bit in the SEL field of AD0CR can
be 1 i.e. only 1 Channel(i.e. Pin) can be selected for conversion at a
time. You can do conversions on multiple Channels (one at a time)
by selecting a particular Channel along with appropriate bit in SEL
field and then do the same for rest of the channels.
Burst or Hardware mode : In Burst or Hardware mode conversions
are performed continuously on the selected channels in round-robin
fashion. Since the conversions cannot be controlled by software,
Overrun may occur in this mode. Overrun is the case when a
previous conversion result is replaced by new conversion result
without previous result being read i.e. the conversion is lost. Usually
an interrupt is used in Burst mode to get the latest conversion
results. This interrupt is triggered when conversion in one of the
selected channel ends.
Setting up and configuring ADC Module for software
controlled mode :
#define CLKDIV 3 // 4Mhz ADC clock (ADC_CLOCK=PCLK/CLKDIV) where "CLKDIV-1"
is actually used , in our case PCLK=12mhz
#define BURST_MODE_OFF (0<<16) // 1 for on and 0 for off
#define PowerUP (1<<21) //setting it to 0 will power it down
#define START_NOW ((0<<26)|(0<<25)|(1<<24)) //001 for starting the conversion
immediately
#define ADC_DONE (1<<31)
Initial step:
unsigned long AD0CR_setup = (CLKDIV<<8) | BURST_MODE_OFF | PowerUP;
AD0CR = AD0CR_setup | SEL_AD06; AD0CR |= START_NOW;
Fetching the conversion result:
while( (AD0DR6 & ADC_DONE) == 0 ); //this loop will terminate when bit 31 of
AD0DR6 changes to 1
result = (AD0DR6>>6) & 0x3FF;
Setting up and configuring ADC Module for Burst mode :
• Configuring ADC Module is similar to what was done in software controlled mode
except here we use the CLKS bits and don't use the START bits in AD0CR.
ADC_DONE is also not applicable since we are using an ISR which gets triggered
when a conversion completes on any of the enabled channels.
• #define CLKDIV 3 // 4Mhz ADC clock (ADC_CLOCK=PCLK/CLKDIV) where "CLKDIV-1"
is actually used , in our case PCLK=12mhz
• #define BURST_MODE_ON (1<<16) // 1 for on and 0 for off
• #define CLKS_10bit ((0<<19)|(0<<18)|(0<<17)) //10 bit resolution
• #define PowerUP (1<<21) //setting it to 0 will power it down
Initial step:
unsigned int AD0CR_setup = (CLKDIV<<8) | BURST_MODE_ON | CLKS_10bit |
PowerUP; AD0CR = AD0CR_setup | SEL_AD06 | SEL_AD07;
Fetching the conversion result:
In Burst mode we use an ISR which triggers at the completion of a conversion in
any one of the channel.
Simple program
unsigned int adc_data()
{
unsigned int adcdata;
while(!(AD0GDR & 0x80000000)); // Check end of conversion (Done bit) and
read result
adcdata=AD0GDR;
return ((adcdata >> 6) & 0x3ff) ; // Return 10 bit result
}
int main(void)
{
unsigned int adc;
IODIR1=0XFF<<16; // for LCD
PINSEL1 = 1<<27|1<<28|1<<29 ; // enable P0.27 for AD0.0, P0.28 for AD0.1,
P0.29 for AD0.2,
lcd_init(); //initialize LCD
while(1)
{
AD0CR = 0x01200301 ; // Select AD0.0, Select clock for ADC, Start of
conversion
adc = adc_data();
sprintf(adcreading,"%d",adc); // read data in decimal format
string(adcreading); // display result on LCD
AD0CR = 0x01200302 ; // Select AD0.1, Select clock for ADC, Start of
conversion
adc = ADC_GetAdcReading();
sprintf(adcreading,"%d",adc); // read data in decimal format
string(adcreading); // display result on LCD
AD0CR = 0x01200304 ; // Select AD0.2, Select clock for ADC, Start of
conversion
adc = ADC_GetAdcReading();
sprintf(adcreading,"%d",adc); // read data in decimal format
string(adcreading); // display result on LCD
}}
Thanks
For any suggestion,
Please contact me on-
Mail id- a.soniarav@gmail.com
Facebook- https:www.facebook.com/arav.soni.98
Twitter- https://twitter.com/AaravSoni1

More Related Content

What's hot

Rs232 485 fundamental
Rs232 485 fundamentalRs232 485 fundamental
Rs232 485 fundamentalrounak077
 
RTC Interfacing and Programming
RTC Interfacing and ProgrammingRTC Interfacing and Programming
RTC Interfacing and ProgrammingDevashish Raval
 
Serial Communication Interfaces
Serial Communication InterfacesSerial Communication Interfaces
Serial Communication Interfacesanishgoel
 
I2c protocol - Inter–Integrated Circuit Communication Protocol
I2c protocol - Inter–Integrated Circuit Communication ProtocolI2c protocol - Inter–Integrated Circuit Communication Protocol
I2c protocol - Inter–Integrated Circuit Communication ProtocolAnkur Soni
 
PIC-18 Microcontroller
PIC-18 MicrocontrollerPIC-18 Microcontroller
PIC-18 MicrocontrollerASHISH RANJAN
 
Embedded system design using arduino
Embedded system design using arduinoEmbedded system design using arduino
Embedded system design using arduinoSantosh Verma
 
Sensor interfacing in 8051
Sensor interfacing in 8051Sensor interfacing in 8051
Sensor interfacing in 8051Irfan Ahmad
 
Serial Communication
Serial CommunicationSerial Communication
Serial CommunicationRashmi
 
Introduction to Embedded System I: Chapter 2 (5th portion)
Introduction to Embedded System I: Chapter 2 (5th portion)Introduction to Embedded System I: Chapter 2 (5th portion)
Introduction to Embedded System I: Chapter 2 (5th portion)Moe Moe Myint
 
Arm7 Interfacing examples
Arm7   Interfacing examples Arm7   Interfacing examples
Arm7 Interfacing examples Dr.YNM
 
LPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLERLPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLERsravannunna24
 
Device drivers and interrupt service mechanism
Device drivers and interrupt service mechanismDevice drivers and interrupt service mechanism
Device drivers and interrupt service mechanismVijay Kumar
 
Interfacing technique with 8085- ADC[0808]
Interfacing technique with 8085- ADC[0808]Interfacing technique with 8085- ADC[0808]
Interfacing technique with 8085- ADC[0808]Guhan k
 

What's hot (20)

Rs232 485 fundamental
Rs232 485 fundamentalRs232 485 fundamental
Rs232 485 fundamental
 
RTC Interfacing and Programming
RTC Interfacing and ProgrammingRTC Interfacing and Programming
RTC Interfacing and Programming
 
Serial Communication in 8051
Serial Communication in 8051Serial Communication in 8051
Serial Communication in 8051
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 
ARM Processors
ARM ProcessorsARM Processors
ARM Processors
 
Serial Communication Interfaces
Serial Communication InterfacesSerial Communication Interfaces
Serial Communication Interfaces
 
DSP Processor
DSP Processor DSP Processor
DSP Processor
 
I2c protocol - Inter–Integrated Circuit Communication Protocol
I2c protocol - Inter–Integrated Circuit Communication ProtocolI2c protocol - Inter–Integrated Circuit Communication Protocol
I2c protocol - Inter–Integrated Circuit Communication Protocol
 
PIC-18 Microcontroller
PIC-18 MicrocontrollerPIC-18 Microcontroller
PIC-18 Microcontroller
 
Embedded system design using arduino
Embedded system design using arduinoEmbedded system design using arduino
Embedded system design using arduino
 
Sensor interfacing in 8051
Sensor interfacing in 8051Sensor interfacing in 8051
Sensor interfacing in 8051
 
Serial Communication
Serial CommunicationSerial Communication
Serial Communication
 
Introduction to Embedded System I: Chapter 2 (5th portion)
Introduction to Embedded System I: Chapter 2 (5th portion)Introduction to Embedded System I: Chapter 2 (5th portion)
Introduction to Embedded System I: Chapter 2 (5th portion)
 
Ec8791 arm 9 processor
Ec8791 arm 9 processorEc8791 arm 9 processor
Ec8791 arm 9 processor
 
Arm7 Interfacing examples
Arm7   Interfacing examples Arm7   Interfacing examples
Arm7 Interfacing examples
 
LPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLERLPC 2148 ARM MICROCONTROLLER
LPC 2148 ARM MICROCONTROLLER
 
Device drivers and interrupt service mechanism
Device drivers and interrupt service mechanismDevice drivers and interrupt service mechanism
Device drivers and interrupt service mechanism
 
Interfacing technique with 8085- ADC[0808]
Interfacing technique with 8085- ADC[0808]Interfacing technique with 8085- ADC[0808]
Interfacing technique with 8085- ADC[0808]
 
Ec8791 lpc2148 pwm
Ec8791 lpc2148 pwmEc8791 lpc2148 pwm
Ec8791 lpc2148 pwm
 
SPI Bus Protocol
SPI Bus ProtocolSPI Bus Protocol
SPI Bus Protocol
 

Viewers also liked

Timer counter in arm7(lpc2148)
Timer counter in arm7(lpc2148)Timer counter in arm7(lpc2148)
Timer counter in arm7(lpc2148)Aarav Soni
 
Spi in arm7(lpc2148)
Spi in arm7(lpc2148)Spi in arm7(lpc2148)
Spi in arm7(lpc2148)Aarav Soni
 
Pll in lpc2148
Pll in lpc2148Pll in lpc2148
Pll in lpc2148Aarav Soni
 
Analog to digital conversion
Analog to digital conversionAnalog to digital conversion
Analog to digital conversionEngr Ahmad Khan
 
Analog to Digital Converter
Analog to Digital ConverterAnalog to Digital Converter
Analog to Digital ConverterRonak Machhi
 
ARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lectureARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lectureanishgoel
 
Analog to digital converter
Analog to digital converterAnalog to digital converter
Analog to digital converterAshutosh Jaiswal
 
ANALOG TO DIGITAL AND DIGITAL TO ANALOG CONVERTER
ANALOG TO DIGITAL AND DIGITAL TO ANALOG CONVERTERANALOG TO DIGITAL AND DIGITAL TO ANALOG CONVERTER
ANALOG TO DIGITAL AND DIGITAL TO ANALOG CONVERTERSripati Mahapatra
 
DAC-digital to analog converter
DAC-digital to analog converterDAC-digital to analog converter
DAC-digital to analog converterShazid Reaj
 
Serial communication in LPC2148
Serial communication in LPC2148Serial communication in LPC2148
Serial communication in LPC2148sravannunna24
 
ARM COMPLETE DETAIL PART 4
ARM COMPLETE DETAIL PART 4ARM COMPLETE DETAIL PART 4
ARM COMPLETE DETAIL PART 4NOWAY
 
4 bit lcd_interfacing_with_arm7_primer
4 bit lcd_interfacing_with_arm7_primer4 bit lcd_interfacing_with_arm7_primer
4 bit lcd_interfacing_with_arm7_primerpvmistary
 
Successive Approximation ADC
Successive Approximation ADCSuccessive Approximation ADC
Successive Approximation ADCankit_master
 
adc converter basics
adc converter basicsadc converter basics
adc converter basicshacker1500
 
DAC , Digital to analog Converter
DAC , Digital to analog ConverterDAC , Digital to analog Converter
DAC , Digital to analog ConverterHossam Zein
 

Viewers also liked (20)

Timer counter in arm7(lpc2148)
Timer counter in arm7(lpc2148)Timer counter in arm7(lpc2148)
Timer counter in arm7(lpc2148)
 
Spi in arm7(lpc2148)
Spi in arm7(lpc2148)Spi in arm7(lpc2148)
Spi in arm7(lpc2148)
 
Pll in lpc2148
Pll in lpc2148Pll in lpc2148
Pll in lpc2148
 
ADC and DAC Best Ever Pers
ADC and DAC Best Ever PersADC and DAC Best Ever Pers
ADC and DAC Best Ever Pers
 
Analog to digital conversion
Analog to digital conversionAnalog to digital conversion
Analog to digital conversion
 
Analog to Digital Converter
Analog to Digital ConverterAnalog to Digital Converter
Analog to Digital Converter
 
ARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lectureARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lecture
 
Analog to digital converter
Analog to digital converterAnalog to digital converter
Analog to digital converter
 
ANALOG TO DIGITAL AND DIGITAL TO ANALOG CONVERTER
ANALOG TO DIGITAL AND DIGITAL TO ANALOG CONVERTERANALOG TO DIGITAL AND DIGITAL TO ANALOG CONVERTER
ANALOG TO DIGITAL AND DIGITAL TO ANALOG CONVERTER
 
DAC-digital to analog converter
DAC-digital to analog converterDAC-digital to analog converter
DAC-digital to analog converter
 
Serial communication in LPC2148
Serial communication in LPC2148Serial communication in LPC2148
Serial communication in LPC2148
 
ARM COMPLETE DETAIL PART 4
ARM COMPLETE DETAIL PART 4ARM COMPLETE DETAIL PART 4
ARM COMPLETE DETAIL PART 4
 
4 bit lcd_interfacing_with_arm7_primer
4 bit lcd_interfacing_with_arm7_primer4 bit lcd_interfacing_with_arm7_primer
4 bit lcd_interfacing_with_arm7_primer
 
Successive Approximation ADC
Successive Approximation ADCSuccessive Approximation ADC
Successive Approximation ADC
 
ARM lab programs
ARM  lab programs  ARM  lab programs
ARM lab programs
 
adc converter basics
adc converter basicsadc converter basics
adc converter basics
 
Lpc2148 i2c
Lpc2148 i2cLpc2148 i2c
Lpc2148 i2c
 
DAC , Digital to analog Converter
DAC , Digital to analog ConverterDAC , Digital to analog Converter
DAC , Digital to analog Converter
 
ARM Processor Tutorial
ARM Processor Tutorial ARM Processor Tutorial
ARM Processor Tutorial
 
presPresentation1
presPresentation1presPresentation1
presPresentation1
 

Similar to Analog to Digital converter in ARM

Analog to digital converter
Analog to digital converterAnalog to digital converter
Analog to digital converterCorrado Santoro
 
analog to digital converter seminar
analog to digital converter seminaranalog to digital converter seminar
analog to digital converter seminargayatrigayu1
 
Analog To Digital Conversion (ADC) Programming in LPC2148
Analog To Digital Conversion (ADC) Programming in LPC2148Analog To Digital Conversion (ADC) Programming in LPC2148
Analog To Digital Conversion (ADC) Programming in LPC2148Omkar Rane
 
AVR_Course_Day6 external hardware interrupts and analogue to digital converter
AVR_Course_Day6 external hardware  interrupts and analogue to digital converterAVR_Course_Day6 external hardware  interrupts and analogue to digital converter
AVR_Course_Day6 external hardware interrupts and analogue to digital converterMohamed Ali
 
UNIT 4 & 5 - I nterfacing_Lecture7.pptx
UNIT 4 & 5 - I         nterfacing_Lecture7.pptxUNIT 4 & 5 - I         nterfacing_Lecture7.pptx
UNIT 4 & 5 - I nterfacing_Lecture7.pptxnaveen088888
 
04 adc (pic24, ds pic with dma)
04 adc (pic24, ds pic with dma)04 adc (pic24, ds pic with dma)
04 adc (pic24, ds pic with dma)antonio michua
 
Training Report on embedded Systems and Robotics
Training Report on embedded  Systems and RoboticsTraining Report on embedded  Systems and Robotics
Training Report on embedded Systems and RoboticsNIT Raipur
 
analog to digital converter.ppt
analog to digital converter.pptanalog to digital converter.ppt
analog to digital converter.pptDreamers6
 
ANALOG TO DIGITALCONVERTOR FOR BLOOD-GLUCOSE MONITORING
ANALOG TO DIGITALCONVERTOR FOR  BLOOD-GLUCOSE MONITORING  ANALOG TO DIGITALCONVERTOR FOR  BLOOD-GLUCOSE MONITORING
ANALOG TO DIGITALCONVERTOR FOR BLOOD-GLUCOSE MONITORING csijjournal
 
Analog to Digitalconvertor for Blood-Glucose Monitoring
Analog to Digitalconvertor for Blood-Glucose MonitoringAnalog to Digitalconvertor for Blood-Glucose Monitoring
Analog to Digitalconvertor for Blood-Glucose Monitoringcsijjournal
 
STM_ADC para microcontroladores STM32 - Conceptos basicos
STM_ADC para microcontroladores STM32 - Conceptos basicosSTM_ADC para microcontroladores STM32 - Conceptos basicos
STM_ADC para microcontroladores STM32 - Conceptos basicosps6005tec
 
project report on embedded system
project report on embedded systemproject report on embedded system
project report on embedded systemram avtar
 

Similar to Analog to Digital converter in ARM (20)

A 1.2V 10-bit 165MSPS Video ADC
A 1.2V 10-bit 165MSPS Video ADCA 1.2V 10-bit 165MSPS Video ADC
A 1.2V 10-bit 165MSPS Video ADC
 
Analog to digital converter
Analog to digital converterAnalog to digital converter
Analog to digital converter
 
Lpc 17xx adc
Lpc 17xx adcLpc 17xx adc
Lpc 17xx adc
 
analog to digital converter seminar
analog to digital converter seminaranalog to digital converter seminar
analog to digital converter seminar
 
Analog To Digital Conversion (ADC) Programming in LPC2148
Analog To Digital Conversion (ADC) Programming in LPC2148Analog To Digital Conversion (ADC) Programming in LPC2148
Analog To Digital Conversion (ADC) Programming in LPC2148
 
AVR_Course_Day6 external hardware interrupts and analogue to digital converter
AVR_Course_Day6 external hardware  interrupts and analogue to digital converterAVR_Course_Day6 external hardware  interrupts and analogue to digital converter
AVR_Course_Day6 external hardware interrupts and analogue to digital converter
 
UNIT 4 & 5 - I nterfacing_Lecture7.pptx
UNIT 4 & 5 - I         nterfacing_Lecture7.pptxUNIT 4 & 5 - I         nterfacing_Lecture7.pptx
UNIT 4 & 5 - I nterfacing_Lecture7.pptx
 
EEE UNIT-2 PPT.pdf
EEE UNIT-2 PPT.pdfEEE UNIT-2 PPT.pdf
EEE UNIT-2 PPT.pdf
 
Analog to Digital Converter
Analog to Digital ConverterAnalog to Digital Converter
Analog to Digital Converter
 
04 adc (pic24, ds pic with dma)
04 adc (pic24, ds pic with dma)04 adc (pic24, ds pic with dma)
04 adc (pic24, ds pic with dma)
 
Training Report on embedded Systems and Robotics
Training Report on embedded  Systems and RoboticsTraining Report on embedded  Systems and Robotics
Training Report on embedded Systems and Robotics
 
analog to digital converter.ppt
analog to digital converter.pptanalog to digital converter.ppt
analog to digital converter.ppt
 
ANALOG TO DIGITALCONVERTOR FOR BLOOD-GLUCOSE MONITORING
ANALOG TO DIGITALCONVERTOR FOR  BLOOD-GLUCOSE MONITORING  ANALOG TO DIGITALCONVERTOR FOR  BLOOD-GLUCOSE MONITORING
ANALOG TO DIGITALCONVERTOR FOR BLOOD-GLUCOSE MONITORING
 
Analog to Digitalconvertor for Blood-Glucose Monitoring
Analog to Digitalconvertor for Blood-Glucose MonitoringAnalog to Digitalconvertor for Blood-Glucose Monitoring
Analog to Digitalconvertor for Blood-Glucose Monitoring
 
Analog to digital converter
Analog to digital converterAnalog to digital converter
Analog to digital converter
 
STM_ADC para microcontroladores STM32 - Conceptos basicos
STM_ADC para microcontroladores STM32 - Conceptos basicosSTM_ADC para microcontroladores STM32 - Conceptos basicos
STM_ADC para microcontroladores STM32 - Conceptos basicos
 
project report on embedded system
project report on embedded systemproject report on embedded system
project report on embedded system
 
Analog to digital converter
Analog to digital converterAnalog to digital converter
Analog to digital converter
 
Lecture 12 (adc) rv01
Lecture 12  (adc) rv01Lecture 12  (adc) rv01
Lecture 12 (adc) rv01
 
chapter 4
chapter 4chapter 4
chapter 4
 

Recently uploaded

Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Aryaabh.arya
 
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical EngineeringIntroduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical EngineeringC Sai Kiran
 
Scaling in conventional MOSFET for constant electric field and constant voltage
Scaling in conventional MOSFET for constant electric field and constant voltageScaling in conventional MOSFET for constant electric field and constant voltage
Scaling in conventional MOSFET for constant electric field and constant voltageRCC Institute of Information Technology
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdfKamal Acharya
 
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsRS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsAtif Razi
 
Hall booking system project report .pdf
Hall booking system project report  .pdfHall booking system project report  .pdf
Hall booking system project report .pdfKamal Acharya
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdfKamal Acharya
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationRobbie Edward Sayers
 
Arduino based vehicle speed tracker project
Arduino based vehicle speed tracker projectArduino based vehicle speed tracker project
Arduino based vehicle speed tracker projectRased Khan
 
Online blood donation management system project.pdf
Online blood donation management system project.pdfOnline blood donation management system project.pdf
Online blood donation management system project.pdfKamal Acharya
 
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and ClusteringKIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and ClusteringDr. Radhey Shyam
 
Pharmacy management system project report..pdf
Pharmacy management system project report..pdfPharmacy management system project report..pdf
Pharmacy management system project report..pdfKamal Acharya
 
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptxCloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptxMd. Shahidul Islam Prodhan
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxR&R Consult
 
İTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering WorkshopİTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering WorkshopEmre Günaydın
 
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data StreamKIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data StreamDr. Radhey Shyam
 
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and VisualizationKIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and VisualizationDr. Radhey Shyam
 
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdf
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdfRESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdf
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdfKamal Acharya
 
Online resume builder management system project report.pdf
Online resume builder management system project report.pdfOnline resume builder management system project report.pdf
Online resume builder management system project report.pdfKamal Acharya
 

Recently uploaded (20)

Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
 
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical EngineeringIntroduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
 
Scaling in conventional MOSFET for constant electric field and constant voltage
Scaling in conventional MOSFET for constant electric field and constant voltageScaling in conventional MOSFET for constant electric field and constant voltage
Scaling in conventional MOSFET for constant electric field and constant voltage
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
 
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsRS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
 
Hall booking system project report .pdf
Hall booking system project report  .pdfHall booking system project report  .pdf
Hall booking system project report .pdf
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
Arduino based vehicle speed tracker project
Arduino based vehicle speed tracker projectArduino based vehicle speed tracker project
Arduino based vehicle speed tracker project
 
Online blood donation management system project.pdf
Online blood donation management system project.pdfOnline blood donation management system project.pdf
Online blood donation management system project.pdf
 
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and ClusteringKIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
 
Pharmacy management system project report..pdf
Pharmacy management system project report..pdfPharmacy management system project report..pdf
Pharmacy management system project report..pdf
 
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptxCloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
İTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering WorkshopİTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering Workshop
 
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data StreamKIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
 
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and VisualizationKIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
KIT-601 Lecture Notes-UNIT-5.pdf Frame Works and Visualization
 
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdf
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdfRESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdf
RESORT MANAGEMENT AND RESERVATION SYSTEM PROJECT REPORT.pdf
 
Online resume builder management system project report.pdf
Online resume builder management system project report.pdfOnline resume builder management system project report.pdf
Online resume builder management system project report.pdf
 

Analog to Digital converter in ARM

  • 2. What is ADC ? • Analog to Digital Conversion(i.e. ADC) , as the name suggests , is all about converting a given analog signal into its digital form or say a digital value. • This conversion or measurement happens in presence of a fixed and accurate reference voltage. • The analog signal is compared to this reference voltage and then estimations are made to get the final measured value.
  • 3. Resolution • ADC is used to convert analog signal/voltage into its equivalent digital number so that microcontroller can process that numbers and make it human readable. • The ADC characterized by resolution. The resolution of ADC indicates the number of digital values. • In LPC2148 microcontroller we have in-built 10-bit ADC. So for 10-bit ADC resolution is 10-bit and maximum value will be 210=1024. This means our digital value or discrete level lies between 0 to 1023. • There is one more term important to understand while dealing with ADC and it is step size. Step size is the minimum change in input voltage which can be resolved by ADC. The concept of step size is closely associated with the resolution of ADC.
  • 4. ADC in LPC2148 ARM7 Microcontroller • The ADC in LPC2148 ARM7 Microcontroller is 10-bit successive approximation analog to digital converter. • LPC2148 has two inbuilt ADC Modules, named as ADC0 & ADC1. • ADC0 has 6-Channels (AD0.1-AD0.6). • ADC1 has 8-Channels (AD1.0-AD1.7). • ADC operating frequency is 4.5 MHz (max.), operating frequency decides the conversion time. • Supports power down mode. • Burst conversion mode for single or multiple inputs. • There are several registers associated with ADC feature but we will mainly discussing about ADC Control Register (ADCR) & ADC Global Data Register (ADGDR).
  • 6. Registers of ADC in LPC2148 Microcontroller
  • 7.
  • 9.
  • 10.
  • 11. A/D Global Data Register (AD0GDR)
  • 13. ADC Operating modes in LPC2148 Software controlled mode : In Software mode only one conversion will be done at a time. This conversion can be controlled in software. To perform another conversion you will need to re-initiate the process. In software mode only 1 bit in the SEL field of AD0CR can be 1 i.e. only 1 Channel(i.e. Pin) can be selected for conversion at a time. You can do conversions on multiple Channels (one at a time) by selecting a particular Channel along with appropriate bit in SEL field and then do the same for rest of the channels. Burst or Hardware mode : In Burst or Hardware mode conversions are performed continuously on the selected channels in round-robin fashion. Since the conversions cannot be controlled by software, Overrun may occur in this mode. Overrun is the case when a previous conversion result is replaced by new conversion result without previous result being read i.e. the conversion is lost. Usually an interrupt is used in Burst mode to get the latest conversion results. This interrupt is triggered when conversion in one of the selected channel ends.
  • 14. Setting up and configuring ADC Module for software controlled mode : #define CLKDIV 3 // 4Mhz ADC clock (ADC_CLOCK=PCLK/CLKDIV) where "CLKDIV-1" is actually used , in our case PCLK=12mhz #define BURST_MODE_OFF (0<<16) // 1 for on and 0 for off #define PowerUP (1<<21) //setting it to 0 will power it down #define START_NOW ((0<<26)|(0<<25)|(1<<24)) //001 for starting the conversion immediately #define ADC_DONE (1<<31) Initial step: unsigned long AD0CR_setup = (CLKDIV<<8) | BURST_MODE_OFF | PowerUP; AD0CR = AD0CR_setup | SEL_AD06; AD0CR |= START_NOW; Fetching the conversion result: while( (AD0DR6 & ADC_DONE) == 0 ); //this loop will terminate when bit 31 of AD0DR6 changes to 1 result = (AD0DR6>>6) & 0x3FF;
  • 15. Setting up and configuring ADC Module for Burst mode : • Configuring ADC Module is similar to what was done in software controlled mode except here we use the CLKS bits and don't use the START bits in AD0CR. ADC_DONE is also not applicable since we are using an ISR which gets triggered when a conversion completes on any of the enabled channels. • #define CLKDIV 3 // 4Mhz ADC clock (ADC_CLOCK=PCLK/CLKDIV) where "CLKDIV-1" is actually used , in our case PCLK=12mhz • #define BURST_MODE_ON (1<<16) // 1 for on and 0 for off • #define CLKS_10bit ((0<<19)|(0<<18)|(0<<17)) //10 bit resolution • #define PowerUP (1<<21) //setting it to 0 will power it down Initial step: unsigned int AD0CR_setup = (CLKDIV<<8) | BURST_MODE_ON | CLKS_10bit | PowerUP; AD0CR = AD0CR_setup | SEL_AD06 | SEL_AD07; Fetching the conversion result: In Burst mode we use an ISR which triggers at the completion of a conversion in any one of the channel.
  • 16. Simple program unsigned int adc_data() { unsigned int adcdata; while(!(AD0GDR & 0x80000000)); // Check end of conversion (Done bit) and read result adcdata=AD0GDR; return ((adcdata >> 6) & 0x3ff) ; // Return 10 bit result } int main(void) { unsigned int adc; IODIR1=0XFF<<16; // for LCD PINSEL1 = 1<<27|1<<28|1<<29 ; // enable P0.27 for AD0.0, P0.28 for AD0.1, P0.29 for AD0.2, lcd_init(); //initialize LCD while(1) {
  • 17. AD0CR = 0x01200301 ; // Select AD0.0, Select clock for ADC, Start of conversion adc = adc_data(); sprintf(adcreading,"%d",adc); // read data in decimal format string(adcreading); // display result on LCD AD0CR = 0x01200302 ; // Select AD0.1, Select clock for ADC, Start of conversion adc = ADC_GetAdcReading(); sprintf(adcreading,"%d",adc); // read data in decimal format string(adcreading); // display result on LCD AD0CR = 0x01200304 ; // Select AD0.2, Select clock for ADC, Start of conversion adc = ADC_GetAdcReading(); sprintf(adcreading,"%d",adc); // read data in decimal format string(adcreading); // display result on LCD }}
  • 18. Thanks For any suggestion, Please contact me on- Mail id- a.soniarav@gmail.com Facebook- https:www.facebook.com/arav.soni.98 Twitter- https://twitter.com/AaravSoni1