conversor analógico

Download Conversor analógico

Post on 22-Mar-2017

151 views

Category:

Technology

0 download

Embed Size (px)

TRANSCRIPT

CONVERSOR ANALGICO DIGITAL DEL PIC16F877

CONVERSOR ANALGICO DIGITAL DEL PIC16F877Rodrguez Ballesteros Nelson RobertoARREOLA ROJAS JESUS SALVADOR

Tanto nuestra voz como muchas de las seales que se envan a travs de un medio guiado como un cable o no guiado como es el aire son de tipo continuo y pueden tomar infinitos valores a lo largo del tiempo.

El muestreo implica que tenemos que coger una muestra de la seal cada T segundos ya que no hay memoria suficiente capaz de almacenar los infinitos puntos de una seal en un intervalo cualquiera de tiempo

Estos valores van a depender del nmero de bits que vayamos a almacenar para cada muestra, por ejemplo, en la imagen se cogen 4 bits y con ellos se pueden formar 16 combinaciones y por lo tanto 16 distintos niveles en los que se puede dividir el eje. El PIC cuantifica con 10 bits luego son 1023 niveles

ERROR DE CUANTIFICACIN

El parmetro fundamental del muestreo digital es el intervalo de muestreo seg., o su equivalente frecuencia de muestreo 1/ Hz.cuanto menor sea , mayor nmero de valores obtendremos de la seal, y viceversala obtencin de una serie discreta ordenada {xr} = {x0, x1, x3,..., xr,...}, en la que el ndice r indica la posicin de orden temporal del valor xr. As, el valor de la seal original, en el tiempo t = r, x (t), se representa por xr.

temp;This code if for the TC74A5-5.0VAT temperature sensor;1st. Check if temperature is ready to be read in config reg.;2nd. If ready, retireve temperatute in hex.; If not ready, check config register again.

bankselTRISC;initialize MSSP modulebsfTRISC,3bsfTRISC,4movlwB'00101000'bankselSSPCONmovwfSSPCONbankselSSPSTATbsfSSPSTAT,SMPmovlw.5movwfSSPADD

bankselPIR1bcfPIR1,TMR1IF

clrfTMR1H;load regs for 2 sec overflowclrfTMR1Lget_tempbankselcmd_bytemovlw0x01;config register command bytemovwfcmd_bytetemp_nowbankselSSPCON2;write to TC74bsfSSPCON2,SENbtfscSSPCON2,SENgoto$-1movlwB'10011010';send TC74 ADDRESS (write)bankselSSPBUFmovwfSSPBUFcallssprwbankselSSPCON2btfscSSPCON2,ACKSTAT;ack?goto$-1

bankselcmd_bytemovfcmd_byte,w;send COMMAND byte (config)bankselSSPBUFmovwfSSPBUFcallssprwbankselSSPCON2btfscSSPCON2,ACKSTAT;ack?goto$-1

bsfSSPCON2,RSEN;send repeated startbtfscSSPCON2,RSENgoto$-1movlwB'10011011';send TC74 ADDRESS (read)bankselSSPBUFmovwfSSPBUFcallssprw;module idle?bankselSSPCON2btfscSSPCON2,ACKSTAT;ack?goto$-1

bsfSSPCON2,RCEN;enable receive modebtfscSSPCON2,RCENgoto$-1

bankselSSPBUF;retrieve config reg or temp regmovfSSPBUF,wbankselSSPCON2;send NOT-ACKbsfSSPCON2,ACKDTbsfSSPCON2,ACKENbtfscSSPCON2,ACKENgoto$-1bsfSSPCON2,PEN;stopbtfscSSPCON2,PENgoto$-1bankselcmd_byte;config command OR temp commandbtfsscmd_byte,0gotoconvert_temp;get temperature ready for display

andlw0x40sublw0x40btfssSTATUS,Z;is temp ready ??gotoget_temp;NO, try againmovlw0x00;YES, send temp commandbankselcmd_byte;send temp register commandmovwfcmd_bytegototemp_now

convert_tempmovwftemperaturecallbin_bcd;NO, get temp ready for LCDcallLCDLine_1movlwA'T';send "Temp=" to LCDmovwftemp_wrcalld_writemovlwA'e'movwftemp_wrcalld_writemovlwA'm'movwftemp_wrcalld_writemovlwA'p'movwftemp_wrcalld_writemovlw0x20;spacemovwftemp_wrcalld_writemovlwA'='movwftemp_wrcalld_write

