8/2/2019 Scroll Pad2
1/48
SUBMITTED BY:
Raman BediAmit SharmaAshish Dhiman
Arvind Chauhan
SCROLL PAD
8/2/2019 Scroll Pad2
2/48
SCROLL PAD
Implementation Environment
1. Microcontroller
The microcontroller we have used is AT89S52 which belongs to 8052 series of
microcontrollers and is a member of 8051 family. The 8052 has all the standard features
of 8051 as well as an extra 128 bytes of RAM and an extra timer. In other words, the
8052 has 256 bytes of RAM and 3 timers. It also has 8k bytes of on-chip ROM instead
of 4Kbytes. All programs written for the 851 will run on the 8052, but the reverse is not
true.
Feature 8051 8052
ROM (on-chip program space in bytes) 4K 8K
RAM (bytes) 128 256
Timers 2 3
I/O pins 32 32
Serial port 1 1
Interrupt sources 6 8
Table i: Comparison between 8051 and 8052
SSGPURC,Hoshiarpur
2
8/2/2019 Scroll Pad2
3/48
SCROLL PAD
SSGPURC,Hoshiarpur
3
8/2/2019 Scroll Pad2
4/48
SCROLL PAD
Figure i: Pin configuration of Microcontroller
8052 micro controller has 4 ports. These are port0, port1, port2, port3 which can be
accessed as I/0 ports. The pins of the micro controller are explained below.
1. Reset: It resets total 8052 micro controller.
2. RXD: It receives data in serial communication.
3. TXD: It transmits data in serial communication.
4. INT0: External interrupt for timer 0.5. INT1: External interrupt for timer1
6. T0: Timer0.
7. T1: Timer1.
8. RD: To read into external memory.
9. WR: To write into external memory.
10. XTAL1 & XTAL2: To connect the crystal oscillator.
11. ALE: Address latch enable which is used to access the address locations
from external memory.
12. PSEN: Program store enable which is used for storing programming code
into the external memory.
13. EA: External Access: 64 KB of ROM is the limit for external memory.
The 8052 has an on-chip oscillator but requires an external clock to run it. A quartz
crystal oscillator is to be connected to the inputs XTAL1 (pin19) and XTAL2 (pin18).
The quartz crystal oscillator also needs two capacitors of 30 pF value.
SSGPURC,Hoshiarpur
4
8/2/2019 Scroll Pad2
5/48
SCROLL PAD
Figure ii: Oscillators connections.
The speed of 8052 refers to the maximum oscillator frequency connected to XTAL. For
example a 12-MHz chip must be connected to a crystal with 12 MHz frequency or less.We can observe the frequency on the
XTAL2 pin using the oscilloscope
RST: RESET pin is an input and is active high (normally low). Upon applying a high
pulse to this pin, the microcontroller will reset and terminate all activities. This is often
referred to as a power-on reset. Activating a power-on reset will cause all values in the
registers to be lost.
In order for the RESET input to be effective, it must have a minimum duration of 2
machine cycles. In other words, the high pulse must be high for a minimum of 2
machine cycles before it is allowed to go low.
SSGPURC,Hoshiarpur
5
8/2/2019 Scroll Pad2
6/48
SCROLL PAD
Figure iii: Reset circuitry.
EA, external access, is an input pin and must be connected to Vcc or GND. The 8051
family members all come with on-chip ROM to store programs. So, EA pin is connected
to Vcc.
The 8031 and 8032 family members do not have on-chip ROM, so code is stored on an
external ROM and is fetched by 8031/32. So, EA pin must be connected to GND to
indicate that the code is stored externally.
The following two pins are used mainly in 8031-based systems:
1. PSEN, program store enable, is an output pin. This pin is connected to
the OE pin of the ROM.
2. ALE, address latch enable, is an output pin and is active high.
Port 0 provides both address and data. The 8031 multiplexes address and data through
port 0 to save pins ALE pin is used for demultiplexing the address and data by
connecting to the G pin of the 74LS373 chip.
The four 8-bit I/O ports P0, P1, P2 and P3 each uses 8 pins. All the ports upon RESET
are configured as output, ready to be used as input ports.
Port 0 is also designated as AD0-AD7, allowing it to be used for both address and data.
When connecting an 8051/31 to an external memory, port 0 provides both address and
SSGPURC,Hoshiarpur
6
8/2/2019 Scroll Pad2
7/48
SCROLL PAD
data. The 8051 multiplexes address and data through port 0 to save pins. ALE indicates
if P0 has address or data
When ALE=0, it provides data D0-D7
When ALE=1, it has address A0-A7
It can be used for input or output, each pin must be connected externally to a 10K ohm
pull-up resistor. This is due to the fact that P0 is an open drain, unlike P1, P2, and P3.
Open drain is a term used for MOS chips in the same way that open collector is used for
TTL chips
Figure iv: Port 0 connections.
In 8051-based systems with no external memory connection, both P1 and P2 are used as
simple I/O. In 8031/51-based systems with external memory connections, port 2 must be
used along with P0 to provide the 16-bit address for the external memory.
P0 provides the lower 8 bits via A0 A7.
P2 is used for the upper 8 bits of the 16-bit address, designated as A8 A15, and it
cannot be used for I/O
Port 3 can be used as input or output
Port 3 does not need any pull-up resistors. It has the additional function of providing
some extremely important signals.
SSGPURC,Hoshiarpur
7
8/2/2019 Scroll Pad2
8/48
SCROLL PAD
Figure v: Port 3 pins.
1. Information Engineering
National Cheng Kung University 28HANEL
2. Software & Hardware used
As we know that the microcontroller is a programmable device and can perform or give
output as per the program burnt into it. The program can be burnt into it using a
programmer (hardware) and software installed in a computer. The program can be burnt
by connecting the COM port of the computer to the RS 232 port of the programmer
using DB9 connector. The programmer burns the program into the microcontroller
through its serial communication ports.
SSGPURC,Hoshiarpur
8
8/2/2019 Scroll Pad2
9/48
SCROLL PAD
Software for programming
ASM51
The programs were written in assembly language using notepad as an editor and weresaved with .asm as the extension. ASM51 is an assembler which assembles the files
with .asm in the folder and generates two files in the same folder with .hex and .list as
the extensions. The .hex file contains the hex conversion of the program and the .list file
contains the errors if any. It is the .hex file which is burnt into the microcontroller.
Software for Simulation
Proteus
Proteus is a simulating software which is used to make the circuits and then to check the
output according to the programming done. The hex file of the program is loaded into
the microcontroller used in the circuit and is simulated to check whether the output is
the desired one or not.
Software for burning programISP Flash Programmer 3.0a
SSGPURC,Hoshiarpur
9
8/2/2019 Scroll Pad2
10/48
SCROLL PAD
ISP Flash Programmer 3.0ais software for burning program into microcontroller. This
software basically acts as an interface for setting up the communication between the
computer and the programmer in which the microcontroller is plugged. Any one of the
COM ports can be used for communication. Usually COM 2 is used as COM 1 is used
by the mouse. The software can be set for programming different types of
microcontrollers. After setting it for the microcontroller being used, the hex file of the
program is loaded and is burnt into the microcontroller with the help of the programmer.
Figure ix: ASM51 working screen
SSGPURC,Hoshiarpur
10
8/2/2019 Scroll Pad2
11/48
SCROLL PAD
Figure x: Proteus working screen
Figure xi: ISP working screen
SSGPURC,Hoshiarpur
11
8/2/2019 Scroll Pad2
12/48
SCROLL PAD
Programmer kit
A programmer is used to burn the hex file into the ROM of the microcontroller. This
programmer can be connected to the COM port of the computer using DB9 connector.
The microcontroller is plugged into the socket and then the hex file is burnt into the
ROM of the microcontroller with the help of software mentioned above.
SSGPURC,Hoshiarpur
12
8/2/2019 Scroll Pad2
13/48
SCROLL PAD
Figure xii: Programmer kit
III. Work Done
1. LCD Interfacing
LCD
LCD stands for Liquid Crystal Display. It is basically used to display data replacing
LEDs (seven segment LEDs or multisegment LEDs). This is due to following reasons:
1. The declining prices of LCDs.
2. The ability to display numbers, characters and graphics.
3. Ease for programming for characters and graphics.
We have studied about 16*2 alphanumeric LCD which can display data in 2 lines.
SSGPURC,Hoshiarpur
13
8/2/2019 Scroll Pad2
14/48
SCROLL PAD
Figure xiii: 16*2 alphanumeric LCD
LCD pin description
Pin Symbol I/O Description1 VSS - Ground
2 VCC - +5V power supply
3 VEE - Power supply to control contrast
4 RS I RS=0 to select command register, RS=1 to select data
register.
5 R/W I R/W=0 for write, R/W=1 for read
6 E I/O Enable
7 PB0 I/O The 8 bit data bus
8 PB1 I/O The 8 bit data bus
9 DB2 I/O The 8 bit data bus
10 DB3 I/O The 8 bit data bus
11 DB4 I/O The 8 bit data bus
12 DB5 I/O The 8 bit data bus
13 DB6 I/O The 8 bit data bus
14 DB7 I/O The 8 bit data bus
SSGPURC,Hoshiarpur
14
8/2/2019 Scroll Pad2
15/48
SCROLL PAD
Table i: LCD pin description
Interfacing LCD with MCU
SSGPURC,Hoshiarpur
15
8/2/2019 Scroll Pad2
16/48
SCROLL PAD
Figure xiv: Interfacing LCD with MCU
From the above picture it is clear that the data pins of the LCD are connected to P1 of
the microcontroller. The control pins i.e. RS, R/W and E of the LCD are connected to
P2.5, P2.4 and P2.3 respectively. The program for displaying SCROLL PAD on the
LCD is given below.
SSGPURC,Hoshiarpur
16
8/2/2019 Scroll Pad2
17/48
8/2/2019 Scroll Pad2
18/48
SCROLL PAD
acall delay
clr p2.3
ret
datawrt: mov p1, a ; Display subroutine.
setb p2.5
clr p2.4
setb p2.3
acall delay
clr p2.3
ret
delay: mov r2, #10
here2: mov r3, #255
here1: djnz r3, here1
djnz r2, here2
ret
org 0100h
db 'SCROLL PAD'
end
SSGPURC,Hoshiarpur
18
8/2/2019 Scroll Pad2
19/48
SCROLL PAD
4. Project Description
Scroll pad
SSGPURC,Hoshiarpur
19
8/2/2019 Scroll Pad2
20/48
SCROLL PAD
Introduction
What is Scroll pad?
It is 8052 based device which can type alphabets, numerals and some other charactersinto the LCD with just a finger scroll. The finger is to be scrolled on a particular pattern
made on the pad in the shape of the character you want to be type.
Need and use of Scroll pad?
Today we are living in the world full of hi-tech gadgets which perform different tasks
efficiently and with minimum human effort. Scroll pad is such a gadget although not so
hi-tech but good enough to sense the motion of a finger resembling English alphabets,
numerals and some other characters and displays the corresponding character on the
LCD fixed above it. Hence this scroll pad reduces human effort as compared to typing
the same text using a keyboard. Moreover with further advancements in this scroll pad,
the usage of the keyboards having large number of keys on it as compared to just few
touch sensors of the scroll pad can be eliminated.
Once the text has been written into the LCD, it can be transferred to a distant LCD for
data presentations. This facility can be used by the professors to deliver the lectures by
writing on the scroll pad in place of boards and then displaying the written data on a
distant LCD for the students to view it. Now, as the lecture delivered has been converted
into electrical form so it can be saved or can be converted into a hard copy.
The concept of sending the data from scroll pads LCD to a distant LCD can be used for
writing the data into the LCD or LED screens used as notice boards. Hence the data can
be written into these screens from a distant place and also without the use of computers.
These could be the few uses of the scroll pad, which could be increased in numbers with
the further advancements in it.
SSGPURC,Hoshiarpur
20
8/2/2019 Scroll Pad2
21/48
SCROLL PAD
Overview
Scroll pad is a set of ten touch sensors. Eight out of which are arranged in a particular
pattern and other two are used for giving commands. These are DISPLAY and
TRANSFER. All these touch sensors are made by using BC547 which is an npn
transistor. The pattern made by the arrangement of eight touch sensors senses the
motion of a finger being scrolled upon it. Once the scrolling is finished, touch
DISPLAY. If the motion of the finger resembles any of the English alphabets (A to Z)
or any of the numerals (0 to 9), then the corresponding character will displayed on the
LCD fixed above it. Along with the alphabets and numerals $, *, -, +, =, < and > can
also be sensed and displayed by the scroll pad. After the text has been written into the
LCD, it can be transferred to a distant LCD. The command for transmission is be given
with just a touch on TRANSFER.
Figure xix: Circuit Model of Scroll pad
Block Diagram of Scroll pad
SSGPURC,Hoshiarpur
21
8/2/2019 Scroll Pad2
22/48
SCROLL PAD
SSGPURC,Hoshiarpur
22
8/2/2019 Scroll Pad2
23/48
SCROLL PAD
Figure xx: Block Diagram of Scroll Pad.
Touch Sensors
The touch sensors used here are made up of BC547 npn transistors. We know thatwhenever npn transistor in CE configuration is supplied with a small value of current at
its base terminal, it acts as a switch i.e. conduction between collector and emitter takes
place. This property of npn transistor is used here.
In a touch sensor, the current to the base is provided by the touch of a finger. The finger
should also be in contact with Vcc. Here, the conductive nature of human body comes
into play.
Now, here a question could arise that Can we use a conductor in place of finger?
The answer to the question is NO. Because if a conductor is used then the current
flowing into the base will not be in small amount and will destroy the transistor. In other
words, applying directly +5v to the base of npn transistor in CE configuration will
destroy it as a result of short circuit.
SSGPURC,Hoshiarpur
23
8/2/2019 Scroll Pad2
24/48
SCROLL PAD
Now, the circuit of this basic touch sensor is slightly modified in order to get a more
useful touch senssor which can be used in the main circuit.
Here, when the biasing is provided, the conduction between C and E takes place and the
output will be approximately 0v as all the voltage will drop across 10 k resistor. And
when the biasing is not provided, there will be no conduction between C and E and
hence the output will be approximately +5v.
The output we get from this touch sensor is in analog form whereas we require a digital
one. For this a comparator is used, which compares the analog voltage with a fixed
reference voltage and gives digital voltage which can be fed directly to the
microcontroller.
SSGPURC,Hoshiarpur
24
8/2/2019 Scroll Pad2
25/48
SCROLL PAD
Analog to digital conversion
The output of the sensor we get will be analog in nature. So, if we are using this output
to drive microcontroller, we will need to convert this to a digital signal first. That can be
done in two ways:
1. using comparators.
2. using ADCs(Analog-to-Digital Converters).
I will be using the comparator as its very easy to handle and also cheap. After the
comparator, we will get a signal that can be directly fed to the micro-controller.
Figure xxiii: LM324 Comparator
SSGPURC,Hoshiarpur
25
8/2/2019 Scroll Pad2
26/48
SCROLL PAD
Pin Diagram of LM324
This device consists of four independent precision voltage comparators with an offset
voltage specifications as low as 2mV. This comparator is designed to specifically
operate from a single power supply over a wide range of voltages. Operation from split
power supplies is also possible. This comparator also has aunique characteristic whichis that the input common-mode voltage range includes ground even though operated
from a single power supply voltage.
SSGPURC,Hoshiarpur
26
8/2/2019 Scroll Pad2
27/48
SCROLL PAD
Figure xxiv: Pin Diagram of LM324
Touch Sensor Circuit
Figure xxv: Touch Sensor circuit
The analog output that we get from the transistor will be compared with a fixed
reference voltage. This reference voltage is set by varying the slider of the
potentiometer. If the transistors ouptput voltage is greater than the reference voltage
then the outout will be +5v and viceversa. Hence, the analog voltage has been converted
into digital form which can be fed directly to the microcontroller.
In the scroll pad 10 touch sensors will be used. So, it is not convenient to touch the base
terminal of the transistors directly. Thus a surface for touch is developed on a copper
clad PCB using PCB printing technique. This has also helped in arranging the sensors
SSGPURC,Hoshiarpur
27
8/2/2019 Scroll Pad2
28/48
SCROLL PAD
according to a fixed pattern. The pattern developed on the PCB looks like the figure
shown below.
Figure xxvi: Scroll Pads Pattern.
As we can see that the red color represents Vcc. It is along this pattern the finger shouldbe scrolled. During scrolling the finger already touching Vcc will come in contact with
the two adjacent touch sensors. As the finger is moved, the set of two adjacent sensors
keep on changing. Hence, different signals will be generated while scrolling. These sets
of signals are continuously saved by the mic. At last the mic will display the
SSGPURC,Hoshiarpur
28
8/2/2019 Scroll Pad2
29/48
SCROLL PAD
corresponding character if the scrolled set matches with a stored set. The character will
be displayed only if DISPLAY is touched.
Once the character has been displayed, it can be sent to a distant LCD with the touch on
TRANSFER.
Microcontroller
The AT89S52 is a low-power, high-performance CMOS 8-bit microcomputer with
8Kbytes of Flash Programmable and Erasable Read Only Memory (PEROM).
The device is manufactured using Atmels high density nonvolatile memory
Technology. The on-chip Flash allows the program memory to be reprogrammed in-
system or by a conventional nonvolatile memory programmer. By combining a versatile
8-bit CPU with Flash on a monolithic chip, the Atmel AT89S52 is a powerful
microcomputer which provides a highly flexible and cost effective solution to many
embedded control applications. The AT89S51 provides the following standard features:
8Kbytes of Flash, 256 bytes of RAM, 32 I/O lines, three 16-bit timer/counters, five
vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator and
clock circuitry. In addition, the AT89S52 is designed with static logic for operation
down to zero frequency and supports two software selectable power saving modes. TheIdle Mode stops the CPU while allowing the RAM, timer/counters, serial port and
interrupt system to continue functioning. The Power down Mode saves the RAM
contents but freezes the oscillator disabling all other chip functions until the next
hardware reset.
SSGPURC,Hoshiarpur
29
8/2/2019 Scroll Pad2
30/48
SCROLL PAD
Onboard Pin Connections
Scroll Pad
SSGPURC,Hoshiarpur
30
8/2/2019 Scroll Pad2
31/48
SCROLL PAD
SSGPURC,Hoshiarpur
31
8/2/2019 Scroll Pad2
32/48
SCROLL PAD
SSGPURC,Hoshiarpur
32
8/2/2019 Scroll Pad2
33/48
SCROLL PAD
Circuit Diagram of SROLL PAD
Figure xxvii: Scroll Pad
SSGPURC,Hoshiarpur
33
8/2/2019 Scroll Pad2
34/48
SCROLL PAD
Construction Procedure of APSPS
Step 1: Circuit diagram of the proposed system is designed and finalized
Step 2: All the components and software platform to be used are selected which are also
mentioned above.
Step 3: The scroll pads pattern is designed and then developed on the copper clad PCB.
Step 4: All the hardware components are soldered on PCB with the help of soldering
ion, solder and flux.
Step 5: Code/program of the proposed system is developed using assembly language
with the help of software platform (Keil u vision3).The coding could be seen in section.
Step 6: The hex code of the program being created by the software platform is burnt
into the flash code memory of our microcontroller IC AT89C52.
Step 7: Testing is done at various levels to finalize the appropriate program for the most
proper working of the system.
SSGPURC,Hoshiarpur
34
8/2/2019 Scroll Pad2
35/48
SCROLL PAD
Program
Scroll Pad
; p0 =====> SCROLL PAD, is a matrix of 8 touch sensors to sense scrolling
; on 16 different lines. Each line is sensed by a set of 2 particular sensors.
; p2.0 =====> TRANSFER, is a touch sensor for transferring data from scroll
; pad's LCD to a distant LCD through RF communication.
; p2.1 =====> DISPLAY, is a touch sensor for comparing the lines being
; scrolled upon with the previously stored set of lines (representing different
; characters). And then displaying the corresponding character on scroll pad's LCD.
; p2.2 =====> LED, it glows after a line is being scrolled upon, while touching
; DISPLAY, TRANSFER and while transferring the data to a distant LCD.
; p2.3 =====> E (scroll pad's LCD)
; p2.4 =====> R/W (scroll pad's LCD)
; p2.5 =====> RS (scroll pad's LCD)
; p1 =====> Data Lines (scroll pad's LCD)
SSGPURC,Hoshiarpur
35
8/2/2019 Scroll Pad2
36/48
SCROLL PAD
;-------------------------------------------------------------------------------------------------------;-
------------------------------------------------------------------------------------------------------
$include(mod51)
org 0000h
mov p0, #0ffh ; For p0 as an i/p port.
lcall LCD_init
main: mov r1, #31h ; Initial RAM address where the
; lines being scrolled upon will be stored.
mov 30h, #0 ; Initialised to zero for comparison
; purposes.
mov r2, #0 ; Counter for counting the lines being
; scrolled upon.
again: mov dptr, #lines ; Dptr pointing the lines stored in ROM
; for comparison.
mov a, p0 ; Getting a byte from the scroll pad.
cjne a, #0ffh, line_match ; Checking for any touch
; on scroll pad.
jnb p2.1, label ; Checking for a touch on DISPLAY.
jnb p2.0, transfer; Checking for a touch on TRANSFER.
sjmp again
label: clr p2.2 ; LED is switched on, representing
; DISPLAY has been touched.
lcall delay2
jb p2.1, label1 ; Checking if DISPLAY is released.
sjmp label
label1: setb p2.2 ; LED is switched off, representing
SSGPURC,Hoshiarpur
36
8/2/2019 Scroll Pad2
37/48
SCROLL PAD
; DISPLAY has been released.
mov a, r2
cjne a, #0, label2 ; Checking the counter, if
; lines are stored in RAM.
sjmp again
label2: mov dptr, #characters ; Dptr ponting sets of lines (representing
; characters) stored in ROM.
sjmp ch_mtch_dsp
transfer: clr p2.2 ; LED is switched on, representing
; TRANSFER has been touched.
lcall delay2
jb p2.0, transfer1 ; Checking if TRANSFER is released.
sjmp transfer
transfer1: mov a, r7
cjne a, #0, transfer2 ; Checking the cursor's
; counter, if any character ;
is displayed on LCD.
setb p2.2
sjmp again
transfer2: mov r6, #41h ; Initial RAM address where the
; characters displayed (to be transferred)
; are be stored.
mov a, r7 ; Counter representing the number of
; characters have been displayed.
mov r3, a
inc r3
trsfr1: mov r4, #4
mov a, r6
mov r0, a
SSGPURC,Hoshiarpur
37
8/2/2019 Scroll Pad2
38/48
SCROLL PAD
mov a, @r0
trsfr: rrc a
mov p3.7, c ; Character is being transferred with 2
; bits at a time, starting from LSB.
rrc a
mov p3.6, c
clr p3.5
lcall delay1
setb p3.5
lcall delay1
djnz r4, trsfr
inc r6
djnz r3, trsfr1
setb p2.2
sjmp main
line_match: mov r3, a ; Storing the received byte.
mov r4, #0 ; Counter for line matching.
again1: mov a, r4
movc a, @a+dptr
cjne a, #0, match1 ; Checking for null
; character.
sjmp again
match1: clr c
subb a, r3
cjne a, #0, next_line ; Checking
; whether the line is
; matched.
clr p2.2 ; LED is switched on, representing a line
; has been scrolled upon.
SSGPURC,Hoshiarpur
38
8/2/2019 Scroll Pad2
39/48
8/2/2019 Scroll Pad2
40/48
SCROLL PAD
sjmp again1
;---------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
ch_mtch_dsp: clr a
movc a, @a+dptr
mov r3, a ; Storing character.
mov a, #1
movc a, @a+dptr
mov r4, a ; Storing ROM counter.
clr c
subb a, r2
cjne a, #0, below5 ; Checking whether the
; counter is equal to that in r1.
mov r6, #2 ; For first line of the stored character.
again2: mov a, r1
mov r0, a ; Storing RAM address.
dec r0
mov a, r2
mov r5, a ; Storing RAM counter.
again3: mov a, r6
movc a, @a+dptr
cjne a, #0, match2 ; Checking for null char.
mov a, r3
cjne a, #'/', display ; '/' is for deleting the
; character.
mov a, r7
cjne a, #0, first_line ; Jump to main if the
SSGPURC,Hoshiarpur
40
8/2/2019 Scroll Pad2
41/48
SCROLL PAD
; cursor is at initial position.
ljmp main
below5: sjmp next_char
first_line: cjne a, #16, del_char1 ; Jump to last position of
; 1st line if the cursor is at
; 1st position of 2nd line.
mov a, #8fh
acall command
acall delay
sjmp del_char2
del_char1: mov a, #10h ; For deleting the character.
acall command
acall delay
del_char2: mov p1, #' '
setb p2.5
clr p2.4
setb p2.3
acall delay
clr p2.3
mov a, #10h
acall command
acall delay
dec r7
dec 40h
stay: mov a, p0
cjne a, #0ffh, below1
jnb p2.1, below2
jnb p2.0, below3
sjmp stay ; Stay here untill DISPLAY is touched or
; any line is scrolled upon.
SSGPURC,Hoshiarpur
41
8/2/2019 Scroll Pad2
42/48
SCROLL PAD
below1: ljmp main
below2: ljmp label
below3: ljmp transfer
display: mov a, r7
cjne a, #16, display1
mov a, #0c0h ; Forcing the cursor to 1st position of 2nd line.
acall command
acall delay
display1: cjne a, #32, display2 ; Initialise the LCD if the
; 16th position of 2nd line
; has been written.
lcall LCD_init
display2: mov p1, r3 ; Displaying the char.
setb p2.5
clr p2.4
setb p2.3
acall delay
clr p2.3
inc r7
mov r0, 40h
mov a, r3
mov @r0, a
inc 40h
sjmp stay
match2: clr c
subb a, @r0
cjne a, #0, next ; Checking if the lines of the
; character in ROM matches with
; the lines stored in RAM.
inc r6 ; Incrementing for next line in ROM.
SSGPURC,Hoshiarpur
42
8/2/2019 Scroll Pad2
43/48
SCROLL PAD
ljmp again2
next: dec r0
djnz r5, again3 ; Decrementing r4 & r5 for previous line
; stored in RAM.
next_char: mov a, r4
add a, #3
mov r4, a
incr: inc dptr ; Incrementing dptr for next character
; stored in ROM.
djnz r4, incr
clr a
movc a, @a+dptr
cjne a, #'!', below4 ; Checking for an invalid
; set of scrolled lines.
ljmp main
below4: ljmp ch_mtch_dsp
LCD_init: mov r7, #0 ; Counter for LCD's cursor position or for
; counting the number of characters that
; have been displayed.
mov 40h, #42h ; Initial RAM address for storing the
; characters to be transferred.
mov 41h, #'!' ; For comparison purpose.
mov a, #38h ; LCD's initialisation.
acall command
acall delay
mov a, #0eh
acall command
acall delay
mov a, #01h
acall command
SSGPURC,Hoshiarpur
43
8/2/2019 Scroll Pad2
44/48
SCROLL PAD
acall delay
mov a, #06h
acall command
acall delay
mov a, #80h
acall command
acall delay
ret
command: mov p1, a
clr p2.5
clr p2.4
setb p2.3
acall delay
clr p2.3
ret
delay: mov r0, #10
here2: mov r4, #255
here1: djnz r4, here1
djnz r0, here2
ret
delay1: mov r0, #255
here4: mov r5, #255
here3: djnz r5, here3
djnz r0, here4
ret
delay2: mov r0, #2
here7: mov r3, #255
here6: mov r4, #255
SSGPURC,Hoshiarpur
44
8/2/2019 Scroll Pad2
45/48
SCROLL PAD
here5: djnz r4, here5
djnz r3, here6
djnz r0, here7
ret
;---------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
org 0300h
lines: db 0ffh,0fah,0f6h,0edh,0f9h,0ddh,0f5h,0beh,7eh,7bh,0f3h,0e7h,0ebh,0dbh,0d7h,0b7h,3fh,0
characters: db 'A',8,1,2,3,4,7,8,12,16,0
db 'B',10,1,2,3,4,5,6,7,8,12,16,0
db 'C',6,1,2,5,6,7,8,0
db 'D',7,3,4,5,6,7,12,16,0
db 'E',8,1,2,5,6,7,8,12,16,0
db 'F',6,1,2,7,8,12,16,0
db 'G',8,1,2,4,5,6,7,8,12,0
db 'H',6,3,4,7,8,12,16,0
db 'I',6,1,2,5,6,10,14,0
db 'J',6,1,2,6,7,10,14,0
db 'K',4,10,11,13,14,0
db 'L',4,5,6,7,8,0
db 'M',6,3,4,7,8,9,11,0
db 'N',6,3,4,7,8,9,13,0
db 'O',8,1,2,3,4,5,6,7,8,0
db 'P',7,1,2,3,7,8,12,16,0
db 'Q',9,1,2,3,4,5,6,7,8,13,0
db 'R',8,1,2,3,7,8,12,13,16,0
SSGPURC,Hoshiarpur
45
8/2/2019 Scroll Pad2
46/48
SCROLL PAD
db 'S',8,1,2,4,5,6,8,12,16,0
db 'T',4,1,2,10,14,0
db 'U',6,3,4,5,6,7,8,0
db 'V',2,9,11,0
db 'W',6,3,4,7,8,13,15,0
db 'X',4,9,11,13,15,0
db 'Y',3,9,11,14,0
db 'Z',6,1,2,5,6,11,15,0
db '0',6,2,3,4,5,10,14,0
db '1',2,10,14,0
db '2',8,1,2,3,5,6,7,12,16,0
db '3',8,1,2,3,4,5,6,12,16,0
db '4',5,3,4,8,12,16,0
db '5',5,2,4,5,10,12,0
db '6',9,1,2,4,5,6,7,8,12,16,0
db '7',4,1,2,11,15,0
db '8',7,2,3,4,5,10,12,14,0
db '9',7,1,2,3,4,8,12,16,0
db '$',10,1,2,4,5,6,8,10,12,14,16,0
db '*',8,9,10,11,12,13,14,15,16,0
db '+',4,10,12,14,16,0
db '-',2,12,16,0
db '',2,9,15,0
space: db ' ',2,5,6,0
delete: db '/',2,11,15,0
invalid:db '!'
END
SSGPURC,Hoshiarpur
46
8/2/2019 Scroll Pad2
47/48
SCROLL PAD
V. References
Books referred:
1) The 8051 Microcontroller and Embedded Systems Using
Assembly and C By Muhammad Ali Mazidi, Janice Gillispie
Mazidi & Ro lin D. McKinlay
Websites referred:
1) Atmel Corp. Makers of the AVR microcontroller
www.atmel.com
2) One of the best sites AVR site www.avrfreaks.net
3) One of the best sites for Microcontroller projects
SSGPURC,Hoshiarpur
47
8/2/2019 Scroll Pad2
48/48
SCROLL PAD
www.kmitl.ac.th
4) Keil, the developer of Keilvision www.keil.com