UNIVERSIDAD NACIONAL DEL CALLAO FACULTAD DE INGENIERÍA ELÉCTRICA Y ELECTRÓNICA ESCUELA PROFESIONAL DE INGENIERÍA ELECTRÓNICA
CONTROL DE TEMPERATURA CON PIC 16F877A
CURSO
:
PROFESOR
:
ELECTRÓNICA DE POTENCIA 1
Ing. RUSEL CORDOVA
ALUMNOS:
1 9 6 6
BELLAVISTA – CALLAO
2009
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
CONTROL DE TEMPERATURA TEMPERATURA CON PIC 16F877A
o
DIAGRAMA DE BLOQUES:
TECLADO (set point)
SENSOR 0 (T ext)
ADC
uC
ETAPA DE POTENCIA
VISUALIZACION
o
SENSOR LM35
Descripción: El LM35 es un sensor de temperatura con una precisión calibrada de 1ºC y un rango que abarca desde -55º a +150ºC. El sensor se presenta en diferentes encapsulados pero el mas común es el to-92 de igual forma que un típico transistor con 3 patas, dos de ellas para alimentarlo y la tercera nos entrega un valor de tensión proporcional a la temperatura medida por el dispositivo. Con el LM35 sobre la mesa las patillas hacia nosotros y las letras del encapsulado hacia arriba tenemos que de izquierda a derecha los pines son: VCC Vout - GND. La salida es lineal y equivale a 10mV/ºC por lo tanto: +1500mV = 150ºC +250mV = 25ºC -550mV = -55ºC • • •
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
CONVERSIÓN A/D Y PROCESADO DE SEÑAL
o
Resolución RES
=
Vref Volts
Vref 2
8
=
1
−
255
bits
Voltaje de entrada
Temperatura en bits
CONVERSOR A/D
0.01T
0.01T
T LUEGO: RESOLUCION =
→
0.0 1T
Vref
=
T
→
Vref =
2.55 Volts
25 5
Conversión AD:
El uC 16F877A tiene el siguiente módulo conversor:
El voltaje de referencia referencia de 2.55 V se introducirá introducirá por RA3 y el canal elegido para la
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Para Para acti activa varr la conv conver ersi sión ón se pone pone el bit bit ADON ADON en “1” “1” y para para come comenz nzar ar la conversión se activa el bit GO, ambos bits estan en el registro ADCON0. En el bloque S/H se hace el muestreo de la señal para ser digitalizada en la siguiente etapa. Una vez que se tiene el valor de la temperatura en ADRESH se compara con el valor introducido por el teclado. Si el valor sensado es menor que el rango establecido anteriormente, entonces D1=ON y D2=OFF. Si el valor censado esta dentro del rango establecido anteriormente, entonces D1=OFF y D2=OFF. Si el valor censado es mayor que el rango establecido anteriormente, entonces D1=OFF y D2=ON. Para la visualización de la temperatura en LCD se transforma el valor que esta en ADRESH a código ascii a través de una rutina de conversión. Luego este valor es enviado al LCD por medio del comando EnviaCarLCD que forma parte de una rutina de manejo de LCD la cual será adjuntada en la última parte del trabajo. Para capturar la tecla pulsada se usa una rutina la cual explora el teclado y devuelve el valor de esta en un registro.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
o
DIAGRAMA DE FLUJOS CONFIGURACION DE REGISTROS
PULSO HELP? NO SI
INGRESAR T1 < 150
INGRESAR T2 < 150
ACTIVAR CONVERSOR
TERMINO CONVERSION? NO
SI
ENVIAR A LCD
NO Text < T1? NO T1 < Text < T2?
SI
Text > T2 D1 = OFF D2 = ON
D1 = OFF D2 = OFF
SI
D1 = ON D2 = OFF
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
o
LIST
LENGUAJE EN ASSEMBLER
P=16F877A INCLUDE
INCLUDE __CONFIG _XT_OSC &_LVP_OFF &_WDT_OFF CBLOC CBLOCK K 0x20 0x20 ENDC T_1 EQU 0x22 T_2 EQU 0x23 INDICADOR EQU 0x24 AUX EQU 0x25 AUX2 EQU 0x26 REG1 EQU 0x27 REG2 EQU 0x28 REG3 EQU 0x29 TEMPER EQU 0x2A ASCII_H EQU 0x2B ASCII_M EQU 0x2C ASCII_L EQU 0x2D HEXADECIMAL EQU 0x2E Key_var equ 0x2F ORG 00H goto EMPEZAR org 0x05 inclu include de NC> EMPEZAR BSF STATUS,RP0 ;banco 1 BSF TRISA,0 ;entrada de sensor BSF TRISA,3 ;voltaje Ref=5.1 CLRF TRISB MOVLW MOVLW B'1111 B'1111110 1100' 0' MOVWF TRISC ;salidas para LEDs CLRF TRISD BSF ADCON1,0 ;para permitir ingreso de Vref=5.1V bcf OPTION_REG,7 ;resistencias Pull Up activada BCF STATUS,RP0 ;banco_0 ;;;configuracion ;;;configuracion de conversor AD MOVLW B'11000001' ;RA0=entrada de sensor MOVW MOVWFF ADCO ADCON0 N0 CLRF PORTC ;iniciar el trabajo CALL inicio_LCD ;inicio de LCD MOVLW OVLW 'P' 'P' call EnviaCarLCD MOVLW OVLW 'U' 'U' call EnviaCarLCD MOVLW OVLW 'L' 'L' call EnviaCarLCD MOVLW OVLW 'S' 'S' call EnviaCarLCD MOVLW OVLW 'E' 'E' call EnviaCarLCD MOVLW OVLW ' ' call EnviaCarLCD MOVLW OVLW 'M' 'M' call EnviaCarLCD MOVLW OVLW 'E' 'E' call EnviaCarLCD MOVLW OVLW 'N' 'N' call EnviaCarLCD MOVLW OVLW 'U' 'U' call EnviaCarLCD
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
subwf Tecla,W btfsc STATUS,Z goto menu movlw 0x0F subwf Tecla,0 btfss STATUS,Z goto menu ;pedir_temperatura_1 CALL inicio_LCD MOVLW OVLW 'T' 'T' call EnviaCarLCD MOVLW OVLW 'E' 'E' call EnviaCarLCD MOVLW OVLW 'M' 'M' call EnviaCarLCD MOVLW OVLW 'P' 'P' call EnviaCarLCD MOVLW OVLW '1' '1' call EnviaCarLCD MOVLW OVLW '=' '=' call EnviaCarLCD call cap_tecla movf TEMPER,0 movwf T_1 MOVLW MOVLW DISP_ON_ DISP_ON_NOCU NOCURSOR RSOR call EnviaCmdLCD btfss INDICADOR,0 GOTO $+2 GOTO MAL pedir_temperatura_2 CALL inicio_LCD MOVLW OVLW 'T' 'T' call EnviaCarLCD MOVLW OVLW 'E' 'E' call EnviaCarLCD MOVLW OVLW 'M' 'M' call EnviaCarLCD MOVLW OVLW 'P' 'P' call EnviaCarLCD MOVLW OVLW '2' '2' call EnviaCarLCD MOVLW OVLW '=' '=' call EnviaCarLCD call cap_tecla movf TEMPER,0 movwf T_2 btfss INDICADOR,0 GOTO $+2 GOTO MAL movf T_2,0 subwf T_1,0 btfsc STATUS,C
;Hay alguna pulsada ?? ;no ;si-->verificar si es Menu ;NO ES MENU ;inicio de LCD
;inicio de LCD
;w=T_1 - W(T_2);T_2>T_1
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
;;;; INICIO
MOVLW OVLW call MOVLW OVLW call MOVLW OVLW call MOVLW OVLW call MOVLW OVLW call MOVLW OVLW call MOVLW OVLW call MOVLW OVLW call MOVLW OVLW call MOVLW OVLW call MOVLW MOVLW call goto
'P' 'P' EnviaCarLCD 'U' 'U' EnviaCarLCD 'L' 'L' EnviaCarLCD 'S' 'S' EnviaCarLCD 'E' 'E' EnviaCarLCD '' EnviaCarLCD 'M' 'M' EnviaCarLCD 'E' 'E' EnviaCarLCD 'N' 'N' EnviaCarLCD 'U' 'U' EnviaCarLCD DISP_ON_ DISP_ON_NOCU NOCURSOR RSOR EnviaCmdLCD menu
BSF ADCON0,GO BTFS TFSC ADCON DCON0 0,GO ,GO GOTO $-1 ;;;;MOSTRAR EN LCD;;;;;;;;;;;;;;;; MOVF ADRESH,0 CALL inicio_LCD MOVF ADRESH,0 CALL Hex_Ascii MOVLW OVLW 'T' 'T' call EnviaCarLCD MOVLW OVLW 'E' 'E' call EnviaCarLCD MOVLW OVLW 'M' 'M' call EnviaCarLCD MOVLW OVLW 'P' 'P' call EnviaCarLCD MOVLW OVLW '=' '=' call EnviaCarLCD MOVLW OVLW ' ' call EnviaCarLCD movf ASCII_H,0 call EnviaCarLCD movf ASCII_M,0 call EnviaCarLCD movf ASCII_L,0 call EnviaCarLCD MOVLW 0xDF
;INICIAR CONVERSION
;W=Temperatura ;inicio de LCD ;para convertir de HEXADECIMAL a ASCII
;envia las centenas de temperatura ;envia las decenas de temperatura ;envia las unidades de temperatura ;envia el simbolo de grados celsius
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
LAZO
MOVLW OVLW .10 .10 MOVWF OVWF 20H 20H
DECFSZ DECFSZ 20H,1 20H,1 GOTO LAZO RETURN ;********************* COMPARAR MOVF ADRESH,0 ;W=TEMPERATURA AC A CTUAL SUBWF T_1,0 ;W=T_1-TEMPERATURA BTFSC STATUS,C ;C=0? (T (TEMP>T_1) GOTO LED_1 ;NO GOTO SIGUIENTE ;SI LED_1 MOVLW MOVLW B'0000 B'0000000 0001' 1' MOVW MOVWFF PORT PORTC C RETURN SIGUIENTE MOVF ADRESH,0 ;W=TEMPERATURA AC A CTUAL SUBWF T_2,0 ;W=T_2-TEMPERATURA BTFSC STATUS,C ;C=0? (T (TEMP>T_2) GOTO LED_2 ;NO GOTO LED_3 ;SI LED_2 MOVLW MOVLW B'0000 B'0000000 0000' 0' MOVW MOVWFF PORT PORTC C RETURN LED_3 MOVLW MOVLW B'0000 B'0000001 0010' 0' MOVW MOVWFF PORT PORTC C RETURN ;************************** ;*************************************** ********************* ******** ;RUTINA PARA CONVERTIR DE HEXADECIMAL A ASCII Hex_Ascii ;cargar en W el dato hex. ; movwf ovwf HEXA HEXADE DECI CIMA MALL clrf ASCII_H ;Para BCD D'0' clrf ASCII_M ;Para BCD D'0' clrf ASCII_L ;Para BCD D'0' Centenas movlw D'100' ;D'100' --> W subwf HEXADECIMAL,W HEXADECIMAL,W ;HEXADECIMAL ;HEXADECIMAL - D'100' --> W btfss btfss STATU STATUS,C S,C ;¿ HEXAD HEXADECI ECIMA MALL es menor menor que D'100' D'100' ? goto Decenas ;Si movwf HEXADECIMAL HEXADECIMAL ;Salva el resto incf ASCII_H,F ;Incrementa el contador de centenas BCD goto Centenas ;Vuelve por otros D'100' Decenas movlw D'10' ;D'10' --> W subwf HEXADECIMAL,W HEXADECIMAL,W ;HEXADECIMAL ;HEXADECIMAL - D'10' --> W btfs btfsss STAT STATUS US,C ,C ;¿ HEXA HEXADE DECI CIMA MALL es meno menorr que que D'10 D'10'' ? goto Unidades ;Si
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
Espacio ;
movlw '0' ;A' ' --> W movwf ASCII_H ;A' ' --> ASCII_H return ;Retorna ;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;; cap_tecla call Key_Scan ;Explora el teclado movlw 0x80 subwf Tecla,W btfsc STATUS,Z ;Hay alguna pulsada ?? goto cap_tecla ;No movf Tecla,W ;Lee el código de la tecla pulsada movwf REG1 ;Tecla-->REG1 call Hex_Ascii movf ASCII_L,0 call EnviaCarLCD pulso1 call Key_Scan ;Explora el teclado movlw 0x80 subwf Tecla,W btfsc STATUS,Z ;Hay alguna pulsada ?? goto pulso1 ;no on1 movlw 0x0D ;si-->verificar si es ON subwf Tecla,0 btfss STATUS,Z ;fue ON?? goto $+2 ;no goto salir1 ;si movf Tecla,W ;Lee el código de la tecla pulsada movwf REG2 ;Tecla-->REG2 call Hex_Ascii movf ASCII_L,0 call EnviaCarLCD pulso2 call Key_Scan ;Explora el teclado movlw 0x80 subwf Tecla,W btfsc STATUS,Z ;Hay alguna pulsada ?? goto pulso2 ;no on2 movlw 0x0D ;si-->verificar si es ON subwf Tecla,0 btfss STATUS,Z ;fue ON?? goto $+2 ;no goto salir2 ;si movf Tecla,W ;Lee el código de la tecla pulsada movwf REG3 ;Tecla-->REG3 call Hex_Ascii movf ASCII_L,0 call EnviaCarLCD pulso_3
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
;***** MALO
BTFS TFSS GOTO MOVF SUBLW BTFS TFSC GOTO GOTO BSF RETURN
STAT STATUS US,Z ,Z MALO REG2,0 .4 STAT STATUS US,C ,C CONTINUA MALO INDICADOR,0
;***** CONTINUA BCF INDICADOR,0 movlw .9 movwf AUX movf REG2,0 movwf AUX2 follow3 movf AUX2,0 addwf REG2,1 decfsz AUX goto follow3 movf REG2,0 addwf REG3,1 falta movlw .99 movwf AUX movf REG1,0 movwf AUX2 otro movf AUX2,0 ADDW ADDWFF REG1 REG1,1 ,1 DECFSZ DECFSZ AUX GOTO otro movf REG1,0 ADDW ADDWFF REG3 REG3,0 ,0 MOVW MOVWFF TEMP TEMPER ER RETURN ;;;;;;;;;;, salir1 movf REG1,0 movwf TEMPER RETURN ;;;;;;;;;; salir2 movlw .9 movwf AUX movf REG1,0 movwf AUX2 follow2 movf AUX2,0
;AUX2=REG2 inicial ;REG2=REG2+REG2
;REG3=10*REG2+REG3
;AUX2=REG1 inicial
;TEMP<--REG1
;AUX2=REG1 inicial ;w=aux2