e00b060.pdf

(477 KB) Pobierz
000113-UK mini-SIPO
MICRO PROCESSOR
BASIC Stamp II
a serial-in, parallel-out (SIPO) module
Design by K. Burkhardt
This circuit needs only
four connections to equip
a BASIC Stamp II with an
LCD module.
The BASIC Stamp II has 16 I/O lines. To con-
nect an LCD module to a BASIC Stamp II
board, you would need eight data lines and
two control lines. Even if you split the data
byte into two sequential four-bit packets, the
LCD module still takes up six I/O connections
of the BASIC Stamp board. With certain appli-
cations, this may mean that there are not
enough I/O connections left over.
5V
P0
CLOCK
DATA
LCD module
P1
2
RS
ENABLE
VCC
P2
3
VS
10k
P3
4
BASIC
STAMP
RS
IC1
6
E
II
11
5
R/W
VSS
C1
1
1
EN
2
3
4
1D
19
14
D7
5V
18
13
D6
Two busses
17
12
D5
5
6
16
11
D4
15
10
The alternative control circuit described here
makes do with only four leads. It employs the
well-known 74HCT574 bus driver in an
unconventional manner, as a serial-in, parallel
out (SIPO) IC. As can be seen in Figure 1 , the
eight flip-flops of the bus driver are connected
in series, so that it functions as a shift register.
The serial input data reach the 74HCT574 via
one lead (DATA), and a second lead (CLOCK)
is required for the shift clock. The data traffic
is similar to that on an I 2 C bus.
20
D3
7
8
9
14
9
IC1
D2
13
8
10
D1
12
7
D0
74HCT574
000113 - 11
Figure 1. A bus driver sits between the BASIC Stamp module and the LCD module.
60
Elektor Electronics
11/2000
LCD Driver for
138909423.003.png 138909423.004.png 138909423.005.png 138909423.006.png 138909423.001.png
 
MICRO PROCESSOR
Whenever a complete byte is
available on the outputs of the shift
register, two additional leads come
into play. The status of the RS (regis-
ter select) lead determines whether
the following byte is to be inter-
preted as a control command (Low)
or as text to be displayed (High). The
byte is transferred into the display
memory on the falling edge of the
BNA (enable) lead. We must do with-
out the option of reading out the con-
tents of the mod ule . Consequently,
the associated R/W pin of the mod-
ule (pin 5) is tied to ground.
memory data “1st Line ———*2nd Line ———*”
charvar byte
sipovar nib
avar byte
commandvar byte
dirs = %0000000000001111
out0 = 0
Clock (SCL)
out1 = 0
Serial data (SDA)
out2 = 0
Register Low = command mode /
High = data mode
out3 = 1
High to Low edge = Enable
in_lcd:
Initialise display
command = %00000001
Clear
Software
gosub shift:gosub ena
pause 10
gosub ena:gosub ena
The program for driving the four rel-
evant I/O leads of the BASIC Stamp
module is shown in Figure 2 . It is
short, and thanks to the comments,
it is not difficult to understand. Fol-
lowing the usual variable definitions,
it consists of a main routine and two
subroutines.
The shift : subroutine reads the
eight-bit value command (control or
text) from right (lsb) to left and
passes it via P1 (out1) to the shift
register, clocked a bit at a time by
the pulsout instruction (SCL).
The second subroutine, ena : , con-
sists of only one instruction. It gen-
erates an enable pulse for transfer-
ring the parallel byte from the
74HCT574 outputs into the module’s
memory.
The main routine in_lcd : takes care
of the configuration of the display
and switching between the first and
second display rows. The comments
in the listing are self-explanatory.
(000113-1)
command = %00000011
Cursor home
gosub shift:gosub ena
gosub ena:gosub ena
command = %00111000
8 bit / 2 lines
gosub shift:gosub ena
command = %00001111
Display on/Cursor+Blink on
gosub shift:gosub ena
command = %00000110
Move to right
gosub shift:gosub ena
toggle 2
Switch to data input
pause 100
for char = 0 to 15
read char,command
Text “1st Line.....”
gosub shift:gosub ena
pause 50: next
toggle 2
Switch to command
command = %11000000
Start of 2nd line
gosub shift:gosub ena
toggle 2
Switch to data input
pause 100
for char = 16 to 30
read char,command
Text “2nd. Line.....”
The program can be downloaded at
no charge from our website at
http://www.elektor-electronics.co.uk .
Select Free Downloads, November
2000, item 000113-11.exe.
gosub shift:gosub ena
pause 50: next
stop
End of subroutine
shift:
for sipo = 0 to 7
a = command & 1 Masked AND command reads LSB only
out1 = a Serial data (SDA)
pulsout 0,10 Shift Clock (SCL)
command = command / 2 Shift right,1
next:return
Figure 2. The short program listed
here can be downloaded from the
Elektor Electronics website.
ena:
pulsout 3,10:return
Enable for data copying
11/2000
Elektor Electronics
61
138909423.002.png
 
Zgłoś jeśli naruszono regulamin