Professional Documents
Culture Documents
Seal Digital
Seal Analgica
Tiempo de Adquisicin
Tiempo de Conversin
FCY = FOSC/2
VR Select
VR+ VR-
Conversion Control
CH0 S/H
A/D converter
Data Format
Bus Interface
AN15
AVDD VR Select AVSS VR+ VCFG2:VCFG0 000 001 010 011 1xx
AD1CON2 Register
bit15
bit8
VREF+
VREF-
VR-
--SMPI1
---
CSNA SMPI 0
--BUFM
--bit0
BUFS
---
SMPI3
SMPI2
ALTS
Mux A
VINH
VINL
(0) VRAD1CHS<CH0NA>
bit15 bit8
VCFG2 --SMPI3
---
---
---
--bit0
BUFS
bit15
ALTS
bit0
CSSL15
bit15
CSSL0
bit8
CH0NB
bit7
CH0SB0
bit0
CH0NA
bit15
CH0SA0
bit0
CSSL8=0 PCFG0
+ CH 0 -
+A -A AN1 VREF-
bit15
bit0
AD1CSSL Register
CSSL15
CSSL2 -----
CSSL0
bit8
AD1CON2 Register
bit7
VCFG2 --SMPI3
---
--bit0
BUFS
SMPI 0
ALTS
AD1CON1<ASAM>
1 Seal de Conversion completa 0 AD1CON1<SAMP>
bit15
bit8
AD1CON2 Register
bit7
VCFG2 ---
VCFG1 SMPI3
CSSL13=0 VCFG0
SMPI2
---
---
CSNA SMPI 0
--BUFM
--bit0
BUFS
SMPI1
ALTS
AD1CON1 <SSRC2:SSRC0>
VINH
VR- VR+
S/ H
VRVR+
VINL
AD1CON1<ASAM>
A/D converter
RESULT
AD1CON1<SAMP>
ADC1BUF0 : ADC1BUF15
0 AD1CON2<BUFS> 1
Activacin por Software Control de Motor PWM Timer 3 Interrupcin Externa Conversin automtica basada en time out interno
VR Select
VR+
VR-
Conversion Control
A/D converter
S/H
Results Buffer
Data Format
Bus Interface
S/H
CH2 *
S/H AN31
CH3 *
Programar el dsPIC con MPLAB en C30. Realizar la conversin digital de una seal analgica en Proteus con DSPIC usando Potencimetro.
Digitalizacin de una seal analgica y su visualizacin usando Leds.
Resultado esperado:
Vss
RA7-RA0
LEDs D10-D3
Pasos a Realizar
Open the project C:\RTC\203_PRC\Lab5\Lab5.mcp Open the file C:\RTC\203_PRC\Lab5\Lab5.c Look for ADCInit() function and configure ADC by initializing the registers AD1CON1, AD1CON2, and AD1CON3 looking into the Register details on the next few pages. STEP 1: AD1CON1
Select Integer Format Result Auto Conversion Start Sample after conversion Select AVDD and AVSS as references Disable Scan mode Interrupt at 16th sample/Convert sequence 16*1 level buffer Always use Mux A Select Sample Time = 13TAD Conversion Time is always 12TAD Select AD Clock Source such that you get 16 samples in around 1 mSec (16 ksps) Assume 1TCY =.25 uS (FCY = 4 MHz)
STEP 2: AD1CON2
STEP 3: AD1CON3
Pasos a Realizar
Continue to configure ADC by initializing the registers AD1CHS,
AD1PCFG, and AD1CSSL looking into the Register details on the next few pages. STEP 4: AD1CHS
Set the positive sample input channel for MUX A to use AN5 Set the negative input channel for MUX A to use VR-
STEP 5: AD1PCFG
Set AD1PCFG so that the only pin using analog functionality is AN5
STEP 6: AD1CSSL
Channel scanning is not enabled, so no input channels should be selected for scanning Build the project and program the device Procedure to Test
Result Format 00: Intiger (0000 00dd dddd dddd) 01: Signed Intiger (ssss sssd dddd dddd) 10: Fractional (dddd dddd dd00 0000) 11: Signed Fractional (sddd dddd dd00 0000)
Bit:0
Bit:7
SSRC2
SSRC1
SSRC0
--
--
ASAM
SAMP
DONE
Conversion Trigger Source Selection Bits 000: Manual Conversion Trigger 001: Active transition on INT0 pin triggers conversion 010: Timer3 compare triggers conversion 111: Auto conversion
Auto Sample Selection bit 1: Sample immediately after completion of last conversion. 0: Sample on setting of SAMP
VCFG2:VCFG0
AVDD
VR Select
VR+
VR-
011
1xx
VREF+
AVDD
VREFAVSS
Bit:0 ALTS
SMPI3:SMPI0
Interrupt Event (Sample/convert sequence) each alternate . Every 15th Every 16th
Buffer Status bit, is valid only when BUFM = 1 1: Buffer 8-F is being filled, can access Buffer 0-7 0: Buffer 0-7 is being filled, can access Buffer 8-F
Bit:0 ADCS0
00000000 00000001
TCY ( FCY ) 2*TCY ( FCY / 2 ) . 255*TCY ( FCY / 255 ) 256*TCY ( FCY / 256 )
ADCS = (TAD/TCY) - 1
.... 11111110 11111111
CH0SB3:CH0SB0
AN0 AN1 .
1110
1111
AN14
AN15
Bit:0 CH0SA0
CH0SA3:CH0SA0
0000
0001 +B ....
AN0
AN1 . AN14 AN15
CH0NB
-B
+
-
1110 1111
CH 0
CH0SA3:CH0SA0
CH0NA
Bit:7
PCFG7 PCFG6 PCFG5 PCFG4 PCFG3 PCFG2 PCFG1
Bit:0
PCFG0
Analog Input Pin Configuration Control bits 0 to 15 1: Pin for corresponding analog channel (ANxx) is in digital mode 0: Pin for corresponding analog channel (ANxx) is in analog mode
Bit:8
CSSL8
Bit:7
CSSL7 CSSL6 CSSL5 CSSL4 CSSL3 CSSL2 CSSL1
Bit:0
CSSL0
Resultado Esperado
El valor del POT es promediado cada 16
muestras en 1 ms. El valor del POT es mostrado en los LEDs como un valor binario desde 0 hasta 255 El Pin RB2 cambia de valor cada 16 muestras (con una frecuencia de 500 Hz)