movlw0x20;spacemovwftemp_wrcalld_write

movfMSD,w;send high digitmovwftemp_wrcalld_writemovfMsD,w;send middle digitmovwftemp_wrcalld_writemovfLSD,w;send low digitmovwftemp_wrcalld_writemovlwA'C';send "C" for Celsiusmovwftemp_wrcalld_write

movlw0x20;spacemovwftemp_wrcalld_writemovlw0x20;spacemovwftemp_wrcalld_writemovlw0x20;spacemovwftemp_wrcalld_writecallLCDLine_2;send "RB0 = Exit" to LCDbankselptr_posmovlw.144movwfptr_poscallstan_char_2btfssselect;wait for RB0 releasegoto$-1calldelay_100msbtfssselect;exit ?gotomenu_clock;YES, goto main menubtfscPIR1, TMR1IF;2 second overflow occur ??callwrite_eeprom;YESgotoget_temp;NO, get temperature again

callssprwbankselSSPCON2btfscSSPCON2,ACKSTAT;ack?goto$-1

bsfSSPCON2,RSEN;send repeated startbtfscSSPCON2,RSENgoto$-1movlwB'10011011';send TC74 ADDRESS (read)bankselSSPBUFmovwfSSPBUFcallssprw;module idle?bankselSSPCON2btfscSSPCON2,ACKSTAT;ack?goto$-1

bsfSSPCON2,RCEN;enable receive modebtfscSSPCON2,RCENgoto$-1

bankselSSPBUF;retrieve config reg or temp regmovfSSPBUF,wbankselSSPCON2;send NOT-ACKbsfSSPCON2,ACKDTbsfSSPCON2,ACKENbtfscSSPCON2,ACKENgoto$-1bsfSSPCON2,PEN;stopbtfscSSPCON2,PENgoto$-1bankselcmd_byte;config command OR temp commandbtfsscmd_byte,0gotoconvert_temp;get temperature ready for display

andlw0x40sublw0x40btfssSTATUS,Z;is temp ready ??gotoget_temp;NO, try againmovlw0x00;YES, send temp commandbankselcmd_byte;send temp register commandmovwfcmd_bytegototemp_now

convert_tempmovwftemperaturecallbin_bcd;NO, get temp ready for LCDcallLCDLine_1movlwA'T';send "Temp=" to LCDmovwftemp_wrcalld_writemovlwA'e'movwftemp_wrcalld_writemovlwA'm'movwftemp_wrcalld_writemovlwA'p'movwftemp_wrcalld_writemovlw0x20;spacemovwftemp_wrcalld_writemovlwA'='movwftemp_wrcalld_write

movlw0x20;spacemovwftemp_wrcalld_write

movfMSD,w;send high digitmovwftemp_wrcalld_writemovfMsD,w;send middle digitmovwftemp_wrcalld_writemovfLSD,w;send low digitmovwftemp_wrcalld_writemovlwA'C';send "C" for Celsiusmovwftemp_wrcalld_write

movlw0x20;spacemovwftemp_wrcalld_writemovlw0x20;spacemovwftemp_wrcalld_writemovlw0x20;spacemovwftemp_wrcalld_writecallLCDLine_2;send "RB0 = Exit" to LCDbankselptr_posmovlw.144movwfptr_poscallstan_char_2btfssselect;wait for RB0 releasegoto$-1calldelay_100msbtfssselect;exit ?gotomenu_clock;YES, goto main menubtfscPIR1, TMR1IF;2 second overflow occur ??callwrite_eeprom;YESgotoget_temp;NO, get temperature again

bsfSSPCON2,ACKDTbsfSSPCON2,ACKENbtfscSSPCON2,ACKENgoto$-1bsfSSPCON2,PEN;stopbtfscSSPCON2,PENgoto$-1bankselcmd_byte;config command OR temp commandbtfsscmd_byte,0gotoconvert_temp;get temperature ready for display

andlw0x40sublw0x40btfssSTATUS,Z;is temp ready ??gotoget_temp;NO, try againmovlw0x00;YES, send temp commandbankselcmd_byte;send temp register commandmovwfcmd_bytegototemp_now

