Search Projects

Blogroll

Final year degree project for engineers DAC0800 based project circuit diagram and interfacing with pic mirocontroller Final year projects based on microcontrollers on programmable peripheral interface 8255
Microcontroller based different projects abstract and source code
PIC 16f877 microcontroller projects Motion control
PIC16f877 motor controller and other light projects
Tutorials of microcontroller PIC16f877, A step by step easy to use self learning rapidex

Tuesday, February 8, 2011

adc interfacing with Pic16f877

I found many questions from students of Electrical and electronics studying Microcontroller in electronics labs or in course related to microcontrollers. They often asked for adc interfacing with Pic16f877.  So i decided to write a page about Interfacing of analog to digital converter with PIC16f877 microcontroller.
An analog-to-digital converter (A/D) is used to convert an analog signal, such as
voltage, to digital form so a microcontroller can read and process it. Some
microcontrollers have built-in A/D converters. External A/D converter can also be connected to any type of microcontroller. A/D converters are usually 8 to 10 bits, having 256 to 1024 quantization levels. Most PIC microcontrollers with A/D features have multiplexed A/D converters which provide more than one analog input channel.
For example, the PIC18F452 microcontroller and PIC16f877 have 10-bit 8-channel A/D converters. The A/D conversion process must be started by the user program and may take several hundred microseconds to complete. A/D converters usually generate interrupts when a conversion is complete so the user program can read the converted data quickly.
A/D converters are especially useful in control and monitoring applications, since most sensors (e.g., temperature sensors, pressure sensors, force sensors, etc.) produce analog output voltages.
First of all if we have checked the data sheet of the microcontroller PIC 16f877. Then we will come to know that it have builtin Analog to digital converter. The microcontroller PIC16f877 have built in adcs. what we need is carefull configuration of the special purpose registers associated with ADC in PIC16f877. Best practice is to start using analog to digital converter from AN0 to onword. becuase if you will start from AN4 or AN5 then you will notic that there are some analog channel which have to configure them as spare channel. At first it appears that the PIC16F877 has 8 built-in ADCs, but this is not the case. The input analogue channels AN4..0 are shared with port A, and channels AN7..5 are shard with port E. If less than eight analogue channels are required then some of the pins can be assigned as digital I/O port lines using PCFG3..0 bits (see datasheet). For example, if PCFG3..0 = 0010 then AN4..0 are configured as analogue inputs, while AN7..5 are digital (port E free), with VDD used as the reference.Any how, I suggest my students, to use builtin ADC of the PIC 16f877 for any general purpose expierement. As they have good enough resolution and in the most of the assignments they have good performance. The typical resolution of the ADC built in PIC 16f1877 are 10bits, i.e you can have 5000(mV)/1024 = 4.88 mV/bit. It is fine for some cases. When you need some higher resolution then you can attach 12bit or 14, 16 bit ADC with PIC16f877 very easily. In the coming post we will learn how to interface 12-bit ADC with Microcontroller PIC16f877.There are many
analog-to-digital converter chips available on the market, and an embedded systems designer should understand the characteristics of such chips so they can be used efficiently. As far as the input and output voltage are concerned A/D converters can be classified as either unipolar and bipolar. Unipolar ADC accept unipolar input voltages in the range 0 to þ0V, and bipolar ADC accept bipolar input voltages in the
range V. Bipolar converters are frequently used in signal processing applications, where the signals by nature are bipolar. Unipolar converters are usually cheaper, and they are used in many control and instrumentation applications. The typical steps involved in reading and converting an analog signal into digital form, a process also known as signal conditioning. Signals received from sensors usually need to be processed before being fed to an ADC. The processing usually begins with scaling the signal to the correct value. Unwanted signal components are then removed by filtering the signal using classical filters (e.g., a lowpass filter). Finally, before feeding the signal to an ADC, the signal is passed through a sample-and-hold device. This is particularly important with fast real-time signals whose value may be changing between the sampling instants. A sample-andhold device ensures that the signal stays at a constant value during the actual conversion
process. Many applications required more than one ADC, which normally involves using an analog multiplexer at the input of the ADC. The multiplexer selects only one signal at any time and presents this signal to the ADC. An ADC usually has a single analog input and a digital parallel output.
The most practical method of reading Analog signal is by using an ADC built into a PICmicro® MCU. The ADC read can be carried out in the following macro:
ADCRead Macro
bsf ADCON0, GO ; Turn on the ADC
btfsc ADCON0, GO ; Wait for it to Complete
goto $ - 1
endm
Method to use Built in ADC of PIC16f877 in MicroC C language:
void main()
{
ADCON1 = 0x00 ; // set PORTA as analog input
TRISA = 0xff ; // set PORTA as inputs
while (1)
{
temp = Adc_Read(0);
}
}
mikroc code adc lcd pic 16f877
In the above example single channel ADC is used , however you can use upto eight ADC by selecting one by one. the analog voltage from PORTA channel 0. The analog voltage is supplied by a potentiometer. As you change the variable resistance the voltage that is applied to PORTA channel 0 will change. The ADC module of the PIC16F877 will convert the input voltage to an integer number between 0 and 1024. Notice that the ADC module of the PIC 16F877 is a 10-bit module, so the there are 1024 binary number to represent the input voltage range.The output of ADC module is a 10-bit binary number.
The Microcontroller PIC16F873A has 5 10-bit ADC channels,16F874A has 8 10-bit ADC channels,16F876A has 5 10-bit ADC channels,16F877A has 8 10-bit ADC channels.
reflectance sensor with PIC16F877 solar panel voltage by using PIC16F877 microcontroller. Microcontroller-based converter is chosen because it permits easy system modifications.
Tag:-
mikroBasic-OSCILLOSCOP,MikroElektronika Visual GLCD Software for visually building,mikroC, mikroBasic,PIC18F2550 KS0108 Graphical LCD,GRAPHIC LCD 128X64 with lpc2138,interface GRAPHIC LCD 128X64 with PIC16F877 by PIC BASICPRO,GLCD TOUCHSCREEN 128x64 & PIC18F452,Proton Development Suite/ BASIC Compiler Features, Graphic Lcd Library * I²C Library * Keypad Library * Lcd Library,EasyPIC6 BASIC Starter Pack ,Glcd Touchscreen 128x64 Pic18f452, libraries for LCD, Graphics LCD, buttons, keypad, PWM, SPI, I2C,BIGPIC6 development board, character LCD, graphic LCD with touchscreen,LCD using 18F4550 by MikroC pro,PID closed loop position control of DC motor interfaced to a graphic LCD,Touchscreen GLCD is available with mikroBasic code examples,เจอแล้ว!! คลิป glcd \(^o^)/ ดูคลิปglcd มากมายที่,pic, pic18, pic18f, 18f4550, A/D, analog, digital, conversion, LED, voltage, potentiometer,PIC, PIC18F, PIC18F2455, 18F2455, LCD, HD44780, 16x2, DISPLAY, mikroc,MCU- 18F4550 DISPAY - KS0108 128x64 GLCD COMPILER-CCS C SIMULATION- PROTEUS

