0% found this document useful (0 votes)
245 views

Project Report 22 PDF

The main aim of this project is to design an SMS driven automatic display which reduces the manual operation. The message to be displayed is sent as an SMS to a GSM receiver module. This message is then stored in PC and is sent to the LCD displays through the controller. The messages stored in the computer acts as a record for future reference.

Uploaded by

Shobhit Goswami
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
245 views

Project Report 22 PDF

The main aim of this project is to design an SMS driven automatic display which reduces the manual operation. The message to be displayed is sent as an SMS to a GSM receiver module. This message is then stored in PC and is sent to the LCD displays through the controller. The messages stored in the computer acts as a record for future reference.

Uploaded by

Shobhit Goswami
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 93

Chapter-1

INTRODUCTION
1.1 Overview
Now-a-days advertisement is going digital. The big shops and the shopping centers use
digital displays now. Also, in trains and buses the information like platform number,
ticket information is displayed in digital boards. People are now adapted to the idea of the
world at its finger-tips. The use mobile phones have increased drastically over years.
Control and communication has become important in all the parts of the world. This gave
us the idea to use mobile phones to receive message and then display it on an electronic
board. The GSM technology is used. GSM stands for Global System for Mobile
Communication. Due to this international roaming capability of GSM, user can send
message to receiver from any part of the world. It is has the system for SMS Short
Message Service.
This is an embedded based project. An embedded system is a combination of hardware
and software and perhaps other mechanical parts designed to perform a specific function.
A Notice Board is a very essential device in any institution/organization or public utility
place like bus stations, railway stations and parks. The main aim of this project is to
design an SMS driven automatic display which reduces the manual operation. The
information can in turn be updated instantly at the desired location. Updates can be done
in individual displays without disturbing other displays. The message to be displayed is
sent as an SMS to a GSM receiver module. This message is then stored in PC and is sent
to the LCD displays through the controller. The messages stored in the computer acts as a
record for future reference. The monitoring system includes a micro-miniature camera
which would be capable of acquiring 3 mega pixel color images, transfer them on to a
personal computer through a Universal Serial Bus (USB) link, and also store the image in
a micro SD card after applying an image compression algorithm. The report explains how

a raw image data is captured by a CCD sensor and interfacing of the sensor with an
ARM7 processor.

1.2 Background
What makes SMS messaging so successful worldwide?
SMS is a success all over the world. The number of SMS messages exchanged every day
is enormous. SMS messaging is now one of the most important revenue sources of
wireless carriers. What is so special about SMS that makes it so popular worldwide?
Some of the reasons are discussed below. SMS messages can be sent and read at any
time: Nowadays, almost every person has a mobile phone and carries it most of the time.
With a mobile phone, you can send and read SMS messages at any time, no matter you
are in your office, on a bus or at home. SMS messages can be sent to an offline mobile
phone: Unlike a phone call, user can send an SMS message to users friend even when
users friend has not switched on the mobile phone or when users friend is in a place
where the wireless signal is temporarily unavailable. The SMS system of the mobile
network operator will store the SMS message and later send it to users friend when
users friend mobile phone is online. All GSM mobile phones support it. Not only that
user can exchange SMS messages with mobile users of the same wireless carrier, but user
can also exchange SMS messages with mobile users of many other wireless carriers
worldwide.
SMS is a suitable technology for wireless applications to build on: Here are some of the
reasons that make SMS a suitable technology for wireless applications to build on:
Firstly, SMS messaging is supported by 100% GSM mobile phones. Building
wireless applications on top of the SMS technology can maximize the potential
user base.
Secondly, SMS messages are capable of carrying binary data besides text. They
can be used to transfer ringtones, pictures, operator logos, wallpapers, animations,
VCards, VCals (calendar entries), etc.

Thirdly, SMS supports reverse billing, which enables payment to be made


conveniently. For example, suppose user want to develop a commercial ringtone
download application that charges a fee from the user for each ringtone
downloaded. One way to accept payment is to use a reverse billing phone number
obtained from a wireless carrier. To buy a ringtone, the user will write an ordinary
SMS text message that contains the ID of the ringtone he/she wants to buy and
send it to users SMS application's reverse billing phone number. Users SMS
application will then send back one or more reverse billing SMS messages that
carry the ringtone. The user will be charged a fee for the reverse billing SMS
messages he/she received. The fee will be included in the user's monthly mobile
phone bill or be deducted from his/her prepaid card credits. Depending on the
agreement between user and the wireless carrier, all or part of the money received
will be given to user.

1.3 Objective
1. This project is a remote notice board with a GSM modem at the receivers end.
2. So if the user wants to display any message, he can send the information by SMS and
thus update the LCD display accordingly.
3. As engineers main aim is to make life simple with help of technology, this is one
step to simplify real time noticing.

1.4Characteristics
It is High Quality Product (Not hobby grade) and Its Quad-Band GSM/GPRS and its
frequency 850/ 900/ 1800/ 1900 MHz. It is built in RS232 Level Converter (MAX3232)
and it has configurable baud rate. It is SMA connector with GSM L Type Antenna. It
Built in SIM Card holder and in Network Status LED. Most Status & Controlling Pins are
available at Connector. Its Normal operation temperature: -20 C to +55 C and Input
Voltage: 5V-12V DC.

1.5 Applications
1. Educational Institutions and Organizations: Currently user rely on putting up
papers on notice boards to inform people of events. This method can be discarded by
using wireless notice boards to display information in real time.
2. Crime Prevention: Display boards put up on roads will display tips on public
security, accident prevention, information on criminals on the run. The board will
help flash messages such as vehicle thefts as and when they occur.
3. Managing Traffic: In metropolitan cities user frequently come across traffic jams.
One way to avoid this would be inform people beforehand to take alternate routes. A
wireless notice board serves well for this purpose.
4. Advertisement: In shopping malls user get to hear the offers on various products
from time to time. Instead everyone continuously display the information regarding
the products and related offers on electronic display boards.
5. Railway Station: Instead of announcing the delay in arrival of trains user can display
the information.

1.6 Merits
1. User friendly: Messages are only to be typed on a mobile or a computer, which in
turn are displayed wirelessly on the display unit.
2. Eliminates use of printers: Since everyone dont use papers to display information,
printers are also of no use in this system.
3. Faster means of transferring information: There is no delay in transmission of
information. Messages are displayed in a matter of seconds after typing.

4. Long Range: As long as everyone have the required network coverage everyone can
send messages from any part of the world.

1.7 Needs
1. Uses in Banks: There is a huge mass of population which depends upon the banks for
all their monetary transactions. To keep a proper track of such huge mass of people
and their transactions this technology helps with certain degree of effectiveness.
2. Uses for Traffic Control: Its known to all of us that traffic are the good servants of
the people and also the major invention to help people but only if it is managed well.
So with the use of this technology we can maintain the flow of traffic according to the
needs of the people and also considering the availability of roads.
3. Uses for advertisement: We can make use of this technology to display the different
advertisement on display panels to reach the larger number of people at a time and in
the populated places like shopping malls, road sides as well as at the theaters, discos,
hotels, motels, restaurants etc. about their products and features.
4. Uses in Educational sector: Currently in India we are relying on the old style of
displaying news by hanging bare time consuming papers on the notice board which
can be replaced by remote controlled notice boards at the colleges and universities,
also at the time of examination scheduling and result publishing etc.
5. Stock Exchange: The stock exchange is the hot topic nowadays. There are millions
of sales of shares every hours and it is very necessary to maintain the real time
services with the certain measures of reliability because it deals with the money large
number of the small or bigger investors. With the help of this technology we can
make it far easier and reliable.

Chapter-2
IMPLEMENTATION OF PROTOTYPE MODEL
2.1: Block Diagram

Fig.2.1 : block diagram


2.2: Description of Block Diagram
The design of the project is basically divided into two section :1. Transmitting section
2. Receiving section

2.2.1: Transmitting Section


Transmitting Section consists of just mobile which has inbuilt GSM modem for wireless
data transfer through GSM.Since it is a multiuser system, various users are authenticated
to use the system or display messages on the notice board.For security, individual
passwords are provided to authorized users. To display their message on notice board, a
user need to authenticate itself with the system by sending message containing the
assigned password and the text to the receiver sections SIM number.

2.2.2: Receiving Section


The receiving sections system verifies password and sends response to the user
and displays the text on the electronic notice board.

Fig. 2.2: Block Diagram of Receiving Section

2.2.3: GSM Network


It consists of Global System for Mobile Communication. It is originally from Group of
Special Mobile. It is the most popular standard for mobile phone in the world. GSM is a
cellular network, which means that mobile phones connect to it by searching for cells in
the immediate vicinity. The modulation used in GSM is Gaussian minimum-shift keying
(GMSK), signal to be modulated onto the carrier is first smoothed with a Gaussian low
pass filter prior to being fed to a frequency modulator which greatly reduces adjacent
channel interference.For this type of application we needed the GSM cell phone which
supports AT commands. After many searches we found out that Motorola C168 is the
7

only mobile which supports each and every AT command. For serial communication we
have used 2.5mm jack cable with the jack provided in mobile.

Fig.2.3: 5mm Jack For serial communication

2.4: Flow Chart

Fig.2.4: Flow Chart

2.4: Circuit Diagram

Fig 2.5: Circuit diagram

2.5: Operation
Initially an authorized mobile user will send a message containing information to choose
the required LCD display. For security purpose we have included a password. Access
will be granted to the user who is aware of the password. Once the message is received it
is stored in the computer. Here a real time clock displays the time in the graphical LCD.
The graphical display can be used to view the marks of the students or any information
about the institution or organization. When there is a high priority message (mobile user)
the current information that is displayed will be held up and this high priority message
will be displayed. The audio driver which has the pre-recorded voice will announce the
arrival of new messages.

10

2.5.1: AT Commands
AT commands are instructions used to control a modem. AT is the abbreviation of AT
tension. 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/GPRS modems and mobile phones.
Besides this common AT command set, GSM/GPRS 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).

2.5.2: Reading Messages


To enable a computer / PC to read SMS messages from a message storage area, the
GSM/GPRS modem or mobile phone has to support either of the AT commands +CMGR
(command name in text: Read Messages) and +CMGL (command name in text: List
Messages). The +CMGR AT command is used to read an SMS message at a certain
location of the message storage area, while the +CMGL AT command is used to read
SMS messages that have a certain status from the message storage area. The status can be
"received unread", "received read", "stored unsent", "stored sent", etc. The +CMGL AT
command also allows you to retrieve all SMS messages stored in the message storage
area Following is an example for illustrating the difference between +CMGR and
+CMGL. Suppose you want to use your computer / PC to read a text message from the
message storage area and you know the index at which the SMS text message is located.
In this case, you should use the +CMGR AT command. Here is the command line to be
typed (assume the SMS text message is stored at index 3) :
AT+CMGR=3
The GSM/GPRS modem or mobile phone should return something like this:
+CMGR: "REC
11

