1
A/D Conversion with PIC 16F877
Dr. Charles Kim
Department of Electrical and Computer Engineering
Howard University
2
A/D Conversion Port
3
ADC Related Registers
4
Registers
5
ADCON0
11001001
6
ADCON1
7
AD Result Justification
8
Resolution (10bit and 8bit)
9
PIE1 and PIR1 Registers
Disable this flag in initialization
This bit is set when conversion is done. So we have to clear it for the next conversion.
10
ADC Diagram and Conversion Process
11
AD Procedure� INITIALIZATION� 1. Configure the A/D module:
� Configure analog pins / voltage reference /and digital I/O (ADCON1)� Select A/D input channel (ADCON0)� Select A/D conversion clock (ADCON0)� Turn on A/D module (ADCON0)
� 2. Configure A/D interrupt (DISABLE IT):PIE1 register� Clear ADIE bit
� CONVERSION� 1. Wait the required acquisition time.� 2. Start conversion
� Set GO/DONE bit (ADCON0)� 3. Wait for A/D conversion to complete
� Polling for the GO/DONE bit to be cleared� 4. Clear Conversion Complete Flag: PIR1 register
� Clear ADIF bit� 5. Read A/D Result register pair (ADRESH:ADRESL).
12
Rheostat Connection to AN0
13
Coding – initialization
Movlw 0xC9
For RA1
14
Coding – ADC subroutine
15
Printing the Result on PC screen –using the upper 8-bit only
0V
5V
16
Continued
17
Continued-
18
Continued- (subroutine TEN)
19
10-bit results with 3 decimal points
20
Continued
21
Continued
22
Infrared Ranger Application
23
Sharp Ranger Module
24
GP2D12 – Non-linearity
25
GP2D12D Connection to AN1
26
GP2D12D Coding – ADC
11010001
For RA2
27
GP2D12D coding – Distance Conversion
28
CSA-1V Hall Effect Current Sensor
29
Sensitivity
30
ADC for CSA1V
31
Pseudo-Code for CSA-1V
32
Battery (power) Monitor using MAX471/MAX472
33
Connection Diagram for Battery Monitoring
34
Allegro ACS750 Current Sensor
35
Current vs. Output Voltage
36
Connection and Coding
37
Thermister for Temperature Sensing
Top Related