4 comments:

Syaz said...

hi..im syaz.sory for disturbing..actually i need your help for my project.my final project is "anger detection based on heart beat,,voice identification and face recognition." for this project i have 2 circuit which are heart beat circuit and voice circuit..then i will combine these two circuit..for heart beat,i will set the value.if it greater than 85bpm,the lcd will display as "cool down".this project is measure the heart beats per minute from finger placing between the sensor. The sensor is made of simple photo resistor and LED. but i must use PIC16f877a.so i am very pleasant if you could help me on this..only for heart beat.i also get trouble with voice circuit and face recognition..but i only ask u for heart beat because my lecture said if i just do heart beat and face,at least i get
syaz: at least i get half mark..i will attach with my abstract.thank you..

Dr.Rana said...

@ Syaz
Ok
I am working on your project for heart rate meter and LCD display using PIC16f877. soon i will make acomplete post on your project here. So keep in contact and visit this blog regularly,

Saumil said...

Sir, can you post the ADC_read() function code here?

Anonymous said...

Hi sir i need a complete code of thermocouple interface with pic microcontroller... i need this schematic as well..kindly send me asp...I shall b very thankful to u..

Post a Comment

Hi: This is PICINF.blogspot.com comments section. Here you are requested to write your question or problems in detail. Write the question in such a way that, it have all necessary information, sothat i can understand and reply.If you want to send pictures and codes then e-mail me (rghkk@hotmail.com).Thanks.