You are on page 1of 6

KS Project Manual

EFY april 2009

Moving-Message Display
ED-based moving-message Circuit description Ports P0 and P2 of the microcon-
displays are becoming popular troller have been configured to act
Fig. 1 shows the circuit of the micro-
for transmitting information to as a common data bus for all the 16
controller-based moving-message
large groups of people quickly. These alphanumeric displays whose cor-
display. It comprises microcontrol-
can be used indoors or outdoors. We responding data pins have been tied
ler AT89C51, three-to-eight decoder
can find such displays in areas like rail- together to make a common 16-bit
74LS138, common anode alphanumeric
way platforms, banks, public offices, data bus. Port-2 provides the higher
displays, regulator 7805 and a few dis-
hotels, training institutes, nightclubs byte of data, while port-0 provides
crete components.
and shops. the lower one to light up a character
At the heart of the moving-mes-
Compared to LEDs, liquid-crystal on the display. Port pins P1.2-P1.4
sage display is Atmel AT89C51 mi-
displays (LCDs) are easy to interface and P1.5-P1.7 of the microcontroller
crocontroller (IC1). It is a low-power,
with a microcontroller for display- have been used as address inputs
high-performance, 8-bit microcontrol-
ing information as these have many for decoder IC3 and IC4 (74LS138) to
ler with 4 kB of flash programmable
built-in functions. But these can’t be enable one of the fourteen alphanu-
and erasable read-only memory
observed from a distance and large- meric displays (DIS3 through DIS16)
(PEROM) used as on-chip program
size LCDs are very costly. at a time, respectively. However,
memory, 128 bytes of RAM used as
LED-based displays can be of two displays DIS1 and DIS2 are enabled
internal data memory, 32 individually
types: dot-matrix and segmental. If you or disabled directly by port pins P1.0
programmable input/output (I/O)
implement a moving-message display and P1.1. Pins 4 and 5 are grounded
lines divided into four 8-bit ports, two
with multiplexed dot-matrix LEDs, it and pin 6 is made high to enable de-
16-bit programmable timers/counters,
will be very costly for displaying 16 coder 74LS138.
a five-vector two-level interrupt archi-
characters or more at a time. Moreover, Fig. 2 shows the pin configuration
tecture, on-chip oscillator and clock
programming will require a lot of data of the common-anode alphanumeric
memory or program memory space. display.
An external RAM may be needed to Parts List All the corresponding data pins
complement a microcontroller like Dis1 through DIS16 of alphanumeric
AT89C51. IC1 - AT89C51 microcontroller displays have been tied together,
However, if you use alphanumeric IC2, IC3 - 74LS138 3-to-8 decoder
(16-segment LED) displays for the IC4 - 7805 5V regulator
List of Messages
above purpose, programming burden T1-T16 - BC558 pnp transistor
is reduced and also it becomes highly D1-D4 - 1N4007 rectifier diode Which can be Selected
DIS1-DIS16 - KLA51 common-anode S3S2S1S0 Message selected
cost-effective. You can make your alphanumeric display
own display panel consisting of 16 LED1 - 5mm LED 0 0 0 0 Happy Birthday
alphanumeric characters at a much Resistors (all ¼-watt, ±5% carbon): 0 0 0 1 Happy New Year
lower cost. R1-R16 - 2.2-kilo-ohm 0 0 1 0 *Happy Diwali*
The circuit presented here uses 16 R17-R32 - 120-ohm 0 0 1 1 Merry Christmas
common-anode, single-digit, alphanu- R33-R37 - 10-kilo-ohm
0 1 0 0 *Happy Holi*
R38 - 220-ohm
meric displays to show 16 characters 0 1 0 1 *Eid Mubarak*
at a time. Moreover, programming has 0 1 1 0 Happy Dashehra
C1, C2 - 33pF ceramic disk
been done to make the characters move C3 - 2200µF, 25V electrolytic 0 1 1 1 Happy Wedding
in a beautiful manner. A message ap- C4 - 1µF, 16V electrolytic
1 0 0 0 Happy Janmashtmi
pears on the panel from the right side, C5 - 10µF, 16V electrolytic
C6 - 0.1µF ceramic disk 1 0 0 1 *Happy Rakhi*
stays for a few seconds when the first
1 0 1 0 *Happy Pongal*
character reaches the leftmost place Miscellaneous:
and then goes out from the left side. X1 - 220V AC primary to 9V, 1 0 1 1 Happy Mothers Day
500mA secondary 1 1 0 0 *Happy Ramjan*
It displays 16 different messages to transformer
depict different occasions, which can 1 1 0 1 *Happy Lohri*
XTAL - 11.0592MHz crystal
be selected by the user through a DIP S0-S3 - 4-pin DIP switch 1 1 1 0 *Happy Easter*
switch. S4 - Push-to-‘on’ switch 1 1 1 1 Welcome to All
EFY april 2009
KS Project Manual

