You are on page 1of 6

Integrantes: Kevin Cárdenas – Steven Pogo

Materia: Microcontroladores
Fecha: 21-01-2019
NRC: 3158
Tema: Comunicación Serie
Realizar una comunicación serie entre dos PIC’s. En el primer PIC, diseñar un
teclado matricial 2x2 y se muestre en un display de 7 segmentos. En el segundo
PIC, realizar un control PWM de un motor con los números del teclado matricial.
DIAGRAMA DE FLUJO
PIC1
INICIO

Config. PB, PD, PC6

PD  00

num  00

portb.0=HIGH pd = %00000110

NO SI num  1
1 portb.6=1

portc.6= serout
1

NO SI
portb.0=LOW portb.7=1 pd = %01011011

num  2

portc.6= serout

NO SI
portb.6 = 1 pd = %01011011

num  3

portc.6= serout

NO SI
2 portb.7 = 1 pd = %01011011

num  4

portc.6= serout

PIC2

INICIO

Config. PB, PC1, PC7

3
3

portc.7= serin

num 00

SI
num = 1 portc.1=25

NO

SI
num = 2 portc.1=50

NO

SI
num = 3 portc.1=75

NO
NO SI
4 num = 4 portc.1=100

CODIFICACIÓN
PIC1 =Teclado y Display num = 00
include "modedefs.bas" inicio
TRISB = %11000000 high portb.0
TRISC = 00 if portb.6 = 1 then
TRISD = %00000000 pd = %00000110
PD var portd num =1
num var byte endif
pd = 00 if portb.7 = 1 then
pd = %01011011 DEFINE LCD_EBIT 2
num =2 TRISC = %10000000
endif trisb=00
LOW portb.0 vel var byte
high portb.1 num var byte
if portb.6 = 1 then num = 00
pd = %01001111 while 1
num = 3 serin portc.7,T2400,vel
endif num = vel
if portb.7 = 1 then LCDOUT $FE,1
pd = %01100110 LCDOUT $FE,1, "VELOCIDAD"
num = 4 lcdout $fe,$c0,DEC num
endif if num = 1 then
LOW portb.1 pwm portc.1,25,3
serout portc.6,T2400,[num] endif
goto inicio if num = 2 then
end pwm portc.1,50,3
endif
PIC2 =Control PWM if num = 3 then
include "modedefs.bas" pwm portc.1,75,3
DEFINE LCD_DREG PORTB endif
DEFINE LCD_DBIT 4 if num = 4 then
DEFINE LCD_RSREG PORTB pwm portc.1,100,3
DEFINE LCD_RSBIT 1 endif
DEFINE LCD_EREG PORTB wend
SIMULACIÓN

You might also like