You are on page 1of 9

DIAGRAMA DE FLUJO

INICIO

CONFIGURACION
CONFIGURACION
NO
SW=1
3

SI

CONT=0
PORTB=DISPLAY(CONT
PORTC=DISPLAY L
ON ALARMA
ON VALVULA
CONT= CONT+20
CONT=20

NO

RETARDO

NO

RETARDO

SI
PORTC = DISPLAY
ON VALVULA
CONT=40
SI
PORTC = DISPLAY
ON VALVULA
1

3
NO

CONT=60

RETARDO

SI
PORTC = DISPLAY
ON VALVULA

CONT=80
SI

NO

RETARDO

PORTC = DISPLAY H
ON VALVULA
NO

CONT=99
SI

RETARDO
INTERRUP

PORTC = DISPLAY H

CONF. INTERRUPCION

ON ALARMA NIVEL ALTO

INCR UNI

OFF VALVULA

NO
UNI=10
SI
SI

DEC=9
NO

UNI=0

DEC=0
CIRCUITO

RETURN

INCR DEC

UNI=0

D3
LED-BIGY

U1
13
14
1
2
3
4
5
6
7
8
9
10

OSC1/CLKIN
OSC2/CLKOUT
MCLR/Vpp/THV

RB0/INT
RB1
RB2
RB3/PGM
RB4
RB5
RB6/PGC
RB7/PGD

RA0/AN0
RA1/AN1
RA2/AN2/VREFRA3/AN3/VREF+
RA4/T0CKI
RA5/AN4/SS
RC0/T1OSO/T1CKI
RC1/T1OSI/CCP2
RE0/AN5/RD
RC2/CCP1
RE1/AN6/WR
RC3/SCK/SCL
RE2/AN7/CS
RC4/SDI/SDA
RC5/SDO
RC6/TX/CK
RC7/RX/DT
RD0/PSP0
RD1/PSP1
RD2/PSP2
RD3/PSP3
RD4/PSP4
RD5/PSP5
RD6/PSP6
RD7/PSP7

33
34
35
36
37
38
39
40

R1

Q2

10k

2N3904

15
16
17
18
23
24
25
26

R10
R11
10k
10k

R2

19
20
21
22
27
28
29
30

Q3

330

R3

2N3904

330

R4
330

R5

PIC16F877

330

R6
R7
330
330

R8
330

R9
10k

PROGRAMA
INCLUDE<P16F877A.INC>
LIST P=16F877A,

R=HEX

Q1
2N3904

UNID
DECE
REG1
REG2
REG3

EQU
EQU
EQU
EQU
EQU

20
21
23
24
25

REG1_2
REG2_2
REG3_2

EQU
EQU
EQU

26
27
28

STA
W_1

EQU
EQU

29
2A

ORG
GOTO
ORG
GOTO

0
INICIO

INTER

ORG
INICIO

NOP
BANKSEL
MOVLW .1
MOVWF TRISB
CLRF TRISC
CLRF TRISD
BSF
BSF
BANKSEL
BCF
BSF
BSF
CLRF
CLRF

LOOP

CALL

MOSTRAR

TRISB

STATUS,5
OPTION_REG,INTEDG
PORTB

UNID
DECE

INTCON,INTF
INTCON,INTE
INTCON,GIE

MOSTRAR
GOTO LOOP

CLRF

PORTC

BSF
PORTC,4
MOVF DECE,W
CALL TABLA
MOVWF PORTD
CALL

RETARDO_1

CLRF
BSF
MOVF

PORTC

PORTC,5

UNID,W

CALL TABLA
MOVWF PORTD
CALL

RETARDO_1

MOVLW
SUBWF
BTFSS
GOTO

.06
DECE,0
STATUS,0
BAJO

MOVLW B'01110110'
MOVWF PORTD
CLRF PORTC
BSF
PORTC,3
CALL RETARDO_1
RETURN
BAJO
MOVLW B'00111000'
MOVWF PORTD
CLRF PORTC
BSF
PORTC,3
CALL RETARDO_1
RETURN

RETARDO_1
TRES

MOVLW .02
MOVWF REG1
MOVLW .100
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MINIMO 5
MOVWF REG2
MOVLW .100
MOVWF REG3

DOS
UNO

DECFSZ
GOTO UNO
DECFSZ
GOTO DOS
DECFSZ
GOTO TRES

REG3,1
REG2,1
REG1,1

RETURN

RETARDO_2
TRES_2
DOS_2
UNO_2

MOVLW .02
MOVWF
MOVLW
MOVWF
MOVLW .100
MOVWF
DECFSZ

GOTO

REG1_2
.100
REG2_2
REG3_2
REG3_2,1
UNO_2

DECFSZ
REG2_2,1
GOTO DOS_2
DECFSZ
REG1_2,1
GOTO TRES_2
RETURN

TABLA

ADDWF PCL,F
RETLW
RETLW
RETLW
RETLW
RETLW
RETLW
RETLW
RETLW
RETLW
RETLW

INTER

MOVWF W_1
MOVF STATUS,0
MOVWF STA
BCF
BCF
MOVLW
XORWF
BTFSC
GOTO
MOVLW
ADDWF
CLRF
MOVLW
XORWF
BTFSS
GOTO
MOVLW
MOVWF
MOVWF
BSF
CALL
CALL
CALL
CALL
CALL
CALL
BCF
BCF

B'00111111'
B'00000110'
B'01011011'
B'01001111'
B'01100110'
B'01101101'
B'01111100'
B'00000111'
B'01111111'
B'01100111'

INTCON,INTE
INTCON,INTF

.9
DECE,W
STATUS,Z
LOOP4
.2
DECE,F
UNID
.10
DECE,W
STATUS,Z
LOOP1
.9
DECE
UNID

PORTC,2;ENCI ALARMA
RETARDO_1
RETARDO_1
RETARDO_1
RETARDO_1
RETARDO_1
RETARDO_1
PORTC,2
PORTC,1
;APAGUE VALVULA

LOOP4
LOOP1

CLRF

GOTO
UNID
CLRF

LOOP1

BSF

DECE
INTCON,INTE

MOVF STA,0
MOVWF STATUS
MOVF

W_1,0

CALL

RETARDO_2

RETFIE
END

PRACTICA DE LABORATORIO # 2

CONTROL DE NIVEL DE TANQUE

MICROCONTRIOADORES

JACKSON RENTERIA MENA

INSTITUCION UNIVERSITARIA DE ENVIGADO


FACULTAD DE INGENIERIAS
INGENIERIA ELECTRONICA
ENVIGADO- ANTIOQUIA
2008-09-17