convert_tempmovwftemperaturecallbin_bcd;NO, get temp ready for LCDcallLCDLine_1movlwA'T';send "Temp=" to LCDmovwftemp_wrcalld_writemovlwA'e'movwftemp_wrcalld_writemovlwA'm'movwftemp_wrcalld_writemovlwA'p'movwftemp_wrcalld_writemovlw0x20;spacemovwftemp_wrcalld_writemovlwA'='movwftemp_wrcalld_write

movlw0x20;spacemovwftemp_wrcalld_write

movfMSD,w;send high digitmovwftemp_wrcalld_writemovfMsD,w;send middle digitmovwftemp_wrcalld_writemovfLSD,w;send low digitmovwftemp_wrcalld_writemovlwA'C';send "C" for Celsiusmovwftemp_wrcalld_write

movlw0x20;spacemovwftemp_wrcalld_writemovlw0x20;spacemovwftemp_wrcalld_writemovlw0x20;spacemovwftemp_wrcalld_writecallLCDLine_2;send "RB0 = Exit" to LCDbankselptr_posmovlw.144movwfptr_poscallstan_char_2btfssselect;wait for RB0 releasegoto$-1calldelay_100msbtfssselect;exit ?gotomenu_clock;YES, goto main menubtfscPIR1, TMR1IF;2 second overflow occur ??callwrite_eeprom;YESgotoget_temp;NO, get temperature again

callbin_bcd;NO, get temp ready for LCDcallLCDLine_1movlwA'T';send "Temp=" to LCDmovwftemp_wrcalld_writemovlwA'e'movwftemp_wrcalld_writemovlwA'm'movwftemp_wrcalld_writemovlwA'p'movwftemp_wrcalld_writemovlw0x20;spacemovwftemp_wrcalld_writemovlwA'='movwftemp_wrcalld_write

movlw0x20;spacemovwftemp_wrcalld_write

movfMSD,w;send high digitmovwftemp_wrcalld_writemovfMsD,w;send middle digitmovwftemp_wrcalld_writemovfLSD,w;send low digitmovwftemp_wrcalld_writemovlwA'C';send "C" for Celsiusmovwftemp_wrcalld_write

movlw0x20;spacemovwftemp_wrcalld_writemovlw0x20;spacemovwftemp_wrcalld_writemovlw0x20;spacemovwftemp_wrcalld_writecallLCDLine_2;send "RB0 = Exit" to LCDbankselptr_posmovlw.144movwfptr_poscallstan_char_2btfssselect;wait for RB0 releasegoto$-1calldelay_100msbtfssselect;exit ?gotomenu_clock;YES, goto main menubtfscPIR1, TMR1IF;2 second overflow occur ??callwrite_eeprom;YESgotoget_temp;NO, get temperature again

Instruccin cambio de seal

calld_write

movfMSD,w;send high digitmovwftemp_wrcalld_writemovfMsD,w;send middle digitmovwftemp_wrcalld_writemovfLSD,w;send low digitmovwftemp_wrcalld_writemovlwA'C';send "C" for Celsiusmovwftemp_wrcalld_write

movlw0x20;spacemovwftemp_wrcalld_writemovlw0x20;spacemovwftemp_wrcalld_writemovlw0x20;spacemovwftemp_wrcalld_writecallLCDLine_2;send "RB0 = Exit" to LCDbankselptr_posmovlw.144movwfptr_poscallstan_char_2btfssselect;wait for RB0 releasegoto$-1calldelay_100msbtfssselect;exit ?gotomenu_clock;YES, goto main menubtfscPIR1, TMR1IF;2 second overflow occur ??callwrite_eeprom;YESgotoget_temp;NO, get temperature again

callLCDLine_2;send "RB0 = Exit" to LCDbankselptr_posmovlw.144movwfptr_poscallstan_char_2btfssselect;wait for RB0 releasegoto$-1calldelay_100msbtfssselect;exit ?gotomenu_clock;YES, goto main menubtfscPIR1, TMR1IF;2 second overflow occur ??callwrite_eeprom;YESgotoget_temp;NO, get temperature again

Medidor de temperatura

Recommended

View more >