Vous êtes sur la page 1sur 37

A/D Conversion with PIC 16F877

Dr. Charles Kim

Department of Electrical and Computer Engineering


Howard University
WWW.MWFTR.COM
1

A/D Conversion Port

ADC Related Registers

Registers

ADCON0

11001001

ADCON1

AD Result Justification

Resolution (10bit and 8bit)

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
9
next conversion.

ADC Diagram and Conversion Process

10

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).
11

Rheostat Connection to AN0

12

Coding initialization

Movlw 0xC9
For RA1

13

Coding ADC subroutine

14

Printing the Result on PC screen using the


upper 8-bit only
5V

0V

15

Continued

16

Continued-

17

Continued- (subroutine TEN)

18

10-bit results with 3 decimal points

19

Continued

20

Continued

21

Infrared Ranger Application

22

Sharp Ranger Module

23

GP2D12 Non-linearity

24

GP2D12D Connection to AN1

25

GP2D12D Coding ADC

11010001
For RA2

26

GP2D12D coding Distance Conversion

27

CSA-1V Hall Effect Current Sensor

28

Sensitivity

29

ADC for CSA1V

30

Pseudo-Code for CSA-1V

31

Battery (power) Monitor using MAX471/MAX472

32

Connection Diagram for Battery Monitoring

33

Allegro ACS750 Current Sensor

34

Current vs.
Output
Voltage

35

Connection and Coding

36

Thermister for Temperature Sensing

37