2001_02_supp(1).pdf
(
1735 KB
)
Pobierz
JOHN BECKER
HOW TO USE
GRAPHICS LIQUID
CRYSTAL DISPLAYS
WITH PICS
A step-by-step guide to understanding
and using pixel-matrixed graphics l.c.d.s
with your PIC microcontroller projects.
RAPHICS
liquid crystal displays
have been available for several
years. It would appear, though, that
EPE
readers have not successfully
explored them. At least, that seems the log-
ical conclusion since we have never been
offered a design which uses them.
One reason may be that the prices of
such devices have, in many instances, been
somewhat expensive. Whilst many contin-
ue to be pricy for the average hobbyist, less
expensive ones have been making their
appearance.
Possibly the principal reason we have
not been offered working designs is that
readers have not been able to obtain, let
alone interpret, the data sheets associated
with them.
The latter stumbling block very
much faced the author when he
decided that he would like to know
how to use graphics displays.
Intermittently over several days,
he scoured the Internet in search of
their manufacturers and suppliers.
As it turned out, there are quite a
few around the globe, but when it
came to obtaining data sheets –
well, that was a totally different
matter.
intelligibility is also marred by having
been translated by someone inadequately
familiar with English. Gross errors of fact
were spotted as well.
To cut short a lengthy and convoluted
tale, no manufacturer or supplier could be
found who had adequate data for graphics
displays available for download.
G
Farnell appeared to have a
selection of displays within a rea-
sonable price range, but stated “no
parametric
data
available’’.
Attempting to Net-search for the
manufacturer of these devices,
Perdix, only revealed countless
sites to do with
partridges
(a bird
for which the Latin and Greek
name is
perdix!)
Whilst research had showed that
RS Components supplies graphics
displays, the only data sheet (RS
DATA DENIAL
During the Net searches, however, vari-
ous manufacturers had stated that their dis-
plays were controlled by the Toshiba
T6963C chip, the same device as used by
Powertip. Seemingly, then, the control
architecture offered by the T6963C could
be regarded as an “industry standard’’, and
thus worth pursuing further through a
Powertip display, the PG12864.
Toshiba state that the T6963C is an l.c.d.
controller that has an 8-bit parallel data bus
plus control lines for reading or writing
through a microcontroller interface (such
as a PIC).
It has a 128-word character generator
ROM (read only memory) which can con-
trol an external display RAM (random
access memory) of up to 64 kilo-
bytes. It can be used in text,
graphic and combination text-and-
graphic modes, and includes vari-
ous attribute functions.
Searching Toshiba’s web site,
the T6963C was eventually locat-
ed
(under
Analogue
&
Peripherals/LCD Driver!), and its
46 page data sheet downloaded.
This data turned out to be the
key to getting to grips with graph-
ics l.c.d.s. Not so much because
the data sheet was intelligible
(which it did not become until
much later), but because it gave
programming examples of con-
trolling the T6963C, albeit written
in a microcontroller command
language unknown to the author.
There were, though, sufficient
commands whose structure
appeared to be close to some other
machine code dialects with which
the author is familiar, for a trans-
Photo 1. Graphics l.c.d. screen showing the display generated
lation to PIC microcontroller
language to be attempted.
by the author’s first demo program.
298-4613) available turned out to be spe-
cific to a development kit which uses them.
However, in the RS catalogue, the man-
ufacturer of their displays is quoted as
Powertip. Doing a Net-search, and eventu-
ally accessing Powertip’s web site in
Taiwan, rudimentary data on the devices
was located. But, frustratingly, Powertip
denies access to its data sheets by those
who are not registered distributors.
Contacting the technical department at
RS, the author was put in touch with an
agent who imports from Powertip. This
company sent Powertip’s data sheet, a doc-
ument which might, perhaps, be under-
standable to those already familiar with
graphics l.c.d.s but is certainly not con-
ducive to teaching those who do not. Its
TOSHIBA T6963C
Everyday Practical Electronics, February 2001
Special Supplement
#
#
#
#
#
1
T
T
N
N
EE E
EE E
M
M
FR LE
FR LE
PP
PP
SU
SU
Photo 2. Toshiba’s demo display.
Success was achieved when the display
in Photo 2 appeared on the author’s
Powertip PG12864 64 × 128 pixel graphics
l.c.d. screen – eventually!
POWERTIP PG12864
Whilst it is the Powertip PG12864 graphics
display (RS 329-0329) used in the demos
discussed, the commands are relevant to
any
connected to a negative voltage supply, of
graphics l.c.d. which uses the Toshiba
about –5V, via a contrast-adjusting preset
T6963C controller, although the pin
potentiometer of typically 10kW to 25kW.
count/order may differ between display types.
A summary of the pin functions is given
The PG12864 has the pinouts shown in Fig.1.
in Table 1.
The PG12864 has a full dot-matrix l.c.d.
Which brings us to the first of the major
structure consisting of a visible screen area
discrepancies found in Powertip’s own data
having 128 dots × 64 dots (8192 dots in
sheet (be warned if you obtain it!):
total). There are eight data lines, D0 to D7,
and six control lines comprising WR, RD,
1. Powertip quote data line D0 as being
CE, CD, RST and FS, names which will be
MSB. It’s not. D0 is LSB (see Table 1).
clarified shortly.
The display has a single positive supply
2. Powertip also show an incorrect cir-
line (Vdd) at pin 3. The recommended
cuit diagram for the control of the screen
working voltage is 5V, with an absolute
contrast. The control pot is shown wrongly
maximum of 7V. There are two 0V con-
connected across pin 3 (+5V) and pin 9
nections, of which GND (pin 2) is the sig-
(RST) with the wiper on pin 4 (CX).
nal ground (Vss), and FG (pin 1) is the
Furthermore, pin 9 is marked as V
EE
(–VE). This configuration does not work.
ground connection for the display’s metal
frame (bezel).
Table 1. Graphics l.c.d. pinout functions.
Display contrast is
controlled via pin 4,
Pin
Symbol
Function
named as CX in Fig.1
1
FG
Frame ground (connected to metal bezel)
but can also be
2
GND
Signal ground supply (Vss)
referred to as V0.
3
+5V
Positive supply for logic (Vdd)
This pin is normally
4
5
6
7
8
CX
WR
RD
CE
CD
Negative supply (V0) for l.c.d. contrast
(–3·5V approx)
Data write (active low)
Data read (active low)
Chip enable (active low)
CD = 1, WR = 0: command write
CD = 1, WR = 1: command read
CD = 0, WR = 0: data write
CD = 0, WR = 1: data read
Module reset (active low)
Data bus (D0 = LSB, D7 = MSB)
Font select:
FS = 0:
8 × 8 dots font
FS = 1 (or open–circuit): 6 × 8 dots font
9
10–17
18
RST
D0–D7
FS
Fig.1. Pinouts of the Powertip PG12864 graphics l.c.d. module.
Fig.2. Circuit diagram for the PIC-
controlled Graphics L.C.D. Demo.
2
#
#
#
#
#
Special Supplement
Everyday Practical Electronics, February 2001
Fig.3. Component and full size copper foil track
master pattern for the Graphics L.C.D. Demo
printed circuit board.
Pin 9 (RST) does not go to –VE. It is
held at logic 1 (+5V) for normal control
chip operation and may be taken (briefly)
to 0V to reset the chip, but it
must never be
taken negative,
nor should one side of the
control pot ever be connected to this pin.
Experimentation showed that the control
pot’s wiper
should
be connected to pin 4.
One outer terminal of the pot then connects
to a negative supply of, for example, –5V.
The unused pot terminal is best connected
to the wiper. This is illustrated in the demo
circuit diagram (Fig.2.). The preset is
adjusted until the desired contrast is
observed.
The Toshiba data sheet does not discuss
l.c.d. contrast setting, whilst that from RS
is highly ambiguous on the subject.
COMPONENTS
Resistors
R1
R2
R3, R4
All 0·25W 5%
VR1
VR2
1k
470W
10k (2 off)
carbon film.
Approx. Cost
Guidance Only
excluding case & batt.
microcontroller,
pre-programmed
(see text)
78L05 +5V 100mA
regulator
7660 negative voltage
converter
min. s.p. push-to-make
switch
3·2768MHz crystal (see
text)
graphics l.c.d. module,
Toshiba T6963C-
based, 64 x 128 pixels,
e.g. Powertip
PG12864-F (see text)
£50
IC2
Potentiometers
See
IC3
22k (or 25k)
min. preset,
round
10k min.
preset, round
page
(see text)
SHOP
TALK
Miscellaneous
S1
X1
X2
DEMO CIRCUIT
Capacitors
10p ceramic, 5mm pitch
(2 off)
C3, C6, C7 22m radial elect. 16V
(3 off)
C4, C5
100n ceramic, 5mm pitch
(2 off)
C1, C2
The circuit diagram which the author
used in his examination of the PG12864
display is shown in Fig.2. The circuit
includes a PIC16F877 microcontroller
(IC1), a crystal (X1) and its two capacitors
(C1, C2), a 5V voltage regulator (IC2), a
negative voltage inverter (IC3) with its two
capacitors (C6, C7), the PG12864 l.c.d.
display (X2) which is connected to the PIC
via connector pins TB1, contrast control-
ling preset (VR1) and switch S1.
Components R1 and D1 are included so
that the PIC may programmed on–board
via connector TB2 and a suitable PIC pro-
grammer, such as the author’s
PIC Toolkit
Mk2
(May–June ’99).
Resistor R2 and l.e.d. D2 were used by
the author when originally translating the
Toshiba demo program, the l.e.d. being set
on or off at strategic points in the develop-
ing software. They have been left in and
Semiconductors
D1
D2
IC1
1N4148 signal diode
red l.e.d. (see text)
PIC16F877
Printed circuit board, available from
the
EPE PCB Service,
code 288; 8-pin
d.i.l. socket; 40-pin d.i.l. socket; terminal
pin header strips and connectors (see
text); 18-way ribbon cable (a few cen-
timetres); p.c.b. supports (4 off); solder,
etc.
may be similarly used by readers when
writing their own software. The control
line is PORTE pin 0 (RE0).
Resistor R4 is included to keep the
l.c.d.’s CE line high when the PIC is being
programmed (so avoiding random displays
appearing on the screen during that
operation).
Resistor R3 biases high open-collector pin
RA4 allowing demo-stepping switch S1 to
operate correctly.
Components VR2 and TB3 are dis-
cussed in a moment.
A d.c. supply of between about 7V and
12V (nominally stated as +9V) can be used
for powering the circuit via the 5V regula-
tor, IC2.
Incidentally, the crystal clock
frequency is not a critical matter and
other frequencies could be used. If a
crystal of greater than 4MHz is used,
though, the PIC’s configuration bit OS1
Everyday Practical Electronics, February 2001
3
Special Supplement
#
#
#
#
#
Fig.4. Character set for the Powertip PG12864 display (note
that the last two lines may differ in some modules).
not included here, but
the pin order and
functions, and the
controlling software
subroutines, are the
same as used in other
recent “normal’’ l.c.d.
projects designed by
the author and pub-
lished in
EPE.
The
connections can be
ascertained by study-
ing any of those. In
Fig.2, the connections
are shown as TB3,
with VR2 as the
contrast control.
program
loaded
into
the
PIC,
GRAPHEPE.OBJ (source code name
GRAPHEPE.ASM). The software is writ-
ten in TASM, but
PIC Toolkit Mk2
can
translate between TASM and MPASM if
the latter is the programming language you
are used to.
Two other program files will be loaded
into the PIC later on.
The software is available free via the
EPE
web site, or on 3·5-inch disk (for
which a nominal handling charge is made)
from the Editorial office. See
Shoptalk
for
details of both matters.
Having loaded the Toshiba demo, the
display shown earlier in Photo 2 should be
seen. It may be necessary for preset VR1 to
be adjusted before the image is clearly
visible.
It is this demo result which is first dis-
cussed before moving on to the author’s
demos, for which various exercises are
suggested at some points.
Photo 3. Demo printed circuit board assembly.
should be set high and OS0 set low (see
later).
For his own demo board, the author in
fact uses a 5MHz crystal, which does frac-
tionally speed up Demo 8.
It may also be worth bearing in mind
that the author’s forthcoming follow–up
constructional article, in which a
PIC16F877 and the same graphics l.c.d. are
used, also requires a 5MHz crystal.
CONSTRUCTION
PRINTED CIRCUIT
BOARD
It is emphasised that unless you have a
PIC programmer, there is no point in build-
ing this design since much of the discus-
sion here concerns experimental software
changes that you are recommended to try.
These changes, once made, need the soft-
ware to be re-assembled and downloaded
to the PIC.
A printed circuit board design and its
component layout are shown in Fig.3. This
board is available from the
EPE PCB
Service,
code 288.
You will observe that the p.c.b. includes
components VR2 and TB3 towards the
right. These are the points at which the
author also included an ordinary alphanu-
meric l.c.d. so that various routines could
be monitored during the development of
the software translation from Toshiba to
PIC.
The holes and tracks have been left
intact so that the p.c.b. could be used as a
future general-purpose development board
with either type of l.c.d., and in conjunc-
tion with a PIC16F877.
A circuit diagram for the second l.c.d. is
It is expected that all who build the cir-
cuit will be sufficiently experienced not to
need constructional advice. It is recom-
mended, though, that sockets are used for
IC1 and IC3, and that pin header strips are
used for the TB1 to TB3 connections.
Ideally, a graphics l.c.d. should be pur-
chased that already has a suitable pin con-
nector wired to it (see this month’s
Shoptalk
page). The connections to the
p.c.b. are in the “natural’’ order of the
PG12864 l.c.d. used (as shown previously
in Fig.1).
DISPLAY STRUCTURE
Before starting to discuss programming
detail, it is necessary to understand the
physical arrangement of the ways in which
data can be shown on the l.c.d. screen.
There are three options, which can be
summarised as:
1.
Alphanumeric text display
using
the built–in character generator (as with
any standard alphanumeric l.c.d.). 128
characters are available, as shown in
Fig.4, and which are called by their own
location numbers. In a very loose sense
they can be regarded as the equivalent of
ASCII characters. The addressing num-
ber order runs from zero to 127. Writing
any of these values to the screen displays
the “text’’ character associated with it.
The characters in lines 7 and 8 may be
slightly different in some variants of the
PG12864 display.
2.
User–defined character generation
and display.
Again this is similar to the
facilities available on standard alphanu-
meric l.c.d.s, but the quantity of characters
that can be simultaneously stored is far
greater, 128 compared to the typical eight.
The addressing order runs from 128 to 255.
Writing any of these values to the screen
displays the character that the user has
created and allocated to the address value.
PIC PROGRAMMING
Having built the board and proved its
workability, three lots of software need to
be programmed into the PIC, one now and
two later.
Before doing so, though, the PIC needs
to be configured with the following set-
tings (which are all
PIC Toolkit Mk2
default settings for a PIC16F877 running at
4MHz):
CP1 CP0 DBG NIL WRT CPD LVP
1
1
1
1
1
1
0
BOR CP1 CP0 POR WDT OS1 OS0
0
1
1
0
0
0
1
Note that Logic 1 and Logic 0 in the set-
tings do NOT necessarily mean that the
function is on/off respectively – refer to the
PIC ’87 data sheet if you need to know
more (also see earlier regarding the oscilla-
tor rate).
For the first part of the discussion that
follows, you need the Toshiba demo
4
#
#
#
#
#
Special Supplement
Everyday Practical Electronics, February 2001
CONTROL LINES
Data is written to or read from the l.c.d.
via the eight data lines D0 to D7. Three
control lines are used in most read or write
situations:
CD: selection of data or command
function, 0 = Data, 1 = Command
CE: chip enable, 0 = enabled, 1 = disabled
RD or WR: read or write functions. These
are two separate lines and the relevant one
is taken low to be active, with the other
remaining high.
Fig.5. Pixel, column and row distribution for the graphics l.c.d.
3.
User–defined graphics detail gener-
ation
in which the “character’’ size is one
pixel high by eight pixels wide (i.e. a sin-
gle byte). Any value between zero and 255
can be written to the screen and the setting
of the binary bits that make up that value
determines whether a screen pixel is turned
on or off.
For both character modes, the characters
are all eight pixels high, but the width can
be specified as six or eight pixels. That is,
the character generation (font) can be set
for 6 × 8 or 8 × 8 format.
Line FS controls the font choice, FS = 0
for 8 × 8, FS = 1 for 6 × 8. The pin has an
internal pull–up resistor that holds it high
(FS = 1) and the pin may be left uncon-
nected if the 6 × 8 font is required (also see
later).
In 8 × 8 font mode (FS = 0), the screen
can display 16 characters horizontally and 8
vertically. In 6 × 8 font mode (FS = 1), the
display format is 20 horizontal × 8 vertical
characters. It is conventional to refer to the
character display in terms of lines (horizon-
tal) and columns (vertical). See Fig.5.
For the graphics mode, 64 character
locations can be written to vertically.
Horizontally, the quantity is determined by
the width mode set for the characters, i.e.
20 or 16.
There are two screen memory areas to
which data is written, known as the Text
screen and the Graphics screen. The Text
screen displays the built–in and user-
defined characters. The Graphics screen
displays only graphics data.
The l.c.d. can be programmed to display
Text only, Graphics only, or Text and
Graphics combined.
There are many additional display
attribute features that can be implemented,
such as highlighting, blanking, flashing,
panning etc.
There is lot of information discussed from
hereon, but it is illustrated with working
program examples, and with many points at
which you can experiment with various
commands in the author’s own demos.
As usual with this type of article, the
author tries to lead you carefully from step
to step.
The timing characteristics for the setting
of the data and control lines are shown in
Fig.6 and Table 2.
Since the l.c.d. includes its own
oscillator, the timings shown are indepen-
dent of the clock rate controlling a PIC
microcontroller.
PIC PORT SETTINGS
CONTROL MATTERS
Those of you familiar with alphanumer-
ic (“intelligent’’) l.c.d. displays will be
aware that they can be operated in either 4-
bit or 8-bit data mode. They can also be
controlled by just two control lines, RS
and E, and rely on a predetermined delay
between sending bytes or nibbles of data.
The same is not true of graphics
displays.
Those using the T6963C can
only be operated in 8-bit mode. They use
five control lines and
require status
check routines to be performed before
each action.
Timed delays are not
used, nor can they
be
used between data
Table 2. Toshiba T6963C Timing Values
transfers.
Item
Symbol
Min
Max
Unit
There are, though,
t
CDS
100
–
ns
delay requirements
C/D Set-up Time
10
–
ns
C/D Hold Time
t
CDH
concerning the order
t
CE
, t
RD
, t
WR
80
–
ns
in which the data and
CE, RD,
WR Pulse Width
control lines are taken
80
–
ns
t
DS
high or low, a matter
Data Set-Up Time
Data Hold Time
t
DH
40
–
ns
which is discussed
Access Time
t
ACC
–
150
ns
now. Status checking
Output Hold Time
t
OH
10
50
ns
will be examined
Test Conditions: V
DD
= 5·0V ± 10%, V
SS
= 0V, Ta = –20 to 75°C
shortly.
In the demo programs, PIC PORTC is
used for setting the l.c.d. control lines, and
PORTD for the data input/output lines.
Some microcontrollers and micro-
processors have internal registers which
allow the same data port to be used either
for input or for output without the user
having to specify the port’s function, other
than by the
write
or
read
command.
For example, the required port (e.g. paral-
lel port connector on a PC computer) has
two separate register addresses, one for
inputting data, the other for outputting it.
These would be equated as values at the
head of the program, e.g. OUTPORT =
&H378 (output register), INPORT = &H379
The next several sections of this discus-
sion relate to the T6963C l.c.d. controller,
and how Toshiba’s example programs are
interpreted using the PG12864 graphics
display and a PIC16F877 microcontroller,
resulting in the display shown earlier in
Photo 2.
Following this, the author’s own
examples of PIC-microcontrolling the
l.c.d. in a variety of situations will be
described. In a future issue, this same
graphics l.c.d. will be the display used in
a PIC-controlled audio frequency oscil-
loscope (currently having the working
title of
PIC G-Scope).
COMING NEXT
Fig.6. Timing waveforms for the Toshiba T6963C graphics l.c.d. controller, see also
Table 2.
Everyday Practical Electronics, February 2001
5
Special Supplement
#
#
#
#
#
Plik z chomika:
fred1144
Inne pliki z tego folderu:
2001_11_supp(2).pdf
(2950 KB)
2000_xmas_supp(2).pdf
(1853 KB)
2001_02_supp(2).pdf
(1735 KB)
2003_04_supp(2).pdf
(912 KB)
2001_04_supp(2).pdf
(935 KB)
Inne foldery tego chomika:
1998
1999
2000
2001
2002
Zgłoś jeśli
naruszono regulamin