Documente Academic
Documente Profesional
Documente Cultură
conectan al LCD (pines tales como datos, enable, escritura, etc.) usando
la funcin DEFINE.
Tenemos las siguientes definiciones:
Tabla 1. Definicin de puerto y bits para el LCD.
DEFINE
DEFINE
DEFINE
DEFINE
DEFINE
DEFINE
DEFINE
DEFINE
DEFINE
DEFINE
DEFINE
DEFINE
LCD_DREG PORTA
LCD_DBIT 0
LCD_RSREG PORTA
LCD_RSBIT 4
LCD_EREG PORTB
LCD_EBIT 3
LCD_RWREG PORTE
LCD_RWBIT 2
LCD_BITS 4
LCD_LINES 2
LCD_COMMANDUS 2000
LCD_DATAUS 50
Una vez definidos los puertos y los pines del LCD, es necesario realizar
una pausa de medio segundo antes de enviar los datos al LCD, esto para
que tenga tiempo de inicializar la memoria RAM el dispositivo. Usamos la
funcin PAUSE.
A continuacin se muestra las sentencias para escritura del LCD, usando
LCDOUT:
Tabla 2. Comandos de escritura del LCD.
Comando
Operacin
$FE, 1
Limpia visor
$FE, 2
$FE, $0C
Apagar cursor
$FE, $0E
$FE, $0F
$FE, $10
$FE, $14
$FE, $C0
TRISB=0
' TAMAO DE VARIABLES DEL CONTADOR
B0 VAR BYTE
B1 VAR BYTE
' PAUSA DE INICIO DEL LCD
PAUSE 500
'-------------------------------------------------------LCDOUT $FE, 1 ' LIMPIAR LCD
LCDOUT $FE, 1, "MICRO 2014" 'ESCRIBIR EN LA PRIMERA LNEA
LCDOUT $FE, $C0, "FIEE" 'ESCRIBIR EN LA SEGUNDA LNEA
PAUSE 1000
' MOSTRAR DATOS DECIMALES Y BINARIOS
LCDOUT $FE, 1, DEC 25
LCDOUT $FE, $C0, BIN 25
'-------------------------------------------------------'MOSTRAR LETRA POR LETRA
PAUSE 500
LCDOUT $FE, 1 ' LIMPIAR LCD
FOR B0 = 0 TO 13
LOOKUP B0,["MICRO 2012"],B1
LCDOUT $FE,$0C,B1
PAUSE 500
NEXT
LCDOUT $FE, $C0 'COLOCAR EL CURSOR EN LA SEG LNEA
FOR B0 = 0 TO 13
LOOKUP B0,["PROMO 2014"],B1
LCDOUT $FE,$0C,B1
PAUSE 500
NEXT
'-------------------------------------------------------'DESPLAZAMIENTO DE TEXTO EN LCD
FOR B0 = 144 TO 128 STEP -1
LCDOUT $FE, 1 ' LIMPIAR LCD
LCDOUT $FE,B0,"MICRO FIEE 2014"
PAUSE 200
NEXT
END
LCDOUT command
LCDOUT Item {,Item...}
Display Items on an intelligent Liquid Crystal Display. PBP supports LCD modules
with a Hitachi 44780 controller or equivalent. These LCDs usually have a 14- or 16pin single- or dual-row header at one edge.
If a pound sign (#) precedes an Item, the ASCII representation for each digit is
sent to the LCD. LCDOUT can also use any of the modifiers used with SEROUT2.
See the section on SEROUT2 for this information.
A program should wait for at least half a second before sending the first command
to an LCD. It can take quite a while for an LCD to start up.
Commands are sent to the LCD by sending a $FE followed by the command. Some
useful commands are listed in the following table:
Command
Operation
$FE, 1
Limpia display
$FE, 2
$FE, $0C
Cursor apagado
$FE, $0E
$FE, $0F
$FE, $10
$FE, $14
$FE, $C0
Note that there is a command to move the cursor to the beginning of the second
line of a 2-line display. For most LCDs, the displayed characters and lines are not
consecutive in display memory - there can be a break in between locations. For
most 16x2 displays, the first line starts at $0 and the second line starts at $40. The
command:
LCDOUT $FE, $C0
sets the display to start writing characters at the beginning of the second line. 16x1
displays are usually formatted as 8x2 displays with a break between the memory
locations for the first and second 8 characters. 4-line displays also have a mixed up
memory map.
See the data sheet for the particular LCD device for the character memory locations
and additional commands..
LCDOUT $FE, 1, "Hello" Clear display and show "Hello"
The LCD may be connected to the PICmicro using either a 4-bit bus or an 8-bit bus.
If an 8-bit bus is used, all 8 bits must be on one port. If a 4-bit bus is used, it must
be connected to either the bottom 4 or top 4 bits of one port. Enable and Register
Select may be connected to any port pin. R/W should be tied to ground as the
LCDOUT command is write only.
Looks pretty darn simple doesn't it..? That's because PicBasic takes care of all the
details for controlling the LCD for you.
Notice the spare I/O-pins left over on the PIC16F84..? You have seven I/O-pins left
to control additional circuitry, and if you're even just a little creative here you can
design your very own Serial LCDs' at a fraction of the cost of purchasing them off
the shelf..
Using the simple serin command in PicBasic you can receive serial data on any I/Opin with the PIC16F84 controlling your LCD, and very easily create your own serial
LCDs'.