Fig. 1: Circuit for microcontroller-based moving-message display

KS Project Manual
EFY april 2009

Fig. 2: Pin configuration of alphanumeric display

while the common anode of each

display is separately powered via a
BC558 transistor which switches ‘on’
or ‘off’ as required, through outputs
of 74LS138 ICs and pins P1.0 and
P1.1 of IC1. The higher nibble of
port P3 (P3.4 through P3.7) is used Fig. 3: Actual-size, single-side PCB for the microcontroller-based moving-message display circuit,
as a selection bus to select one of except alphanumeric display and associated components
the 16 previously stored messages
using the 4-bit binary value present
on these pins. This value can be
changed through a 4-pin DIP switch
(S0 through S3).
Selection pins P3.4 through P3.7
are pulled high via resistors R36
through R33, respectively. When the
switch connected to a given pin is
open the value is high (1), and when
it is closed the pin is held low and
the value becomes ‘0.’ In this way,
by using a 4-bit number you can
select any of the 16 messages shown
in the Table.
Capacitor C5 and resistor R37
form the power-‘on’ reset circuit,
while a push-to-connect switch has
been used for manual reset. An
11.0592MHz crystal generates the
basic clock frequency for the micro-
Fig. 4: Component layout for the PCB shown in Fig. 3
controller. To change the message
being displayed while the circuit is
working, first change the number regulated power supply. LED1 acts as Fig. 5 shows the PCB for displays
present at the selection bus, then the power-‘on’ indicator. DIS1 through DIS8, transistors T1
press ‘reset’ key. through T8 and resistors R17 through
The 220V AC mains is stepped Construction R24. Component layout for this PCB
down by transformer X1 to deliver Fig. 3 shows an actual-size, single- is shown in Fig. 6. You need to use an
the secondary output of 9V, 500 mA. side PCB layout for the microcontrol- additional PCB as shown in Fig. 5 for
The output of the transformer is ler-based moving-message display DIS9 through DIS16, so as to configure
rectified by a full-wave bridge recti- circuit, except displays DIS1 through 16 alphanumeric displays. For this
fier comprising diodes D1 through DIS16, transistors T1 through T16 PCB, the corresponding components
D4, filtered by capacitor C3 and then and resistors R17 through R32. Com- will be transistors T9 through T16 and
regulated by IC 7805 (IC4). Capacitor ponent layout for this PCB is shown resistors R25 through R32 in addition
C4 bypasses any ripple present in the in Fig. 4. to displays DIS9 through DIS16. Cor-
KS Project Manual
EFY april 2009

Fig. 5: Actual-size, single-side PCB for alphanumeric display

Fig. 6: Component layout for the PCB shown in Fig. 5

