gsm based security system
DESCRIPTION
communication projectTRANSCRIPT
Table of contents
Executive Summary ............................................................................................................. 2
Introduction ........................................................................................................................ 3
Part one .............................................................................................................................. 5
Hardware ............................................................................................................................ 5
Infrared Transmitter ....................................................................................................... 5
Infrared receiver ............................................................................................................. 6
Inverter gate (SN54/74LS04) .......................................................................................... 7
Microcontroller ............................................................................................................... 7
A Brief Introduction to 8051 Microcontroller ............................................................. 7
Pin Description of the AT89C55WD microcontroller: ............................................... 10
Interrupt .................................................................................................................... 12
Level-triggered interrupts ..................................................................................... 12
Enabling and disabling an interrupt .................................................................. 13
Serial Interrupt ...................................................................................................... 14
Serial data cable ............................................................................................................ 17
An Introduction to Nokia F-Bus ................................................................................ 18
The difference between F (Fast) bus and M (master) bus .................................... 18
Introduction to serial data cable (DB-9) ................................................................... 18
AT command supporting GSM mobile phone. ............................................................. 20
The phone we used for the project is an AT command supporting. At commands will
be explained in later topics later .................................................................................. 20
Part two ............................................................................................................................ 21
Software ........................................................................................................................... 21
Theory of Operation...................................................................................................... 21
Assembly Language ....................................................................................................... 23
Advantages of Assembly language .......................................................................... 23
ASM (assembly) form........................................................................................... 25
HEX (the program in hexadecimal values) form .................................................. 25
LST (list) form ...................................................................................................... 27
AT-Command set overview ....................................................................................... 30
Table 3: AT command set ......................................................................................... 30
AT command formats ............................................................................................... 30
The text mode ....................................................................................................... 30
PDU (protocol data unit) mode ............................................................................ 31
Coding 7-bit data (septets) into octets .............................................................. 31
ASCII Character Chart with Decimal, Binary and Hexadecimal Conversions .... 31
Sending a message in the PDU mode ....................................................................... 33
Serial Communication ................................................................................................... 35
Setting the Serial Port Mode ..................................................................................... 36
Setting the Baud rate ................................................................................................ 37
Application and future development ............................................................................... 38
Conclusion ......................................................................................................................... 39
Recommendation .............................................................................................................. 40
Reference materials .......................................................................................................... 41
Executive Summary
In today’s world, where the issue of security is of paramount importance, people,
institutions, government and non-government offices are concerned about it. And also
the field is growing with a very high pace.
This project, GSM BASED HOME SECURITY SYSTEM, is a system which works by using
Infrared sensors, Microcontroller, mobile transmitter and receiver units to alarm the
user of the system up on the intrusion of any unauthorized person or material in any
application area by sending text SMS to the user.
The GSM (Global system for Mobile communication) network, which we use in our daily
life for mobile communications, is utilized for different purposes other than simple voice
call services. And Security is one of the areas where GSM technology applies.
To make the microcontroller send SMS and make voice calls, the project exploited the
F/M protocol which applies in every mobile phone that supports AT commands.
A more specific block diagram representation of the project would be given in the
following form.
Fig.1 block diagram representation of the project
Fig.2 practical view of the block
Diagram
AT89C55
WD
Microcont
roller
Serial
Interface
Transmitte
r mobile
unit
Receiver
mobile
unit
IR
Receiver
Inverter
Gate
IR
Transmitter
AT89C55
WD
Serial
Connec
tion
SMS
IR
Sensor PORT1
And in practical ways we can view the system as the following diagram.
Introduction
There is a growing interest in intelligent home network as a way to offer a comfortable,
convenient and safe environment for occupants. In order to enhance the occupants’
convenience and safety, home security system is indispensable in the field of intelligent
home network. The requirements of a home security system include low cost, low
power consumption, easy installation and rapid response to alarm incidents.
How to inform user in real time when alarm incidents occur has become a crucial
feature of home security system. This can be done via internet or GSM. GSM is more
convenient than internet. The main reason is that the GSM network has wide spread
coverage making the whole system available for almost all the time. Furthermore, GSM
network has high security infrastructure which makes sure that the information sent or
received cannot be monitored
The project is aimed at developing the security of Home against Intruders. In this case,
while you are out of your home and a place is intruded then the device sends SMS to
the emergency number provided to it.
The report consists of a background into the area of 8051 microcontroller and mobile
communication, how they are interfaced to each other and AT (Attention) command
sets used in communication.
The project can be effectively applied to the following areas:-
• Home security- to monitor intrusion
• In monitoring restricted area, military areas
• In monitoring cash lockers
Furthermore by changing the sensors, signal conditioning elements and by
applying some changes on the microcontroller program it can also be applied for
• Fire alarm
• Sound level monitoring
• Pressure, water level, humidity monitoring etc…
Such security and also microcontroller based projects has not been made
previously in our department, and hence the project is not a continuation or based on
previous works.
Part one
Hardware The following materials are the hard ware components employed for this project.
1. Infrared Transmitter
2. Infrared receiver
3. Inverter gate (SN54/74LS04)
4. AT89C55WD Microcontroller
5. Serial cable
6. AT command supporting GSM mobile phone.
Infrared Transmitter Infra-Red actually is normal light with a particular colour. Humans can't see this
colour because its wave length of 950nm is below the visible spectrum. That's one of the
reasons why IR is chosen for remote control purposes or for detecting intrusion in our
case.
The infrared transmitter (LED) usually is a battery powered component. It should
consume as little power as possible, and the IR signal should also be as strong as possible
to achieve an acceptable control distance. Preferably it should be shock proof as well.
The current through the LED (or LEDs) can vary from 100mA to well over 1A.
In order to get an acceptable control distance the LED currents have to be as high as
possible. A trade-off should be made between LED parameters, battery lifetime and
maximum control distance. LED currents can be that high because the pulses driving
the LEDs are very short. Average power dissipation of the LED should not exceed the
maximum value though. You should also see to it that the maximum peek current for
the LED is not exceeded. All these parameters can be found in the LED's data sheet.
A simple transistor circuit can be used to drive the LED. A
transistor with a suitable HFE (transistor current gain) and switching
speed should be selected for this purpose. The resistor values can
simply be calculated using Ohm's law. The nominal voltage drop over
an IR LED is approximately 1.1V.
R
R
The normal driver, described above, has one disadvantage. As
the battery voltage drops, the current through the LED will decrease
as well. This will result in a shorter control distance that can be
covered.
fig.3 I/R transmitters
An emitter follower circuit can avoid this. The 2 diodes in
series will limit the pulses on the base of the transistor to 1.2V. The base-emitter
voltage of the transistor subtracts 0.6V from that, resulting in constant amplitude of
0.6V at the emitter. This constant amplitude across a constant resistor results in
current pulses of a constant magnitude. Calculating the current through the LED is
simply applying Ohm's law again.
Infrared receiver
In the picture below we can see a typical block diagram of an IR receiver.
The received IR signal is picked up by the IR detection diode on the left side of the
diagram. This signal is amplified and limited by the first 2 stages. The limiter acts as
an AGC circuit to get a constant pulse level, regardless of the distance to the
transmitter.
Fig.4 I/R receiver
As we can see only the AC signal is sent to the Band Pass Filter. The Band Pass
Filter is tuned to the modulation frequency of the transmitter unit. Common
frequencies range from 30 KHz to 60 KHz in consumer electronics.
The next stages are a detector (demodulator), integrator and comparator. The
purpose of these three blocks is to detect the presence of the modulation frequency. If
this modulation frequency is present the output of the comparator will be pulled low.
All these blocks are integrated into a single electronic component. There are
many different manufacturers of these components on the market. And most devices
are available in several versions each of which are tuned to a particular modulation
frequency.
Fig.5 integrated
I/R receiver
Inverter gate (SN54/74LS04)
In digital logic, an inverter or NOT gate is a logic gate which implements logical
negation. The truth table is shown below
Fig.6: Typical inverter gate
In our case we used the SN54/74LS04 which is a group of 6 inverters found in an
IC form. The purpose of this inverter gate in our case is to invert the signal from the
receiver unit so that it changes the normally high state of the receiver (low state at the
output of the inverter) to high state, so that the intrusion (low state at the receiver) is
detected.
Fig. 7: SN54/74LS04 inverter gate
Microcontroller
A Brief Introduction to 8051 Microcontroller
When we have to learn about a new computer we have to familiarize about the
machine capability we are using, and we can do it by studying the internal hardware
design (devices architecture), and also to know about the size, number and the size of
the registers.
INPUT A
OUTPUT NOT A
0 1
1 0
Vcc
7 2 3 4 5 6 1
8 9 10 11 12 14 13
GND
Table 1: Truth
table for
Inverter Gate
A microcontroller is a single chip that contains the processor (the CPU), non-
volatile memory for the program (ROM or flash), volatile memory for input and output
(RAM), a clock and an I/O control unit. Also called a "computer on a chip," billions of
microcontroller units (MCUs) are embedded each year in a myriad of products from toys
to appliances to automobiles. For example, a single vehicle can use 70 or more
microcontrollers. The following picture describes a general block diagram of
microcontroller.
The following are some of the capabilities of 8051 microcontroller.
� Internal ROM and RAM
� I/O ports with programmable pins
� Timers and counters
� Serial data communication
The 8051 architecture consists of these specific features:
� 16 bit PC &data pointer (DPTR)
Fig.8: Block
diagram of
microcontroller
� 8 bit program status word (PSW)
� 8 bit stack pointer (SP)
� Internal ROM 4k
� Internal RAM of 128 bytes.
� 4 register banks, each containing 8 registers
� 80 bits of general purpose data memory
� 32 input/output pins arranged as four 8 bit ports: P0-P3
� Two 16 bit timer/counters: T0-T1
� Two external and three internal interrupt sources Oscillator
and clock circuits.
The microcontroller used in this project is Atmel’s AT89C55WD. The AT89C55WD is a
low-power; high-performance CMOS 8-bit microcomputer with 20K bytes of Flash
programmable read only memory and 256 bytes of RAM. The device is manufactured
using Atmel’s high-density nonvolatile memory technology and is compatible with the
industry standard 80C51 and 80C52 instruction set and pin out. The on-chip Flash allows
the program memory to be user programmed by a conventional nonvolatile memory
programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the
Atmel AT89C55WD is a powerful microcomputer which provides a highly flexible and
cost effective solution to many embedded control applications.
The AT89C55WD provides the following standard features:
• 20K bytes of flash, 256 bytes of RAM, 32 I/O lines, three 16-bit timer/counters, a
six-vector, two-level interrupt architecture, a full-duplex serial port, on-chip
oscillator, and clock circuitry.
• In addition, the AT89C55WD is designed with static logic for operation down to
zero frequency and supports two software selectable power saving modes. The
Idle 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 external interrupt or hardware reset.
The pin diagram of the 8051 shows all of the input/output pins unique to
microcontrollers:
Pin Description of the AT89C55WD microcontroller:
• VCC: Supply voltage.
• GND: Ground.
• Port 0: Port 0 is an 8-bit open-drain bi-directional I/O port. As an output port,
each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins
can be used as high impedance inputs. Port 0 may also be configured to be the
multiplexed low order address/data bus during accesses to external program and
data memory. In this mode P0 has internal pull-ups. Port 0 also receives the code
bytes during Flash programming, and outputs the code bytes during program
verification. External pull-ups are required during program verification
• Port 1: Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port
1 output buffers can sink/source four TTL inputs. When 1s are written to Port 1
pins they are pulled high by the internal pull-ups and can be used as inputs. As
Fig. 9: 8051 family
microcontroller chip
inputs, Port 1 pins that are externally being pulled low will source current (IIL)
because of the internal pull-ups. Port 1 also receives the low-order address bytes
during Flash programming and verification.
• Port 2: Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The Port
2 output buffers can sink/source four TTL inputs. When 1s are written to Port 2
pins they are pulled high by the internal pull-ups and can be used as inputs. As
inputs, Port 2 pins that are externally being pulled low will source current (IIL)
because of the internal pull-ups. Port 2 emits the high-order address byte during
fetches from external program memory and during accesses to external data
memory that uses 16-bit addresses (MOVX @ DPTR). In this application, it uses
strong internal pull-ups when emitting 1s. During accesses to external data
memory that uses 8-bit addresses (MOVX @ RI), Port 2 emits the contents of the
P2 Special Function Register. Port 2 also receives the high-order address bits and
some control signals during Flash programming and verification.
• Port 3
Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 3 output buffers
can sink/source four TTL inputs. When 1s are written to Port 3 pins they are pulled high
by the internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are
externally being pulled low will source current because of the pull-ups. Port 3 also
serves the functions of various special features of the AT89C51 as listed below:
Table 2: pin description of port 3
Port Pin Alternate Functions
P3.0 RXD (serial input port)
P3.1 TXD (serial output port)
P3.2 INT0 (external interrupt 0)
P3.3 INT1 (external interrupt 1)
P3.4 T0 (timer 0 external input)
P3.5 T1 (timer 1 external input)
P3.6 WR (external data memory write strobe)
P3.7 RD (external data memory read strobe)
Interrupt
As the name implies, an interrupt is some event which interrupts normal program
execution.
Program flow is always sequential, being altered only by those instructions which
expressly cause program flow to deviate in some way. However, interrupts give us a
mechanism to "put on hold" the normal program flow, execute a subroutine, and then
resume normal program flow as if we had never left it. This subroutine, called an
interrupt handler, is only executed when a certain event (interrupt) occurs. The event may
be one of the timers "overflowing," receiving a character via the serial port, transmitting a
character via the serial port, or one of two "external events."(INT0, INT1)
The 8051 may be configured so that when any of these events occur the main program is
temporarily suspended and control passed to a special section of code which presumably
would execute some function related to the event that occurred. Once complete, control
would be returned to the original program. The main program never even knows it was
interrupted.
The ability to interrupt normal program execution when certain events occur makes it
much easier and much more efficient to handle certain conditions. If it were not for
interrupts we would have to manually check in our main program whether the timers had
overblown, whether we had received another character via the serial port, or if some
external event had occurred.
Interrupts can be triggered externally in two ways.
Edge triggered and
Level triggered
Level-triggered interrupts
– INT0 and INT1 pins are normally high
– if low-level signal is applied, it triggers the interrupt
– microcontroller stops whatever it is doing and jumps to the interrupt
vector table to service the interrupt
– the low level signal must be removed before the execution of the last
instruction of the interrupt service routine, RETI
– otherwise, another interrupt will be generated
Edge triggered interrupt
is a class of interrupts that are signaled by a level transition on the interrupt line,
either a falling edge (1 to 0) or a rising edge (0 to 1). A device wishing to signal an
interrupt drives a pulse onto the line and then releases the line to its quiescent state. If
the pulse is too short to be detected by polled I/O then special hardware may be
required to detect the edge.
Enabling and disabling an interrupt
– upon reset all interrupts are disabled
– interrupts must be enabled by software
– IE register (interrupt enable) is responsible for enabling and disabling the
interrupts
– IE is a bit-addressable register
Steps in enabling an interrupt
– EA must be set to 1
– set the relevant bits in IE register to high
– EA = 0, no interrupt will be responded to, even if the relevant bit in the IE
register is high
In this project external interrupt 1 (INT1) is used. This interrupt is falling edge interrupt
(i.e. it is triggered when the input signal changes from logic 1 (HIGH) to logic 0 (LOW).)
For instance, the following program line shows how external interrupt 1 is enabled for
the falling edge trigger.
MOV IE, #84H ; ENABLE EXTERNAL INTERRUPT 1
84H is 10000100 in binary and loading 84H to the Interrupt enable (IE) register
84H 1 0 0 0 0 1 0 0
IE bits EA -- ET2 ES ET1 EX1 ET0 EX0
Serial Interrupt
Serial Interrupts are slightly different than the rest of the interrupts. This is due to the
fact that there are two interrupt flags: RI and TI. If either flag is set, a serial interrupt is
triggered. The RI bit is set when a byte is received by the serial port and the TI bit is set
when a byte has been sent.
This means that when your serial interrupt is executed, it may have been triggered
because the RI flag was set or because the TI flag was set--or because both flags were
set. Thus, your routine must check the status of these flags to determine what action is
appropriate. Also, since the 8051 does not automatically clear the RI and TI flags you
must clear these bits in your interrupt handler.
Example,
MOV SBUF, #’A’ ; Character A is sent through the serial interface
CLR Ti ; Clear the TI bit before we send another character
CHECK: JNB TI, CHECK ; if the TI flag is not set, we jump to the exit point
CLR TI; Clear the TI bit before we send another character
MOV SBUF, #’T’ ; Send another character to the serial port
• RST
Reset input. A high on this pin for two machine cycles while the oscillator is running
resets the device.
• ALE/PROG
Address Latch Enable output pulse for latching the low byte of the address during
accesses to external memory. This pin is also the program pulse input (PROG) during
Flash Programming. In normal operation ALE is emitted at a constant rate of 1/6 the
oscillator frequency, and may be used for external timing or clocking purposes. Note,
however, that one ALE pulse is skipped during each access to external Data Memory. If
desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit
set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly
pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in external
execution mode.
• PSEN
Program Store Enable is the read strobe to external program memory. When the
AT89C51 is executing code from external program memory, PSEN is activated twice each
machine cycle, except that two PSEN activations are skipped during each access to
external data memory.
• EA/VPP
External Access Enable (EA) must be strapped to GND in order to enable the device to
fetch code from external program memory locations starting at 0000H up to FFFFH.
Note, however, that if lock bit 1 is programmed, EA will be internally latched on
reset. EA should be strapped to VCC for internal program executions. This pin also
receives the 12-volt programming enable voltage (VPP) during Flash programming, for
parts that require 12-volt VPP.
• XTAL1
Input to the inverting oscillator amplifier and input to the internal clock operating
circuit.
• XTAL2
It is the output from the inverting oscillator amplifier. Unconnected while XTAL1 is
driven as shown in Figure 2. There are no requirements on the duty cycle of the external
clock signal, since the input to the internal clocking circuitry is through a divide-by-two
flip-flop, but minimum and maximum voltage high and low time specifications must be
observed.
• Idle Mode
In idle mode, the CPU puts itself to sleep while all the on chip peripherals remain active.
The mode is invoked by software. The content of the on-chip RAM and all the special
functions registers remain unchanged during this mode. The idle mode can be
terminated by any enabled interrupt or by a hardware reset. It should be noted that
when idle is terminated by a hard ware reset, the device normally resumes program
execution, from where it left off, up to two machine cycles before
The internal reset algorithm takes control. On-chip hardware inhibits access to internal
RAM in this event, but access to the port pins is not inhibited. To eliminate the
possibility of an unexpected write to a port pin when Idle is terminated by reset, the
instruction following the one that invokes Idle should not be one that writes to a port
pin or to external memory.
Serial data cable
Is a data transfer cable to connect the phone with a PC and to a Microcontroller in our
case. There are many different types of such cables depending on their manufacturers,
architecture, protocols, number of pins, time of manufacturing. Some of these cables. . .
• Serial data cable
• USB data cable
• RJ-45 data cable
• POP port data cable
This project uses an F/M bus serial data cable. This data cable has one end an F/M bus
to connect to the mobile f/M pins and other end a serial to directly connect with the
microcontroller. We use this cable because the microcontrollers have no any other ports
than the serial port with nine pins (DB-9).
Fig 10: F/M bus serial data cable for Nokia 3310 fig.11: Nokia 3310
An Introduction to Nokia F-Bus
Most Nokia phones have F-Bus and M-Bus connections that can be used to connect
a phone to a PC or in our case a microcontroller. The connection can be used for
controlling just about all functions of the phone, as well as uploading new firmware etc.
This bus will allow us to send and receive SMS messages. The cable contains electronics
to level convert 3V signals (of the F/M bus) to RS232 (of the serial port) type signals.
There are also M and F bus switching in most cables.
The difference between F (Fast) bus and M (master) bus
M-Bus is a one pin bi-directional bus for both transmitting and receiving data from
the phone. It is slow (9600bps) and only half-duplex. Only two pins on the phone are
used. One ground and one data. M-Bus runs at 9600bps, 8 data bits, odd parity, and one
stop bit. The data terminal ready (DTR) pin must be cleared with the request to send
(RTS). This powers the electronics in the cable.
F-Bus is the later high-speed full-duplex bus. It uses one pin for transmitting data and
one pin for receiving data plus the ground pin. Very much like a standard serial port. It is
fast 115,200bps, 8 data bits, no parity, and one stop bit. For F-Bus the data terminal ready
(DTR) pin must be set and the request to send (RTS) pin cleared.
Introduction to serial data cable (DB-9)
In telecommunications, RS-232 (Recommended Standard 232) is a 9 pin standard for
serial binary single-ended data and control signals connecting between a DTE (Data
Terminal Equipment) and a DCE (Data Circuit-terminating Equipment). It is commonly
used in computer serial ports. In RS-232, user data is sent as a time-series of bits.
Fig.12:
F/M bus pins for Nokia 3310
(Under the back cover)
Both synchronous and asynchronous transmissions are supported by the standard. In
addition to the data circuits, the standard defines a number of control circuits used to
manage the connection between the DTE and DCE. Each data or control circuit only
operates in one direction, which is, signaling from a DTE to the attached DCE or the
reverse. Since transmit data and receive data are separate circuits, the interface can
operate in a full duplex manner, supporting concurrent data flow in both directions. The
standard does not define character framing within the data stream, or character encoding.
Synchronous serial transmission requires that the sender and receiver share a
clock with one another, or that the sender provide a strobe or other timing signal
so that the receiver knows when to “read” the next bit of the data.
Asynchronous transmission allows data to be transmitted without the sender
having to send a clock signal to the receiver. Instead, the sender and receiver must
agree on timing parameters in advance and special bits are added to each word
which are used to synchronize the sending and receiving units.
Fig. 13: DB-9 female connector
AT command supporting GSM mobile phone.
The phone we used for the project is an AT command supporting. At
commands will be explained in later topics later
Introduction to GSM network
GSM (Global System for Mobile Communications): is the most popular standard for
mobile telephony systems in the world. It is estimated that 80% of the global mobile
market uses the standard. Its ubiquity enables international roaming arrangements
between mobile phone operators, providing subscribers the use of their phones in many
parts of the world.
GSM differs from its predecessor technologies in that both signaling and speech
channels are digital, and thus GSM is considered a second generation (2G) mobile phone
system. This also facilitates the wide-spread implementation of data communication
applications into the system.
GSM also pioneered low-cost implementation of the short message service (SMS), also
called text messaging, which has since been supported on other mobile phone
standards as well.
The GSM network works in the spectral range of 900MHz-1800MHz. Our country also
uses this GSM network for mobile communication and to the benefit of the network we
use a GSM phone, found widely in the market too.
Part two
Software
Theory of Operation
In this project we interfaced the AT89C55WD microcontroller with Nokia GSM mobile
phone through an F/M bus serial data cable to send SMS message automatically upon
intrusion which is detected by the use of an infrared sensor as discussed above. The
protocol used for the communication between the microcontroller and the GSM phone
is called AT command.
When the interrupt fed to the microcontroller is triggered (i.e. when there is an intruder
in the house), the microcontroller sends a predefined AT commands for a predefined
mobile numbers.
Any microcontroller can be programmed using C language or assembly language
programming. In the project the assembly is applied because it uses very small memory
space and also more compact than other languages such as C.
Flow Chart of the microcontroller program to accomplish the required task is give below
and description about the assembly programming and AT command sets will follow.
Yes
Label
Check
interrupt
START
Select external interrupt as edge trigger
Select six cycle machine mode
Select baud rate of 115200 bps
Give the sms command to mobile for first number
Delay of 4 sec
Give the SMS command to mobile for the second number
Delay of 4 sec
Give dialing command to mobile for second number
Give dialing command to mobile for first number
Jump on label
Reset
Stop
NO
Fig. 14: flow diagram of the program
Assembly Language
Assembly languages are a type of low-level languages for programming computers,
microprocessors, microcontrollers, and other (usually) integrated circuits. They
implement a symbolic representation of the numeric machine codes and other
constants needed to program a particular CPU architecture. This representation is
usually defined by the hardware manufacturer, and is based on abbreviations (called
mnemonics) that help the programmer remember individual instructions, registers, etc.
An assembly language family is thus specific to certain physical (or virtual) computer
architecture. This is in contrast to most high-level languages, which are (ideally)
portable.
A utility program called an assembler is used to translate assembly language statements
into the target computer's machine code. The assembler performs a more or less
isomorphic translation (a one-to-one mapping) from mnemonic statements into
machine instructions and data. This is in contrast with high-level languages, in which a
single statement generally results in many machine instructions.
Many sophisticated assemblers offer additional mechanisms to facilitate program
development, control the assembly process, and aid debugging. In particular, most
modern assemblers include a macro facility (described below), and are called macro
assemblers.
Advantages of Assembly language
It is possible to program a microcontroller by using either assembly language or C
programming language. We chose assembly language because of the following reasons.
• Assembly language is compact (i.e. it takes small memory space compared to C)
• Assembly code has fine control that it allows over the code.
An advantage of assembly language over high level languages is the fine control that it
allows over the code. Since assembly language directly correlates which machine
instructions, the only way to get closer to the machine is to write in binary or hex code.
Another advantage is that you can invoke specialized instructions to do I/O, or
manipulate hardware, such as page descriptor tables in the kernel.
The fine control advantage is, however, illusive. Modern compilers do a very good job of
optimizing, and assembly language is very verbose, requiring you to specify
"everything", and to keep track of "everything".
The project uses an assembler environment called MIDE-51 studio. The snap shot and
some explanation is given below of the assembler.
Features of the MIDE-51 studio:
• Syntax highlighter on ASEM-51 reserved word & addition register on selected
device (devices listed on ASEM51/MCU folder)
• Support standard editor feature and shortcut key such as Cut , Copy, Paste, Find,
Replace and Windows tile & cascade
• Save recent file(s) opened in list
• Report assembler & compiler message
The MIDE-51 studio saves the microcontroller program we written on it is three different
formats. ASM (assembly) form, HEX (the program in hexadecimal values) form, and the
LST (list) file formats.
Fig. 15: snapshot
Of MIDE-51
studio
ASM (assembly) form
Program written in assembly language, a low level programming language that can be
converted to machine language; may be edited with a text editor and run using an
assembler program, such as MIDE-51 studio.This format is the type we call the source
code for the microcontroller.
Example of .ASM file
ORG 807FH
HERE1: MOV PCON, #80H; TO SET SMOD BIT FOR DOUBLE BAUD RATE
MOV TMOD, #20H; TIMER 1 MODE 2 (AUTORELOAD)
MOV TH1, #0FFH; 115200 BAUD RATE
MOV SCON, #40H; 8 BIT, 1 STOP BIT
SETB TR1 ; START TIMER 1
CLR TI
MOV SBUF, #’A’; COMMAND
AAAA: JNB TI, AAAA
CLR TI
MOV SBUF,’#'
HEX (the program in hexadecimal values) form
The format is a text file, with each line containing hexadecimal values encoding a
sequence of data and their starting offset or absolute address.
There are three types of HEX: 8-bit, 16-bit, and 32-bit. They are distinguished by their
byte order.
Each line of HEX file consists of six parts:
1. Start code, one character, an ASCII colon ':'.
2. Byte count, two hex digits, a number of bytes (hex digit pairs) in the data field.
16 (0x10) or 32 (0x20) bytes of data are the usual compromise values between
line length and address overhead.
3. Address, four hex digits, a 16-bit address of the beginning of the memory
position for the data. Limited to 64 kilobytes, the limit is worked around by
specifying higher bits via additional record types.
4. Record type, two hex digits, 00 to 05, defining the type of the data field.
5. Data, a sequence of n bytes of the data themselves, represented by 2n hex digits.
6. Checksum, two hex digits - the least significant byte of the two's complement of
the sum of the values of all fields except fields 1 and 6 (Start code ":" byte and
two hex digits of the Checksum).
Example of .HEX file
Following is a typical Hex-record module consisting of four data records and a
termination record.
: 10010000214601360121470136007EFE09D2190140
: 100110002146017EB7C20001FF5F16002148011988
: 10012000194E79234623965778239EDA3F01B2CAA7
: 100130003F0156702B5E712B722B732146013421C7
: 00000001FF
The first data record is explained as follows:
: Start code.
10 Hex 10 (decimal 16), indicating 16 data character
pairs, 16 bytes of binary data, in this record.
01 Four-character 2-byte address field: hex address 0100,
00 indicates location where the following data is to be loaded.
00 Record types indicating a data record.
The next 16 character pairs are the ASCII bytes of the actual program
data.
40 Checksum of the first Hex-record.
The termination record is explained as follows:
: Start code.
00 Byte count is zero, no data in termination record.
00 Four-character 2-byte address fields, zeros.
00
01 Record type 01 is termination.
FF Checksum of termination record.
LST (list) form
Is the machine language equivalent of the .ASM file formats. In this case each of the
.ASM commands has their respective representation on the machine code, the .LST
representation.
Below is the .LST equivalent for the section of source code we wrote above.
16: N 807F ORG 807FH
17: 807F 75 87 80 HERE1: MOV PCON,#80H ;TO SET SMOD BIT FOR DOUBLE BAUD RATE
18: 8082 75 89 20 MOV TMOD,#20H ;TIMER 1 MODE 2 (AUTORELOAD)
19: 8085 75 8D FF MOV TH1,#0FFH ;115200 BAUD RATE
20: 8088 75 98 40 MOV SCON,#40H ;8 BIT,1 STOP BIT
21: 808B D2 8E SETB TR1 ;START TIMER 1
22: 808D C2 99 CLR TI
23: 808F 75 99 41 MOV SBUF,#'A' ;COMMAND
24: 8092 30 99 FD AAAA: JNB TI,AAAA
25: 8095 C2 99 CLR TI
26: 8097 75 99 54 MOV SBUF,#'T'
AT-Command set
AT commands are instructions used to control a modem. AT is the abbreviation of
Attention. Every command line starts with "AT" or "at". That's why modem commands
are called AT commands. Many of the commands that are used to control wired dial-up
modems, such as ATD (Dial), ATA (Answer), ATH (Hook control) and ATO (Return to
online data state), are also supported by GSM modems and mobile phones. Besides this
List form Source code
common AT command set, GSM modems and mobile phones support an AT command
set that is specific to the GSM technology, which includes SMS-related commands like
AT+CMGS (Send SMS message), AT+CMSS (Send SMS message from storage), AT+CMGL
(List SMS messages) and AT+CMGR (Read SMS messages).
Note that the starting "AT" is the prefix that informs the modem about the start of a
command line. It is not part of the AT command name. For example, D is the actual AT
command name in ATD and +CMGS is the actual AT command name in AT+CMGS.
However, some books and web sites use them interchangeably as the name of an AT
command.
Here are some of the tasks that can be done using AT commands with a GSM modem or
mobile phone:
• Get basic information about the mobile phone or GSM/GPRS modem. For
example, name of manufacturer (AT+CGMI), model number (AT+CGMM), IMEI
number (International Mobile Equipment Identity) (AT+CGSN) and software
version (AT+CGMR).
• Get basic information about the subscriber. For example, MSISDN (AT+CNUM)
and IMSI number (International Mobile Subscriber Identity) (AT+CIMI).
• Get the current status of the mobile phone or GSM/GPRS modem. For example,
mobile phone activity status (AT+CPAS), mobile network registration status
(AT+CREG), radio signal strength (AT+CSQ), battery charge level and battery
charging status (AT+CBC).
• Establish a data connection or voice connection to a remote modem (ATD, ATA,
etc).
• Send and receive fax (ATD, ATA, AT+F*).
• Send (AT+CMGS, AT+CMSS), read (AT+CMGR, AT+CMGL), write (AT+CMGW) or
delete (AT+CMGD) SMS messages and obtain notifications of newly received
SMS messages (AT+CNMI).
• Read (AT+CPBR), write (AT+CPBW) or search (AT+CPBF) phonebook entries.
• Perform security-related tasks, such as opening or closing facility locks
(AT+CLCK), checking whether a facility is locked (AT+CLCK) and changing
passwords (AT+CPWD).
(Facility lock examples: SIM lock [a password must be given to the SIM card
every time the mobile phone is switched on] and PH-SIM lock [a certain SIM card
is associated with the mobile phone. To use other SIM cards with the mobile
phone, a password must be entered.])
• Control the presentation of result codes / error messages of AT commands. For
example, you can control whether to enable certain error messages (AT+CMEE)
and whether error messages should be displayed in numeric format or verbose
format (AT+CMEE=1 or AT+CMEE=2).
• Get or change the configurations of the mobile phone or GSM/GPRS modem. For
example, change the GSM network (AT+COPS), bearer service type (AT+CBST),
radio link protocol parameters (AT+CRLP), SMS center address (AT+CSCA) and
storage of SMS messages (AT+CPMS).
• Save and restore configurations of the mobile phone or GSM modem. For
example, save (AT+CSAS) and restore (AT+CRES) settings related to SMS
messaging such as the SMS center address.
Note that mobile phone manufacturers usually do not implement all AT commands,
command parameters and parameter values in their mobile phones. Also, the behavior
of the implemented AT commands may be different from that defined in the standard.
In general, GSM modems designed for wireless applications have better support of AT
commands than ordinary mobile phones.
In addition, some AT commands require the support of mobile network operators. For
example, SMS over GPRS can be enabled on some GPRS mobile phones and GPRS
modems with the +CGSMS command (command name in text: Select Service for MO
SMS Messages). But if the mobile network operator does not support the transmission
of SMS over GPRS, you cannot use this feature.
The commands can be tried out by connecting a GSM modem to one of the PC’s COM
ports. Type in the test-command, adding CR + LF (Carriage return + Line feed = \r\n)
before executing. Table gives an overview of the implemented AT-Commands in this
application. The use of the commands is described in the later sections.
AT-Command set overview
Table 3: AT command set AT command formats
There are two ways of sending and receiving SMS messages by using a PC or
microcontroller.
• Text mode and
• PDU (protocol description unit) mode.
The text mode
(unavailable on some phones) is just an encoding of the bit stream represented by the
PDU mode. This mode simply uses the above explained AT commands directly to send
SMS and for dialing. Alphabets may differ and there are several encoding alternatives
when displaying an SMS message. The most common options are "PCCP437", "PCDN",
"8859-1", "IRA" and "GSM". These are all set by the at-command AT+CSCS, when you
read the message in a computer application. If you read the message on your phone,
the phone will choose a proper encoding. An application capable of reading incoming
SMS messages can thus use text mode or PDU mode. If text mode is used, the
application is bound to (or limited by) the set of preset encoding options. In some cases,
that's just not good enough. If PDU mode is used, any encoding can be implemented.
When selecting from text mode and PDU mode AT+CMGF=1 will select us the TEXT
mode and AT+CMGF=0 will select us the PDU mode.
E.g.
• ATI Returns general modem identification
Command Description
AT
Check if serial interface and GSM modem is
working.
ATE0 Turn echo off, less traffic on serial line.
AT+CNMI Display of new incoming SMS.
AT+CPMS Selection of SMS memory.
AT+CMGF SMS string format, how they are compressed.
AT+CMGR
Read new message from a given memory
location.
AT+CMGS Send message to a given recipient.
AT+CMGD Delete message.
• ATD<phone number> Dials the phone number you supplied (don’t enter the <>
brackets)
• ATH Hang-up the phone (useful after the previous command).
PDU (protocol data unit) mode
The formatting of these PDU’s is a little more complicated and requires some bit
manipulations that are hard to do by hand.
The GSM modem is put into PDU mode with the command ‘AT+CMGF=0’. Once in
PDU mode a PDU can be sent using the ‘AT+CMGS’ command:
AT+CMGS=<length><CR>
> <here goes your PDU><Crtl-Z>
The actual PDU consists of a number of octets (bytes). In the command the <length>
field represents the number of octets and the PDU is given in the hexadecimal
representation of those octets. The ‘> ‘on the second line is a prompt that is written by the
GSM modem to indicate that it is ready to accept the PDU.
Coding 7-bit data (septets) into octets
The message "hello GSM" consists of 10 characters, called septets when represented by
7 bits each. These septets need to be transformed into octets for the SMS transfer.
Table 4: coding 7 bit data into octates
ASCII Character Chart with Decimal, Binary and Hexadecimal Conversions
text h e l l o Space G S M
Deci. 104 101 108 108 111 32 71 83 77
7.bit
binary(septate) 1101000 1100101 1101100 1101100 1101111 0100000 1000111 1010011 1001101
7.bit
binary(septate) 1101000
110010 1
11011 00
1101 100
110 1111
0100000 1 000111
1010011
1001101
octate 1 1101000
00 110010
100 11011
1111 1101
00000 110
000111 01
1010011 1
1001101
Hex. E8 32 9B FD 06 1D A7
4D
ASCII stands for "American Standard Code for Information Interchange". It is the
character set that is used in PCs and most other small computers. The table below lists all
of the alphanumeric characters in the character set, along with their decimal, 7 bit
septet(7 bit binary) and hexadecimal number equivalents, so you can also use it as a
conversion chart:
Instead of using the above time taking and boring method It’s also possible to use an
application to change the 7-bit data (septets) into octets. This application which can be
downloaded easily from the internet is called SMS packer.
Table5: ASCII HEX Binary conversion chart
By using this application we can easily convert any message type in to its hexadecimal
equivalent.
Sending a message in the PDU mode
The following example shows how to send the message "hello GSM" in the PDU mode
from a Cell phone.
AT+CMGF=0 //Set PDU mode
AT+CSMS=0 //Check if modem supports SMS commands
AT+CMGS=21 //Send message, 21 octets (excluding the two initial zeros)
>0011000A8190212000120000AA08E8329BFD061DA74D <ctrl-z>
There are 23 octets in this message (46 'characters'). The first octet ("00") doesn't count,
it is only an indicator of the length of the SMSC information supplied (0). The PDU string
consists of the following:
Fig. 16: snap shot of SMS packer
Octet(s) Description
00
Length of SMSC information. Here the length is 0, which means
that the SMSC stored in the phone should be used. Note: This
octet is optional. On some phones this octet should be omitted!
(Using the SMSC stored in phone is thus implicit)
11 First octet of the SMS-SUBMIT message.
00 TP-Message-Reference. The "00" value here lets the phone set
the message reference number itself.
0A Address-Length. Length of phone number (10)
81
Type-of-Address. (81 indicates unknown phone format of the
phone number). This is used when the user or network has no a
priori information about the numbering plan. In this case, the
Address-Value field is organized according to the network
dialing plan.
9021200012
The phone number in semi octets (0912020021). The length of
the phone number is even (10), therefore a trailing F is not
added.
00 TP-PID. Protocol identifier
00
TP-DCS. Data coding scheme. This message is coded according to
the 7bit default alphabet. Having "04" instead of "00" here,
would indicate that the TP-User-Data field of this message
should be interpreted as 8bit rather than 7bit (used in e.g. smart
messaging, OTA provisioning etc).
AA TP-Validity-Period. "AA" means 4 days. Note: This octet is
optional, see bits 4 and 3 of the first octet
08
TP-User-Data-Length. Length of message. The TP-DCS field
indicated 7-bit data, so the length here is the number of septets
(8). If the TP-DCS field were set to 8-bit data or Unicode, the
length would be the number of octets.
E8329BFD061DA74D TP-User-Data. These octets represent the message "hello GSM".
Table 6: parts of the PDU string
Serial Communication
Serial communication is often used either to control or to receive data from an embedded
microprocessor.
In serial communication the bits are transmitted at specific time intervals determined by
the baud rate of the serial signal. Each byte is preceded by a start bit and followed by
one stop bit as shown in the figure below. The start and stop bits are used to
synchronize the serial receivers. The data byte is always transmitted least-significant-bit
first. For error checking it is possible to include a parity bit as well, just prior to the stop
bit.
Fig.17: Serial Waveform
One of the 8051’s many powerful features is its integrated UART, otherwise known as a
serial port. The fact that the 8051 has an integrated serial port means that you may very
easily read and write values to the serial port. If it were not for the integrated serial port,
writing a byte to a serial line would be a rather tedious process requiring turning on and
off one of the I/O lines in rapid succession to properly "clock out" each individual bit,
including start bits, stop bits, and parity bits.
However, we do not have to do this. Instead, we simply need to configure:
• The serial ports operation mode and
• Baud rate
Once configured, all we have to do is write to an SFR (special function register) to write
a value to the serial port or read the same SFR to read a value from the serial port. The
8051 will automatically let us know when it has finished sending the character we wrote
and will also let us know whenever it has received a byte so that we can process it. We do
not have to worry about transmission at the bit level--which saves us quite a bit of coding
and processing time.
Setting the Serial Port Mode
First, let’s present the "Serial Control" (SCON) SFR and define what each bit of the SFR
represents:
Bit Name Bit
Address Explanation of Function
7 SM0 9Fh Serial port mode bit 0
6 SM1 9Eh Serial port mode bit 1.
5 SM2 9Dh Multiprocessor Communications Enable (explained later)
4 REN 9Ch Receiver Enable. This bit must be set in order to receive
characters.
3 TB8 9Bh Transmit bit 8. The 9th bit to transmit in mode 2 and 3.
2 RB8 9Ah Receive bit 8. The 9th bit received in mode 2 and 3.
1 TI 99h Transmit Flag. Set when a byte has been completely
transmitted.
0 RI 98h Receive Flag. Set when a byte has been completely received.
Additionally, it is necessary to define the function of SM0 and SM1 by an additional
table:
Table 7: bit description of SCON
Note: The baud rate indicated in this table is doubled if PCON.7 (SMOD) is set.
In the program, for sending the AT command to the serial port the program line used is:-
MOV SCON, #40H; 8 BIT, 1 STOP BIT
The Special function register SCON (serial control) is loaded with #40H which has
binary equivalent of 01000000.
40H 0 1 0 0 0 0 0 0
SCON bits SM0 SM1 SM2 REN TB8 RB8 TI RI
The combination of SM0 and SM1 for 40H is 0, 1 which is defined as 8-bit UART and
baud rate set by timer 1 (*) in the additional table above.
Setting the Baud rate
The baud rate is the reciprocal of the time to send 1 bit. Error-free serial communication
requires that the baud rate, number of data bits, number of stop bits, and presence or
absence of a parity bit be the same at the transmitter and at the receiver.
In mode 1, the baud rate is determined by how frequently timer 1 overflows. The more
frequently timer 1 overflows, the higher the baud rate. There are many ways one can
cause timer 1 to overflow at a rate that determines a baud rate, but the most common
method is to put timer 1 in 8-bit auto-reload mode (timer mode 2) and set a reload value
(TH1) that causes Timer 1 to overflow at a frequency appropriate to generate a baud rate.
The baud rate of 115200 bps is used in this project. This was set by the program line:
MOV TMOD, #20H; TIMER 1 MODE 2 (AUTORELOAD)
MOV TH1, #0FFH; 115200 BAUD RATE
SM0 SM1 Serial Mode Explanation Baud Rate
0 0 0 8-bit Shift Register Oscillator / 12
0 1 1 8-bit UART Set by Timer 1 (*)
1 0 2 9-bit UART Oscillator / 64 (*)
1 1 3 9-bit UART Set by Timer 1 (*)
Application and future development
The project can be applied to areas of maximum security concern like:-
• Banks, treasury and jewelry
• It can be used for the military purpose for security of restricted zones
• It can also be used the reverse way. i.e. controlling appliances by using
SMS messages like switching fan, freezers and other on/off controlled
devices.
Conclusion
• Assembly language programming is a very good choice for
designing embedded systems. It may have some discomforts
compared with high-level languages but have good flexibility
and is compact, can be applied with in very low memory
spaces
• As SMS is much cheaper in today time it is economical to
exploit such technology for application like our system.
• The system gives real time alert to the user.
• The system uses the reliability of the existing cellular network
• The total system is hidden and can be made very small in size
so that is cannot be exposed to or detected by thief.
• The system can be made more faithful and reliable by
increasing authorized security personnel or user, and if there is
network problem for one authorized user or security
personnel then the call goes to other user or security persons.
• The total system cost and power consumption is very low.
• The system is very flexible so that by changing the sensors
adding signal conditioning circuits and by modifying the
assembly program it can be applied to respond for many
different situations.
Recommendation
The system, as explained earlier, is very important in many areas and we
recommend our campus, MU, to be one of the beneficiaries of such
systems.
As we’ve tried to express before, such microcontroller projects had not
been made before in our department so we recommend our department
staff take the initiative to support such projects and give the required
support so that such projects could perform well students could share their
knowledge for the benefit of the society.
We recommend our department have very good record of all its resources
which is available for students and can serve as a good standing point for
prospective projects in the future.
We highly recommend the establishment of technology research centers so
that many different professional and beginner technologists could apply
their knowledge and contribute for the development of our country.
Reference materials
http://www.wikipedia.com/
http://www.gsmforum.com/
http://www.sonsivri.com/
http://www.freebsd.org/
http://www.activeexperts.com/
http://www.dreamfabric.com/sms/
http://www.8052.com
http://www.embedtronics.com/nokia/fbus.html
Appendix a: source code for GSM based security system
; SOFTWARE COMMENTS
ORG 8000H
MOV 8FH,#01H ;SELECT 6 MACHINE CYCLE MODE
LJMP MAIN
ORG 9400H; MAIN PROGRAM
MAIN: SETB IT1; SELECT EXTERNAL INTERRUPT 1 AS EDGE TRI
MOV IE, #84H; ENABLE EXTERNAL INTERRUPT 1
HERE: SJMP HERE; ISR OF INTERRUPT
ORG 0013H
LJMP HERE1; long jump to HERE1
RETI
ORG 807FH
HERE1: MOV PCON, #80H; TO SET SMOD BIT FOR DOUBLE BAUD RATE
MOV TMOD, #20H; TIMER 1 MODE 2 (AUTORELOAD)
MOV TH1, #0FFH; 115200 BAUD RATE
MOV SCON, #40H; 8 BIT, 1 STOP BIT
SETB TR1 ; START TIMER 1
CLR TI
MOV SBUF, #’A’; COMMAND
AAAA: JNB TI, AAAA
CLR TI
MOV SBUF, #'T'
AAAB: JNB TI, AAAB
CLR TI
LCALL ENTER
MOV SBUF, #’A’; COMMAND
AAAC: JNB TI, AAAC
CLR TI
MOV SBUF, #'T'
AAAD: JNB TI, AAAD
CLR TI
LCALL ENTER
LCALL MODESEL
LCALL PDUFORMAT
LCALL DELAY
LCALL DELAY
MOV SBUF, #’A’; COMMAND
AAAE: JNB TI, AAAE
CLR TI
MOV SBUF, #'T'
AAAF: JNB TI, AAAF
CLR TI
LCALL ENTER
MOV SBUF, #’A’; COMMAND
AAAG: JNB TI, AAAG
CLR TI
MOV SBUF, #'T'
AAAH: JNB TI, AAAH
CLR TI
LCALL ENTER
LCALL MODESEL
LCALL PDUFORMAT1
LCALL DELAY
LCALL DELAY
LCALL CONTINEOUSDIALLING
ORG 8500H
MODESEL: MOV SBUF, #’A’; COMMAND FOR PDU MODE SELECTION
AAAI: JNB TI, AAAI
CLR TI
MOV SBUF, #'T'
AAAJ: JNB TI, AAAJ
CLR TI
MOV SBUF, #'+'
AAAK: JNB TI, AAAK
CLR TI
MOV SBUF, #'C'
AAAL: JNB TI, AAAL
CLR TI
MOV SBUF, #'M'
AAAM: JNB TI, AAAM
CLR TI
MOV SBUF, #'G'
AAAN: JNB TI, AAAN
CLR TI
MOV SBUF, #'F'
AAAO: JNB TI, AAAO
CLR TI
MOV SBUF, #'='
AAAP: JNB TI, AAAP
CLR TI
MOV SBUF, #'0'
AAAQ: JNB TI, AAAQ
CLR TI
LCALL ENTER
RET
ORG 8700H
PDUFORMAT: MOV SBUF, #’A’; COMMAND FOR PDU FORMAT
AAAR: JNB TI, AAAR
CLR TI
MOV SBUF, #'T'
AAAS: JNB TI, AAAS
CLR TI
MOV SBUF, #'+'
AAAT: JNB TI, AAAT
CLR TI
MOV SBUF, #'C'
AAAU: JNB TI, AAAU
CLR TI
MOV SBUF, #'M'
AAAV: JNB TI, AAAV
CLR TI
MOV SBUF, #'G'
AAAW: JNB TI, AAAW
CLR TI
MOV SBUF, #'S'
AAAX: JNB TI, AAAX
CLR TI
MOV SBUF, #'='
AAAY: JNB TI, AAAY
CLR TI
MOV SBUF, #'3'
AAAZ: JNB TI, AAAZ
CLR TI
MOV SBUF, #'3'
AZZQ: JNB TI, AZZQ
CLR TI
LCALL ENTER
LCALL DELAY
MOV SBUF, #'0'
AABB: JNB TI, AABB
CLR TI
MOV SBUF, #'0'
AABC: JNB TI, AABC
CLR TI
MOV SBUF, #'1'
AABD: JNB TI, AABD
CLR TI
MOV SBUF, #'1'
AABE: JNB TI, AABE
CLR TI
MOV SBUF, #'0'
AABF: JNB TI, AABF
CLR TI
MOV SBUF, #'0'
AABG: JNB TI, AABG
CLR TI
MOV SBUF, #'0'
AABH: JNB TI, AABH
CLR TI
MOV SBUF, #'A'
AABI: JNB TI, AABI
CLR TI
MOV SBUF, #'8'
AABJ: JNB TI, AABJ
CLR TI
MOV SBUF, #'1'
AABK: JNB TI, AABK
CLR TI
MOV SBUF, #'9'
AABL: JNB TI, AABL
CLR TI
MOV SBUF, #'0'
AABM: JNB TI, AABM
CLR TI
MOV SBUF, #'4'
AABN: JNB TI, AABN
CLR TI
MOV SBUF, #'1'
AABO: JNB TI, AABO
CLR TI
MOV SBUF, #'4'
AABP: JNB TI, AABP
CLR TI
MOV SBUF, #'7'
AABQ: JNB TI, AABQ
CLR TI
MOV SBUF, #'5'
AABR: JNB TI, AABR
CLR TI
MOV SBUF, #'0'
AABS: JNB TI, AABS
CLR TI
MOV SBUF, #'6'
AABT: JNB TI, AABT
CLR TI
MOV SBUF, #'4'
AAFA: JNB TI, AAFA
CLR TI
MOV SBUF, #'0'
AABV: JNB TI, AABV
CLR TI
MOV SBUF, #'0'
AABW: JNB TI, AABW
CLR TI
MOV SBUF, #'0'
AABX: JNB TI, AABX
CLR TI
MOV SBUF, #'0'
AABY: JNB TI, AABY
CLR TI
MOV SBUF, #'A'
AABZ: JNB TI, AABZ
CLR TI
MOV SBUF, #'A'
AACA: JNB TI, AACA
CLR TI
MOV SBUF, #'1'
AACB: JNB TI, AACB
CLR TI
MOV SBUF, #'6'
AACC: JNB TI, AACC
CLR TI
MOV SBUF, #'D'
AACD: JNB TI, AACD
CLR TI
MOV SBUF, #'7'
AACE: JNB TI, AACE
CLR TI
MOV SBUF, #'A'
AACF: JNB TI, AACF
CLR TI
MOV SBUF, #'0'
AACG: JNB TI, AACG
CLR TI
MOV SBUF, #'D'
AACH: JNB TI, AACH
CLR TI
MOV SBUF, #'4'
AACI: JNB TI, AACI
CLR TI
MOV SBUF, #'9'
AACJ: JNB TI, AACJ
CLR TI
MOV SBUF, #'9'
AACK: JNB TI, AACK
CLR TI
MOV SBUF, #'7'
AACL: JNB TI, AACL
CLR TI
MOV SBUF, #'4'
AACM: JNB TI, AACM
CLR TI
MOV SBUF, #'1'
AAFB: JNB TI, AAFB
CLR TI
MOV SBUF, #'E'
AAFC: JNB TI, AAFC
CLR TI
MOV SBUF, #'4'
AAFD: JNB TI, AAFD
CLR TI
MOV SBUF, #'3'
AAFE: JNB TI, AAFE
CLR TI
MOV SBUF, #'A'
AAFF: JNB TI, AAFF
CLR TI
MOV SBUF, #'0'
AAFG: JNB TI, AAFG
CLR TI
MOV SBUF, #'6'
AAFH: JNB TI, AAFH
CLR TI
MOV SBUF, #'3'
AAFI: JNB TI, AAFI
CLR TI
MOV SBUF, #'9'
AAFJ: JNB TI, AAFJ
CLR TI
MOV SBUF, #'0'
AAFK: JNB TI, AAFK
CLR TI
MOV SBUF, #'5'
AAFL: JNB TI, AAFL
CLR TI
MOV SBUF, #'A'
AAFM: JNB TI, AAFM
CLR TI
MOV SBUF, #'0'
AAFN: JNB TI, AAFN
CLR TI
MOV SBUF, #'4'
AAFO: JNB TI, AAFO
CLR TI
MOV SBUF, #'2'
AAFP: JNB TI, AAFP
CLR TI
MOV SBUF, #'5'
AAFQ: JNB TI, AAFQ
CLR TI
MOV SBUF, #'9'
AAFR: JNB TI, AAFR
CLR TI
MOV SBUF, #'D'
AAFS: JNB TI, AAFS
CLR TI
MOV SBUF, #'5'
AAFT: JNB TI, AAFT
CLR TI
MOV SBUF, #'4'
AAFU: JNB TI, AAFU
CLR TI
MOV SBUF, #'6'
AAFV: JNB TI, AAFV
CLR TI
MOV SBUF, #'9'
AAFX: JNB TI, AAFX
CLR TI
MOV SBUF, #'9'
AAFY: JNB TI, AAFY
CLR TI
MOV SBUF, #'5'
AAFZ: JNB TI, AAFZ
CLR TI
MOV SBUF, #'5'
AAGA: JNB TI, AAGA
CLR TI
MOV SBUF, #'8'
AAGB: JNB TI, AAGB
CLR TI
MOV SBUF, #'2'
AAGC: JNB TI, AAGC
CLR TI
MOV SBUF, #'4'
AAGD: JNB TI, AAGD
CLR TI
MOV SBUF, #'0'
AAGE: JNB TI, AAGE
CLR TI
MOV SBUF, #'2'
AACN: JNB TI, AACN
CLR TI
MOV SBUF, #1AH
AACO: JNB TI, AACO
CLR TI
RET
ORG 8B00H
PDUFORMAT1: MOV SBUF, #’A’; COMMAND FOR PDU FORMAT
AACP: JNB TI, AACP
CLR TI
MOV SBUF, #'T'
AACQ: JNB TI, AACQ
CLR TI
MOV SBUF, #'+'
AACR: JNB TI, AACR
CLR TI
MOV SBUF, #'C'
AACS: JNB TI, AACS
CLR TI
MOV SBUF, #'M'
AACT: JNB TI, AACT
CLR TI
MOV SBUF, #'G'
AACU: JNB TI, AACU
CLR TI
MOV SBUF, #'S'
AACV: JNB TI, AACV
CLR TI
MOV SBUF, #'='
AACW: JNB TI, AACW
CLR TI
MOV SBUF, #'3'
AACX: JNB TI, AACX
CLR TI
MOV SBUF, #'3'
AACY: JNB TI, AACY
CLR TI
LCALL ENTER
LCALL DELAY
MOV SBUF, #'0'
AAKY: JNB TI, AAKY
CLR TI
MOV SBUF, #'0'
AACZ: JNB TI, AACZ
CLR TI
MOV SBUF, #'1'
AADA: JNB TI, AADA
CLR TI
MOV SBU, #'1'
AADB: JNB TI, AADB
CLR TI
MOV SBUF, #'0'
AADC: JNB TI, AADC
CLR TI
MOV SBUF, #'0'
AADD: JNB TI, AADD
CLR TI
MOV SBUF, #'0'
AADE: JNB TI, AADE
CLR TI
MOV SBUF, #'A'
AADF: JNB TI, AADF
CLR TI
MOV SBUF, #'8'
AADG: JNB TI, AADG
CLR TI
MOV SBUF, #'1'
AADH: JNB TI, AADH
CLR TI
MOV SBUF, #'9'
AADJ: JNB TI, AADJ
CLR TI
MOV SBUF, #'0'
AADK: JNB TI, AADK
CLR TI
MOV SBUF, #'2'
AADL: JNB TI, AADL
CLR TI
MOV SBUF, #'1'
AADM: JNB TI, AADM
CLR TI
MOV SBUF, #'2'
AADN: JNB TI, AADN
CLR TI
MOV SBUF, #'0'
AADO: JNB TI, AADO
CLR TI
MOV SBUF, #'3'
AADP: JNB TI, AADP
CLR TI
MOV SBUF, #'3'
AADQ: JNB TI, AADQ
CLR TI
MOV SBUF, #'6'
AAGF: JNB TI, AAGF
CLR TI
MOV SBUF, #'3'
AADR: JNB TI, AADR
CLR TI
MOV SBUF, #'1'
AADS: JNB TI, AADS
CLR TI
MOV SBUF, #'0'
AADT: JNB TI, AADT
CLR TI
MOV SBUF, #'0'
AADU: JNB TI, AADU
CLR TI
MOV SBUF, #'0'
AADV: JNB TI, AADV
CLR TI
MOV SBUF, #'0'
AADW: JNB TI, AADW
CLR TI
MOV SBUF, #'A'
AADX: JNB TI, AADX
CLR TI
MOV SBUF, #'A'
AADY: JNB TI, AADY
CLR TI
MOV SBUF, #'1'
AADZ: JNB TI, AADZ
CLR TI
MOV SBUF, #'6'
AAHA: JNB TI, AAHA
CLR TI
MOV SBUF, #'D'
AAHB: JNB TI, AAHB
CLR TI
MOV SBUF, #'7'
AAHC: JNB TI, AAHC
CLR TI
MOV SBUF, #'A'
AAHD: JNB TI, AAHD
CLR TI
MOV SBUF, #'0'
AAHE: JNB TI, AAHE
CLR TI
MOV SBUF, #'D'
AAHF: JNB TI, AAHF
CLR TI
MOV SBUF, #'4'
AAHG: JNB TI, AAHG
CLR TI
MOV SBUF, #'9'
AAHH: JNB TI, AAHH
CLR TI
MOV SBUF, #'9'
AAHI: JNB TI, AAHI
CLR TI
MOV SBUF, #'7'
AAHJ: JNB TI, AAHJ
CLR TI
MOV SBUF, #'4'
AAHK: JNB TI, AAHK
CLR TI
MOV SBUF, #'1'
AAHL: JNB TI, AAHL
CLR TI
MOV SBUF, #'E'
AAHM: JNB TI, AAHM
CLR TI
MOV SBUF, #'4'
AAHN: JNB TI, AAHN
CLR TI
MOV SBUF, #'3'
AAHO: JNB TI, AAHO
CLR TI
MOV SBUF, #'A'
AAHP: JNB TI, AAHP
CLR TI
MOV SBUF, #'0'
AAHQ: JNB TI, AAHQ
CLR TI
MOV SBUF, #'6'
AAHR: JNB TI, AAHR
CLR TI
MOV SBUF, #'3'
AAHS: JNB TI, AAHS
CLR TI
MOV SBUF, #'9'
AAHT: JNB TI, AAHT
CLR TI
MOV SBUF, #'0'
AAHU: JNB TI, AAHU
CLR TI
MOV SBUF, #'5'
AAHV: JNB TI, AAHV
CLR TI
MOV SBUF, #'A'
AAHX: JNB TI, AAHX
CLR TI
MOV SBUF, #'0'
AAHY: JNB TI, AAHY
CLR TI
MOV SBUF, #'4'
AAHZ: JNB TI, AAHZ
CLR TI
MOV SBUF, #'2'
AAIA: JNB TI, AAIA
CLR TI
MOV SBUF, #'5'
AAIB: JNB TI, AAIB
CLR TI
MOV SBUF, #'9'
AAIC: JNB TI, AAIC
CLR TI
MOV SBUF, #'D'
AAID: JNB TI, AAID
CLR TI
MOV SBUF, #'5'
AAIE: JNB TI, AAIE
CLR TI
MOV SBUF, #'4'
AAIF: JNB TI, AAIF
CLR TI
MOV SBUF, #'6'
AAIG: JNB TI, AAIG
CLR TI
MOV SBUF, #'9'
AAIH: JNB TI, AAIH
CLR TI
MOV SBUF, #'9'
AAII: JNB TI, AAII
CLR TI
MOV SBUF, #'5'
AAIJ: JNB TI, AAIJ
CLR TI
MOV SBUF, #'5'
AAIK: JNB TI, AAIK
CLR TI
MOV SBUF, #'8'
AAIL: JNB TI, AAIL
CLR TI
MOV SBUF, #'2'
AAIM: JNB TI, AAIM
CLR TI
MOV SBUF, #'4'
AAIN: JNB TI, AAIN
CLR TI
MOV SBUF, #'0'
AAIO: JNB TI, AAIO
CLR TI
MOV SBUF, #'2'
AAEK: JNB TI, AAEK
CLR TI
MOV SBUF, #1AH
AAEL: JNB TI, AAEL
CLR TI
RET
ORG 9000H
ENTER: MOV SBUF, #0DH; THIS IS CARRIAGE RETURNS i.e. CR
AAEM: JNB TI, AAEM
CLR TI
MOV SBUF, #0AH ; THIS IS LINE FEED i.e. LF
AAEN: JNB TI, AAEN
CLR TI
RET
ORG 9100H
DELAY: MOV R0, #0FFH
MOV R1, #0FFH
MOV R2, #3FH
BBB: DJNZ R0, BBB; 5 SEC DELAYS
DJNZ R1, BBB
DJNZ R2, BBB
RET
ORG 9200H
CONTINEOUSDIALLING:
HERE22: MOV SBUF, #'A'; COMMAND FOR ANOTHER NUMBER DIALLING
BBC: JNB TI, BBC
CLR TI
MOV SBUF, #'T'
BBD: JNB TI, BBD
CLR TI
MOV SBUF, #'D'
BBE: JNB TI, BBE
CLR TI
MOV SBUF, #'='
BBF: JNB TI, BBF
CLR TI
MOV SBUF, #'9'
BBG: JNB TI, BBG
CLR TI
MOV SBUF, #'1'
BBH: JNB TI, BBH
CLR TI
MOV SBUF, #'4'
BBI: JNB TI, BBI
CLR TI
MOV SBUF, #'7'
BBJ: JNB TI, BBJ
CLR TI
MOV SBUF, #'4'
BBK: JNB TI, BBK
CLR TI
MOV SBUF, #'0'
BBL: JNB TI, BBL
CLR TI
MOV SBUF, #'5'
BBM: JNB TI, BBM
CLR TI
MOV SBUF, #'4'
BBN: JNB TI, BBN
CLR TI
MOV SBUF, #'6'
BBP: JNB TI, BBP
CLR TI
MOV SBUF, #';'
BBQ: JNB TI, BBQ
CLR TI
MOV SBUF, #0DH; THIS IS CARRIAGE RETURN I.E CR
BBR: JNB TI, BBR
CLR TI
MOV SBUF, #0AH; THIS IS LINE FEED I.E LF
BBS: JNB TI, BBS
CLR TI
MOV SBUF, #’A’; COMMAND FOR DIALLING MOBILE
BBT: JNB TI, BBT
CLR TI
MOV SBUF, #'T'
BBU: JNB TI, BBU
CLR TI
MOV SBUF, #'D'
BBV: JNB TI, BBV
CLR TI
MOV SBUF, #'='
BBW: JNB TI, BBW
CLR TI
MOV SBUF, #'9'
BBX: JNB TI, BBX
CLR TI
MOV SBUF, #'1'
BBY: JNB TI, BBY
CLR TI
MOV SBUF, #'3'
BBZ: JNB TI, BBZ
CLR TI
MOV SBUF, #'8'
BCC: JNB TI, BCC
CLR TI
MOV SBUF, #'2'
BCD: JNB TI, BCD
CLR TI
MOV SBUF, #'6'
BCE: JNB TI, BCE
CLR TI
MOV SBUF, #'8'
BCF: JNB TI, BCF
CLR TI
MOV SBUF, #'8'
BCG: JNB TI, BCG
CLR TI
MOV SBUF, #'2'
BCI: JNB TI,BCI
CLR TI
MOV SBUF, #';'
BCJ: JNB TI, BCJ
CLR TI
MOV SBUF, #0DH ; THIS IS CARRIAGE RETURN I.E CR TO EXECUTE COMMAND
BCK: JNB TI, BCK
CLR TI
MOV SBUF, #0AH; THIS IS LINE FEED I.E LF TO EXECUTE COMMAND
BCL: JNB TI, BCL
CLR TI
LJMP HERE22
END