READ","+85291234567","07/02/18,00:12:05+32"
Hello, welcome to our SMS tutorial.
OK

2.5.3: Software
For more efficient and hasty programming user went for Bascom AVR which is specially
for AVRs like ATmega16. It is because it have the in-built functions for LCDs , UARTs
etc. so and also by simulation user can check our output on virtual LCD. Also by direct
connection out AVR user can burn the program from Bascom AVR only. Here user
provide a

basic starting of a code to configure LCD and UART

$regfile = "m48def.dat"

' we use the M48

$crystal = 8000000

` crystal frequency

$baud = 19200

` baud rate

$hwstack = 32

` hardware stack

$frame size = 24
Dim A As Byte , C As Integer , S As String * 4
A=1
So as given, code is very easy to write and it have many other advantages than our
conventional AVR Studio 4 software.

12

2.5.4: Schematic and Layout


Here we use Express PCB to design Schematic and Layout of our main circuit before
printing. This software is very easy to use for beginners. Let I explain you the steps for
PCB
There are two parts to Express PCB, CAD software and board manufacturing
service.CAD software includes Express SCH for drawing schematics and Express
PCB for designing circuit boards. After completing PC board design, we provide
a low cost, high quality and fast source for having boards made. Here is how it
works:
1. It is recommend that you begin your project by drawing a schematic using
Express SCH. Drawing a schematic is not required, but it will save you time
when designing your board and reduce the possibility of wiring errors.
2. Next, use the Express PCB program to lay out PC board. If you link schematic
to the Express PCB program, the program will guide you through the wiring
process by highlighting how the components should be connected.
3. When layout is complete, the Express PCB program will tell you the exact
cost to have your boards made.
4. To order the boards, simply enter your name, address and billing information
into Express PCB and press the Send button in the Order Boards Via The
Internet dialog box.
5. In a few business days (typically 2 or 3) an overnight courier will deliver your
PC boards.

13

2.6: Working
1. Using GSM mobile user can send message to any distant located e-notice board from
any remote area.
2. By interfacing the GSM modem with mobile phone user can send text message from
any remote area.
3. GSM MODEM, SIM, LCD (Liquid Crystal Display), microcontroller,power supply
and also some connecting wires are the common peripherals required for developing
any GSM based applications. As the components required for the application are
available at pocket friendly prices and due to their ease of accessibility enhanced
GSM based applications.

14

Chapter-3
HARDWARE REQUIREMENT
3.1: Components
Essential components for assembling GSM based applications including:
1. GSM MODEM
2. SIM
3. Power supply or Power Adapter
4. LCD
5. Voltage Regulator
6. Transformer
7. Capacitor
8. LED
9. Resistor
10. Push Switch
11. Microcontroller

3.1.1: GSM Modem


It is a wireless MODEM-just like dial-up MODEM works with GSM wireless
network. The difference between dial-up MODEM and wireless MODEM is, wireless
MODEM send and receive data through radio waves whereas dial-up MODEM send and
receives data through a fixed telephone line. GSM (Global System for Mobile
Communications, originally Groupe Spcial Mobile), is a standard developed by
15

the European Telecommunications Standards Institute (ETSI) to describe protocols for


second-generation (2G) digital cellular networks used by mobile phones. As of 2014 it
has become the default global standard for mobile communications - with over 90%
market share, operating in over 219 countries and territories. 2G networks developed as a
replacement for first generation (1G) analog cellular networks, and the GSM standard
originally

described

digital,

circuit-switched

network

optimized

for full

duplex voice telephony. This expanded over time to include data communications, first
by circuit-switched transport, then by packet data transport via GPRS (General Packet
Radio Services) and EDGE (Enhanced Data rates for GSM Evolution or EGPRS).
Subsequently, the 3GPP developed third-generation (3G) UMTS standards followed by
fourth-generation (4G) LTE Advanced standards, which do not form part of the ETSI
GSM standard. "GSM" is a trademark owned by the GSM Association. It may also refer
to the (initially) most common voice codec used, Full Rate.

Fig. 3.1: GSM MODEM available in local market.


16

3.1.1.1: Technical Details

Fig. 3.2: Structure of GSM Network

3.1.1.2: Network Structure


The network is structured into a number of discrete sections:
1. Base Station Subsystem: the base stations and their controllers explained.
2. Network and Switching Subsystem: the part of the network most similar to a fixed
network, sometimes just called the "core network."
3. GPRS Core Network: the optional part which allows packet-based Internet
connections.
4. Operations support system (OSS): network maintenance.

17

3.1.1.3: Pin Diagram of GSM Module

Fig. 3.3: Pin Diagram of GSM Module

3.1.2 Subscriber Identity Module (SIM)


One of the key features of GSM is the Subscriber Identity Module, commonly known as
a SIM card. The SIM is a detachable smart card containing the user's subscription
information and phone book. This allows the user to retain his or her information after
switching handsets. Alternatively, the user can also change operators while retaining the
handset simply by changing the SIM. Some operators will block this by allowing the
phone to use only a single SIM, or only a SIM issued by them; this practice is known
as SIM locking

18

3.1.2.1: Phone locking


Sometimes mobile network operators restrict handsets that they sell for use with their
own network. This is called locking and is implemented by a software feature of the
phone. A subscriber may usually contact the provider to remove the lock for a fee, utilize
private services to remove the lock, or use software and websites to unlock the handset
themselves.

In some countries (e.g., Bangladesh, Brazil, Chile, Germany, Hong Kong,

India, Iran, Lebanon, Malaysia, Nepal, Pakistan, Singapore, South Africa) all phones are
sold unlocked.

3.1.2.2: GSM service security


GSM was designed with a moderate level of service security. The system was designed to
authenticate

the

subscriber

using

a pre-shared

key and challenge-response.

Communications between the subscriber and the base station can be encrypted. The
development

of UMTS introduces

an

optional Universal

Subscriber

Identity

Module (USIM), that uses a longer authentication key to give greater security, as well as
mutually authenticating the network and the user, whereas GSM only authenticates the
user to the network (and not vice versa). The security model therefore offers
confidentiality and authentication, but limited authorization capabilities, and no nonrepudiation.
GSM uses General Packet Radio Service (GPRS) for data transmissions like browsing the
web. The most commonly deployed GPRS ciphers were publicly broken in 2011. The
researchers revealed flaws in the commonly used GEA/1 and GEA/2 ciphers and
published the open-source "GPRS decode" software for sniffing GPRS networks. They
also noted that some carriers do not encrypt the data (i.e., using GEA/0) in order to detect
the use of traffic or protocols they do not like (e.g., Skype), leaving customers
unprotected. GEA/3 seems to remain relatively hard to break and is said to be in use on
some more modern networks. If used with USIM to prevent connections to fake base
stations and downgrade attacks, users will be protected in the medium term, though
migration to 128-bit GEA/4 is still recommended.

19

3.1.3: Power Supply


Power supply is the source of electrical power. Normally any electronic circuit uses +5v
DC power for its regular working .User can directly built +5v Dc power supply using 4
diodes, filter capacitors and regulator IC-7805(Integrated Circuit)or can directly purchase
a +5v DC power adopter from the local market.

Fig. 3.4: +5v DC power supply for microcontroller

3.1.4: Liquid Crystal Display (LCD)


One of the most common devices attached to an 8051 is an LCD display. Some of the
most common LCDs connected to the 8051 are 16x2 and 20x2 displays. This means 16
characters per line by 2 lines and 20 characters per line by 2 lines, respectively. In recent
years the LCD is finding widespread use replacing LEDs. This is due to the following
reasons:
Declining prices
Ability to display numbers, characters and graphics.
Incorporation of a refreshing controller into the LCD.
Ease of programming.
The command register stores the command instructions given to the LCD. A command is
an instruction given to LCD to do a predefined task like initializing it, clearing its screen,
setting the cursor position, controlling display etc. The data register stores the data to be
displayed on the LCD. The data is the ASCII value of the character to be displayed on the
LCD.

20

Fig. 3.5: 16x2 LCD

3.1.4.1: Features
It has 5 x 8 dots with cursor.
Built- in controller (KS 0066 or Equivalent) In 16X2 LCD.
It consist of + 5V power supply (Also available for + 3V).
This LCD has 1/16 duty cycle.
Table 3.1: Pin Configuration of LCD

21

3.1.4.2: Important Signals


The following pins are important to LCDs while programming:
A. Enable (EN): The EN line is called "Enable." This control line is used to tell the
LCD that you are sending it data. To send data to the LCD, your program should
make sure this line is low (0) and then set the other two control lines and/or put
data on the data bus. When the other lines are completely ready, bring EN high
(1) and wait for the minimum amount of time required by the LCD datasheet (this
varies from LCD to LCD), and end by bringing it low (0) again.
B. Register Select (RS): The RS line is the "Register Select" line. When RS is low
(0), the data is to be treated as a command or special instruction (such as clear
screen, position cursor, etc.). When RS is high (1), the data being sent is text data
which should be displayed on the screen. For example, to display the letter "T" on
the screen you would set RS high.
C. Read/Write (R/W): The RW line is the "Read/Write" control line. When RW is
low (0), the information on the data bus is being written to the LCD. When RW is
high (1), the program is effectively querying (or reading) the LCD. Only one
instruction ("Get LCD status") is a read command. All others are write
commands--so RW will almost always be low. The 10k Potentiometer controls
the contrast of the LCD panel.

3.1.5: Voltage Regulator


7805 is a voltage regulator integrated circuit. It is a member of 78xx series of fixed linear
voltage regulator ICs. The voltage source in a circuit may have fluctuations and would
not give the fixed voltage output. The voltage regulator IC maintains the output voltage at
a constant value. The xx in 78xx indicates the fixed output voltage it is designed to
provide. 7805 provides +5V regulated power supply. Capacitors of suitable values can be
connected at input and output pins depending upon the respective voltage levels.
22

Fig. 3.6: Voltage Regulator 7805

Fig. 3.7: Pin diagram of Voltage


Regulator 7805

3.1.6: Transformer
Transformer is a static electrical device which transfers electrical energy from one circuit
to another circuit. Transformer working can be easily understood by its primary and
secondary windings.

Fig. 3.8: Step down Transformer

3.1.7: Capacitor
The

capacitor's

function

is

to

store

electricity,

or

electrical

energy.

The capacitor also functions as a filter, passing alternating current (AC), and blocking
direct current (DC). This symbol

is used to indicate a capacitor in a circuit diagram.


23

The capacitor is constructed with two electrode plates facing each other, but separated by
an insulator. When DC voltage is applied to the capacitor, an electric charge is stored on
each electrode. While the capacitor is charging up, current flows. The current will stop
flowing when the capacitor has fully charged.

Fig. 3.9: Circuit Diagram of Capacitor


When a circuit tester, such as an analog meter set to measure resistance, is connected to a
10 microfarad (F) electrolytic capacitor, a current will flow, but only for a moment. You
can confirm that the meter's needle moves off of zero, but returns to zero right away.
When user connect the meter's probes to the capacitor in reverse, you will note that
current once again flows for a moment. Once again, when the capacitor has fully charged,
the current stops flowing. So the capacitor can be used as a filter that blocks DC current.
(A "DC cut" filter.) However, in the case of alternating current, the current will be
allowed to pass. Alternating current is similar to repeatedly switching the test meter's
probes back and forth on the capacitor. Current flows every time the probes are switched.
Sometimes, a three-digit code is used to indicate the value of a capacitor. There are two
ways in which the capacitance can be written. One uses letters and numbers, the other
uses only numbers. In either case, there are only three characters used. [10n] and [103]
denote the same value of capacitance. The method used differs depending on the
capacitor supplier. In the case that the value is displayed with the three-digit code, the 1st
and 2nd digits from the left show the 1st figure and the 2nd figure, and the 3rd digit is a
multiplier which determines how many zeros are to be added to the capacitance. Pico
farad (pF) units are written this way.

24

3.1.7.1: Breakdown Voltage


When using a capacitor, you must pay attention to the maximum voltage which can be
used. This is the "breakdown voltage." The breakdown voltage depends on the kind of
capacitor being used. You must be especially careful with electrolytic capacitors because
the breakdown voltage is comparatively low. The breakdown voltage of electrolytic
capacitors is displayed as Working Voltage. The breakdown voltage is the voltage that
when exceeded will cause the dielectric (insulator) inside the capacitor to break down and
conduct. When this happens, the failure can be catastrophic.

3.1.8 Light Emitting Diode (LED)


A light-emitting diode (LED) is a two-lead semiconductor light source.

It is apn-

junction diode, which emits light when activated. When a suitable voltage is applied to
the leads, electrons are able to recombine with electron holes within the device, releasing
energy in the form of photons. This effect is called electroluminescence, and the color of
the light (corresponding to the energy of the photon) is determined by the energy band
gap of the semiconductor.
An LED is often small in area (less than 1 mm2) and integrated optical components may
be used to shape its radiation pattern. Appearing as practical electronic components in
1962,[6] the earliest LEDs emitted low-intensity infrared light. Infrared LEDs are still
frequently used as transmitting elements in remote-control circuits, such as those in
remote controls for a wide variety of consumer electronics. The first visible-light LEDs
were also of low intensity, and limited to red. Modern LEDs are available across
the visible, ultraviolet, and infrared wavelengths, with very high brightness.
Early LEDs were often used as indicator lamps for electronic devices, replacing small
incandescent bulbs. They were soon packaged into numeric readouts in the form
of seven-segment

displays,

and

were

commonly seen in digital clocks.

Recent

developments in LEDs permit them to be used in environmental and task lighting. LEDs
25

have

many

advantages

over

incandescent

light sources including lower energy

consumption, longer lifetime, improved physical robustness, smaller size, and faster
switching. Light-emitting diodes are now used in applications as diverse as aviation
lighting, automotive headlamps, advertising, general lighting, traffic signals, and camera
flashes. However, LEDs powerful enough for room lighting are still relatively expensive,
and require more precise current and heat management than compact fluorescent
lamp sources of comparable output. LEDs have allowed new text, video displays, and
sensors to be developed, while their high switching rates are also useful in advanced
communications technology.

Fig. 3.10: Diagram of LED

Fig.3.11: Characteristics of Diode

26

The graph above shows the electrical characteristics of a typical diode. When a small
voltage is applied to the diode in the forward direction, current flows easily. Because the
diode has a certain amount of resistance, the voltage will drop slightly as current flows
through the diode. A typical diode causes a voltage drop of about 0.6 - 1V (VF) (In the
case of silicon diode, almost 0.6V). This voltage drop needs to be taken into
consideration in a circuit which uses many diodes in series. Also, the amount of current
passing through the diodes must be considered. When voltage is applied in the reverse
direction through a diode, the diode will have a great resistance to current flow. Different
diodes have different characteristics when reverse-biased. A given diode should be
selected depending on how it will be used in the circuit. The current that will flow
through a diode biased in the reverse direction will vary from several mA to just A,
which is very small. The limiting voltages and currents permissible must be considered
on a case by case basis. For example, when using diodes for rectification, part of the time
they will be required to withstand a reverse voltage. If the diodes are not chosen
carefully, they will break down.

3.1.9 Resistor
The

resistor's

This symbol

function

is

to

reduce

the

flow

of

electric

current.

is used to indicate a resistor in a circuit diagram, known as a

schematic. Resistance value is designated in units called the "Ohm." A 1000 Ohm resistor
is typically shown as 1K-Ohm ( kilo Ohm ), and 1000 K-Ohms is written as 1M-Ohm
(mega ohm).
There are two classes of resistors; fixed resistors and the variable resistors.
They are also classified according to the material from which they are made. The typical
resistor is made of either carbon film or metal film. There are other types as well, but
these are the most common. The resistance value of the resistor is not the only thing to
consider when selecting a resistor for use in a circuit. The "tolerance" and the electric
power ratings of the resistor are also important. The tolerance of a resistor denotes how
close it is to the actual rated resistance value. For example, a 5% tolerance would
indicate

resistor

that

is

within

5%
27

of

the

specified

resistance

value.

The power rating indicates how much power the resistor can safely tolerate. The
maximum

rated

power

of

the

resistor

is

specified

in

Watts.

Power is calculated using the square of the current ( I2 ) x the resistance value ( R ) of the
resistor. If the maximum rating of the resistor is exceeded, it will become extremely hot,
and even burn. Resistors in electronic circuits are typically rated 1/8W, 1/4W, and
1/2W.When powering a light emitting diode, a comparatively large current flows through
the resistor, so you need to consider the power rating of the resistor you choose.

Fig. 3.12: Diagram of Resistor

3.1.10 Switch
A wide variety of PIN diode and GaAs high-speed, high-isolation switches are available
from Mini-Circuits, including models with built-in TTL drivers, operating up to 5 GHz.
Select from SPST, SPDT, and SP4T models in EMI-shielded plug-in, TO-8, surfacemount and connector zed packages. PIN diode units are available in SPST/SPDT
configurations as well as SPDT/SP4T models with built-in drivers with 2 sec switching
speed, tough enough to pass stringent MIL-STD-202 tests. Despite their small size, the
TO-8 models (TOSW-230 and TOSW- 425) provide isolation as high as 40 dB, only 1.1
dB insertion loss, with a 1dB compression point of +27 dBm. Switching speed as fast as
2 neno sec is offered with Mini-Circuits GaAs switches, available in absorptive and
reflective models, with and without TTL built-in drivers. All models are available with
SMA connectorized or surface-mount packages. The connectorized packages are
miniature, easily mountable, and well suited for test set-ups. Surface-mount units are
offered in a low-cost plastic package and hermetic ceramic cases for military
28

applications. These packages are rugged enough to pass MIL-STD-883 vibration,


mechanical and thermal shock, fine and gross leak tests. These fast acting switches can
operate from DC up to 5 GHz with 50dB isolation and only 1 dB insertion loss. The
absorptive models exhibit a typical VSWR of 1.5 in the "OFF" state.

Fig. 3.13: Diagram of Switch

3.1.11 Microcontroller
A microcontroller is a small computer on a single integrated circuit containing a
processor core, memory and programmable input/output peripherals. Due to simplicity in
design and pocket friendly prices, microcontroller is widely adopted for various fields
including automobiles, medical science, defense, domestic applications, industrial use,
energy management and lots more domains. Microcontrollers are commonly built using
CMOS (Complementary Metal Oxide semiconductor) technology resulting optimum
performance with the least consumption of power. As it is designed to perform a specific
task ,latency of the task is fast and is more reliable. Microcontroller is the heart of
system. It is used for interfacing the display, memory and peripherals with GSM modem.
1. The microcontroller used in this project is ATmega16.
2. It is a low power CMOS 8-bit microcontroller based on the AVR enhanced RISC
(reduced instruction set computing) architecture.

Fig. 3.14: Circuit Diagram of Microcontroller


29

3.1.11.1: Pin Diagram

Fig.3.15: Pin Diagram of Microcontroller

3.1.11.2: Pin Description


VCC

Digital supply voltage.

GND

Ground.

Port A (PA7.PA0)

Port A serves as the analog inputs to the A/D Converter.

30

Port A also serves as an 8-bit bi-directional I/O port, if the A/D Converter is not used.
Port pins can provide internal pull-up resistors (selected for each bit). The Port A output
buffers have symmetrical drive characteristics with both high sink and source capability.
When pins PA0 to PA7 are used as inputs and are externally pulled low, they will source
current if the internal pull-up resistors are activated. The Port A pins are tri-stated when a
reset condition becomes active, even if the clock is not running.
Port B (PB7.PB0)
Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each
bit). The Port B output buffers have symmetrical drive characteristics with both high sink
and source capability. As inputs, Port B pins that are externally pulled low will source
current if the pull-up resistors are activated. The Port B pins are tri-stated when a reset
condition becomes active, even if the clock is not running. Port B also serves the
functions of various special features of the ATmega16 as listed on page 55.
Port C (PC7.PC0)
Port C is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each
bit). The Port C output buffers have symmetrical drive characteristics with both high sink
and source capability. As inputs, Port C pins that are externally pulled low will source
current if the pull-up resistors are activated. The Port C pins are tri-stated when a reset
condition becomes active, even if the clock is not running. If the JTAG interface is
enabled, the pull-up resistors on pins PC5(TDI), PC3(TMS) and PC2(TCK) will be
activated even if a reset occurs. Port C also serves the functions of the JTAG interface
and other special features of the ATmega16 as listed on page 58.
Port D (PD7.PD0)
Port D is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each
bit). The Port D output buffers have symmetrical drive characteristics with both high sink
and source capability. As inputs, Port D pins that are externally pulled low will source
current if the pull-up resistors are activated. The Port D pins are tri-stated when a reset
condition becomes active, even if the clock is not running.
31

Port D also serves the functions of various special features of the ATmega16 as listed on
page 60.
RESET

Reset Input.

A low level on this pin for longer than the minimum pulse length will generate a reset,
even if the clock is not running. The minimum pulse length is given in Table 15 on page
35. Shorter pulses are not guaranteed to generate a reset.
XTAL1
Input to the inverting Oscillator amplifier and input to the internal clock operating circuit.
XTAL2
Output from the inverting Oscillator amplifier.
AVCC
AVCC is the supply voltage pin for Port A and the A/D Converter. It should be externally
connected to VCC, even if the ADC is not used. If the ADC is used, it should be
connected to VCC through a low-pass filter.
AREF
AREF is the analog reference pin for the A/D Converter.

3.1.11.3: Operation
The AVR core combines a rich instruction set with 32 general purpose working registers.
All the 32 registers are directly connected to the Arithmetic Logic Unit (ALU), allowing
two independent registers to be accessed in one single instruction executed in one clock
cycle. The resulting architecture is more code efficient while achieving throughputs up to
ten times faster than conventional CISC microcontrollers.
The ATmega16 provides the following features: 16K bytes of In-System Programmable
Flash Program memory with Read-While-Write capabilities, 512 bytes EEPROM, 1K
byte SRAM, 32 general purpose I/O lines, 32 general purpose working registers, a JTAG
interface for Boundary-scan, On-chip Debugging support and programming, three
32

flexible Timer/Counters with compare modes, Internal and External Interrupts, a serial
programmable USART, a byte oriented Two-wire Serial Interface, an 8-channel, 10-bit
ADC with optional differential input stage with programmable gain (TQFP package
only), a programmable Watchdog Timer with Internal Oscillator, an SPI serial port, and
six software selectable power saving modes.
The ATmega16 AVR is supported with a full suite of program and system development
tools including: C compilers, macro assemblers, program debugger/simulators, in-circuit
emulators, and evaluation kits.

3.1.11.4: Features
This is High-performance, Low-power AVR 8-bit Microcontroller.
It is having Advanced RISC Architecture.
131 Powerful Instructions Most Single-clock Cycle Execution
32 x 8 General Purpose Working Registers
Fully Static Operation
Up to 16 MIPS Throughput at 16 MHz
On-chip 2-cycle Multiplier
Nonvolatile Program and Data Memories
16K Bytes of In-System Self-Programmable Flash
Endurance: 10,000 Write/Erase Cycles
Optional Boot Code Section with Independent Lock Bits
In-System Programming by On-chip Boot Program
True Read-While-Write Operation
512 Bytes EEPROM
1K Byte Internal SRM
Programming Lock for Software Security
JTAG (IEEE std. 1149.1 Compliant) Interface
Boundary-scan Capabilities According to the JTAG Standard
Extensive On-chip Debug Support

33

Programming of Flash, EEPROM, Fuses, and Lock Bits through the JTAG
Interface
Peripheral Features
Two 8-bit Timer/Counters with Separate Prescalers and Compare Modes
One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture
Mode.
Real Time Counter with Separate Oscillator
Four PWM Channels
8-channel, 10-bit ADC
8 Single-ended Channels
7 Differential Channels in TQFP Package Only
2 Differential Channels with Programmable Gain at 1x, 10x, or 200x
Byte-oriented Two-wire Serial Interface
Programmable Serial USART
Master/Slave SPI Serial Interface
Programmable Watchdog Timer with Separate On-chip Oscillator
On-chip Analog Comparator
Special Microcontroller Features
Power-on Reset and Programmable Brown-out Detection
Internal Calibrated RC Oscillator
External and Internal Interrupt Sources
Six Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, Standby
and Extended Standby
I/O and Packages
32 Programmable I/O Lines
40-pin PDIP, 44-lead TQFP, and 44-pad MLF
Operating Voltages
2.7 - 5.5V for ATmega16L
4.5 - 5.5V for ATmega16
Speed Grades
0 - 8 MHz for ATmega16L
34

0 - 16 MHz for ATmega16

3.1.11.5: Block Diagram of Microcontroller (ATmega16)

Fig.3.16: Block Diagram of Microcontroller (ATmega16)

35

Chapter-4
SOFTWARE DESCRIPTION
4.1 Concept of Embedded C
4.1.1 Introduction
An embedded system is some combination of computer hardware and software, either
fixed in capability or programmable, that is specifically designed for a particular
function.

Industrial machines,

automobiles, medical equipment, cameras, household

appliances, airplanes, vending machines and toys (as well as the more obvious cellular
phone and PDA) are among the myriad possible hosts of an embedded system. Embedded
systems that are programmable are provided with programming interfaces, and embedded
systems programming is a specialized occupation.
Most C programmers are spoiled because they program in environments where not only
is there a standard library implementation, but there are frequently a number of other
libraries available for use. The cold fact is, that in embedded systems, there rarely are
many of the libraries that programmers have grown used to, but occasionally an
embedded system might not have a complete standard library, if there is a standard
library at all. Few embedded systems have capability for dynamic linking, so if standard
library functions are to be available at all, they often need to be directly linked into the
executable. C remains a very popular language for microcontroller developers due to the
code efficiency and reduced overhead and development time. C offers low level control
and is considered more readable than assembly. Many free C compilers are available for
a wide variety of development platforms. The compilers are part of an IDEs with ICD
support, breakpoints, single-stepping and an assembly window. The performance of C
compilers has improved considerably in recent years, and they are claimed to be more or
less as good as assembly, depending on who you ask. Most tools now offer options for
customizing the compiler optimization. Additionally, using C increases portability, since
C code can be compiled for different types of processors.
36

4.1.2: Difference between C and Embedded C


Though C and embedded C appear different and are used in different contexts, they have
more similarities than the differences. Most of the constructs are same; the difference lies
in their applications.

C is used for desktop computers, while embedded C is for microcontroller based


applications.

C takes more resources of a desktop PC like memory, OS, etc. while


programming on desktop systems what embedded C cannot. Embedded C has to
use the limited resources (RAM, ROM, I/Os) on an embedded processor. Thus,
program code must fit into the available program memory. If code exceeds the
limit, the system is likely to crash.

Compilers for C (ANSI C) typically generate OS dependent executable files.

Embedded C requires compilers to create files to be downloaded to the Microcontrollers


/microprocessors where it needs to run. Embedded compilers give access to all resources
which is not provided in compilers for desktop computer applications. Embedded systems
often have the real-time constraints, which is usually not there with desktop computer
applications.

Embedded systems often do not have a console, which is available in case of


desktop applications. The C programming language is perhaps the most popular

programming language for programming embedded systems. C continues to be a very


popular language for micro-controller developers/programmers due to the code efficiency
and reduced overhead and development time. C offers low-level control and is considered
more readable than assembly language which is a little difficult to understand. Assembly
language requires more code writing, whereas C is easy to understand and requires less
coding. Plus, using C increases portability, since C code can be compiled for different
types of processors. We can program microcontrollers using 8051, PIC. We can develop
our programs as per our electronic hardware using 8051 microcontroller. For example we
can blink led, increment decrement counters, token displays etc.
37

C remains a very popular language for micro-controller developers due to the code
efficiency and reduced overhead and development time. C offers low-level control and is
considered more readable than assembly. Many free C compilers are available for a wide
variety of development platforms. The compilers are part of an IDEs with ICD support,
breakpoints, single-stepping and an assembly window. The performance of C compilers
has improved considerably in recent years, and they are claimed to be more or less as
good as assembly, depending on who you ask. Most tools now offer options for
customizing the compiler optimization. Additionally, using C increases portability, since
C code can be compiled for different types of processors.

4.1.3: Concept of Embedded Systems in C


An embedded system is a system that connects preprogrammed software on a controller
embedded in the computer hardware. The software is installed on the controller, the
brains of the electronic device. Each embedded system is used for one specific function.
A complex device like a PDA or smart phone may have embedded devices that can
control several functions. However, embedded systems are not as complex or
programmable as a personal computer. C is one of the most commonly used
programming languages in embedded devices. Embedded systems are used to control
electronic devices such as DVD players, cell phones, watches and medical devices. Video
cards and network switches are embedded systems used in computer peripherals. The
cruise control and anti-lock brakes in a car are also embedded systems. Embedded
systems are cheaper than complex processors due to their simplicity and frequent mass
production. Software written in a language like C is used to control the mechanical
devices within the embedded system.

4.1.3.1: Reasons C is Common in Embedded Systems


C is one of the most commonly used software languages used on embedded device
controllers. One reason is because it is one of the few software languages that operates on
both 8 bit controllers and 64 bit PCs, meaning that many computer programmers can
38

write C software for both personal computers and embedded devices. The C language can
also use very simple commands to control the device, freeing up the limited memory of
the device to hold many commands or parameters. C can be written for both
microcontrollers and digital signal processors.

4.1.3.2: C Languages Used in Embedded Systems


C and C!! are used frequently in creation of embedded systems. Embedded systems are
rarely programmed using the C++ because embedded systems rarely have the memory
space for the complex programming used in C++. C# is occasionally used on embedded
Linux systems.

4.1.3.3: How C Programs Are Created and Installed on Embedded


Systems
Code is written in C on a programmer's PC. Code is run through a compiler on the
programmer's PC to create a software program. The embedded system software may be
run through a simulator on the programmer's computer. The software program is copied
onto the controller using a "programmer." The controller is then tested on a "test bed" to
ensure that it works properly.

4.1.3.4: Common Embedded Systems that Use C


Bluetooth devices are programmed in C. PIC microcontrollers such as those used in web
cameras are frequently programmed in C. PIC microcontrollers programmed in C have
also been used in LED (light emitting diodes) devices and LCD (liquid crystal display)
monitors. USB devices are embedded devices frequently coded in C.

4.1.3.5: Standards for Embedded System Programming in C


The American National Standards Institute (ANSI) has written standards for the C
programming

language.

The

International Standards

Organization

wrote

standard

ISO/IEC 9899 for the C programming language. The Motor Industry Software Reliability

39

Association has created a proprietary set of standards for programming in C for


embedded devices in automobiles.

4.1.4: How C is used Differently for Embedded Programming


If you are new to embedded C programming, you will notice that there are only subtle
differences between a regular C program and an embedded C program. The following is a
list of the most important differences between C programming for embedded systems and
C programming for PCs.

4.1.5: Keil Software


Keil development tools for the 8051 Microcontroller Architecture support every level of
software developer from the professional applications engineer to the student just
learning about embedded software development. The Keil 8051 Development Tools are
designed to solve the complex problems facing embedded software developers.
When starting a new project, simply select the microcontroller you use from the
Device Database and the Vision IDE sets all compiler, assembler, linker, and memory
options for you.
Numerous example programs are included to help you get started with the most
popular embedded 8051 devices.

40

Chapter 5
SYSTEM DESIGN
5.1: Functional Decomposition

Fig 5.1: functional decomposition diagram


The constituent parts involved in the process are

Mobile phone

GSM (global system for mobile)

Microcontroller

LCD display

First block portrays to be GSM which receives, verifies and forwards the message to the
Microcontroller. Micro is the second block. Micro processes the message and sends to the
41

LCD. LCD behaving as the third constituent part displays the message until it is invoked
by micro to display a new message.

5.2: State Transition Diagram

Fig 5.2: state transition diagram


The state transition refers to all the finite states the system enters during the process,
pointing out the behavior of the system when the message is received from the end user.
Just as soon as the message is received from the user the message is validated by
comparing with the password characters. The message is stored and sent to display. In the
other scenario the invalid user message is discarded by the microcontroller and later
keeps checking for any new recent messages.

42

FUTURE SCOPE
Temperature display during periods wherein no message buffers are empty is one
such theoretical improvement that is well possible. Another very interesting and
significant improvement would be to accommodate multiple receiver MODEMS at
different positions in the geographical area carrying duplicate SIM cards. Multilingual
display can be another added variation in the project.
Alphanumeric LCDs have a limitation on size as well as no. of characters. These can be
replaced with large LED display boards. Robots can be controlled in a similar fashion by
sending the commands to the robots.
This technology could be further modified and more upgraded as per individual need and
interest. We have discussed some basic ideas of this technology. And depending on
innovative applications user can upgrade as per requirement.

43

CONCLUSION
The prototype of the GSM based display toolkit was efficiently designed. This prototype
has facilities to be integrated with a display board thus making it truly mobile. The toolkit
accepts the SMS, stores it, validates it and then displays it in the LCD module. The SMS
is deleted from the SIM each time it is read, thus making room for the next SMS. The
major constraints incorporated are the use of * as the termination character of the SMS
and the display of one SMS as a time. These limitations can be removed by the use of
higher end microcontrollers and extended RAM. The prototype can be implemented
using commercial display boards. In this case, it can solve the problem of instant
information transfer in the campus.

44

References
http://www.daimlerchrysler.com/dccomDatasheet of NE555
http://www.gm.com/company/careers/career_paths/rnd/nws_071800.html

http://www.ehow.com/about_6677935_description-visual-basic.html

45

Appendix
Appendix-A

Programming

// File Name

: 'lcd_lib.c

// Title

: 8 and 4 bit LCd interface

// Author

: Scienceprog.com - Copyright (C) 2007

// Created

: 2007-03-29

// Revised

: 2007-08-08

// Version

: 1.0

// Target MCU : Atmel AVR series


// This code is distributed under the GNU Public License
//

which can be found at http://www.gnu.org/licenses/gpl.txt

/#include "lcd_lib.h"
#include <inttypes.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <util/delay.h>

const uint8_t LcdCustomChar[] PROGMEM=//define 8 custom LCD chars


{
0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, // 0. 0/5 full progress block
0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x00, // 1. 1/5 full progress block
0x00, 0x1F, 0x18, 0x18, 0x18, 0x18, 0x1F, 0x00, // 2. 2/5 full progress block
0x00, 0x1F, 0x1C, 0x1C, 0x1C, 0x1C, 0x1F, 0x00, // 3. 3/5 full progress block
46

0x00, 0x1F, 0x1E, 0x1E, 0x1E, 0x1E, 0x1F, 0x00, // 4. 4/5 full progress block
0x00, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, // 5. 5/5 full progress block
0x03, 0x07, 0x0F, 0x1F, 0x0F, 0x07, 0x03, 0x00, // 6. rewind arrow
0x18, 0x1C, 0x1E, 0x1F, 0x1E, 0x1C, 0x18, 0x00, // 7. fast forward arrow
};

Void LCD send Char(uint8_t ch )


{

//Sends Char to LCD

LDP= (ch&0b11110000);
LCP|=1<<LCD_RS;
LCP|=1<<LCD_E;
_delay_ms(1);
LCP&=~(1<<LCD_E);
LCP&=~(1<<LCD_RS);
_delay_ms(1);
LDP=((ch&0b00001111)<<4);
LCP|=1<<LCD_RS;
LCP|=1<<LCD_E;
_delay_ms(1);
LCP&=~(1<<LCD_E);
LCP&=~(1<<LCD_RS);
_delay_ms(1);
}
void LCDsendCommand(uint8_t cmd)
{

//Sends Command to LCD

LDP=(cmd&0b11110000);
LCP|=1<<LCD_E;
_delay_ms(1);
LCP&=~(1<<LCD_E);
_delay_ms(1);
LDP=((cmd&0b00001111)<<4);
LCP|=1<<LCD_E;
47

_delay_ms(1);
LCP&=~(1<<LCD_E);
_delay_ms(1);
}
void LCDinit(void)//Initializes LCD
{
_delay_ms(15);
LDP=0x00;
LCP=0x00;
LDDR|=1<<LCD_D7|1<<LCD_D6|1<<LCD_D5|1<<LCD_D4;
LCDR|=1<<LCD_E|1<<LCD_RW|1<<LCD_RS;
//---------one-----LDP=0<<LCD_D7|0<<LCD_D6|1<<LCD_D5|1<<LCD_D4; //4 bit mode
LCP|=1<<LCD_E|0<<LCD_RW|0<<LCD_RS;
_delay_ms(1);
LCP&=~(1<<LCD_E);
_delay_ms(1);
//-----------two----------LDP=0<<LCD_D7|0<<LCD_D6|1<<LCD_D5|1<<LCD_D4; //4 bit mode
LCP|=1<<LCD_E|0<<LCD_RW|0<<LCD_RS;
_delay_ms(1);
LCP&=~(1<<LCD_E);
_delay_ms(1);
//-------three------------LDP=0<<LCD_D7|0<<LCD_D6|1<<LCD_D5|0<<LCD_D4; //4 bit mode
48

LCP|=1<<LCD_E|0<<LCD_RW|0<<LCD_RS;
_delay_ms(1);
LCP&=~(1<<LCD_E);
_delay_ms(1);
//--------4 bit--dual line--------------LCDsendCommand(0b00101000);
//-----increment address, invisible cursor shift-----LCDsendCommand(0b00001100);
//init 8 custom chars
uint8_t ch=0, chn=0;
while(ch<64)
{
LCDdefinechar((LcdCustomChar+ch),chn++);
ch=ch+8;
}
}
void LCDclr(void)

//Clears LCD

{
LCDsendCommand(1<<LCD_CLR);
}
void LCDhome(void)

//LCD cursor home

{
LCDsendCommand(1<<LCD_HOME);
}
void LCDstring(uint8_t* data, uint8_t nBytes)
49

//Outputs string to LCD

{
register uint8_t i;
if (!data) return;
// print data
for(i=0; i<nBytes; i++)
{

LCDsendChar(data[i]);

}
}
void LCDGotoXY(uint8_t x, uint8_t y)

//Cursor to X Y position

{ register uint8_t DDRAMAddr;


// remap lines into proper order
switch(y)
{
case 0: DDRAMAddr = LCD_LINE0_DDRAMADDR+x; break;
case 1: DDRAMAddr = LCD_LINE1_DDRAMADDR+x; break;
case 2: DDRAMAddr = LCD_LINE2_DDRAMADDR+x; break;
case 3: DDRAMAddr = LCD_LINE3_DDRAMADDR+x; break;
default: DDRAMAddr = LCD_LINE0_DDRAMADDR+x;
}
// set data address
LCDsendCommand(1<<LCD_DDRAM | DDRAMAddr);
}
//Copies string from flash memory to LCD at x y position
//const uint8_t welcomeln1[] PROGMEM="AVR LCD DEMO\0";
//CopyStringtoLCD(welcomeln1, 3, 1);
void CopyStringtoLCD(const uint8_t *FlashLoc, uint8_t x, uint8_t y)
50

{
uint8_t i;
LCDGotoXY(x,y);
for(i=0;(uint8_t)pgm_read_byte(&FlashLoc[i]);i++)
{ LCDsendChar((uint8_t)pgm_read_byte(&FlashLoc[i]));
}
}
//defines char symbol in CGRAM
/*
const uint8_t backslash[] PROGMEM=
{
0b00000000,//back slash
0b00010000,
0b00001000,
0b00000100,
0b00000010,
0b00000001,
0b00000000,
0b00000000
};
LCDdefinechar(backslash,0);
*/
void LCDdefinechar(const uint8_t *pc,uint8_t char_code){
uint8_t a, pcc;
uint16_t i;
a=(char_code<<3)|0x40;
51

for (i=0; i<8; i++){


pcc=pgm_read_byte(&pc[i]);
LCDsendCommand(a++);
LCDsendChar(pcc);
}
}
void LCDshiftLeft(uint8_t n) //Scrol n of characters Right
{int i;
for ( i=0;i<n;i++)
{ LCDsendCommand(0x1E);
}
}
void LCDshiftRight(uint8_t n)

//Scrol n of characters Left

{int i;
for ( i=0;i<n;i++)
{ LCDsendCommand(0x18);
}
}
void LCDcursorOn(void) //displays LCD cursor
{ LCDsendCommand(0x0E);
}
void LCDcursorOnBlink(void)
{

//displays LCD blinking cursor

LCDsendCommand(0x0F);

}
void LCDcursorOFF(void)

//turns OFF cursor


52

{
LCDsendCommand(0x0C);
}
void LCDblank(void)

//blanks LCD

{ LCDsendCommand(0x08);
}
void LCDvisible(void)
{

//Shows LCD

LCDsendCommand(0x0C);

}
void LCDcursorLeft(uint8_t n)

//Moves cursor by n poisitions left

{int i;
for ( i=0;i<n;i++)
{ LCDsendCommand(0x10);
}
}
void LCDcursorRight(uint8_t n)

//Moves cursor by n poisitions left

{int i;
for (i=0;i<n;i++)
{ LCDsendCommand(0x14);
}
}
//adapted fro mAVRLIB
void LCDprogressBar(uint8_t progress, uint8_t maxprogress, uint8_t length)
{

uint8_t i;
uint16_t pixelprogress;
uint8_t c;
53

// draw a progress bar displaying (progress / maxprogress)


// starting from the current cursor position
// with a total length of "length" characters
// ***note, LCD chars 0-5 must be programmed as the bar characters
// char 0 = empty ... char 5 = full
// total pixel length of bargraph equals length*PROGRESSPIXELS_PER_CHAR;
// pixel length of bar itself is
pixelprogress
((progress*(length*PROGRESSPIXELS_PER_CHAR))/maxprogress);

// print exactly "length" characters


for(i=0; i<length; i++)
{

// check if this is a full block, or partial or empty


// (u16) cast is needed to avoid sign comparison warning
if( ((i*(uint16_t)PROGRESSPIXELS_PER_CHAR)+5) > pixelprogress )
{

// this is a partial or empty block


if(

((i*(uint16_t)PROGRESSPIXELS_PER_CHAR))

pixelprogress )
{

// this is an empty block


// use space character?
c = 0;

}
else
{

// this is a partial block


c = pixelprogress % PROGRESSPIXELS_PER_CHAR;

}
54

>

}
else
{

// this is a full block


c = 5;

}
// write character to display
LCDsendChar(c);
}
}
void LCDdisplay(char arr[])
{ LCDstring(arr,strlen(arr));
}
// File Name

: 'lcd_lib.h'

// Title

: 8 and 4 bit LCd interface

// Author

: Scienceprog.com - Copyright (C) 2007

// Created

: 2007-03-29

// Revised

: 2007-08-08

// Version

: 1.0

// Target MCU : Atmel AVR series


//
// This code is distributed under the GNU Public License
//

which can be found at http://www.gnu.org/licenses/gpl.txt

#ifndef LCD_LIB
#define LCD_LIB
#include <inttypes.h>

55

#define LCD_RS

//define MCU pin connected to LCD RS

#define LCD_RW

//define MCU pin connected to LCD R/W

#define LCD_E

//define MCU pin connected to LCD E

#define LCD_D4

//define MCU pin connected to LCD D3

#define LCD_D5

//define MCU pin connected to LCD D4

#define LCD_D6

//define MCU pin connected to LCD D5

#define LCD_D7

//define MCU pin connected to LCD D6

#define LDP PORTC //define MCU port connected to LCD data pins
#define LCP PORTC //define MCU port connected to LCD control pins
#define LDDR DDRC //define MCU direction register for port connected to LCD data
pins
#define LCDR DDRC //define MCU direction register for port connected to LCD control
pins
#define LCD_CLR

0 //DB0: clear display

#define LCD_HOME

//DB1: return to home position

#define LCD_ENTRY_MODE

2 //DB2: set entry mode

#define LCD_ENTRY_INC

#define LCD_ENTRY_SHIFT
#define LCD_ON_CTRL

//DB1: increment
0 //DB2: shift

//DB3: turn lcd/cursor on

#define LCD_ON_DISPLAY

//DB2: turn display on

#define LCD_ON_CURSOR

//DB1: turn cursor on

#define LCD_ON_BLINK
#define LCD_MOVE
#define LCD_MOVE_DISP

0
4

//DB0: blinking cursor


//DB4: move cursor/display

//DB3: move display (0-> move cursor)


56

#define LCD_MOVE_RIGHT

2 //DB2: move right (0-> left)

#define LCD_FUNCTION

//DB5: function set

#define LCD_FUNCTION_8BIT 4 //DB4: set 8BIT mode (0->4BIT mode)


#define LCD_FUNCTION_2LINES 3

//DB3: two lines (0->one line)

#define LCD_FUNCTION_10DOTS 2

//DB2: 5x10 font (0->5x7 font)

#define LCD_CGRAM

//DB6: set CG RAM address

#define LCD_DDRAM

//DB7: set DD RAM address

// reading:
#define LCD_BUSY

7 //DB7: LCD is busy

#define LCD_LINES

2 //visible lines

#define LCD_LINE_LENGTH

16

//line length (in characters)

// cursor position to DDRAM mapping


#define LCD_LINE0_DDRAMADDR

0x00

#define LCD_LINE1_DDRAMADDR

0x40

#define LCD_LINE2_DDRAMADDR

0x14

#define LCD_LINE3_DDRAMADDR

0x54

// progress bar defines


#define PROGRESSPIXELS_PER_CHAR 6
Void LCD send Char (uint8_t);

//forms data ready to send to 74HC164

Void LCD send Command (uint8_t); //forms data ready to send to 74HC164
Void LCD int (void);

//Initializes LCD

Void LCD clr (void);

//Clears LCD

Void LCD home (void);

//LCD cursor home

Void LCD string (uint8_t*, uint8_t); //Outputs string to LCD


void LCDGotoXY(uint8_t, uint8_t); //Cursor to X Y position
57

void CopyStringtoLCD(const uint8_t*, uint8_t, uint8_t);//copies flash string to LCD at


x,y
void LCDdefinechar(const uint8_t *,uint8_t);//write char to LCD CGRAM
void LCDshiftRight(uint8_t); //shift by n characters Right
Void LCD shift Left (uint8_t);

//shift by n characters Left

Void LCD cursor on (void);

//Underline cursor ON

Void LCD cursor On Blink (void);

//Underline blinking cursor ON

Void LCD cursor OFF (void);

//Cursor OFF

Void LCD blank (void);

//LCD blank but not cleared

Void LCD visible (void);

//LCD visible

Void LCD cursor Left (uint8_t);

//Shift cursor left by n

Void LCD cursor Right (uint8_t);

//shift cursor right by n

// displays a horizontal progress bar at the current cursor location


// <progress> is the value the bar graph should indicate
// <max progress> is the value at the end of the bar graph
// <length> is the number of LCD characters that the bar graph should cover
//adapted from AVRLIB - displays progress only for 8 bit variables
Void LCD progress Bar (uint8_t progress, uint8_t max progress, uint8_t length);
Void LCD display (char []);
#endif
#define F_CPU 12000000UL
#include <avr/io.h>
#include <util/delay.h>
#include "lcd_lib.h"
#include "sim300.h"
char A[20]= "

";
58

void Halt();
int main(void)
{ //Initialize LCD Module
LCDinit();
LCDclr();
//Intro Message
LCDGotoXY(0,0);
LCDdisplay("GSM MSG BOARD");
_delay_ms(1000);
LCDclr();
//Initialize SIM300 module
LCDdisplay("Initializing........");
int8_t r= SIM300Init();
_delay_ms(1000);
_delay_ms(1000);
//Check the status of initialization
switch(r)
{ case SIM300_OK:
LCDGotoXY(0,1);
LCDdisplay("OK");
break;
case SIM300_TIMEOUT:
LCDGotoXY(0,1);
LCDdisplay("NO Response");
Halt();
59

case SIM300_INVALID_RESPONSE:
LCDGotoXY(0,1);
LCDdisplay("INVALID RESPONSE");
Halt();
case SIM300_FAIL:
LCDGotoXY(0,1);
LCDdisplay("FAIL");
Halt();
default:
LCDGotoXY(0,1);
LCDdisplay("UNKNOWN ERROR");
Halt();
}
_delay_ms(1000);
//IMEI No display
LCDclr();
char imei[16];
r=SIM300GetIMEI(imei);
if(r==SIM300_TIMEOUT)
{

LCDdisplay("COMM ERROR !");


Halt();

}
sprintf(A, "IMEI:%d", imei);
LCDGotoXY(0,0);
LCDstring(A,14);
60

_delay_ms(1000);
//Manufacturer ID
LCDclr();
char man_id[48];
r=SIM300GetManufacturer(man_id)
if(r==SIM300_TIMEOUT)
{

LCDdisplay(CommError!);
Halt();

}
LCDdisplay("Manufacturer:");
sprintf(A, "%d", man_id);
LCDGotoXY(0,1);
LCDstring(A,14);
_delay_ms(1000);
//Manufacturer ID
LCDclr();
char model[48];
r=SIM300GetModel(model);
if(r==SIM300_TIMEOUT)
{

LCDdisplay("Comm Error !");


Halt();

}
LCDdisplay("Model:");
sprintf(A, "%d", model);
LCDGotoXY(0,1);
LCDstring(A,14);
61

_delay_ms(1000);
//Check Sim Card Presence
LCDclr();
LCDdisplay("Checking SIMCard");
_delay_ms(1000);
r=SIM300IsSIMInserted();
if (r==SIM300_SIM_NOT_PRESENT)
{ //Sim card is NOT present
LCDGotoXY(0,1);
LCDdisplay("No SIM Card !");
Halt();
}
else if(r==SIM300_TIMEOUT)
{

//Communication Error
LCDGotoXY(0,1);
LCDdisplay("Comm Error !");
Halt();

}
else if(r==SIM300_SIM_PRESENT)
{

//Sim card present


LCDGotoXY(0,1);
LCDdisplay("SIM Card Present");
_delay_ms(1000);

}
//Network search
62

LCDclr();
LCDdisplay("SearchingNetwork");
uint8_t

nw_found=0;

uint16_t

tries=0;

uint8_t

x=0;

while(!nw_found)
{r=SIM300GetNetStat();
if(r==SIM300_NW_SEARCHING)
{ LCDGotoXY(0,1);
LCD display("%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0");
LCD Goto XY(x,1);
LCD display("%1");
LCD Goto XY(17,1);
x++;
if(x==16) x=0;
_delay_m(50);
tries++;
if(tries==600)
break;}
else
break;
}
LCDclr();
if(r==SIM300_NW_REGISTERED_HOME)
{

LCDdisplay("Network Found");
63

}
else
{

LCDdisplay("Cant Connt to NW!");


Halt();

}
_delay_ms(1000);
LCDclr();
//Show Provider Name
char pname[32];
r=SIM300GetProviderName(pname);
if(r==0)
{
LCDdisplay("Comm Error !");
Halt();
}
LCDdisplay(pname);
_delay_ms(1000);
/*

//Send MSG
LCDclr();
LCDdisplay("Sending Msg");
uint8_t ref;

r=SIM300SendMsg("+919939XXXXXX","Test",&ref);//Change phone number to some


valid value!
if(r==SIM300_OK)
{
LCDdisplayXY(0,1,"Success");
64

LCDWriteIntXY(9,1,ref,3);
}
else if(r==SIM300_TIMEOUT)
{ LCDdisplayXY(0,1,"Time out !");
}
else
{ LCDdisplayXY(0,1,"Fail !");
}
_delay_ms(2000);
//Wait for MSG
uint8_t id = 0;
int x = 0;
UFlushBuffer();
while(1)
{LCDclr();
LCDdisplay("Waiting for msg");
x=0;
int8_t vx=1;
while(SIM300WaitForMsg(&id)!=SIM300_OK)
{
LCDGotoXY(0,1);
LCDdisplay("%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0%0");
LCDGotoXY(x,1);
LCDdisplay("%1");
LCDGotoXY(17,1);
65

x+=vx;
if(x==15 || x==0) vx=vx*-1;
}
LCDGotoXY(0,1);
LCDdisplay("MSG Received

");

_delay_ms(1000);
//Now read and display msg
LCDclr();
char msg[300];
r=SIM300ReadMsg(id,msg)
if(r==SIM300_OK)
{LCDdisplay(msg);
_delay_ms(3000);
}else
{

LCDdisplay("Err Reading Msg !");

_delay_ms(3000);
}
//Finally delete the msg
if (SIM300DeleteMsg(id)!=SIM300_OK)
{LCDdisplay("Err Deleting Msg !");
_delay_ms(3000);
}
}
Halt();}
void Halt()
66

{while(1);
}
#ifndef MYUTILS_H
#define MYUTILS_H
#define _CONCAT(a,b) a##b
#define PORT(x) _CONCAT(PORT,x)
#define PIN(x) _CONCAT(PIN,x)
#define DDR(x) _CONCAT(DDR,x)
#endif
#include <avr/io.h>
#include <util/delay.h>
#include <string.h>
#include "usart.h"
#include "lcd_lib.h"
#include "sim300.h"
//A common buffer used to read response from SIM300
char sim300_buffer[128];
int8_t SIM300Init()
{
//Init USART lib
set_uartbaud(9600);
//Check communication line
SIM300Cmd("AT"); //Test command
//Now wait for response
uint16_t i=0;
67

//correct response is 6 byte long


//So wait until we have got 6 bytes
//in buffer.
while(i<10)
{if(UDataAvailable()<6)
{
i++;
_delay_ms(10);
continue;}
else
{//We got a response that is 6 bytes long
//Now check it
UReadBuffer(sim300_buffer,6);

//Read serial Data

return SIM300CheckResponse(sim300_buffer,"OK",6)
}
//We waited so long but got no response
//So tell caller that we timed out
return SIM300_TIMEOUT;
}
int8_t SIM300Cmd(const char *cmd)
{ UWriteString(cmd);
UWriteData(0x0D);

//Send Command
//CR

uint8_t len=strlen(cmd);
len++; //Add 1 for trailing CR added to all commands
uint16_t i=0;
//Wait for echo
68

while(i<10*len)
{ if(UDataAvailable()<len)
{ i++;
_delay_ms(10);
continue; }
else
{ //We got an echo
//Now check it
UReadBuffer(sim300_buffer,len);

//Read serial Data

return SIM300_OK;
}
}
return SIM300_TIMEOUT;
}
int8_t SIM300CheckResponse(const char *response,const char *check,uint8_t len)
{
uint8_t i;
len-=2;
//Check leading CR LF
if(response[0]!=0x0D | response[1]!=0x0A)
return SIM300_INVALID_RESPONSE;
//Check trailing CR LF
if(response[len]!=0x0D | response[len+1]!=0x0A)
return SIM300_INVALID_RESPONSE;
//Compare the response
69

for(i=2;i<len;i++)
{ if(response[i]!=check[i-2])
return SIM300_FAIL;
}
return SIM300_OK;

int8_t SIM300WaitForResponse(uint16_t timeout)


{ uint8_t i=0;
uint16_t n=0;
while(1)
{ while (UDataAvailable()==0 && n<timeout){n++; _delay_ms(1);}
if(n==timeout)
return 0; else
{
sim300_buffer[i]=UReadData();
if(sim300_buffer[i]==0x0D && i!=0)
{

UFlushBuffer();
return i+1;
}
else
i++;}

}
}
int8_t SIM300GetNetStat()
{
//Send Command
70

SIM300Cmd("AT+CREG?");
//Now wait for response
uint16_t i=0;
//correct response is 20 byte long
//So wait until we have got 20 bytes
//in buffer.
while(i<10)
{ if(UDataAvailable()<20)
{ i++;
_delay_ms(10);
continue; }
else
{//We got a response that is 20 bytes long
//Now check it
UReadBuffer(sim300_buffer,20);

//Read serial Data

if(sim300_buffer[11]=='1')
return SIM300_NW_REGISTERED_HOME;
else if(sim300_buffer[11]=='2')
return SIM300_NW_SEARCHING;
else if(sim300_buffer[11]=='5')
return SIM300_NW_REGISTED_ROAMING;
else
return SIM300_NW_ERROR;
}
}
71

//We waited so long but got no response


//So tell caller that we timed out
return SIM300_TIMEOUT;
}
int8_t SIM300IsSIMInserted()
{ UFlushBuffer();
//Send Command
SIM300Cmd("AT+CSMINS?");
//Now wait for response
uint16_t i=0;
//correct response is 22 byte long
//So wait until we have got 22 bytes
//in buffer.
while(i<30)
{ if(UDataAvailable()<22)
{ i++;
_delay_ms(10);
continue;
}
else
{ //We got a response that is 22 bytes long
//Now check it
UReadBuffer(sim300_buffer,22);
if(sim300_buffer[13]=='1')
return SIM300_SIM_PRESENT;
72

//Read serial Data

else
return SIM300_SIM_NOT_PRESENT;
}
}
//We waited so long but got no response
//So tell caller that we timed out
return SIM300_TIMEOUT;
}
uint8_t SIM300GetProviderName(char *name)
{ UFlushBuffer();
//Send Command
SIM300Cmd("AT+CSPN?");
uint8_t len=SIM300WaitForResponse(1000);
if(len==0)
return SIM300_TIMEOUT;
char *start,*end;
start=strchr(sim300_buffer,'"');
start++;
end=strchr(start,'"');
*end='\0';
strcpy(name,start);
return strlen(name);
}
int8_t SIM300GetIMEI(char *emei)
{ UFlushBuffer();
73

//Send Command
SIM300Cmd("AT+GSN");
uint8_t len=SIM300WaitForResponse(1000);
if(len==0)
return SIM300_TIMEOUT;
sim300_buffer[len-1]='\0';
strcpy(emei,sim300_buffer+2);
return SIM300_OK;
}
int8_t SIM300GetManufacturer(char *man_id)
{ UFlushBuffer();
//Send Command
SIM300Cmd("AT+GMI");
uint8_t len=SIM300WaitForResponse(1000);
if(len==0)
return SIM300_TIMEOUT;
sim300_buffer[len-1]='\0';
strcpy(man_id,sim300_buffer+2);//+2 for removing leading CR LF
return SIM300_OK;
}
int8_t SIM300GetModel(char *model)
{ UFlushBuffer();
//Send Command
SIM300Cmd("AT+GMM");
uint8_t len=SIM300WaitForResponse(1000);
74

if(len==0)
return SIM300_TIMEOUT;
sim300_buffer[len-1]='\0';
strcpy(model,sim300_buffer+2);//+2 for removing leading CR LF
return SIM300_OK;
}
int8_t SIM300DeleteMsg(uint8_t i)
{ UFlushBuffer();
//String for storing the command to be sent
char cmd[16];
//Build command string
sprintf(cmd,"AT+CMGD=%d",i);
//Send Command
SIM300Cmd(cmd);

uint8_t len=SIM300WaitForResponse(1000);
if(len==0)
return SIM300_TIMEOUT;
sim300_buffer[len-1]='\0';
//Check if the response is OK
if(strcasecmp(sim300_buffer+2,"OK")==0)
return SIM300_OK;
else
return SIM300_FAIL;
}
75

int8_t SIM300WaitForMsg(uint8_t *id)


{

uint8_t len=SIM300WaitForResponse(250);
if(len==0)
return SIM300_TIMEOUT;
sim300_buffer[len-1]='\0';
if(strncasecmp(sim300_buffer+2,"+CMTI:",6)==0)
{ char str_id[4];
char *start;
start=strchr(sim300_buffer,',');
start++;
strcpy(str_id,start);
*id=atoi(str_id);
return SIM300_OK;
}

else

return SIM300_FAIL;
}
int8_t SIM300ReadMsg(uint8_t i, char *msg)
{
//Clear pending data in queue
UFlushBuffer();

//String for storing the command to be sent


char cmd[16];

//Build command string


76

sprintf(cmd,"AT+CMGR=%d",i);

//Send Command
SIM300Cmd(cmd);

uint8_t len=SIM300WaitForResponse(1000);

if(len==0)
return SIM300_TIMEOUT;

sim300_buffer[len-1]='\0';

//Check of SIM NOT Ready error


if(strcasecmp(sim300_buffer+2,"+CMS ERROR: 517")==0)
{ //SIM NOT Ready
return SIM300_SIM_NOT_READY;
}
//MSG Slot Empty
if(strcasecmp(sim300_buffer+2,"OK")==0)
{ return SIM300_MSG_EMPTY;
}
//Now read the actual msg text
len=SIM300WaitForResponse(1000);
if(len==0)
return SIM300_TIMEOUT;
77

sim300_buffer[len-1]='\0';
strcpy(msg,sim300_buffer+1);//+1 for removing trailing LF of prev line
return SIM300_OK;
}
int8_t SIM300SendMsg(const char *num, const char *msg,uint8_t *msg_ref)
{ UFlushBuffer();
char cmd[25];
sprintf(cmd,"AT+CMGS= %s",num);
cmd[8]=0x22; //"
uint8_t n=strlen(cmd);
cmd[n]=0x22; //"
cmd[n+1]='\0';
//Send Command
SIM300Cmd(cmd);
_delay_ms(100);
UWriteString(msg);
UWriteData(0x1A);
while(

UDataAvailable()<(strlen(msg)+5)

);

//Remove Echo
UReadBuffer(sim300_buffer,strlen(msg)+5);
uint8_t len=SIM300WaitForResponse(6000);
if(len==0)
return SIM300_TIMEOUT;
sim300_buffer[len-1]='\0':
if(strncasecmp(sim300_buffer+2,"CMGS:",5)==0)
78

*msg_ref=atoi(sim300_buffer+8);
UFlushBuffer();
return SIM300_OK;

}
else
{ UFlushBuffer();
return SIM300_FAIL;
}
}
#ifndef SIM300_H_
#define SIM300_H_

//Error List
#define SIM300_OK
SIM300_INVALID_RESPONSE

1#define
-1

#define SIM300_FAIL

-2

#define SIM300_TIMEOUT

-3

//Status
#define SIM300_NW_REGISTERED_HOME

#define SIM300_NW_SEARCHING

#define SIM300_NW_REGISTED_ROAMING

#define SIM300_NW_ERROR

99

#define SIM300_SIM_NOT_READY

100

#define SIM300_MSG_EMPTY

101

#define SIM300_SIM_PRESENT

1
79

#define SIM300_SIM_NOT_PRESENT

//Low Level Functions


int8_t SIM300Cmd(const char *cmd);
//Public Interface
int8_t SIM300Init();
int8_t SIM300CheckResponse(const char *response,const char *check,uint8_t len);
int8_t SIM300WaitForResponse(uint16_t timeout);
int8_t SIM300GetNetStat();
int8_t SIM300IsSIMInserted();
uint8_t SIM300GetProviderName(char *);
int8_t SIM300GetIMEI(char *);
int8_t SIM300GetManufacturer(char *);
int8_t SIM300GetModel(char *);
int8_t SIM300DeleteMsg(uint8_t i);
int8_t SIM300WaitForMsg(uint8_t *);
int8_t SIM300ReadMsg(uint8_t i, char *);
int8_t SIM300SendMsg(const char *, const char *,uint8_t *)
#endif /* SIM300_H_ */
/*
* uart_lib.c
*
* Created on: Apr 27, 2011
*

Author: simplifix

*/
#include<uart_lib.h>
80

#include<avr/io.h>
#include<util/delay.h>
#define FOSC 12000000
void set_uartbaud(int BAUD)
{
UBRRH = (unsigned char)((FOSC/16/BAUD-1)>>8);
UBRRL = (unsigned char)(FOSC/16/BAUD-1);
UCSRC|=(1<<URSEL)|(1<<UCSZ1)|(1<<UCSZ0);
UCSRB|=(1<<RXEN)|(1<<TXEN);
}
void disable_uart()
{ UCSRB&=~(1<<TXEN);
UCSRB&=~(1<<RXEN);
}
void enable_uart_txcint()
{ UCSRB|=(1<<TXCIE);
}
void enable_uart_rxcint()
{ UCSRB|=(1<<RXCIE);
}
void enable_uart_udreint()
{ UCSRB|=(1<<UDRIE);
}
void disable_uart_txcint()
{ UCSRB&=~(1<<TXCIE);
81

}
void disable_uart_rxcint()
{
UCSRB&=~(1<<RXCIE);
}

void disable_uart_udreint()
{
UCSRB&=~(1<<UDRIE);
}
void sendchar_uart(char data)
{

int temp;
temp=UCSRA&(1<<UDRE);
temp=temp>>UDRE;
while(!temp)
{
}
UDR=data;

}
char getchar_uart()
{ // Wait until a byte has been received
while((UCSRA&(1<<RXC)) == 0);
// Return received data
return UDR;
}
82

void sendstring_uart(char v[])


{ int i;
for(i=0;i<strlen(v);i++)
{ sendchar_uart(v[i]);
_delay_ms(10);
}
}
/*
* uart_lib.h
*
* Created on: Apr 27, 2011
*

Author: simplifix

*/
#include <avr/io.>
#define FOSC 12000000// Clock Speed
#include <avr/io.h>
#include <avr/interrupt.h>
#include <inttypes.h>
#include "usart.h"
#define FOSC 12000000
void USARTInit(uint16_t BAUD)
{ //Setup q
UQFront=UQEnd=-1;
//Set Baud rate
UBRRH = (unsigned char)((FOSC/16/BAUD-1)>>8);
83

UBRRL = (unsigned char)(FOSC/16/BAUD-1);


/*Set Frame Format
Asynchronous mode
No Parity
1 StopBit
char size 8
*/
UCSRC=(1<<URSEL)|(3<<UCSZ0);
/*Enable Interrupts
RXCIE- Receive complete
UDRIE- Data register empty
Enable The recevier and transmitter
*/
UCSRB=(1<<RXCIE)|(1<<RXEN)|(1<<TXEN);
sei();
}
//The USART ISR
ISR(USART_RXC_VECT)
{ //Read the data
char data=UDR;
//Now add it to q
if(((UQEnd==RECEIVE_BUFF_SIZE-1) && UQFront==0) || ((UQEnd+1)==UQFront))
{

//Q Full
UQFront++;
if(UQFront==RECEIVE_BUFF_SIZE) UQFront=0;
84

}
if(UQEnd==RECEIVE_BUFF_SIZE-1)
UQEnd=0;
else
UQEnd++;
URBuff[UQEnd]=data;
if(UQFront==-1) UQFront=0;
}
char UReadData()
{ char data;
//Check if q is empty
if(UQFront==-1)
return 0;

data=URBuff[UQFront];
if(UQFront==UQEnd)
{
//If single data is left
//So empty q
UQFront=UQEnd=-1;
}
else
{
UQFront++;
if(UQFront==RECEIVE_BUFF_SIZE)
85

UQFront=0;
}
return data;
}
void UWriteData(char data)
{ //Wait For Transmitter to become ready
while(!(UCSRA & (1<<UDRE)));
//Now write
UDR=data;
}
uint8_t UDataAvailable()
{

if(UQFront==-1) return 0;
if(UQFront<UQEnd)
return(UQEnd-UQFront+1);
else if(UQFront>UQEnd)
return (RECEIVE_BUFF_SIZE-UQFront+UQEnd+1);
else
return 1;

}
void UWriteString(char *str)
{
while((*str)!='\0')
{
UWriteData(*str);
str++;
86

}
}
void UReadBuffer(void *buff,uint16_t len)
{

uint16_t i;
for(i=0;i<len;i++)
{

((char*)buff)[i]=UReadData();

}
}
void UFlushBuffer()
{ while(UDataAvailable()>0)
{ UReadData();
}
}

#include <inttypes.h>
#ifndef USART_H
#define USART_H
//Macros
#define RECEIVE_BUFF_SIZE 64
#define USART_RXC_VECT USART_RXC_vect //This change from mcu to mcu. This
is for mega8, mega16, mega32
#define F_CPU 12000000UL
#define UBRR_VALUE(baud) ((F_CPU/(baud<<4))-1
//Varriables
volatile char URBuff[RECEIVE_BUFF_SIZE];
volatile int8_t UQFront;
87

//USART Receive Buffer

volatile int8_t UQEnd;


//Functions
void USARTInit(uint16_t BAUD);
uint8_t UDataAvailable();
char UReadData();
void UWriteData(char data)
void UWriteString(char *str);
void UReadBuffer(void *buff,uint16_t len);
void UFlushBuffer();
#endif

88

Appendix-B Data Sheet


GSM Shield
The GSM shield by Arduino is used to send/ receive messages and make/receive calls
just like a mobile phone by using a SIM card by a network provider. User can do this by
plugging the GSM shield into the Arduino board and then plugging in a SIM card from
an operator that offers GPRS coverage. The shield employs the use of a radio modem by
SIMComm. User can communicate easily with the shield using the AT commands. The
GSM library contains many methods of communication with the shield. This GSM
Modem can work with any GSM network operator SIM card just like a mobile phone
with its own unique phone number. Advantage of using this modem will be that its
RS232 port can be used to communicate and develop embedded applications.
Applications like SMS Control, data transfer, remote control and logging can be
developed easily using this. The modem can either be connected to PC serial port directly
or to any microcontroller through MAX232. It can be used to send/receive SMS and
make/receive voice calls. It can also be used in GPRS mode to connect to internet and run
many applications for data logging and control. In GPRS mode you can also connect to
any remote FTP server and upload files for data logging This GSM modem is a highly
flexible plug and play quad band SIM900A GSM modem for direct and easy integration
to RS232 applications. It Supports features like Voice, SMS, Data/Fax, GPRS and
integrated TCP/IP stack. To be connected to a cellular network, the shield requires a SIM
card provided by a network provider.

Fig. Components of GSM Shield


89

Specifications for SMS via GSM/GPRS:

Power Requirement:
The board should be powered with an external power supply that can provide current
between 700mA and 1000mA. Powering an Arduino and the GSM shield from a USB
connection is not recommended, as USB cannot provide the required current when the
modem is in heavy use. So instead we have to use 12V adapter. The modem can pull up
to 2A of current at peak usage, which can occur during data transmission.

On Board Indicators:
The shield contains a number of status LEDS:
ON: It shows that the shield is getting power and is switched on.
NET: This LED blinks when the modem is communicating with the radio network.

LED Network
The Network LED indicates the various states of the GSM module i.e. POWER ON,
NETWORK REGISTERATION and GPRS CONNECTIVITY. When the modem is
powered up, this NETWORK LED will blink every second. After the Modem registers in
the network (it takes 10-60 seconds), this LED will blink in step of 3 seconds at slow
rate. At this stage we can start using the modem for our application. This shows that the
modem is registered with the network.

Microcontroller 8051
Pin Description
VCC -Supply voltage.
GND -Ground.
Port 0- Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin

90

can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as
high-impedance inputs.
Port 1 -Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1 output
buffers can sink/source four TTL inputs.
Port 2 -Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 2 output
buffers can sink/source four TTL inputs. pulled low will source current (IIL) because of
the internal pull-ups.Port 2 uses strong internal pull-ups when emitting 1s. During
accesses to external
.Port 3 -Port 3 is an 8-bit bidirectional 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.
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 (ALE) is an output pulse for latching the low byte of
the address during .In normal operation, ALE is emitted at a constant rate of 1/6 the
oscillator frequency If desired, ALE operation can be disabled by setting bit 0 of SFR
location 8EH. .
PSEN -Program Store Enable (PSEN) is the read strobe to external program memory.
When the AT89S51 is executing code from external program memory.
EA/VPP -External Access Enable. EA must be strapped to GND in order to enable the
device to fetch .This pin also receives the 12-volt programming enable voltage (VPP)
during Flash programming.
XTAL1- Input to the inverting oscillator amplifier and input to the internal clock
operating circuit.
XTAL2- Output from the inverting oscillator amplifier.

Terminal 1A Positive Voltage Regulator

Description
The MC78XX/LM78XX/MC78XXA series of three terminal positive regulators are
available in the TO-220/D-PAK package and with several fixed output voltages, making
them useful in a wide range of applications. If adequate heat sinking is provided, they can
deliver over 1A output current.Although designed primarily as fixed voltage regulators,
these devices can be used with external components to obtain adjustable voltages and
currents.

Fig.-Voltage Regulator
91

Features
Its Output Current up to 1A.
It consist of Output Voltages of 5, 6, 8, 9, 10, 12, 15, 18, 24V.
It includes Thermal Overload Protection.
It is having Short Circuit Protection.

MAX232
Description
The MAX232 IC is used to convert the TTL/CMOS logic levels to RS232 logic levels
during serial communication of microcontrollers with PC. The controller operates at TTL
logic level (0-5V) whereas the serial communication in PC works on RS232 standards (25 V to + 25V). This makes it difficult to establish a direct link between them to
communicate with each other.
The transmitters take input from controllers serial transmission pin and send the output
to RS232s receiver. The receivers, on the other hand, take input from transmission pin of
RS232 serial port and give serial output to microcontrollers receiver pin. MAX232 needs
four external capacitors whose value ranges from 1F to 22F.

Fig. - Pin Diagram of MAX232

92

LED
Now that we know that even the mighty LED has its limits, we need to make sure we stay
below those limits. Being kind to your LEDs will let them last longer and keep them
shiny & bright! Lets examine the specification sheet for a 5mm LED, specification sheets
are also called datasheets. Datasheets are immensely useful, they have all the
information you need for an electronic component. The first useful thing you'll find is the
dimensional 'package' information. The 'package' here is the LED itself.

Features

It has Single color.


It consists of High bright output.
It is having Low power consumption.
It include High reliability and long life.

Table. - Description of LED Types

93

You might also like