responding connector are provided to each message stored in the look-up starting address of DIS16 (right-most
make a proper connection. Connectors table at the end of the program. display). As soon as the first character
CON2, CON4 and CON6 of Fig. 3 are Each time, to display a character at reaches DIS16, the message stays for a
connected to CON2, CON4 and CON6 a given display, first two bytes (16 bits) longer time so that the entire message
of Fig. 5, respectively, through external of data are sent to Port-2 and Port-0, (message length not longer than 16
wires to interface DIS1 through DIS9. then the desired display is enabled by characters) can be easily read. There-
Connectors CON3, CON5 and CON7 sending its address to Port-1. Thereaf- after, characters again start scrolling
of Fig. 3 are connected to CON2, CON4 ter, a delay of 1 ms (slightly more than rightwards, so the entire message goes
and CON6 of Fig. 5, respectively, that) is generated by timer 1. Upon out and disappears after a while to
through external cable to interface DIS9 timer overflow, the entire display panel reappear from left side.
through DIS16. is refreshed by passing ‘FFFFH’ to the All the messages are stored in the
data bus. Then the next character at the form of a look-up table in the program
Software and its working next display is passed in the similar memory (ROM) itself. When the circuit
The source code ‘movmsg.asm’ is writ- manner. The cycle frequency is vari- is switched ‘on’ (or reset), the monitor-
ten in Assembly language and assem- able (depending upon the length of the ing program first checks for the binary
bled using cross-compiler. It is well- message) but always high enough so number present at the selection bus
commented and easy to understand. that the message appears continuous and according to that, the ROM ad-
Timer 1 has been used to generate a to the human eye. dress of the starting character of the
delay of around 1 ms for the switching Timer 0, with its interrupt enabled, selected message is loaded into the
gap between two consecutive displays. is used to change the starting address data-pointer. Thereafter, on-chip ROM
Thus, each display is enabled for 1 ms of the message in cyclic manner so reading is used to read the entire mes-
while displaying a message. The length that the characters scroll from left sage over there.
of this cycle depends upon the length to right with a proper gap between Note that each character is rep-
of the message string. The cycle repeats each shift. Meanwhile, the interrupt resented in the look-up table of the
after a ‘0’ is encountered at the end of service sub-routine also checks for the source code by two bytes. For exam-
KS Project Manual
EFY april 2009
ple, ‘S’ is represented by ‘Sh’ and ‘Sl’ msg0: db Hh, Hl, Oh, Ol, Uh, Ul, Sh, kept free, so that these can be used
separated by a comma. In addition to Sl, Eh, El, bsh, bsl, Nh, Nl, Oh, for interfacing with the serial port
the alphabets, Arabic numerals and Ol, bsh, bsl, fourh, fourl, zeroh, of the PC. Also, interrupt pins can
a few special characters have been zerol, oneh, onel, msh, msl, Hh, Hl, 0 be used to display some message
defined in the program. For instance, (Please note that the assembler is and sound an alarm in the case of
a blank space is represented by ‘bsh, case-insensitive. Still, upper and lower an emergency. For example, a fire
bsl.’ Thus, it is very easy to modify cases have been used for clarity.) sensor can be connected to ‘INT0’ and
the program. a vibration detector to ‘INT1.’ These
Suppose you want to display
Future enhancements pins can also be used to send signals
“HOUSE NO 401-H” in place of mes- Many more messages would be to synchronise a similar system that
sage ‘0.’ First, open the source code in possible if complete Port-3 is used displays another related message at
the editor. Delete the old string and for message selection. Pins RxD, the same time, so a 16-character, two-
write the new string as below: TxD, INT0 and INT1 have been line display is made possible.

$mod51 Fl equ 0e8h Zl equ 7ch
DBH equ p2 ; Higher byte of Data
Bus GH equ 1bh ;** codes for few special characters:
DBL equ p0 ; Lower byte of Data Bus Gl equ 0e8h
ADB equ p1 ; Address Bus strh equ 0e8h ;for star sign (as-
input equ p3 ; message select input Hh equ 0c3h terisk)
Hl equ 0ebh strl equ 17h
;** codes for decimal digits are given
below: Ih equ 0ffh plsh equ 0ebh ;for ‘+’ sign
; (‘h’ refers to higher byte, ‘l’ to Il equ 9fh plsl equ 9fh
lower one)
zeroh equ 17h Jh equ 17h mnsh equ 0ebh ;minus sign
zerol equ 0e8h Jl equ 0ffh mnsl equ 0ffh

oneh equ 0d7h Kh equ 0ech _h equ 3fh ;underscore sign

onel equ 0ffh Kl equ 0ebh _l equ 0ffh

twoh equ 23h Lh equ 3fh bsh equ 0ffh ;blank space
twol equ 0ech Ll equ 0ebh bsl equ 0ffh

threeh equ 2bh Mh equ 0d5h pieh equ 0eah ;for pie
threel equ 0fch Ml equ 0e3h piel equ 7fh

fourh equ 0c3h Nh equ 0d6h mueh equ 0e3h ;for micro (mu)
fourl equ 0fbh Nl equ 0e3h muel equ 0ebh

fiveh equ 0bh Oh equ 17h org 0000h

fivel equ 0f8h Ol equ 0e8h sjmp main

sixh equ 0bh Ph equ 0e3h org 000bh ;timer0 inter-

sixl equ 0e8h Pl equ 0e8h rupt vector address
clr tr0 ;clear timer0
sevenh equ 0d7h Qh equ 06h run bit
sevenl equ 0fch Ql equ 0e8h mov tl0,#00h
mov th0,#00h ;reload timer0
eighth equ 03h Rh equ 0e2h with initial count
eightl equ 0e8h Rlw equ 0e8h djnz r7,a1
mov r7,#46
nineh equ 03h Sh equ 0bh cjne r1,#60h,a5 ;check to again
ninel equ 0f8h Sl equ 0f8h start entering from left-side
sjmp a4
;** codes for alphabets are given Th equ 0ffh a5: cjne r1,#50h,a2 ;check for display
below: Tl equ 9ch to stay on reaching display-16
sjmp a3
Ah equ 0c3h Uh equ 17h a2: inc r1
Al equ 0e8h Ul equ 0ebh sjmp a1
a3: djnz r6,a1
Bh equ 0bh Vh equ 0fdh inc r1
Bl equ 0ebh Vl equ 6bh sjmp a1
a4: mov r6,#10
Ch equ 3fh Wh equ 17h mov r1,#41h
Cl equ 0e8h Wl equ 0abh a1: setb tr0 ;set timer0 run
Dh equ 03h Xh equ 0fch reti ;return from
Dl equ 0efh Xl equ 77h timer0 ISR and clear tf0

