lcd y glcd con pic 16f877a (informe 4)
DESCRIPTION
MARZO – JULIO 2010UNIVERSIDAD POLITÉCNICA SALESIANASISTEMAS MICROPROCESADOS 1INFORME PRÁCTICA #04 TEMA: Display alfanuméricos y gráficos.DAVID ESPÍN ANDRÉS MOGROQUITO - ECUADORPRACTICA #04 OBJETIVO: Utilizar con el microcontrolador pic display alfanuméricos y gráficos. 4.1 Escribir la sentencia Hola e Ingeniería Electrónica en un display. Entradas: Los datos que se van a guardar en el microcontrolador. Procesos: • Habilitar el display mediante el puerto B como salida. • Escribir senteTRANSCRIPT
![Page 1: lcd y Glcd con pic 16f877A (informe 4)](https://reader030.vdocuments.net/reader030/viewer/2022012403/5571f42749795947648f15eb/html5/thumbnails/1.jpg)
UNIVERSIDAD POLITÉCNICA
SALESIANA
SISTEMAS MICROPROCESADOS 1
INFORME PRÁCTICA #04
TEMA: Display alfanuméricos y gráficos.
DAVID ESPÍN
ANDRÉS MOGRO
MARZO – JULIO 2010
QUITO - ECUADOR
![Page 2: lcd y Glcd con pic 16f877A (informe 4)](https://reader030.vdocuments.net/reader030/viewer/2022012403/5571f42749795947648f15eb/html5/thumbnails/2.jpg)
PRACTICA #04
OBJETIVO: Utilizar con el microcontrolador pic display alfanuméricos y
gráficos.
4.1 Escribir la sentencia Hola e Ingeniería Electrónica en un display.
Entradas:
Los datos que se van a guardar en el microcontrolador.
Procesos:
• Habilitar el display mediante el puerto B como salida.
• Escribir sentencias en el puerto B y enviarlas hacia el display.
Salidas:
Salida del puerto B hacia el display alfanumérico.
CÓDIGO
program escribiring
'programa para escribir en un LCD 16X2
'D7=PORTB.7,D6=PORTB.6,D5=PORTB.5,D4=PORTB.4;
'RS=PORT.0,/W=PORTB.1,E=PORTB.2
'PARA ELIMINAR EL CURSOR SE APAGA MEDIANTE EL SIGUI ENTE COMANDO
'LCD_cmd(LCD_CURSOR_OFF)
main:
'trisb=0
'portb=255
LCD_cmd(LCD_CURSOR_OFF)
Lcd_config(portb,7,6,5,4,portb,0,1,2)
![Page 3: lcd y Glcd con pic 16f877A (informe 4)](https://reader030.vdocuments.net/reader030/viewer/2022012403/5571f42749795947648f15eb/html5/thumbnails/3.jpg)
lcd_out(1,1,"HOLA")
delay_ms(2000)
lcd_cmd(lcd_clear)
lcd_out(1,1,"INGENIERIA")
lcd_out(2,1,"ELECTRONICA")
end.
DIAGRAMA DE FLUJO
INICIO
CONFIGURAR LCD
COMO SALIDA
ESCRIBIR “HOLA” EN EL LCD
RETRASO 2000 mS.
ESCRIBIR “INGENIERIA
ELECTRONICA” EN EL LCD
RETRASO 2000 mS.
![Page 4: lcd y Glcd con pic 16f877A (informe 4)](https://reader030.vdocuments.net/reader030/viewer/2022012403/5571f42749795947648f15eb/html5/thumbnails/4.jpg)
ESQUEMÁTICO Y SIMULACIÓN
![Page 5: lcd y Glcd con pic 16f877A (informe 4)](https://reader030.vdocuments.net/reader030/viewer/2022012403/5571f42749795947648f15eb/html5/thumbnails/5.jpg)
FOTOS
4.2 Elaborar un programa para que aparezca los nombres de los integrantes
del grupo por 3 segundos.
Entradas:
Los datos que se van a guardar en el microcontrolador.
Procesos:
• Habilitar el display mediante el puerto B como salida.
• Escribir sentencias en el puerto B y enviarlas hacia el display.
Salidas:
Salida del puerto B hacia el display alfanumérico.
![Page 6: lcd y Glcd con pic 16f877A (informe 4)](https://reader030.vdocuments.net/reader030/viewer/2022012403/5571f42749795947648f15eb/html5/thumbnails/6.jpg)
CÓDIGO
program escribirnombres
main:
'trisb=0
'portb=255
LCD_cmd(LCD_CURSOR_OFF)
Lcd_config(portb,7,6,5,4,portb,0,1,2)
lcd_out(1,1,"DAVID ESPIN")
delay_ms(3000)
lcd_cmd(lcd_clear)
lcd_out(1,2,"ANDRES MOGRO")
delay_ms(3000)
GOTO MAIN
end.
![Page 7: lcd y Glcd con pic 16f877A (informe 4)](https://reader030.vdocuments.net/reader030/viewer/2022012403/5571f42749795947648f15eb/html5/thumbnails/7.jpg)
DIAGRAMA DE FLUJO
INICIO
CONFIGURAR LCD
COMO SALIDA
ESCRIBIR “DAVID ESPIN” EN EL
LCD
RETRASO 3000 mS.
ESCRIBIR “ANDRES MOGRO” EN
EL LCD
RETRASO 3000 mS.
![Page 8: lcd y Glcd con pic 16f877A (informe 4)](https://reader030.vdocuments.net/reader030/viewer/2022012403/5571f42749795947648f15eb/html5/thumbnails/8.jpg)
ESQUEMÁTICO Y SIMULACIÓN
![Page 9: lcd y Glcd con pic 16f877A (informe 4)](https://reader030.vdocuments.net/reader030/viewer/2022012403/5571f42749795947648f15eb/html5/thumbnails/9.jpg)
FOTOS
![Page 10: lcd y Glcd con pic 16f877A (informe 4)](https://reader030.vdocuments.net/reader030/viewer/2022012403/5571f42749795947648f15eb/html5/thumbnails/10.jpg)
4.3 Elabore un programa para que se observe un contador ascendente, cuyo
valor se observa en un display 16x2, con un intervalo de tiempo entre cada
valor de 2 segundos. Utilice el esquema del numeral 1.
Entradas:
Los datos que se van a guardar en el microcontrolador.
Procesos:
• Habilitar el display mediante el puerto B como salida.
• Realizar la cuenta de 0 a 255 y enviar datos al puerto B para
posteriormente enviarlos hacia el display.
Salidas:
Salida del puerto B hacia el display alfanumérico.
CÓDIGO
program contadorLcd
dim A as STRING
dim X as string[6]
main:
trisb=0
Lcd_config(portb,7,6,5,4,portb,0,1,2)
Lcd_cmd(lcd_cursor_off)
while true
![Page 11: lcd y Glcd con pic 16f877A (informe 4)](https://reader030.vdocuments.net/reader030/viewer/2022012403/5571f42749795947648f15eb/html5/thumbnails/11.jpg)
A=A+1
WORDTOSTR(A,X)
Lcd_cmd(lcd_clear)
Lcd_out(2,1,x)
delay_ms(500)
wend
end.
DIAGRAMA DE FLUJO
INICIO
CONFIGURAR LCD
COMO SALIDA
DECLARAR VARIABLES PARA
REALIZAR LA CUENTA
REALIZAR LAZO WHILE-WEND
PARA LA CUENTA
RESTRASO 2000 ms
![Page 12: lcd y Glcd con pic 16f877A (informe 4)](https://reader030.vdocuments.net/reader030/viewer/2022012403/5571f42749795947648f15eb/html5/thumbnails/12.jpg)
ESQUEMÁTICO Y SIMULACIÓN
FOTOS
![Page 13: lcd y Glcd con pic 16f877A (informe 4)](https://reader030.vdocuments.net/reader030/viewer/2022012403/5571f42749795947648f15eb/html5/thumbnails/13.jpg)
4.4 Utilice el temporizador 1 del 16f877A, para crear un contador ascendente
por señal externa, muestre el valor en un display, la señal de reloj se genera
mediante un pulsante externo, realice los ajustes necesarios al esquema del
numeral 1.
Entradas:
• Los datos que se van a guardar en el microcontrolador.
• Los pulsos externos ingresados por el usuario.
Procesos:
• Habilitar el display mediante el puerto B como salida.
• Realizar la cuenta de 0 a 255 mediante el timer externo.
• Enviar datos al puerto B para posteriormente enviarlos hacia el
display.
Salidas:
Salida del puerto B hacia el display alfanumérico.
CÓDIGO
program contLCD
dim A as STRING
dim X as string[6]
main:
trisa=$FF
trisb=$0
'Option_reg=%10100000 'solo para ir de 2, 4, 8, 16 , etc.
![Page 14: lcd y Glcd con pic 16f877A (informe 4)](https://reader030.vdocuments.net/reader030/viewer/2022012403/5571f42749795947648f15eb/html5/thumbnails/14.jpg)
intcon=$0
tmr0=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(500)
wend
end.
DIAGRAMA DE FLUJO
INICIO
CONFIGURAR LCD
COMO SALIDA
DECLARAR VARIABLES PARA
REALIZAR LA CUENTA
REALIZAR LAZO WHILE-WEND
USANDO EL TMR0 PARA LA
CUENTA
RESTRASO 2000 ms
![Page 15: lcd y Glcd con pic 16f877A (informe 4)](https://reader030.vdocuments.net/reader030/viewer/2022012403/5571f42749795947648f15eb/html5/thumbnails/15.jpg)
ESQUEMÁTICO Y SIMULACIÓN
FOTOS
![Page 16: lcd y Glcd con pic 16f877A (informe 4)](https://reader030.vdocuments.net/reader030/viewer/2022012403/5571f42749795947648f15eb/html5/thumbnails/16.jpg)
5.5 Programa de ejemplo para el uso de display gráfico.
Entradas:
• Los datos que se van a guardar en el microcontrolador.
Procesos:
• Habilitar el display gráfico mediante el puerto B como salida.
• Cargar la imagen de una imagen predeterminada.
• Dibujar círculos en el display gráfico.
• Dibujar círculos en el display gráfico.
• Dibujar líneas en el display gráfico.
Salidas:
Salida del puerto B hacia el display gráfico.
CÓDIGO
program Glcd1
include "imagen1"'librería de imagenes mikrobasic
dim j, k as byte
main:
Glcd_init(Portb, 0,1,2,3,4,5, portd)
do
Glcd_Set_Font(@FontSystem5x8, 5, 8, 32)
Glcd_Image(carsun_bmp)
![Page 17: lcd y Glcd con pic 16f877A (informe 4)](https://reader030.vdocuments.net/reader030/viewer/2022012403/5571f42749795947648f15eb/html5/thumbnails/17.jpg)
Delay_ms(1000)
Glcd_Fill(0)
Glcd_Set_font(@FontSystem5x8, 5, 8, 32)
delay_ms(1000)
Glcd_Write_Text("Circulos", 0, 0,1)
j=4
While j<31
Glcd_Circle(63, 31, j, 2)
j=j+4
wend
Delay_ms(4000)
Glcd_Fill(0)
Glcd_Set_Font(@FontSystem5x8, 5, 8,32)
Glcd_Write_Text("Rectangulos", 0, 0,1)
delay_ms(1000)
Glcd_Fill(0)
j=0
While j<31
Glcd_Box(j, 0, j+20, j+25,2)
![Page 18: lcd y Glcd con pic 16f877A (informe 4)](https://reader030.vdocuments.net/reader030/viewer/2022012403/5571f42749795947648f15eb/html5/thumbnails/18.jpg)
j=j+4
wend
delay_ms(4000)
Glcd_Fill(0)
Glcd_Set_Font(@FontSystem5x8, 5, 8, 32)
Glcd_Write_Text("lineas", 0, 0, 1)
delay_ms(1000)
Glcd_Fill(0)
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.
![Page 19: lcd y Glcd con pic 16f877A (informe 4)](https://reader030.vdocuments.net/reader030/viewer/2022012403/5571f42749795947648f15eb/html5/thumbnails/19.jpg)
Creamos un nuevo programa no proyecto y lo guardamos en la misma
carpeta en donde se guardó proyecto.
module imagen1
' ------------------------------------------------------
' GLCD Picture name: carsun.bmp
' GLCD Model: KS0108 128x64
' ------------------------------------------------------
const carsun_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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,128,128,128,128,128,128, 0,
![Page 20: lcd y Glcd con pic 16f877A (informe 4)](https://reader030.vdocuments.net/reader030/viewer/2022012403/5571f42749795947648f15eb/html5/thumbnails/20.jpg)
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
128,128,128,128,128,144,144,144,144,144,144,128,144,128, 0,144,
144, 0, 0, 32, 32, 0, 0, 0, 0, 16, 0, 0, 4, 4, 4,132,
128,128,128, 64, 64, 64, 64, 64, 64, 68, 64, 64, 64, 64, 64, 68,
64, 64, 64, 64, 0, 0, 0, 68, 36,164, 4, 4,132,132,132, 4,
36, 36, 36, 4,132,188,226,161, 56,192, 2,130,130,130, 66, 68,
25,129,102, 0, 0, 0, 0, 0, 0, 0, 70, 66, 66, 2, 66, 2,
32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 8, 72, 72, 72, 72,
8, 40, 40, 8, 8, 8, 64, 64, 64, 64, 64, 64, 0, 0, 0, 0,
0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,128,128, 0, 64, 66,
2, 66,129, 1, 1, 67, 1, 34, 34, 34, 34, 2, 0, 0, 80,136,
8, 0, 0, 0,128,194, 96, 2,209, 9, 9, 9,137, 81, 16, 16,
28, 31,224,136, 24, 72,152,152, 32,148, 44,156, 68, 52,128,224,
248, 64, 72, 72,184,120,184, 24, 25,164, 86,158,215,211,187,181,
189,173,164,236,160,200,184,248,232,240,236,208,215,239,203,213,
229,253,237,209,168, 89,169, 81,145,113, 80, 48, 96,160,160, 64,
193, 65,121, 60,128,128,128,248,112,128, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1,
1, 2, 17, 23, 30, 1,128, 64, 64, 37, 36, 7, 18, 18, 10, 7,
![Page 21: lcd y Glcd con pic 16f877A (informe 4)](https://reader030.vdocuments.net/reader030/viewer/2022012403/5571f42749795947648f15eb/html5/thumbnails/21.jpg)
6, 6, 7, 7, 6, 2, 3, 2, 2, 3, 2, 3, 3, 3, 2, 2,
7, 6, 7, 7, 6, 7,134,198,182,158,199,235,127, 65, 94,110,
102, 94, 94, 94, 94,114,115, 99, 67, 67, 67, 67, 67, 67, 67, 83,
83, 94, 94, 76, 79,124,100, 68,134,133, 4, 5, 5, 6, 5, 6,
20, 15, 0,224, 47, 32, 8, 23,112, 19, 8, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 16, 16, 8, 8,
4, 4, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0,128,224, 48,216,126,127, 79, 75,105, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
64, 64, 64, 64, 64, 64, 64, 64, 64, 81,111,111,110,124,240, 32,
64,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, 0, 0, 0, 0, 4,
6, 1, 0, 0, 3, 6, 7, 31, 31, 31, 31, 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, 15, 15, 15, 15, 7, 3, 0,
0, 0, 1, 3, 6, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
![Page 22: lcd y Glcd con pic 16f877A (informe 4)](https://reader030.vdocuments.net/reader030/viewer/2022012403/5571f42749795947648f15eb/html5/thumbnails/22.jpg)
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 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.
![Page 23: lcd y Glcd con pic 16f877A (informe 4)](https://reader030.vdocuments.net/reader030/viewer/2022012403/5571f42749795947648f15eb/html5/thumbnails/23.jpg)
DIAGRAMA DE FLUJO
INICIO
CONFIGURAR LOS
PUERTOS PARA EL
GLCD
DIBUJAR CÍRCULOS
DIBUJAR UNA IMAGEN
PREDETERMINADA
DIBUJAR RECTÁNGULOS
DIBUJAR LÍNEAS
![Page 24: lcd y Glcd con pic 16f877A (informe 4)](https://reader030.vdocuments.net/reader030/viewer/2022012403/5571f42749795947648f15eb/html5/thumbnails/24.jpg)
ESQUEMÁTICO Y SIMULACIÓN
FOTOS
![Page 25: lcd y Glcd con pic 16f877A (informe 4)](https://reader030.vdocuments.net/reader030/viewer/2022012403/5571f42749795947648f15eb/html5/thumbnails/25.jpg)
![Page 26: lcd y Glcd con pic 16f877A (informe 4)](https://reader030.vdocuments.net/reader030/viewer/2022012403/5571f42749795947648f15eb/html5/thumbnails/26.jpg)
CONCLUSIONES.
• Utilizamos con el microcontrolador pic displays alfanuméricos y
gráficos.
• Para el display gráfico lo ideal es utilizar un PIC de la familia 18FXX, con
la familia 16FXX los programas funcionan pero las imágenes se ven un
poco distorsionadas.
• Aprendimos a utiñizar la herramienta para la generación de arreglos
para mapa de bits GLCD BITMAP EDITOR.
BIBLIOGRAFÍA
• MICROCONTROLADORES PIC. Diseño práctico de aplicaciones SEGUNDA PARTE: PIC
16F87X PIC 18FXXXX. Segunda edición. Segundo Angulo, Susana Romero, Mc Graw
Hill. España.
• Hojas guías de la práctica.
• Ayuda del software Mikrobasic.