Está en la página 1de 12

UNIVERSIDAD POLITECNICA

SALESIANA

FACULTAD DE INGENIERIAS
INGENIERIA ELECTRONICA

SISTEMAS
MICROPROCESADOS I

INFORME N: 4

ADRIAN VILELA
JUAN CARLOS YACELGA
PEDRO TENE
Tema: Entrada y salida de micro controladores PIC18F877A y PIC18F4520
Objetivo: Utilizar los Puertos del Micro controlador PIC, como interface
digital al mundo exterior.

1. Escribir la sentencia Hola e ingeniería electrónica en un display.

program P4_1
'Programa para escribir en un LCD 16X2
'D7=PORTB.7,D6=PORTB.6,D5=PORTB.5,D4=PORTB.4;
RS=PORTB.0,R/W=PORTB.1,E=PORTB.2
'Para eliminar el curso, se apaga mediante el siguiente comando
'LCD_CMD(LCD_CURSOR_OFF)
main:
Lcd_Config (portb, 7,6,5,4,portb, 0,1,2)
Lcd_Out(1,1,"Hola")
delay_ms(500)
Lcd_Cmd(lcd_clear)
Lcd_Out(1,1,"Ingenieria")
delay_ms(100)
Lcd_Out(2,1,"Electronica")
delay_ms(300)
goto main
end.

Simulación en Proteus:

Fotografías tomadas en la práctica:


2. Elaborar un programa para que aparezcan los nombres de cada uno de
los integrantes del grupo port res segundos.
program P4_2
main:
Lcd_Config (portb, 7,6,5,4,portb, 0,1,2)
Lcd_Out(1,1,"Adrian Vilela")
delay_ms(1000)
Lcd_Cmd(lcd_clear)
Lcd_Out(1,1,"Pedro Tene")
delay_ms(1000)
Lcd_Out(1,1,"Juan Carlos Yacelga")
delay_ms(1000)
goto main
end.

Simulación en Proteus:

Fotografías tomadas en la práctica:


3. Elabore un programa para que se observe un contador ascendente,
cuyo valor se observa en un display para 16x2, con un intervalo de
tiempo entre cada valor de 2 segundos. Utilice el esquema del numeral
uno.
program P4_3
DIM A AS BYTE
DIM X AS STRING[6]
main:
Lcd_config (portb,7,6,5,4,portb,0,1,2)
lcd_cmd(lcd_cursor_off)
WHILE TRUE
A=A+1
WORDTOSTR(A,X)
lcd_cmd(lcd_clear)
LCD_OUT(2,1,X)
delay_ms(2000)
wend
end.

Simulación en Proteus:

Fotografías tomadas en la práctica:


4. Utilice el temporizador 1 del 16F877, para crear un contador por señal
externa, muestre El valor en un display, la señal del reloj se genera
mediante un pulsante externo, realice los ajustes necesarios al esquema
del numeral uno.
program ejercicio_3
main:
dim a as byte
dim x as string[6]
trisa=$ff
trisb=$0
option_reg=%10100000
intcon=$0
tmr0=0
portb=tmr0
trisb=0
lcd_config(portb,7,6,5,4,portb,0,1,2)
lcd_cmd(lcd_cursor_off)
while true
a=tmr0
wordtostr(a,x)
lcd_cmd(lcd_clear)
lcd_out(2,1,x)
delay_ms(100)
wend
end.

Simulación en Proteus:

Fotografías tomadas en la práctica:


5. Programa de ejemplo para el uso de display grafico, solo para la familia
18fxxx(utilice un18f452 o 18f4520).

program Led_Blinking
include "logo" ' Pull in the file with my images

dim j, k as byte

main:
Glcd_Init(PORTC, 2, 3, 4, 5, 6, 7, PORTD)

do

' Set font for displaying text


Glcd_Set_Font(@FontSystem5x8, 5, 8, 32)

' Draw my image


Glcd_Image(mikro_logo_bmp)
Delay_ms(4000)

' Draw circles


Glcd_Fill(0) ' Clear screen
Glcd_Write_Text("Circles", 0, 0, 1)
j=4
while j < 31
Glcd_Circle(63, 31, j, 2)
j=j+4
wend
Delay_ms(4000)

' Draw boxes


Glcd_Fill(0) ' Clear screen
Glcd_Write_Text("Rectangles", 0, 0, 1)
j=0
while j < 31
Glcd_Box(j, 0, j + 20, j + 25, 2)
j=j+4
wend
Delay_Ms(4000)

' Draw Lines


Glcd_Fill(0) ' Clear screen
Glcd_Write_Text("Lines", 0, 0, 1)
for j = 0 to 15
k = j*4 + 3
Glcd_Line(0, 0, 127, k, 2)
next j
for j = 0 to 31
k = j*4 + 3
Glcd_Line(0, 63, k, 0, 2)
next j
Delay_ms(4000)

