Section 22. Basic 8-bit A/D Converter ppt

20 409 0
Section 22. Basic 8-bit A/D Converter ppt

Đ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

 1997 Microchip Technology Inc. DS31022A page 22-1 M Basic 8-bit A/D Converter 22 Section 22. Basic 8-bit A/D Converter HIGHLIGHTS This section of the manual contains the following major topics: 22.1 Introduction 22-2 22.2 Control Registers 22-3 22.3 A/D Acquisition Requirements 22-6 22.4 Selecting the A/D Conversion Clock 22-8 22.5 Configuring Analog Port Pins 22-10 22.6 A/D Conversions 22-11 22.7 A/D Operation During Sleep 22-14 22.8 A/D Accuracy/Error 22-15 22.9 Effects of a RESET 22-16 22.10 Connection Considerations 22-16 22.11 Transfer Function 22-16 22.12 Initialization 22-17 22.13 Design Tips 22-18 22.14 Related Application Notes 22-19 22.15 Revision History 22-20 Note: Please refer to Appendix C.2 or the device Data Sheet to determine which devices use this module. PICmicro MID-RANGE MCU FAMILY DS31022A-page 22-2  1997 Microchip Technology Inc. 22.1 Introduction This Analog-to-Digital (A/D) converter module has four analog inputs. The A/D allows conversion of an analog input signal to a corresponding 8-bit digital number. The output of the sample and hold is the input into the converter, which generates the result via suc- cessive approximation. The analog reference voltage is software selectable to either the device’s positive supply voltage (V DD ) or the voltage level on the AN3/V REF pin. The A/D converter has a unique feature of being able to operate while the device is in SLEEP mode. The A/D module has three registers. These registers are: • A/D Result Register (ADRES) • A/D Control Register0 (ADCON0) • A/D Control Register1 (ADCON1) The ADCON0 register, shown in Figure 22-1 controls the operation of the A/D module. The ADCON1 register, shown in Figure 22-2, configures the functions of the port pins. The port pins can be configured as analog inputs (or a voltage reference) or as digital I/O. Figure 22-1: Basic 8-bit A/D Block Diagram (Input voltage) VAIN VREF (Reference voltage) VDD PCFG1:PCFG0 CHS1:CHS0 00 or 10 or 11 01 AN3/V REF AN0 AN2 AN1 11 10 01 00 Basic 8-bit Converter A/D  1997 Microchip Technology Inc. DS31022A-page 22-3 Section 22. Basic 8-bit A/D Converter Basic 8-bit A/D Converter 22 22.2 Control Registers Register 22-1: ADCON0 Register R/W-0 R/W-0 U-0 R/W-0 R/W-0 R/W-0 R/W-0 R/W-0 ADCS1 ADCS0 — (1) CHS1 CHS0 GO/DONE ADIF / — (2) ADON bit 7 bit 0 bit 7:6 ADCS1:ADCS0: A/D Conversion Clock Select bits 00 = F OSC /2 01 = F OSC /8 10 = F OSC /32 11 = F RC (clock derived from the internal A/D RC oscillator) bit 5 Unimplemented : Read as '0'. bit 4:3 CHS1:CHS0 : Analog Channel Select bits 00 = channel 0, (AN0) 01 = channel 1, (AN1) 10 = channel 2, (AN2) 11 = channel 3, (AN3) bit 2 GO/DONE : A/D Conversion Status bit If ADON = 1 1 = A/D conversion in progress (setting this bit starts the A/D conversion) 0 = A/D conversion not in progress (This bit is automatically cleared by hardware when the A/D conversion is complete) bit 1 ADIF (2) : A/D Conversion Complete Interrupt Flag bit 1 = conversion is complete (must be cleared in software) 0 = conversion is not complete bit 0 ADON: A/D On bit 1 = A/D converter module is operating 0 = A/D converter module is shutoff and consumes no operating current Legend R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’ - n = Value at POR reset Note 1: For the PIC16C71, Bit5 of ADCON0 is a General Purpose R/W bit. For the PIC16C710/711/715, this bit is unimplemented, read as '0'. Note 2: For the PIC12CXXX devices, this bit is reserved. The ADIF bit is implemented in the PIR register. Use of this bit a a general purpose R/W bit is not recommended. Always maintain this bit cleared. PICmicro MID-RANGE MCU FAMILY DS31022A-page 22-4  1997 Microchip Technology Inc. Register 22-2: ADCON1 Register U-0 U-0 U-0 U-0 U-0 U-0 / R/W-0 R/W-0 R/W-0 — — — — — — / PCFG2 (1) PCFG1 PCFG0 bit 7 bit 0 bit 7:2 Unimplemented: Read as '0' Note: Some devices implement bit2 as the PCFG2 bit. bit 1:0 PCFG1:PCFG0 : A/D Port Configuration Control bits bit 2:0 PCFG2:PCFG0 : A/D Port Configuration Control bits (1) Legend R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’ - n = Value at POR reset Note 1: Some devices add an additional Port configuration bit (PCFG2). This allows the min- imum number of analog channels to be one. This is of most benefit to the 8-pin devices with the A/D converter, since in an 8-pin device I/O is a premium resource. In the other devices this bit is unimplemented, and read as ‘0’. Note 2: On any device reset, the Port pins multiplexed with analog functions (ANx) are forced to be an analog input. A = Analog input D = Digital I/O Note: When AN3 is selected as V REF+, the A/D reference is the voltage on the AN3 pin. When AN3 is selected as an analog input (A), then the voltage reference for the A/D is the device V DD. PCFG1:PCFG0 AN3 AN2 AN1 AN0 00 AAAA 01 V REF+A A A 10 DDAA 11 DDDD A = Analog input D = Digital I/O Note: When AN1 is selected as V REF+, the A/D reference is the voltage on the AN1 pin. When AN1 is selected as an analog input (A), then the voltage reference for the A/D is the device V DD. PCFG2:PCFG0 AN3 AN2 AN1 AN0 000 AAAA 001 AAV REF+A 010 DAAA 011 DAV REF+A 100 DDAA 101 DDV REF+A 110 DDDA 111 DDDD  1997 Microchip Technology Inc. DS31022A-page 22-5 Section 22. Basic 8-bit A/D Converter Basic 8-bit A/D Converter 22 The ADRES register contains the result of the A/D conversion. When the A/D conversion is com- plete, the result is loaded into the ADRES register, the GO/DONE bit (ADCON0<2>) is cleared, and A/D interrupt flag bit ADIF is set. The block diagram of the A/D module is shown in Figure 22-1. After the A/D module has been configured as desired, the selected channel must be acquired before the conversion is started. The analog input channels must have their corresponding TRIS bits selected as an input. To determine sample time, see Subsection 22.3 “A/D Acquisition Requirements” After this acquisition time has elapsed the A/D conversion can be started. The following steps should be followed for doing an A/D conversion: 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 (if desired): • Clear the ADIF bit • Set the ADIE bit • Set the GIE bit 3. Wait the required acquisition time. 4. Start conversion: • Set the GO/DONE bit (ADCON0) 5. Wait for A/D conversion to complete, by either: • Polling for the GO/DONE bit to be cleared OR • Waiting for the A/D interrupt 6. Read A/D Result register (ADRES), clear the ADIF bit, if required. 7. For next conversion, go to step 1 or step 2 as required. The A/D conversion time per bit is defined as T AD . A minimum wait of 2T AD is required before next acquisition starts. Figure 22-2 shows the conversion sequence, and the terms that are used. Acquisition time is the time that the A/D module’s holding capacitor is connected to the external voltage level. Then there is the conversion time of 10 T AD , which is started when the GO bit is set. The sum of these two times is the sampling time. There is a minimum acquisition time to ensure that the holding capacitor is charged to a level that will give the desired accuracy for the A/D conversion. Figure 22-2: A/D Conversion Sequence Acquisition Time A/D Conversion Time A/D Sample Time When A/D holding capacitor start to charge. After A/D conversion, or new A/D channel is selected When A/D conversion is started (setting the GO bit) A/D conversion complete, result is loaded in ADRES register. Holding capacitor begins acquiring voltage level on selected channel ADIF bit is set PICmicro MID-RANGE MCU FAMILY DS31022A-page 22-6  1997 Microchip Technology Inc. 22.3 A/D Acquisition Requirements For the A/D converter to meet its specified accuracy, the charge holding capacitor (C HOLD ) must be allowed to fully charge to the input channel voltage level. The analog input model is shown in Figure 22-3. The source impedance (R S ) and the internal sampling switch (R SS ) impedance directly affect the time required to charge the capacitor C HOLD . The sampling switch (R SS ) imped- ance varies over the device voltage (V DD ), see Figure 22-3. The maximum recommended impedance for analog sources is 10 k Ω . After the analog input channel is selected (changed) this acquisition must be done before the conversion can be started. To calculate the minimum acquisition time, Equation 22-1 may be used. This equation assumes that 1/2 LSb error is used (512 steps for the A/D). The 1/2 LSb error is the maximum error allowed for the A/D to meet its specified resolution. Equation 22-1:Acquisition Time Equation 22-2:A/D Minimum Charging Time Example 22-1 shows the calculation of the minimum required acquisition time T ACQ . This calcu- lation is based on the following system assumptions. Rs = 10 k Ω Conversion Error ≤ 1/2 LSb V DD = 5V → Rss = 7 kΩ (see graph in Figure 22-3) Temperature = 50 °C (system max.) V HOLD = 0V @ time = 0 Example 22-1: Calculating the Minimum Required Acquisition Time TACQ = Amplifier Settling Time + Holding Capacitor Charging Time + Temperature Coefficient =TAMP + TC + TCOFF VHOLD = (VREF - (VREF/512)) • (1 - e (-Tc/CHOLD(RIC + RSS + RS)) ) or Tc = -(51.2 pF)(1 kΩ + RSS + RS) ln(1/511) TACQ =TAMP + TC + TCOFF TACQ =5 µs + Tc + [(Temp - 25°C)(0.05 µs/°C)] T C =-CHOLD (RIC + RSS + RS) ln(1/512) -51.2 pF (1 kΩ + 7 kΩ + 10 kΩ) ln(0.0020) -51.2 pF (18 kΩ) ln(0.0020) -0.921 µs (-6.2146) 5.724 µs TACQ =5 µs + 5.724 µs + [(50°C - 25°C)(0.05 µs/°C)] 10.724 µs + 1.25 µs 11.974 µs  1997 Microchip Technology Inc. DS31022A-page 22-7 Section 22. Basic 8-bit A/D Converter Basic 8-bit A/D Converter 22 Figure 22-3: Analog Input Model Note 1: The reference voltage (VREF) has no effect on the equation, since it cancels itself out. Note 2: The charge holding capacitor (C HOLD) is not discharged after each conversion. Note 3: The maximum recommended impedance for analog sources is 10 kΩ. This is required to meet the pin leakage specification. Note 4: After a conversion has completed, a 2.0 T AD delay must complete before acquisition can begin again. During this time the holding capacitor is not connected to the selected A/D input channel. CPIN VA Rs RAx 5 pF V DD VT = 0.6V V T = 0.6V I leakage R IC ≤ 1k Sampling Switch SS R SS CHOLD = 51.2 pF V SS 6V Sampling Switch 5V 4V 3V 2V 5 6 7 8 9 10 11 ( kΩ ) VDD ± 500 nA Legend CPIN VT I LEAKAGE RIC SS CHOLD = input capacitance = threshold voltage = leakage current at the pin due to = interconnect resistance = sampling switch = sample/hold capacitance (from DAC) VARIOUS JUNCTIONS PICmicro MID-RANGE MCU FAMILY DS31022A-page 22-8  1997 Microchip Technology Inc. 22.4 Selecting the A/D Conversion Clock The A/D conversion time per bit is defined as TAD. The A/D conversion requires 9.5 TAD per 8-bit conversion. The source of the A/D conversion clock is software selected. The four possible options for T AD are: •2T OSC •8TOSC • 32TOSC • Internal RC oscillator For correct A/D conversions, the A/D conversion clock (T AD) must be selected to ensure a mini- mum T AD time of: 2.0 µs for the PIC16C71, as shown in parameter 130 of devices electrical specifications. 1.6 µs for all other devices, as shown in parameter 130 of devices electrical specifications. Table 22-1 through Table 22-4 show the resultant T AD times derived from the device operating frequencies and the A/D clock source selected. Table 22-1: T AD vs. Device Operating Frequencies, All Devices (except PIC16C71) (C Devices) Table 22-2: T AD vs. Device Operating Frequencies, All Devices (except PIC16LC71) (LC Devices) AD Clock Source (T AD) Device Frequency Operation ADCS1:ADCS0 20 MHz 5 MHz 1.25 MHz 333.33 kHz 2T OSC 00 100 ns (2) 400 ns (2) 1.6 µs6 µs 8T OSC 01 400 ns (2) 1.6 µs 6.4 µs 24 µs (3) 32TOSC 10 1.6 µs 6.4 µs 25.6 µs (3) 96 µs (3) RC (5) 11 2 - 6 µs (1,4) 2 - 6 µs (1,4) 2 - 6 µs (1,4) 2 - 6 µs (1) Note 1: The RC source has a typical TAD time of 4 µs. 2: These values violate the minimum required T AD time. 3: For faster conversion times, the selection of another clock source is recommended. 4: For device frequencies above 1 MHz, the device must be in SLEEP for the entire conversion, or the A/D accuracy may be out of specification. AD Clock Source (T AD) Device Frequency Operation ADCS1:ADCS0 4 MHz 2 MHz 1.25 MHz 333.33 kHz 2T OSC 00 500 ns (2) 1.0 µs (2) 1.6 µs (2) 6 µs 8T OSC 01 2.0 µs (2) 4.0 µs 6.4 µs 24 µs (3) 32TOSC 10 8.0 µs 16.0 µs 25.6 µs (3) 96 µs (3) RC (5) 11 3 - 9 µs (1,4) 3 - 9 µs (1,4) 3 - 9 µs (1,4) 3 - 9 µs (1) Note 1: The RC source has a typical TAD time of 6 µs. 2: These values violate the minimum required T AD time. 3: For faster conversion times, the selection of another clock source is recommended. 4: For device frequencies above 1 MHz, the device must be in SLEEP for the entire conversion, or the A/D accuracy may be out of specification.  1997 Microchip Technology Inc. DS31022A-page 22-9 Section 22. Basic 8-bit A/D Converter Basic 8-bit A/D Converter 22 Table 22-3: TAD vs. Device Operating Frequencies, PIC16C71 ( C Devices) Table 22-4: T AD vs. Device Operating Frequencies, PIC16LC71 ( LC Devices) AD Clock Source (TAD) Device Frequency Operation ADCS1:ADCS0 20 MHz 16 MHz 4 MHz 1 MHz 333.33 kHz 2T OSC 00 100 ns (2) 125 ns (2) 500 ns (2) 2.0 µs6 µs 8T OSC 01 400 ns (2) 500 ns (2) 2.0 µs 8.0 µs 24 µs (3) 32TOSC 10 1.6 µs (2) 2.0 µs 8.0 µs 32.0 µs (3) 96 µs (3) RC 11 2 - 6 µs (1,4) 2 - 6 µs (1,4) 2 - 6 µs (1,4) 2 - 6 µs (1) 2 - 6 µs (1) Legend: Shaded cells are outside of recommended range. Note 1: The RC source has a typical T AD time of 4 µs. 2: These values violate the minimum required T AD time. 3: For faster conversion times, the selection of another clock source is recommended. 4: For device frequencies above 1 MHz, the device must be in SLEEP for the entire conversion, or the A/D accuracy may be out of specification. AD Clock Source (T AD) Device Frequency Operation ADCS1:ADCS0 4 MHz 2 MHz 1.25 MHz 333.33 kHz 2T OSC 00 500 ns (2) 1.0 µs (2) 1.6 µs (2) 6 µs 8T OSC 01 2.0 µs (2) 4.0 µs 6.4 µs 24 µs (3) 32TOSC 10 8.0 µs 16.0 µs 25.6 µs (3) 96 µs (3) RC 11 3 - 9 µs (1,4) 3 - 9 µs (1,4) 3 - 9 µs (1,4) 3 - 9 µs (1) Legend: Shaded cells are outside of recommended range. Note 1: The RC source has a typical T AD time of 6 µs. 2: These values violate the minimum required T AD time. 3: For faster conversion times, the selection of another clock source is recommended. 4: For device frequencies above 1 MHz, the device must be in SLEEP for the entire conversion, or the A/D accuracy may be out of specification. PICmicro MID-RANGE MCU FAMILY DS31022A-page 22-10  1997 Microchip Technology Inc. 22.5 Configuring Analog Port Pins The ADCON1 and TRISA registers control the operation of the A/D port pins. The port pins that are desired as analog inputs must have their corresponding TRIS bits set (input). If the TRIS bit is cleared (output), the digital output level (V OH or VOL) will be converted. The A/D operation is independent of the state of the CHS1:CHS0 bits and the TRIS bits. Note 1: When reading the port register, all pins configured as analog input channel will read as cleared (a low level). Pins configured as digital inputs, will convert an analog input. Analog levels on a digitally configured input will not affect the conversion accuracy. Note 2: Analog levels on any pin that is defined as a digital input (including the AN3:AN0 pins), may cause the input buffer to consume current that is out of the devices spec- ification. [...]... notes related to the Basic 8-bit A/D module are: Title Application Note # Using the Analog to Digital Converter AN546 Four Channel Digital Voltmeter with Display and Keyboard AN557 22 Basic 8-bit A/D Converter © 1997 Microchip Technology Inc DS31022A-page 22-19 PICmicro MID-RANGE MCU FAMILY 22.1 5 Revision History Revision A This is the initial released revision of the Basic 8-bit A/D Converter module description... Turning off the A/D places the A/D module in its lowest current consumption state Note: DS31022A-page 22-14 For the A/D module to operate in SLEEP, the A/D clock source must be set to RC (ADCS1:ADCS0 = 11) To perform an A/D conversion in SLEEP, the GO/DONE bit must be set, followed by the SLEEP instruction © 1997 Microchip Technology Inc Section 22 Basic 8-bit A/D Converter 22.8 A/D Accuracy/Error In systems.. .Section 22 Basic 8-bit A/D Converter 22.6 A/D Conversions Example 22-2 show how to perform an A/D conversion The RA pins are configured as analog inputs The analog reference (VREF) is the device VDD The A/D interrupt is enabled, and the A/D conversion clock is FRC The conversion is performed on the RA0 channel Note: The GO/DONE bit should NOT be set in the same instruction that turns on the A/D, ... good reference on A/D s? Answer 3: A very good reference for understanding A/D conversions is the “Analog-Digital Conversion Handbook” third edition, published by Prentice Hall (ISBN 0-13-03-2848-0) DS31022A-page 22-18 © 1997 Microchip Technology Inc Section 22 Basic 8-bit A/D Converter 22.1 4 Related Application Notes This section lists application notes that are related to this section of the manual... Microchip Technology Inc Section 22 Basic 8-bit A/D Converter 22.1 2 Initialization Example 22-4 shows the initialization of the A/D module in the PIC16C711 Example 22-4: BSF CLRF BCF MOVLW MOVWF BSF BSF STATUS, ADCON1 STATUS, 0xC1 ADCON0 INTCON, INTCON, RP0 RP0 ADIE GIE ; ; ; ; ; ; ; Select Bank1 Configure A/D inputs Select Bank0 RC Clock, A/D is on, Channel 0 selected Enable A/D Interrupt Enable all... Sleep? SLEEP Power-down A/D Wait 2TAD Stay in Sleep Power-down A/D Wait 2TAD DS31022A-page 22-12 © 1997 Microchip Technology Inc Section 22 Basic 8-bit A/D Converter 22.6 .1 Faster Conversion - Lower Resolution Trade-off Not all applications require a result with 8-bits of resolution, but may instead require a faster conversion time The A/D module allows users to make the trade-off of conversion speed... Technology Inc ADCON0, GO ; Start A/D Conversion ; The ADIF bit will be set and the GO/DONE bit ; is cleared upon completion of the ; A/D Conversion DS31022A-page 22-17 22 Basic 8-bit A/D Converter ; ; ; ; A/D Initialization (for PIC16C711) PICmicro MID-RANGE MCU FAMILY 22.1 3 Design Tips Question 1: I am using one of your PIC16C7X devices, and I find that the Analog to Digital Converter result is not always... DS31022A-page 22-13 Basic 8-bit A/D Converter Since the TAD is based from the device oscillator, the user must use some method (a timer, software loop, etc.) to determine when the A/D oscillator may be changed Example 22-3 shows a comparison of time required for a conversion with 4-bits of resolution, versus the 8-bit resolution conversion The example is for devices operating at 20 MHz and 16 MHz (The A/D clock... the A/D interrupt is enabled, the device will wake-up from SLEEP If the A/D interrupt is not enabled, the A/D module will then be turned off, although the ADON bit will remain set When the A/D clock source is another clock option (not RC), a SLEEP instruction will cause the present conversion to be aborted and the A/D module to be turned off, though the ADON bit will remain set Turning off the A/D. .. upon completion of the ; A/D Conversion A/D Conversion TAD Cycles TAD2 b7 TAD3 TAD4 TAD5 TAD6 TAD7 TAD8 b6 b5 b4 b3 b2 b1 Holding capacitor is disconnected from analog input TAD9 TAD10 TAD11 b0 b0 Next Q4: ADRES is loaded GO bit is cleared ADIF bit is set Set GO bit Holding capacitor is connected to analog input © 1997 Microchip Technology Inc DS31022A-page 22-11 Basic 8-bit A/D Converter Example 22-2: . Microchip Technology Inc. DS31022A-page 22- 11 Section 22. Basic 8-bit A/D Converter Basic 8-bit A/D Converter 22 22.6 A/D Conversions Example 22- 2 show how to perform an A/D conversion. The RA pins. DS31022A-page 22- 17 Section 22. Basic 8-bit A/D Converter Basic 8-bit A/D Converter 22 22.12 Initialization Example 22- 4 shows the initialization of the A/D module in the PIC16C711. Example 22- 4:. Technology Inc. DS31022A-page 22- 15 Section 22. Basic 8-bit A/D Converter Basic 8-bit A/D Converter 22 22.8 A/D Accuracy/Error In systems where the device frequency is low, use of the A/D RC clock is

Ngày đăng: 29/07/2014, 10:20

Mục lục

    22.3 A/D Acquisition Requirements

    22.4 Selecting the A/D Conversion Clock

    22.5 Configuring Analog Port Pins

    22.7 A/D Operation During Sleep

    22.8 A/D Accuracy/Error

    22.9 Effects of a RESET

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan