1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

Vi điều khiển và ứng dụng ADC

26 320 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 26
Dung lượng 1,11 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Các bước khởi động ADCConfigure the A/D module configure the port pins as analogue inputs, voltage reference, and digital I/O pins, select A/D converter input channel, select A/D co

Trang 1

Chuyên đề II

Vi điều khiển và ứng dụng

Trang 2

Ví dụ về ADC

2

Trang 3

Conversion time

3

Trang 4

Mạch ứng dụng

4

To help designing analog hardware filters, Microchip offers a small application named FilterLab

Trang 6

6

Trang 7

A/D block

7

Trang 8

Các bước khởi động ADC

Configure the A/D module

configure the port pins as analogue inputs, voltage reference, and digital I/O pins,

select A/D converter input channel,

select A/D conversion clock,

select A/D conversion trigger source,

turn on A/D module;

8

Trang 9

Configure A/D interrupt (if required)

clear ADIF bit (IFS0,11>),

select A/D interrupt priority,

set ADIE bit (IEC0<11>);

Start sampling

Wait the required acquisition time;

Trigger acquisition end, start conversion;

9

Trang 10

Wait for A/D to complete, by either

waiting for the A/D interrupt, or

waiting for the DONE bit to get set;

Read A/D result buffer, clear ADIF bit if required.

10

Trang 11

Voltage reference

11

Trang 12

Acquisition / Conversion Timing

12

Trang 13

Chọn kênh

13

Trang 14

Manual Acquisition / Conversion

14

Trang 15

Setting A/D Conversion Time

ADCS sets conversion clock period

D

 Related to clock used by processor

Tcy = 1 / MIPS

Tconv = Desired conversion time

Clocks per conversion = 14 for 12-bit A/D

 ADCS = ((2 * Tconv) / (14 * Tcy)) - 1

15

Trang 16

Ví dụ

 ADCS = ((2 * Tconv) / (CConv * Tcy)) - 1

Example: 30 MIPS device, 12-bit A/D, max rate

 Tcy = 1 / 30 MIPS = 33.3 nsec

 Tconv = 10 mSec (min) by specification

ADCS = ((2 * 10*10-6) / (14 * 33.3*10-9)) – 1

= 41.8

 ADCS = 42 = 0x24 = 0b101010

Tad = (ADCS+1) * (Tcy/2) = 716 nsec

Tconv = 14 * Tad= 10.03 mSec

16

Trang 17

Internal AD RC clock

ADRC enables internal AD RC clock

 ADCS bits are ignored

 For 12-bit A/D

 Nominal Rate = 47 KSPS Nominal Tconv = 21 mSec

17

Trang 18

Chu kỳ ADC

18

Trang 19

Ví dụ lấy mẫu và chuyển đổi thủ công

19

Trang 20

Ví dụ về khởi động bằng timer ngoài

20

Trang 21

C sample

21

Trang 22

Buffer will reset to

ADCBUF0 after each

Interrupt

User software has

read only access to buffer

22

Trang 23

Buffer Data Formats

Results presented in one of four formats

Trang 24

Channel Scanning

When (CSCNA = 1) group A will scan analog inputs

24

Trang 25

AD1CON2 = 0; // use MUXA, AVss and AVdd are used as AD1CON3 = 0x1F02; // Tad = 2 x Tcy = 125ns >75ns

Vref+/-AD1CON1bits.ADON = 1; // turn on the ADC

while (TMR1< 100); // 6.25 us AD1CON1bits.DONE = 1; // 4 start the conversion while (!AD1CON1bits.DONE); // 5 wait for the conversion to complete return ADC1BUF0; // 6 read the conversion result

} // readADC

25

Trang 26

AD1CON2 = 0; // use MUXA, AVss and AVdd are used as AD1CON3 = 0x1F02; // Tsamp = 32 x Tad; Tad=125ns

Vref+/-AD1CON1bits.ADON = 1; // turn on the ADC } //initADC

int readADC( int ch)

{

AD1CHS = ch; // 1 select analog input channel AD1CON1bits.SAMP = 1; // 2 start sampling while (!AD1CON1bits.DONE); // 3 wait for the conversion to complete return ADC1BUF0; // 4 read the conversion result

} // readADC

26

Ngày đăng: 30/12/2015, 18:04

TỪ KHÓA LIÊN QUAN

w