Project Report 22 PDF
Project Report 22 PDF
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.
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
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.
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).
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
$regfile = "m48def.dat"
$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
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
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.
17
18
India, Iran, Lebanon, Malaysia, Nepal, Pakistan, Singapore, South Africa) all phones are
sold unlocked.
the
subscriber
using
a pre-shared
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
20
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.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.
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
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.
24
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
Recent
developments in LEDs permit them to be used in environmental and task lighting. LEDs
25
have
many
advantages
over
incandescent
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.
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.
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.
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
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.
GND
Ground.
Port A (PA7.PA0)
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
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,
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
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.
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.
language.
The
International Standards
Organization
wrote
standard
ISO/IEC 9899 for the C programming language. The Motor Industry Software Reliability
39
40
Chapter 5
SYSTEM DESIGN
5.1: Functional Decomposition
Mobile phone
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.
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
// Author
// Created
: 2007-03-29
// Revised
: 2007-08-08
// Version
: 1.0
/#include "lcd_lib.h"
#include <inttypes.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <util/delay.h>
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
};
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)
{
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)
{
LCDsendCommand(1<<LCD_HOME);
}
void LCDstring(uint8_t* data, uint8_t nBytes)
49
{
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
{
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
{int i;
for ( i=0;i<n;i++)
{ LCDsendCommand(0x18);
}
}
void LCDcursorOn(void) //displays LCD cursor
{ LCDsendCommand(0x0E);
}
void LCDcursorOnBlink(void)
{
LCDsendCommand(0x0F);
}
void LCDcursorOFF(void)
{
LCDsendCommand(0x0C);
}
void LCDblank(void)
//blanks LCD
{ LCDsendCommand(0x08);
}
void LCDvisible(void)
{
//Shows LCD
LCDsendCommand(0x0C);
}
void LCDcursorLeft(uint8_t n)
{int i;
for ( i=0;i<n;i++)
{ LCDsendCommand(0x10);
}
}
void LCDcursorRight(uint8_t n)
{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
((i*(uint16_t)PROGRESSPIXELS_PER_CHAR))
pixelprogress )
{
}
else
{
}
54
>
}
else
{
}
// write character to display
LCDsendChar(c);
}
}
void LCDdisplay(char arr[])
{ LCDstring(arr,strlen(arr));
}
// File Name
: 'lcd_lib.h'
// Title
// Author
// Created
: 2007-03-29
// Revised
: 2007-08-08
// Version
: 1.0
#ifndef LCD_LIB
#define LCD_LIB
#include <inttypes.h>
55
#define LCD_RS
#define LCD_RW
#define LCD_E
#define LCD_D4
#define LCD_D5
#define LCD_D6
#define LCD_D7
#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
#define LCD_HOME
#define LCD_ENTRY_MODE
#define LCD_ENTRY_INC
#define LCD_ENTRY_SHIFT
#define LCD_ON_CTRL
//DB1: increment
0 //DB2: shift
#define LCD_ON_DISPLAY
#define LCD_ON_CURSOR
#define LCD_ON_BLINK
#define LCD_MOVE
#define LCD_MOVE_DISP
0
4
#define LCD_MOVE_RIGHT
#define LCD_FUNCTION
#define LCD_FUNCTION_10DOTS 2
#define LCD_CGRAM
#define LCD_DDRAM
// reading:
#define LCD_BUSY
#define LCD_LINES
2 //visible lines
#define LCD_LINE_LENGTH
16
0x00
#define LCD_LINE1_DDRAMADDR
0x40
#define LCD_LINE2_DDRAMADDR
0x14
#define LCD_LINE3_DDRAMADDR
0x54
Void LCD send Command (uint8_t); //forms data ready to send to 74HC164
Void LCD int (void);
//Initializes LCD
//Clears LCD
//Underline cursor ON
//Cursor OFF
//LCD visible
";
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)
{
}
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("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)
{
}
//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
{
}
_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;
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
{
_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
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);
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;
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);
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
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
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();
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';
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
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
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
//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
88
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.
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.
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
93