loop until FALSE

end.

' ------------------------------------------------------
' GLCD Picture name: mikro_logo.bmp
' GLCD Model: KS0108 128x64
' ------------------------------------------------------
module logo
const mikro_logo_bmp as byte[1024] = (
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,192,224,112,176,176,176,176,176,176,176,176,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,
176,176,176,176,176,176,176,176,176, 96,224,128, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,255,255, 0,255,255,255, 3, 35, 49, 49, 49,
49, 49, 49, 49, 51, 3,199,255,127, 31, 31, 15, 7, 7, 3, 3,
3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 7, 7, 15,
15, 31,127,255,255,255,255,255,255, 0,255,255, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,255,255, 0,255,255,255, 7, 6, 6, 14, 30,
30, 30, 30, 30,254,255,255, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0,252,255,255,255,254, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 7,255,255,255,255, 0,255,255, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,255,255, 0,255,255,255, 17, 51, 3, 3, 15,
7, 3, 3, 17,255,255,255, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,129,129,129,129,128,128,128,128,128,128,128,128,
128,128,128,128,128,255,255,255,255, 0,255,255, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,255,255, 0,255,255,255, 98,127,111, 99, 99,
99, 99, 99, 99,255,255,255, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0,255,255,255,255,255,255, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3,255,255,255,255, 0,255,255, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,255,255, 0,255,255,255, 8,140,140,140,140,
140,140,140,140,141,159,255,240,192, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 7, 31, 63, 31, 31, 7, 0, 0, 0, 0, 0, 0, 0,
0, 0,128,192,248,255,255,255,255, 0,255,255, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,127,255,128,127,127,127,112,113,113,113,113,
113,113,113,113,113,113,113,113,115,119,126,124,124,120,120,112,
112,112,112,112,112,112,112,112,112,112,112,112,112,120,120,124,
126,127,127,127,127,127,127,127, 63,192,255,127, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 0, 0, 0, 0, 0, 0
)
end.

Simulación en Proteus:

Fotografías tomadas en la práctica:


6. Mediante un LCD gráfico dibuje una onda sinodal, se debe incluir ejes,
en el eje y debe ir la etiqueta voltaje y en el eje x debe ir la etiqueta
segundos.

program seno
include "sino" ' Pull in the file with my images

dim j, k as byte

main:
Glcd_Init(PORTC, 2, 3, 4, 5, 6, 7, PORTD)

do

' Set font for displaying text


Glcd_Set_Font(@FontSystem5x8, 5, 8, 32)

' Draw my image


Glcd_Image(senoidal_bmp)
Delay_ms(4000)

' Draw circles


Glcd_Fill(0) ' Clear screen
Glcd_Write_Text("Circles", 0, 0, 1)
j=4
while j < 31
Glcd_Circle(63, 31, j, 2)
j=j+4
wend
Delay_ms(4000)

' Draw boxes


Glcd_Fill(0) ' Clear screen
Glcd_Write_Text("Rectangles", 0, 0, 1)
j=0
while j < 31
Glcd_Box(j, 0, j + 20, j + 25, 2)
j=j+4
wend
Delay_Ms(4000)

' Draw Lines


Glcd_Fill(0) ' Clear screen
Glcd_Write_Text("Lines", 0, 0, 1)
for j = 0 to 15
k = j*4 + 3
Glcd_Line(0, 0, 127, k, 2)
next j
for j = 0 to 31
k = j*4 + 3
Glcd_Line(0, 63, k, 0, 2)
next j
Delay_ms(4000)

loop until FALSE

end.

' ------------------------------------------------------
' GLCD Picture name: senoidal.bmp
' GLCD Model: KS0108 128x64
' ------------------------------------------------------
module sino
const senoidal_bmp as byte[1024] = (
0, 14, 16, 32, 16, 14, 0, 62, 34, 34, 62, 0, 62, 32, 32, 32,
2, 2, 62, 2, 2, 0, 62, 18, 18,190, 0, 34, 34, 62, 2, 2,
0, 62, 42, 34, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,255, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
)
end.

Simulación en Proteus:

Fotografías tomadas en la práctica:


Recomendaciones:

Como primera cosa de debe tener en cuenta el cristal de la


programadora, ya que de esta elección depende que nos corra bien
el programa.
Tratar de armar en lo posible los circuitos en el proto para
facilitar la programación y en si el hardware.

Conclusiones:

Pudimos entender La utilización del LCD y el LCD grafico su


funcionamiento y su polarización.

Nos pudimos dar cuenta de los comandos de mikrobasic y la


utilización de mas código para funcionamiento de esta práctica.

La utilización de otro pic como el 18f4520 que es para el LCD


grafico la utilización de los puertos y la distribución de ellos.