Eh equ 2bh Yh equ 0e3h main: mov ie,#00h

El equ 0e8h Yl equ 0bbh setb ea ;set global
interrupt bit
Fh equ 0ebh Zh equ 3dh setb et0 ;enable
KS Project Manual
EFY april 2009
timer0 interrupt chk2: cjne a,#2fh,chk3 timer1
mov tmod,#01h ;timer0 con- mov dptr,#msg2 mov th1,#0fch ;FC66H will gen-
figured in mode 1 sjmp read erate a delay of 1ms with 11.0592MHz
mov tcon,#00h Xtal
mov tl0,#00h chk3: cjne a,#3fh,chk4 mov tl1,#66h
mov th0,#00h ;set initial mov dptr,#msg3 setb tr1
count to 0000H sjmp read jnb tf1,$ ;wait until timer1
mov r7,#46 ;provides gap overflows
between each shift chk4: cjne a,#4fh,chk5 clr tr1
mov r6,#10 ; mov dptr,#msg4 clr tf1
sjmp read mov DBH,#0ffh
mov r0,#60h mov DBL,#0ffh
blank: mov @r0,#0ffh ;initialize the chk5: cjne a,#5fh,chk6 ret
pointed location by null address mov dptr,#msg5
dec r0 sjmp read ;** look-up table starts from here:
cjne r0,#2fh,blank msg0: db Hh,Hl,Ah,Al,Ph,Pl,Ph,Pl,Yh
mov r1,#41h ;load address- chk6: cjne a,#6fh,chk7 ,Yl,bsh,bsl,Bh,Bl,Ih,Il,Rh,Rlw,Th,Tl,Hh
pointer with initial address mov dptr,#msg6 ,Hl,bsh,bsl,Dh,Dl,Ah,Al,Yh,Yl,0
sjmp read msg1: db Hh,Hl,Ah,Al,Ph,Pl,Ph,Pl,Y
mov 50h,#0dfh ;address for 16th chk7: cjne a,#7fh,chk8 Yh,Yl,Eh,El,Ah,Al,Rh,Rlw,0
Display (rightmost) mov dptr,#msg7 msg2: db strh,strl,bsh,bsl,Hh,Hl,
mov 4fh,#0bfh ;address for 15th sjmp read Ah,Al,Ph,Pl,Ph,Pl,Yh,Yl,bsh,bsl,Dh,Dl,
Display Ih,Il,Wh,Wl,Ah,Al,Lh,Ll,Ih,Il,bsh,bsl,
mov 4eh,#9fh ;address for 14th chk8: cjne a,#8fh,chk9 strh,strl,0
Display mov dptr,#msg8 msg3: db Mh,Ml,Eh,El,Rh,Rlw,Rh,Rlw,
mov 4dh,#7fh ;address for 13th sjmp read Yh,Yl,bsh,bsl,Ch,Cl,Hh,Hl,Rh,Rlw,Ih,Il,
Display Sh,Sl,Th,Tl,Mh,Ml,Ah,Al,Sh,Sl,0
mov 4ch,#5fh ;address for 12th chk9: cjne a,#9fh,chk10 msg4: db strh,strl,bsh,bsl,Hh,Hl,Ah
Display mov dptr,#msg9 ,Al,Ph,Pl,Ph,Pl,Yh,Yl,bsh,bsl,Hh,Hl,Oh,O
mov 4bh,#3fh ;address for 11th sjmp read l,Lh,Ll,Ih,Il,bsh,bsl,strh,strl,0
Display msg5: db strh,strl,bsh,bsl,Eh,El,
mov 4ah,#1fh ;address for 10th chk10: cjne a,#0afh,chk11 Ih,Il,Dh,Dl,bsh,bsl,Mh,Ml,Uh,Ul,Bh,Bl,
Display mov dptr,#msg10 Ah,Al,Rh,Rlw,Ah,Al,Kh,Kl,bsh,bsl,strh,
mov 49h,#0fbh ;address for 9th sjmp read strl,0
Display msg6: db Hh,Hl,Ah,Al,Ph,Pl,Ph,Pl,Y
mov 48h,#0f7h ;address for 8th chk11: cjne a,#0bfh,chk12 h,Yl,bsh,bsl,Dh,Dl,Ah,Al,Sh,Sl,Hh,Hl,Eh
Display mov dptr,#msg11 ,El,Hh,Hl,Rh,Rlw,Ah,Al,0
mov 47h,#0f3h ;address for 7th sjmp read msg7: db Hh,Hl,Ah,Al,Ph,Pl,Ph,Pl,Y
Display h,Yl,bsh,bsl,Wh,Wl,Eh,El,Dh,Dl,Dh,Dl,Ih
mov 46h,#0efh ;address for 6th chk12: cjne a,#0cfh,chk13 ,Il,Nh,Nl,Gh,Gl,0
Display mov dptr,#msg12 msg8: db Hh,Hl,Ah,Al,Ph,Pl,Ph,Pl,Yh
mov 45h,#0ebh ;address for 5th sjmp read ,Yl,bsh,bsl,Jh,Jl,Ah,Al,Nh,Nl,Mh,Ml,Ah,A
Display l,Sh,Sl,Hh,Hl,Th,Tl,Mh,Ml,Ih,Il,0
mov 44h,#0e7h ;address for 4th chk13: cjne a,#0dfh,chk14 msg9: db strh,strl,bsh,bsl,Hh,Hl,
Display mov dptr,#msg13 Ah,Al,Ph,Pl,Ph,Pl,Yh,Yl,bsh,bsl,Rh,Rlw
mov 43h,#0e3h ;address for 3rd sjmp read ,Ah,Al,Kh,Kl,Hh,Hl,Ih,Il,bsh,bsl,strh,
Display strl,0
mov 42h,#0fdh ;address for 2nd chk14: mov dptr,#msg14 msg10: db strh,strl,bsh,bsl,Hh,Hl,
Display sjmp read Ah,Al,Ph,Pl,Ph,Pl,Yh,Yl,bsh,bsl,Ph,Pl,
mov 41h,#0feh ;address for 1st Oh,Ol,Nh,Nl,Gh,Gl,Ah,Al,Lh,Ll,bsh,bsl,
Display (leftmost) read: mov r3,dph strh,strl,0
mov r2,dpl msg11: db Hh,Hl,Ah,Al,Ph,Pl,Ph,Pl,Yh
chk: mov a,input ;load accumulator setb tr0 ,Yl,bsh,bsl,Mh,Ml,Oh,Ol,Th,Tl,Hh,Hl,Eh,E
with value at P3 rd1: mov r0,01h l,Rh,Rlw,Sh,Sl,Dh,Dl,Ah,Al,Yh,Yl,0
orl a,#0fh ;mask lower nible rd2: clr a msg12: db strh,strl,bsh,bsl,Hh,Hl,
to get selection bus value movc a,@a+dptr Ah,Al,Ph,Pl,Ph,Pl,Yh,Yl,bsh,bsl,Rh,Rlw
cjne a,#0ffh,chk0 jz down ,Ah,Al,Mh,Ml,Jh,Jl,Ah,Al,Nh,Nl,bsh,bsl
mov dptr,#default ;load dptr mov DBH,a ,strh,strl,0
with starting address of defalt message clr a msg13: db strh,strl,bsh,bsl,Hh,Hl,
sjmp read ; now start inc dptr Ah,Al,Ph,Pl,Ph,Pl,Yh,Yl,bsh,bsl,Lh,Ll,
reading movc a,@a+dptr Oh,Ol,Hh,Hl,Rh,Rlw,Ih,Il,bsh,bsl,strh,
mov DBL,a strl,0
chk0: cjne a,#0fh,chk1 mov ADB,@r0 msg14: db strh,strl,bsh,bsl,Hh,Hl,
mov dptr,#msg0 ;load dptr with acall timer Ah,Al,Ph,Pl,Ph,Pl,Yh,Yl,bsh,bsl,Eh,El,
starting address of msg0 dec r0 Ah,Al,Sh,Sl,Th,Tl,Eh,El,Rh,Rlw,bsh,bsl
sjmp read ; now start inc dptr ,strh,strl,0
reading sjmp rd2 default: db Wh,Wl,Eh,El,Lh,Ll,Ch,Cl,O
down: mov dph,r3 ;reload dph h,Ol,Mh,Ml,Eh,El,bsh,bsl,Th,Tl,Oh,Ol,bs
chk1: cjne a,#1fh,chk2 mov dpl,r2 ;reload dpl h,bsl,Ah,Al,Lh,Ll,Lh,Ll,0
mov dptr,#msg1 sjmp rd1 end
sjmp read 
timer: mov tmod,#10h ;set mode 1 for