Sie sind auf Seite 1von 61

1.

INTRODUCTION

About the Project:

The aim of the project is to develop wireless network for monitoring the street light system and
to use renewable solar energy. The advancement of technology brings advantages to human race
to certain extent. Unfortunately, some of the technological inventions not only brings
advantages, but also disadvantages.

Considering the increase of electricity consumption every year, Solar powered street lighting
system is proposed in order to reduce the burning of fossil fuels to generate electricity, hence
reducing air pollution. The street lighting system will consist to reduce the electricity
consumption of street lights. The system will also be able to provide energy measurement to
determine the efficiency of street lights. Some security features provided by selected wireless
communication protocol will also be implemented to secure the system.

The proposed system consists of microcontroller, rechargeable battery, solar panel, light sensor,
motion sensor, temperature sensor, zigbee. The motion sensor works simultaneously with the IP
camera module. The camera will start capturing the event when there is a trigger from the motion
sensor. The purpose of the motion sensor is to send out trigger when there is suspicion subject
noticed around the area of the street light and that information will send to the admin when alert
information receives at monitor unit a alarm will ON manually with the help of Matlab GUI, at
the same time at the street light section also an alert siren is given. The light sensor (LDR)
captures the light intensity of the environment and turns on or off the LED lamp post. The
voltage of the battery continuously monitored using micro controller. All these information will
send to the control section using wireless network zigbee. The control section is designed with
MATLAB.

The system uses NXP's LPC2148 family with ARM7 Core microprocessor for the unit of main
control. The system consists of the ARM controller, zigbee wireless transmission, LDR, IR
sensor, the information display and so on. ARM Intelligent control composes of ARM7
microcontroller. The ARM7TDMI core is a member of the ARM family of general-purpose 32-
bit microprocessors. The ARM family offers high performance for very low power consumption,
and small size. The ARM architecture is based on Reduced Instruction Set Computer (RISC)

1
principles. That combines the microcontroller with embedded high speed flash memory ranging
from 32 kb to 512 kb. it consists of 2 UARTs used to Connect to the ZIGBEE and the computer,
it has single or dual 10-bit ADC’s with14 channel input from the sensors, We are connecting the
LDR to one of the channel of ADC to convert the analog signal to digital signal, it also consists
of 45 GPIO pins to connect the street lights and IR are connected to this pins of the ARM
controller.

WORKING:

Power Supply with Solar Panel:

The solar panel connects to the controller through positive and negative leads, only creating a
charging function when the controller is connected to a battery. The load is then responsible for
the discharging function from the controller (if it is connected to the controller). The energy
obtained from the sunlight.

The resistance of light dependant resistor (LDR) varies according to the light falling on it. The
LDR sensor is used to monitor the light and this information is given to the microcontroller
either Dark or Light displayed in MATLAB window.

The PIR sensor is used to find the human movements in the street by using IP camera observed
in MATLAB.

2
Zigbee (Trans-Reciever):

The information of ON and OFF of the street light is transmitted through the ZIGBEE and it is
received at the other end of ZIGBEE and sends the information to the microcontroller then it is
transmitted to the computer by the RS232 protocol and displayed in the MATLAB GUI present
in the computer.

GUI:

Fig. 1.1 GUI

3
If any emergency occur and if we want to ON the lights then we manually ON the lights from the
MATLAB GUI Terminal by clicking the buttons in it, it will transmit the information through
the ZIGBEE and at the other section the light will be turn ON, in the same way we can turn OFF
the light manually.

If any suspicion observed in the street an alert raised to the admin. By giving buzzer ON
command the street light section also an alert siren is given.

In this software design we are using the Keil uVision3 software to write the program and we
have used the flash magic software to dump the program in to the controller.

BLOCK DIAGRAM:

Fig. 1.2 Block Diagram of Street Light System

4
SCHEMATIC DIAGRAM:

Fig. 1.2 Schematic Diagram of Street Light System

5
INTRODUCTION TO MATLAB

2.1 What Is MATLAB?


MATLAB is a high-performance language for technical computing. It integrates computation,
visualization, and programming in an easy-to-use environment where problems and solutions are
expressed in familiar mathematical notation. Typical uses include:

 Math and computation

 Algorithm development

 Modeling, simulation, and prototyping

 Data analysis, exploration, and visualization

 Scientific and engineering graphics

 Application development, including Graphical User Interface building

MATLAB is an interactive system whose basic data element is an array that does not require
dimensioning. This allows you to solve many technical computing problems, especially those
with matrix and vector formulations, in a fraction of the time it would take to write a program in
a scalar non-interactive language such as C or FORTRAN. The name MATLAB stands for
matrix laboratory.
MATLAB has evolved over a period of years with input from many users. In university
environments, it is the standard instructional tool for introductory and advanced courses in
mathematics, engineering, and science. In industry, MATLAB is the tool of choice for high-
productivity research, development, and analysis.
MATLAB features a family of application-specific solutions called toolboxes. Very important to
most users of MATLAB, toolboxes allow learning and applying specialized technology.
Toolboxes are comprehensive collections of MATLAB functions (M-files) that extend the
MATLAB environment to solve particular classes of problems. Areas in which toolboxes are
available include signal processing, control systems, neural networks, fuzzy logic, wavelets,
simulation, and many others.

6
2.2 The MATLAB System
The MATLAB system consists of five main parts:
The MATLAB Language: This is a high-level matrix/array language with control flow
statements, functions, data structures, input/output, and object-oriented programming features. It
allows both "programming in the small" to rapidly create quick and dirty throw-away programs,
and "programming in the large" to create complete large and complex application programs.
The MATLAB Working Environment: This is the set of tools and facilities that you work with
as the MATLAB user or programmer. It includes facilities for managing the variables in your
workspace and importing and exporting data. It also includes tools for developing, managing,
debugging, and profiling M-files, MATLAB's applications.
Handle Graphics: This is the MATLAB graphics system. It includes high-level commands for
two-dimensional and three-dimensional data visualization, image processing, animation, and
presentation graphics. It also includes low-level commands that allow you to fully customize the
appearance of graphics as well as to build complete Graphical User Interfaces on your MATLAB
applications.
The MATLAB Mathematical Function Library: This is a vast collection of computational
algorithms ranging from elementary functions like sum, sine, cosine, and complex arithmetic, to
more sophisticated functions like matrix inverse, matrix Eigen values, Bessel functions, and fast
Fourier transforms.

The MATLAB Application Program Interface (API): This is a library that allows you to write
C and FORTRAN programs that interact with MATLAB. It include facilities for calling routines
from MATLAB (dynamic linking), calling MATLAB as a computational engine, and for reading
and writing MAT-files.
2.3 ADVANTAGES OF MATLAB
Its basic data element is the matrix. A simple integer is considered an matrix of one row and one
column. Several mathematical operations that work on arrays or matrices are built-in to the
Matlab environment. For example, cross-products, dot-products, determinants, inverse matrices.
 Vectorized operations. Adding two arrays together needs only one command, instead of for
or while loop.

7
 The graphical output is optimized for interaction. You can plot your data very easily, and
then change colors, sizes, scales, etc, by using the graphical interactive tools.

 Matlab’s functionality can be greatly expanded by the addition of toolboxes. These are sets
of specific functions that provided more specialized functionality. Ex: Excel link allows data
to be written in a format recognized by Excel, Statistics Toolbox allows more specialized
statistical manipulation of data (Anova, Basic Fits, etc)

8
3. EMBEDDED SYSTEMS
3.1 INTRODUCTION
Embedded systems are electronic devices that incorporate microprocessors with in their
implementations. The main purposes of the microprocessors are to simplify the system design
and provide flexibility. Having a microprocessor in the device helps in removing the bugs,
making modifications, or adding new features are only matter of rewriting the software that
controls the device. Or in other words embedded computer systems are electronic systems that
include a microcomputer to perform a specific dedicated application. The computer is hidden
inside these products. Embedded systems are ubiquitous. Every week millions of tiny computer
chips come pouring out of factories finding their way into our everyday products.

Embedded systems are self-contained programs that are embedded within a piece of hardware.
Whereas a regular computer has many different applications and software that can be applied to
various tasks, embedded systems are usually set to a specific task that cannot be altered without
physically manipulating the circuitry. Another way to think of an embedded system is as a
computer system that is created with optimal efficiency, thereby allowing it to complete specific
functions as quickly as possible.

Embedded systems designers usually have a significant grasp of hardware technologies. They
use specific programming languages and software to develop embedded systems and manipulate
the equipment. When searching online, companies offer embedded systems development kits and
other embedded systems tools for use by engineers and businesses.

Embedded systems technologies are usually fairly expensive due to the necessary development
time and built in efficiencies, but they are also highly valued in specific industries. Smaller
businesses may wish to hire a consultant to determine what sort of embedded systems will add
value to their organization.

Characteristics:
Two major areas of differences are cost and power consumption. Since many embedded systems
are produced in tens of thousands to millions of units range, reducing cost is a major concern.
Embedded systems often use a (relatively) slow processor and small memory size to minimize
costs.

9
The slowness is not just clock speed. The whole architecture of the computer is often
intentionally simplified to lower costs. For example, embedded systems often use peripherals
controlled by synchronous serial interfaces, which are ten to hundreds of times slower than
comparable peripherals used in PCs. Programs on an embedded system often run with real-time
constraints with limited hardware resources: often there is no disk drive, operating system,
keyboard or screen. A flash drive may replace rotating media, and a small keypad and LCD
screen may be used instead of a PC's keyboard and screen.

Firmware is the name for software that is embedded in hardware devices, e.g. in one or more
ROM/Flash memory IC chips. Embedded systems are routinely expected to maintain 100%
reliability while running continuously for long periods, sometimes measured in years. Firmware
is usually developed and tested too much harsher requirements than is general-purpose software,
which can usually be easily restarted if a problem occurs.

Platform:
There are many different CPU architectures used in embedded designs. This in contrast to the
desktop computer market which is limited to just a few competing architectures mainly the
Intel/AMD x86 and the Apple/Motorola/IBM Power PC’s which are used in the Apple
Macintosh. One common configuration for embedded systems is the system on a chip, an
application-specific integrated circuit, for which the CPU was purchased as intellectual property
to add to the IC's design.

Tools:
Like a typical computer programmer, embedded system designers use compilers, assemblers and
debuggers to develop an embedded system. Those software tools can come from several sources:

Software companies that specialize in the embedded market Ported from the GNU software
development tools. Sometimes, development tools for a personal computer can be used if the
embedded processor is a close relative to a common PC processor. Embedded system designers
also use a few software tools rarely used by typical computer programmers. Some designers keep
a utility program to turn data files into code, so that they can include any kind of data in a
program. Most designers also have utility programs to add a checksum or CRC to a program, so
it can check its program data before executing it.

10
Operating system:
They often have no operating system, or a specialized embedded operating system (often a real-
time operating system), or the programmer is assigned to port one of these to the new system.

Debugging:
Debugging is usually performed with an in-circuit emulator, or some type of debugger that can
interrupt the micro controller’s internal microcode. The microcode interrupt lets the debugger
operate in hardware in which only the CPU works. The CPU-based debugger can be used to test
and debug the electronics of the computer from the viewpoint of the CPU.

Developers should insist on debugging which shows the high-level language, with breakpoints
and single stepping, because these features are widely available. Also, developers should write
and use simple logging facilities to debug sequences of real-time events. PC or mainframe
programmers first encountering this sort of programming often become confused about design
priorities and acceptable methods. Mentoring, code-reviews and ego less programming are
recommended.

3.1.2 DESIGN OF EMBEDDED SYSTEMS:


The electronics usually uses either a microprocessor or a microcontroller. Some large or old
systems use general-purpose mainframes computers or minicomputers.

Start-up:

All embedded systems have start-up code. Usually it disables interrupts, sets up the electronics,
tests the computer (RAM, CPU and software), and then starts the application code. Many
embedded systems recover from short-term power failures by restarting (without recent self-
tests). Restart times under a tenth of a second are common.

Many designers have found one of more hardware plus software-controlled LED’s useful to
indicate errors during development (and in some instances, after product release, to produce
troubleshooting diagnostics). A common scheme is to have the electronics turn off the LED(s) at
reset, whereupon the software turns it on at the first opportunity, to prove that the hardware and
start-up software have performed their job so far. After that, the software blinks the LED(s) or

11
sets up light patterns during normal operation, to indicate program execution progress and/or
errors. This serves to reassure most technicians/engineers and some users.

The control loop:


In this design, the software has a loop. The loop calls subroutines. Each subroutine manages a
part of the hardware or software. Interrupts generally set flags, or update counters that are read
by the rest of the software. A simple API disables and enables interrupts. Done right, it handles
nested calls in nested subroutines, and restores the preceding interrupt state in the outermost
enable. This is one of the simplest methods of creating an exocrine.

Typically, there's some sort of subroutine in the loop to manage a list of software timers, using a
periodic real time interrupt. When a timer expires, an associated subroutine is run, or flag is set.
Any expected hardware event should be backed-up with a software timer. Hardware events fail
about once in a trillion times.

State machines may be implemented with a function-pointer per state-machine (in C++, C or
assembly, anyway). A change of state stores a different function into the pointer. The function
pointer is executed every time the loop runs.

Many designers recommend reading each IO device once per loop, and storing the result so the
logic acts on consistent values. Many designers prefer to design their state machines to check
only one or two things per state. Usually this is a hardware event, and a software timer.
Designers recommend that hierarchical state machines should run the lower-level state machines
before the higher, so the higher run with accurate information.

Complex functions like internal combustion controls are often handled with multi-dimensional
tables. Instead of complex calculations, the code looks up the values. The software can
interpolate between entries, to keep the tables small and cheap.

One major disadvantage of this system is that it does not guarantee a time to respond to any
particular hardware event. Careful coding can easily assure that nothing disables interrupts for
long. Thus interrupt code can run at very precise timings. Another major weakness of this system
is that it can become complex to add new features. Algorithms that take a long time to run must
be carefully broken down so only a little piece gets done each time through the main loop.

12
This system's strength is its simplicity, and on small pieces of software the loop is usually so fast
that nobody cares that it is not predictable. Another advantage is that this system guarantees that
the software will run. There is no mysterious operating system to blame for bad behavior.

USER INTERFACES:
Interface designers at PARC, Apple Computer, Boeing and HP minimize the number of types of
user actions. For example, use two buttons (the absolute minimum) to control a menu system
(just to be clear, one button should be "next menu entry" the other button should be "select this
menu entry"). A touch-screen or screen-edge buttons also minimize the types of user actions.

Another basic trick is to minimize and simplify the type of output. Designs should consider using
a status light for each interface plug, or failure condition, to tell what failed. A cheap variation is
to have two light bars with a printed matrix of errors that they select- the user can glue on the
labels for the language that she speaks.

For example, Boeing's standard test interface is a button and some lights. When you press the
button, all the lights turn on. When you release the button, the lights with failures stay on. The
labels are in Basic English.

Designers use colors. Red defines the users can get hurt- think of blood. Yellow defines
something might be wrong. Green defines everything's OK.

Another essential trick is to make any modes absolutely clear on the user's display. If an interface
has modes, they must be reversible in an obvious way. Most designers prefer the display to
respond to the user. The display should change immediately after a user action. If the machine is
going to do anything, it should start within 7 seconds, or give progress reports.

One of the most successful general-purpose screen-based interfaces is the two menu buttons and
a line of text in the user's native language. It's used in pagers, medium-priced printers, network
switches, and other medium-priced situations that require complex behavior from users. When
there's text, there are languages. The default language should be the one most widely understood.

3.2 MICROCONTROLLERS
Microcontrollers as the name suggests are small controllers. They are like single chip computers
that are often embedded into other systems to function as processing/controlling unit. For
example the remote control you are using probably has microcontrollers inside that do decoding

13
and other controlling functions. They are also used in automobiles, washing machines,
microwave ovens, toys ... etc, where automation is needed.
Micro-controllers are useful to the extent that they communicate with other devices, such as
sensors, motors, switches, keypads, displays, memory and even other micro-controllers. Many
interface methods have been developed over the years to solve the complex problem of balancing
circuit design criteria such as features, cost, size, weight, power consumption, reliability,
availability, manufacturability. Many microcontroller designs typically mix multiple interfacing
methods. In a very simplistic form, a micro-controller system can be viewed as a system that
reads from (monitors) inputs, performs processing and writes to (controls) outputs.
Embedded system means the processor is embedded into the required application. An embedded
product uses a microprocessor or microcontroller to do one task only. In an embedded system,
there is only one application software that is typically burned into ROM. Example: printer,
keyboard, video game player
Microprocessor - A single chip that contains the CPU or most of the computer
Microcontroller - A single chip used to control other devices
Microcontroller differs from a microprocessor in many ways. First and the most important is its
functionality. In order for a microprocessor to be used, other components such as memory, or
components for receiving and sending data must be added to it. In short that means that
microprocessor is the very heart of the computer. On the other hand, microcontroller is designed
to be all of that in one. No other external components are needed for its application because all
necessary peripherals are already built into it. Thus, we save the time and space needed to
construct devices.
MICROPROCESSOR VS MICROCONTROLLER:
Microprocessor:
 CPU is stand-alone, RAM, ROM, I/O, timer are separate
 Designer can decide on the amount of ROM, RAM and I/O ports.
 expensive
 versatility general-purpose
Microcontroller:
 CPU, RAM, ROM, I/O and timer are all on a single chip
 fix amount of on-chip ROM, RAM, I/O ports

14
 for applications in which cost, power and space are critical
 single-purpose

3.3 ARM7 PROCESSOR FAMILY


In 1994, the ARM7 Processor family has been immensely successful, and has helped establish
ARM as the architecture of choice in the digital world. Over the years, more than 10 billion
ARM7 processor family-based devices have powered a wide variety of cost and power- sensitive
applications.
While the Arm7 processor family continues to be used today for simple 32-bit devices, newer
embedded designs are increasingly making use of latest ARM processors such as the Cortex-M0
and Cortex-M3 processors, both of which offer significant technical enhancements over the
ARM7 family.
The ARM7 family is the world’s most widely used 32-bit embedded processor family, with more
than 170 silicon licensees and over 10 Billion units shipped since its introduction in 1994.
While the ARM7 processor family continues to be used today for simple 32-bit devices, newer
digital designs are increasingly making use of the newer, more powerful and feature-rich ARM
processors which offer significant technical enhancements over the ARM7 family.
System designers wishing to upgrade from ARM7 benefit from a robust ARM processor
roadmap providing multiple upgrade options, including the latest Cortex processors.
In most cases migration is straightforward, and brings significant benefits in PPA, features and
efficiency.
In 2005, about 98% of all mobile phones sold used at least one ARM processor. The low power
consumption of ARM processors has made them very popular: 37 billion ARM processors have
been produced as of 2013, up from 10 billion in 2008. The ARM architecture (32-bit) is the most
widely used architecture in mobile devices, and most popular 32-bit one in embedded systems.
According to ARM Holdings, in 2010 alone, producers of chips based on ARM architectures
reported shipments of 6.1 billion ARM Based processors, representing 95% of smart phones,
35% of digital televisions and set-top boxes and 10% of mobile computers. It is the most widely
used 32-bit instruction set architecture in terms of quantity produced.

15
Fig. 3.1 ARM7 Family-ARM

16
4. COMPONENT DESCRIPTION
4.1 LPC2148

FEATURES:

 High-performance, Low-power Consumption 32-bit Microcontroller


 RISC Architecture
 64-pin High-Performance ARM Microcontroller
 Flash Program Memory: 512 K Bytes
 SRAM Data Memory: 32 K Bytes
 I/O Pins: 45
 Timers: Two 32-bit
 A/D Converter: 10-bit Fourteen Channels
 DAC: 10-bit
 Real-Time Clock (RTC): Independent Power and Dedicated 32kHz Input
 I²C: Two Modules with Master or Slave Operation
 SPI: Full Duplex Serial Operation
 UART: Two Modules
 USB: 2.0B Fully Compliant Controller with RAM
 External Oscillator: up to 25MHz with integrated PLL for 60MHz Operation
Pin Configurations:

17
Fig. 4.1 LPC214X

Fig. 4.2 LPC2148 Pin Diagram

Overview:
The LPC2148 is a general purpose 32-bit microprocessor, which offers high performance
and very low power consumption. The architecture is based on RISC
Principles, and the instruction set and related decode mechanism are much simpler than those of
micro programmed CISC. This simplicity results in a high instruction throughput and impressive
real-time interrupt response from a small and cost-effective processor core.

18
Pipeline techniques are employed so that all parts of the processing and memory systems can
operate continuously. Typically, while one instruction is being executed, its successor is being
decoded, and a third instruction is being fetched from memory.
The key idea behind Thumb is that of a super-reduced instruction set. Essentially, the LPC2148
processor has two instruction sets: The standard 32-bit ARM set.
LPC2148 combines microcontroller with embedded high speed flash memory ranging from 32
kb to 512 kb. A 128-bit wide memory interface and a Unique accelerator architecture enable 32-
bit code execution at the maximum clock rate. For critical code size applications, the alternative
16-bit Thumb mode reduces code by more than 30 % with minimal performance penalty.
Due to its tiny size and low power consumption, LPC2148 is ideal for applications where
miniaturization is a key requirement. Serial communications interfaces ranging from a USB 2.0
Full-speed device, multiple UARTs, SPI, SSP to I2C-bus and on-chip SRAM of 8 KB up to 40
KB, make these devices very well suited for communication gateways and protocol converters,
providing both large buffer size and high processing power.
The instruction pipeline:
The ARM7TDMI core uses a pipeline to increase the speed of the flow of instructions to
the processor. This enables several operations to take place simultaneously, and the processing
and memory systems to operate continuously.
A three-stage pipeline is used as shown in fig 4.3, so instructions are executed in three stages:
• Fetch
• Decode
• Execute.

Fig. 4.3 ARM Instruction Pipeline

19
During normal operation, while one instruction is being executed, its successor is being decoded,
and a third instruction is being fetched from memory. The program counter points to the
instruction being fetched rather than to the instruction being executed. This is important because
it means that the Program Counter (PC) value used in an executing instruction is always two
instructions ahead of the address.

Fig. 4.4 LPC2148 Architecture Diagram

20
PIN DESCRIPTION:
LPC2148 has two I/0 ports namely PORT0 and PORT1. Each PORT has 32 IO pins. In PORT0
pins P0.24, P0.26 and P0.27 are not available. In PORT1 pins 0 to 15 are not available. Each port
pin has multiple functions. These functions can be selected by using pin Connect Block. Pin
Connect Block contains three 32-bit registers namely PINSEL0, PINSEL1 and PINSEL2.
IOPIN (IOPIN0 for PORT0 and IOPIN0 for PORT1):
GPIO Port pin value register. The current state of the GPIO configured port pins can always be
read from this register, regardless of pin direction. This register has the current status of the
corresponding port.
IODIR (IODIR0 for PORT0 and IODIR0 for PORT1):
GPIO Port Direction control register. This register individually controls the direction of each port
pin. This register is used to set each port pin as either input or output. If ‘0’, the port pin is
considered as input and if ‘1’, then the port pin is considered as output.
IOSET (IOSET0 for PORT0 and IOSET0 for PORT1):
GPIO Port Output Set register. This register controls the state of output pins in conjunction with
the IOCLR register. Writing ones produces highs at the corresponding port pins. Writing zeroes
has no effect.
IOCLR (IOCLR0 for PORT0 and IOCLR0 for PORT1):
GPIO Port Output Set register. This register controls the state of output pins in conjunction with
the IOSET register. Writing ones produces lows at the corresponding port pins. Writing zeroes
has no effect.
PINSEL0 Register:
PINSEL0 register serves to select any function from the pins P0.0 to P0.15

Table no 4.1 PINSEL0 Register

21
PINSEL1 Register:
PINSEL1 register serves to select any function from the pins P0.16 to P0.31

Table No 4.2 PINSEL1 Register


The PINSEL0 and PINSEL1 register control the function of device pins as show below. Pairs of
bits in these registers correspond to specific device pins.

Table No 4.3 PINSEL0 Register Functions


PINSEL2 Register:
PINSEL2 register serves to select any function from the pins P1.16 to P1.31.

Table No 4.4 PINSEL2 Register

22
UARTs (Universal Asynchronous Receiver and Transmitter):

Fig.4.5 UARTs in LPC2148 ARM7 Microcontroller

The LPC2148 contains two UARTs, UART0 and UART1. In addition to standard transmit and
receive data lines, the LPC2148 UART1 also provide a full modem control handshake interface.
Compared to previous LPC2000 microcontrollers, Arts in LPC2148 introduce a fractional baud
rate generator for both UARTs, enabling these microcontrollers to achieve standard baud rates
such as 115200 with any crystal frequency above 2 MHz
· 16 byte Receive and Transmit FIFOs (First In First Out).
· Register locations conform to ‘550 industry standard.
· Receiver FIFO trigger points at 1, 4, 8, and 14 bytes
· Built-in fractional baud rate generator covering wide range of baud rates without a
need for external crystals of particular values.
· Transmission FIFO control enables implementation of software (ON/OFF) flow control
on both UARTs.
· LPC2148 UART1 equipped with standard modem interface signals. This module also
provides full support for hardware flow control.

23
I2C-Bus serial I/O Controller:
The LPC2148 contains two I2C-bus controllers. The I2C-bus is bidirectional, for inter-IC control
using only two wires: A serial clock line (SCL), A serial data line (SDL).Each device is
recognized by a unique address and can operate as either a receiver-only device. Transmitters
and/or receivers can operate in either master or slave mode, depending on whether the chip has
to initiate a data transfer or is only addressed. The I2C-bus is a multi-master bus, it can be
controlled by more than one bus master connected to it. The I2C-bus implemented in LP2148
supports bit rates up to 400 Kbit/s (Fast I2C-bus).
· Compliant with standard I2C-bus interface.
· Easy to configure as master, slave, or master/slave.
· Programmable clocks allow versatile rate control.
· Bidirectional data transfer between masters and slaves.
· Multi-master bus (no central master).
· Arbitration between simultaneously transmitting masters without corruption of serial data
on the bus.
· Serial clock synchronization allows devices with different bit rates to communicate via
one serial bus.
· Serial clock synchronization can be used as a handshake mechanism to suspend and
resume serial transfer.
· The I2C-bus can be used for test and diagnostic purposes.

SPI (Serial Peripheral Interface) I/O Controller:


The LPC2148 contains one SPI controller. The SPI is a full duplex serial interface, designed to
handle multiple masters and slaves connected to a given bus. Only a single master and a single
slave can communicate on the interface during a given data transfer. During a data transfer the
master always sends a byte of data to the slave, and the slave always sends a byte of data to the
master.
· Compliant with Serial Peripheral Interface (SPI) specification.
· Synchronous, Serial, Full Duplex, Communication.
· Combined SPI master and slave.

24
· Maximum data bit rate of one eighth of the input clock rate.
· Compatible with Motorola’s SPI, TI’s 4-wire SSI and National Semiconductor’s
Micro-Wire buses.
· Synchronous serial communication.
· Master or slave operation.
· 8-frame FIFOs for both transmit and receive.
Crystal Oscillator:

Fig. 4.6 Crystal Oscillator


On-chip integrated oscillator operates with external crystal in range of 1 MHz to 25 MHz The
oscillator output frequency, fosc and the ARM processor clock frequency is referred to as CCLK
for purposes of rate equations, etc. fosc and CCLK are the same value unless the PLL (Phase
Locked Loop) is running and connected.
Power Control:
The LPC2148 supports two reduced power modes:
 Idle mode
 Power down mode.
In Idle mode, execution of instructions is suspended until either a reset or interrupt
occurs. Peripheral functions continue operation during idle mode and may generate interrupts to
cause the processor to resume execution. Idle mode eliminates power used by the processor
itself, memory systems and related controllers, and internal buses.

25
In Power-down mode, the oscillator is shut down and the chip receives no internal clocks. The
processor state and registers, peripheral registers, and internal SRAM values are preserved
throughout Power-down mode and the logic levels of chip output pins remain static. The Power-
down mode can be terminated and normal operation resumed by either a reset or certain specific
interrupts that are able to function without clocks. Since all dynamic operation of the chip is
suspended, Power-down mode reduces chip power consumption to nearly zero.
Reset Circuit:
Reset button is essential in a system to avoid programming pitfalls and sometimes to
manually bring back the system.

Fig. 4.7 Reset circuit


4.2 POWER SUPPLY
LPC2148 works on 3.3 V power supply. LM 117 can be used for generating 3.3 V supply.
However, basic peripherals like LCD, ULN 2003 (Motor Driver IC) etc. works on 5V. So AC
mains supply is converted into 5V using below mentioned circuit and after that LM 117 is used
to convert 5V into 3.3V.

Fig. 4.7 Power Supply Block Diagram

26
Transformer:
It is used to step down 230V AC to 9V AC supply and provides isolation between power grids
and circuit.
Rectifier:
It is used to convert AC supply into DC.
Filter:
It is used to reduce ripple factor of DC output available from rectifier end.
Regulator:
It is used to regulate DC supply output.

Fig. 4.8 Regulator

Here, Regulator IC 7805 is used to provide fix 5V dc supply.


Now we can use LM 117 for generating 3.3V supply from 5V.

27
Fig. 4.9 IC 7805 Regulator

4.3 LIQUID CRYSTAL DISPLAY (LCD)

A liquid crystal display (LCD) is a thin, flat panel used for electronically displaying information
such as text, images, and moving pictures. Its uses include monitors for computers, televisions,
instrument panels, and other devices ranging from aircraft cockpit displays, to every-day
consumer devices such as video players, gaming devices, clocks, watches, calculators, and
telephones. Among its major features are its lightweight construction, its portability, and its
ability to be produced in much larger screen sizes than are practical for the construction of
cathode ray tube (CRT) display technology. Its low electrical power consumption enables it to be
used in battery-powered electronic equipment. It is an electronically-modulated optical device
made up of any number of pixels filled with liquid crystals and arrayed in front of a light source
(backlight) or reflector to produce images in color or monochrome. The earliest discovery
leading to the development of LCD technology, the discovery of liquid crystals, dates from 1888.
By 2008, worldwide sales of televisions with LCD screens had surpassed the sale of CRT units.

28
PIN DESCRIPTION:

Fig. 4.10 LCD Pin Discription

PIN SYMBOL I/O DESCRIPTION

1 VSS -- Ground
2 VCC -- +5V power supply
3 VEE -- Power supply to control contrast
4 RS I RS=0 to select command register
RS=1 to select data register
5 R/W I R/W=0 for write
R/W=1 for read
6 EN I/O Enable
7 DB0 I/O The 8-bit data bus
8 DB1 I/O The 8-bit data bus
9 DB2 I/O The 8-bit data bus
10 DB3 I/O The 8-bit data bus
11 DB4 I/O The 8-bit data bus
12 DB5 I/O The 8-bit data bus
13 DB6 I/O The 8-bit data bus
14 DB7 I/O The 8-bit data bus
Table no 4.5 LCD Pin Description

29
VCC, VSS and VEE: While VCC and VSS provide +5V and ground respectively, VEE is used
for controlling LCD contrast.

RS (REGISTER SELECT):
There are two important registers inside the LCD. 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 that is sent is a text data which should be displayed on the screen. For example, to
display the letter "T" on the screen you would set RS high.
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 (o)
RW (READ/WRITE):
Reading the LCD, Only one instruction ("Get LCD status") is a read command. All others are
write commands, so RW will almost be low.
EN (ENABLE):

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 first set this line high (1) 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 low (0) again. The 1-0 transition tells the 44780 to take the data currently found
on the other control lines and on the data bus and to treat it as a command.

D0-D7 (DATA LINES):

The 8-bit data pins, D0-D7 are used to send information to the LCD or read the content of the
LCD’s internal registers.

To display letters and numbers, we send ASCII codes for the letters A-Z, a-z and numbers 0-9 to
these pins while making RS=1. There are also instruction command codes that can be sent to the
LCD to clear the display or force the cursor to the home position or blink the cursor.

We also use RS=0 to check the busy flag bit to see if the LCD is ready to receive the
information. The busy flag is D7 and can be read when R/W = 1 and RS=0, as follows: if R/W =
1, RS = 0. When D7=1 (busy flag = 1), the LCD is busy taking care of internal operations and

30
will not accept any new information. When D7 = 0, the LCD is ready to receive new
information.

Note: It is recommended to check the flag before writing any data to LCD.

LCD COMMAND CODES:

CODE (HEX) COMMAND TO LCD INSTRUCTION REGISTER


1 CLEAR DISPLAY SCREEN
2 RETURN HOME
4 DECREMENT CURSOR(SHIFT CURSOR TO LEFT)
6 INCREMENT CURSOR(SHIFT CURSOR TO RIGHT)
5 SHIFT DISPLAY RIGHT
7 SHIFT DISPLAY LEFT
8 DISPLAY OFF,CURSOR OFF
A DISPLAY OFF,CURSOR ON
C DISPLAY ON,CURSOR OFF
E DISPLAY ON CURSOR BLINKING
F DISPLAY ON CURSOR BLINKING
10 SHIFT CURSOR POSITION TO LEFT
14 SHIFT CURSOR POSITION TO RIGHT
18 SHIFT THE ENTIRE DISPLAY TO THE LEFT
1C SHIFT THE ENTIRE DISPLAY TO THE RIGHT
80 FORCE CURSOR TO BEGINNING OF 1ST LINE
C0 FORCE CURSOR TO BEGINNING OF 2ND LINE
38 2 LINES AND 5x7 MATRIX
Table no 4.6 LCD Command Codes
CURSOR ADDRESSES FOR LCD’S:

16x2 LCD 80 81 82 83 84 85 86 through 8F


C0 C1 C2 C3 C4 C5 C6 through CF
20x1 LCD 80 81 82 83 through 93
20x2 LCD 80 81 82 83 through 93
C0 C1 C2 C3 through D3
20x4 LCD 80 81 82 83 through 93
C0 C1 C2 C3 through D3
94 95 96 97 through A7
D4 D5 D6 D7 through E7
40x2 LCD 80 81 82 83 through A7
C0 C1 C2 C3 through E7
NOTE: All data is in HEX.
Table no 4.7 Cursor Addresses For LCD’s

31
ADVANTAGES:
LCD interfacing with 8051 is a real-world application. In recent years the LCD is finding
widespread use replacing LED’s (seven segment LED’s or other multi segment LED’s).

This is due to following reasons:

 The declining prices of LCD’s.


 The ability to display numbers, characters and graphics. This is in contrast to LED’s,
which are limited to numbers and a few characters. An intelligent LCD displays two
lines, 20 characters per line, which is interfaced to the 8051.
 Incorporation of a refreshing controller into the LCD, thereby relieving the CPU to keep
displaying the data.
 Ease of programming for characters and graphics.

4.4 LIGHT EMITTING DIODE

A light-emitting diode (LED) is a semiconductor diode that emits incoherent narrow


spectrum light when electrically biased in the forward direction of the pn-junction, as in the
common LED circuit. This effect is a form of electroluminescence.

Fig. 4.11 Parts of a Conventional LED

32
Fig. 4.12 Types of LEDs

Like a normal diode, the LED consists of a chip of semi-conducting material impregnated, or
doped, with impurities to create a p-n junction. As in other diodes, current flows easily from the
p-side, or anode, to the n-side, or cathode, but not in the reverse direction. Charge-carriers—
electrons and holes—flow into the junction from electrodes with different voltages. When an
electron meets a hole, it falls into a lower energy level, and releases energy in the form of a
photon.

Fig. 4.13 PN Junction-LED-E

The wavelength of the light emitted, and therefore its color, depends on the band gap energy of
the materials forming the p-n junction. In silicon or germanium diodes, the electrons and holes
recombine by a non-radiative transition which produces no optical emission, because these are

33
indirect band gap materials. The materials used for the LED have a direct band gap with energies
corresponding to near-infrared, visible or near-ultraviolet light.

LED development began with infrared and red devices made with gallium arsenide. Advances in
materials science have made possible the production of devices with ever-shorter wavelengths,
producing light in a variety of colors.

LEDs are usually built on an n-type substrate, with an electrode attached to the p-type layer
deposited on its surface. P-type substrates, while less common, occur as well. Many commercial
LEDs, especially GaN/InGaN, also use sapphire substrate.

Most materials used for LED production have very high refractive indices. This means that much
light will be reflected back in to the material at the material/air surface interface. Therefore Light
extraction in LEDs is an important aspect of LED production, subject to much research and
development.

Solid state devices such as LEDs are subject to very limited wear and tear if operated at low
currents and at low temperatures. Many of the LEDs produced in the 1970s and 1980s are still in
service today. Typical lifetimes quoted are 25,000 to 100,000 hours but heat and current settings
can extend or shorten this time significantly.

Conventional LEDs are made from a variety of inorganic semiconductor materials; the following
table shows the available colors with wavelength range and voltage drop.

Color Wavelength (nm) Voltage (V)


Infrared λ > 760 ΔV < 1.9
Red 610 < λ < 760 1.63 < ΔV < 2.03
Orange 590 < λ < 610 2.03 < ΔV < 2.10
Yellow 570 < λ < 590 2.10 < ΔV < 2.18
Green 500 < λ < 570 1.9 < ΔV < 4.0
Blue 450 < λ < 500 2.48 < ΔV < 3.7
Violet 400 < λ < 450 2.76 < ΔV < 4.0

34
Purple multiple types 2.48 < ΔV < 3.7
Ultraviolet λ < 400 3.1 < ΔV < 4.4
White Broad spectrum ΔV = 3.5
Table no 4.8 Color Specifications

ADVANTAGES OF LEDS:

 LED’s have many advantages over other technologies like lasers. As compared to laser
diodes or IR sources.
 LED’s are conventional incandescent lamps. For one thing, they don't have a filament
that will burn out, so they last much longer. Additionally, their small plastic bulb makes
them a lot more durable. They also fit more easily into modern electronic circuits.
 The main advantage is efficiency. In conventional incandescent bulbs, the light-
production process involves generating a lot of heat (the filament must be warmed).
Unless you're using the lamp as a heater, because a huge portion of the available
electricity isn't going toward producing visible light.
 LED’s generate very little heat. A much higher percentage of the electrical power is
going directly for generating light, which cuts down the electricity demands considerably.
 LED’s offer advantages such as low cost and long service life. Moreover LED’s have
very low power consumption and are easy to maintain.

DISADVANTAGES OF LEDS:

 LED’s performance largely depends on the ambient temperature of the operating


environment.
 LED’s must be supplied with the correct current.
 LED’s do not approximate a "point source" of light, so cannot be used in applications
needing a highly collimated beam.

But the disadvantages are quite negligible as the negative properties of LED’s do not apply and
the advantages far exceed the limitations.

35
4.5 RS232

RS-232 stands for Recommend Standard number 232 and C is the latest revision of the standard.
The serial ports on most computers use a subset of the RS-232C standard. The full RS-232C
standard specifies a 25-pin "D" connector of which 22 pins are used. Most of these pins are not
needed for normal PC communications, and indeed, most new PCs are equipped with male D
type connectors having only 9 pins.

Pin Number Direction of signal

1 Carrier Detect (CD) (from DCE) Incoming signal from a modem

2 Received Data (RD) Incoming Data from a DCE

3 Transmitted Data (TD) Outgoing Data to a DCE

4 Data Terminal Ready (DTR) Outgoing handshaking signal

5 Signal Ground Common reference voltage

6 Data Set Ready (DSR) Incoming handshaking signal

7 Request To Send (RTS) Outgoing flow control signal

8 Clear To Send (CTS) Incoming flow control signal

9 Ring Indicator (RI) (from DCE) Incoming signal from a modem

Table no 4.9 RS232 Direction of Signal

36
Fig. 4.14 RS232 DB9 Pin out Diagram

4.6 MAX232

The MAX232 device is a dual driver/receiver that includes a capacitive voltage generator
to supply EIA-232 voltage levels from a single 5-V supply. Each receiver converts EIA-232
inputs to 5-V TTL/CMOS levels. These receivers have a typical threshold of 1.3 V and a typical
hysteresis of 0.5 V, and can accept ±30-V inputs. Each driver converts TTL/CMOS input levels
into EIA-232 levels. The driver, receiver, and voltage-generator functions are available as cells
in the Texas Instruments LinASICE library. The MAX232 is characterized for operation from
0°C to 70°C. The MAX232I is characterized for operation from –40°C to 85°C.

Features:

 Operates With Single 5-V Power Supply


 Lin Bi CMOSE Process Technology
 Two Drivers and Two Receivers
 ±30-V Input Levels

37
 Low Supply Current up to 8mA Typical Meets or Exceeds TIA/EIA-232-F and ITU
Recommendation Designed to be Interchangeable With Maxim MAX232.
 Applications TIA/EIA-232-F Battery-Powered Systems Terminals Modems Computers.
 ESD Protection Exceeds 2000 V Per MIL-STD-883, Method 3015

Package Options Include Plastic Small-Outline (D, DW) Packages and Standard Plastic (N)
DIPs.

Fig.4.15 MAX232

38
Fig. 4.16 MAX232 and Proteus
4.7 ZIGBEE COMMUNICATION

Fig. 4.17 Zigbee Transreceiver

Pin Description:

VDD: 3.3V or 5V power supply positive

39
GND: Power negative
TXD: serial output module, connected microcontroller or USB to serial RXD
RXD: module serial input connected microcontroller or USB to serial TXD
CMD: enter upgrade mode or AT mode pin, active low
Special note:
CMD pin functions:
On the ground before power: the module into upgrade mode, firmware upgrades. The electrical
grounding, the module into AT mode, AT mode is used to configure the module parameters.
After power if vacant, Module enters pass-through mode.After power can be switched AT mode
and transparent mode via CMD foot Freedom.
Power:
1. The module’s serial port level TTL level, do not communicate with GND short
2. When the transmitter module current can reach 120mA, when receiving a current of about
30mA, note the use of grain
4.8 RELAY DRIVER
Darlington Transistor Array ULN2003

Fig. 4.18 Relay Driver IC ULN2003


General description:
The ULN2003 is a monolithic high voltage and high current Darlington transistor arrays. It
consists of seven NPN darlington pairs that features high-voltage outputs with common-cathode
clamp diode for switching inductive loads. The darlington pairs may be paralleled for higher
current capability. Each channel rated at 500mA and can withstand peak currents of 600mA.
Suppression diodes are included for inductive load driving and the inputs are pinned opposite the
outputs to simplify board layout.

40
The versions interface to all common logic families:
– ULN2001 (general purpose, DTL, TTL, PMOS, CMOS)
– ULN2002 (14-25V PMOS)
– ULN2003 (5V TTL, CMOS)
– ULN2004 (6-15V CMOS, PMOS)
Applications include relay drivers, hammer drivers, lamp drivers, display drivers (LED
gas discharge),line drivers, and logic buffers. The ULN2003 has a 2.7kW series base resistor for
each darlington pair for operation directly with TTL or 5V CMOS devices.
FEATURES:
 Seven darlingtons per package
 Output current 500mA per driver (600mApeak)
 Output voltage 50 V
 Integrated suppression diodes for inductive loads
 Outputs can be paralleled for higher current
 TTL/CMOS/PMOS/DTL Compatible inputs
4.9 PIR SENSOR

Fig. 4.19 PIR Sensor Module


Compact and complete, easy to use Pyroelectric Infrared (PIR) Sensor Module for human body
detection. Incorporating a Fresnel lens and motion detection circuit. High sensitivity and low
noise. Output is a standard 5V active low output signal. Module provides an optimized circuit
that will detect motion up to 6 meters away and can be used in burglar alarms and access control
systems. Inexpensive and easy to use, it's ideal for alarm systems, motion-activated lighting,
holiday props, and robotics applications.
The Output can be connected to microcontroller pin directly to monitor signal or a connected to
transistor to drive DC loads like a bell, buzzer, siren, relay, Optocoupler (e.g. PC817,

41
MOC3021), etc. The PIR sensor and Fresnel lens are fitted onto the PCB. This enables the board
to be mounted inside a case with the detecting lens protruding outwards.
Features:
 Complete with PIR, Motion Detection IC and Fresnel Lens
 Simple 3 connections
 Dual Element Sensor with Low Noise and High Sensitivity
 Supply Voltage: 5V DC
 Standard Active Low Output pin for connecting to microcontroller directly
 Detecting range up to 6 meters LED indication
 Module Dimensions: 25mm Length, 32mmWidth, 25mm Height
Applications
 Motion-activated nightlight
 Alarm systems
 Robotics & Holiday animated props

4.10 TEMPERATURE SENSOR

Fig. 4.20 Temperature Sensor


The LM35 series are precision integrated-circuit temperature sensors, whose output voltage is
linearly proportional to the Celsius (Centigrade) temperature. The LM35 thus has an advantage
over linear temperature sensors calibrated in ° Kelvin, as the user is not required to subtract a
large constant voltage from its output to obtain convenient Centigrade scaling. The LM35 does
not require any external calibration or trimming to provide typical accuracies of ±1⁄4°C at room
temperature and ±3⁄4°C over a full −55 to +150°C temperature range. Low cost is assured by
trimming and calibration at the wafer level. The LM35’s low output impedance, linear output,
and precise inherent calibration make interfacing to readout or control circuitry especially easy.

42
It can be used with single power supplies, or with plus and minus supplies. As it draws only 60
μA from its supply, it has very low self-heating, less than 0.1°C in still air. The LM35 is rated to
operate over a −55° to +150°C temperature range, while the LM35C is rated for a −40° to
+110°C range (−10° with improved accuracy).

4.11 Light Dependent Resistor – LDR

Fig. 4.21 Light Dependent Resistor – LDR


Two cadmium sulphide(cds) photoconductive cells with spectral responses similar to that of the
human eye. The cell resistance falls with increasing light intensity. Applications include smoke
detection, automatic lighting control, batch counting and burglar alarm systems.
Applications:
Photoconductive cells are used in many different types of circuits and applications.
Analog Applications:
 Camera Exposure Control
 Auto Slide Focus - dual cell
 Photocopy Machines - density of toner
 Colorimetric Test Equipment
 Densitometer
 Electronic Scales - dual cell
 Automatic Gain Control – modulated light source
 Automated Rear View Mirror

43
Digital Applications:
 Automatic Headlight Dimmer
 Night Light Control
 Oil Burner Flame Out
 Street Light Control
 Absence / Presence (beam breaker)
 Position Sensor
4.12 BATTERY

Fig. 4.22 UB1213 Battery

Batteries are manufactured under the most versatile computer control battery formation system
and technology to achieve the highest quality. The automated, computer controlled system
provides programmed functions for steps of current, time, voltage, temperature and event control
to match the performance specifications of your application requirements.

NON-SPILLABLE by DOT(Department of Transportation), ICAO (International Civil Airline


Organization) and IATA (International Airline Transportation Association) definitions.

Features:

 Maintenance Free
 Valve Regulated
44
 Used in Multiple Applications
 Float and Cycle Use
 High Discharge Rate
 Absorbed Glass Mat (often referenced as Gel Cell)
 Leak Proof/Spill Proof

 Tank formed plates


 Temperature control formation
 Constant current formation
 High quality battery/better uniformity

4.13 SOLAR PANEL

Fig. 4.23 Solar Panels

These panels are designed for the most rugged off-grid applications including; RV's, cabins,
street lighting, water pumping, ventilation fans, navigation lights, traffic signs and signals.

Features:

 Nominal 12V DC
 Outstanding low light performance
 Heady-duty anodized frames.
 High transparent low-iron, tempered glass.
 Rugged design to withstand high wind pressure, hail and snow load.

45
5. SOFTWARE DESCRIPTION

5.1 KEIL UVISON4


Keil uvision4 Software provides you with software development tools for the ARM7TDMI
family of microprocessors. With the Keil tools, you can generate embedded applications for
multitude of ARM7TDMI derivatives. Throughout this project we refer to these tools as the
ARM7TDMI development tools. However, they support all derivatives and variants of the
ARM7TDMImicrocontrollerFamily.
The Keil Software ARMD7TDMI development tools listed below are the programs used to
compile your C code, assemble your assembler source files, link your
Program together, create HEX files, and debug your target program.
How to create a Project in keil?
Step 1: Double click on the Keil uVision 2/3/4 icon at desktop.
Step 2: At Menu Bar, click on Project >>New Project>> Project name>> Save>> Select
Device>> Atmel>> 89C51>>OK.

46
Step 3: Take New file, give some name and save it with respective extension either .asm or .c.
Step 4: On project window, right click on Source Group>>Add file to source group ‘Source
Group1’.
How to Build a program?

 Step 1: Start writing program in Keil, after completion of writing program save and
Build Target/Rebuild all Target files with the help of Build button at standard tool bar.
 Step 2: You can find warnings and errors at the output window if at all occur, which is at
bottom of the screen.
 Step 3: If you found with no warnings and errors, you can debug now.

How to Debug a program?


 Step 1: Click on Debug button on Standard tool bar

Debug button

 Step 2: Start pressing Step into button at Debugger tool bar.

Step into
 Step 3: Do step 2 until you finish the program
 Step 4: Select the Peripherals from the Menu bar if any Peripheral is involved in your
program, like as shown below.

How to create HEX file in Keil?

47
 Step 1: Select Project from Menu bar>>Options for Target ‘Target 1’

 Step 2: Set the Xtal Freq to 11.0592 MHz.


 Step 3: Select Output and check create HEX file.
 Step 4: Give the path for hex file and click OK.

5.2 FLASH MAGIC SOFTWARE:


Flash Magic is an application developed by Embedded Systems Academy to allow you to easily
access the features of a microcontroller device. With this program you can erase individual
blocks or the entire Flash memory of the microcontroller.
Flash Magic can burn programs into the flash memories of NXP microcontrollers. It will
automatically program checksums, which is then verified to ensure uncorrupted code. The
application can specifically identify and erase those flash blocks that are in-use.
Features:
 Five simple steps to erasing and programming a device and setting key options.
 Programs Intel Hex Files.

48
 Automatic verifying after programming.
 Fills unused Flash to increase firmware security.
 Program security bits.
 Read any section of Flash and save as an Intel Hex File.
 Display the contents of Flash in ASCII and Hexadecimal formats.

Using Flash Magic Software:

Step 1:

49
Step 2:

Step 3:

50
6. RESULTS

51
52
53
7. CONCLUSION AND FUTURE SCOPE

CONCLUSION:
The project work “ZIGBEE WIRELESS COMMUNICATION FOR MONITORING
RENEWABLE STREET LIGHT SYSTEM” is designed & developed successfully. For the
demonstration purpose, a proto type module constructed with lower ratings of devices, & results
are found to be satisfactory. As the concept is near to the real working system, to make it more
realistic, desired rating devices and components should be implemented practically. So, finally
from the results observed in the prototype we can clearly say that a large amount of power can be
saved by the use of automatic ON/OFF mechanism of street lighting in addition to renewable
source of energy i.e., solar energy. Highly efficient solutions like MPPT are needed to maximize
the efficiency from solar panels. Expectations are increasing for solar powered LED lighting to
become the environmentally friendly outdoor solution for the 21st century.
FUTURE SCOPE:
For further development, Android based applications can be developed for Smart Tabs/Mobile
Phones making mobility of control possible.

54
BIBLIOGRAPHY

CONTENTS REFERED:

1. LPC2148 User Manual


2. LPC 2148 Datasheet
3. GSM AT Commands
4. Magnetic card reader manual
5. “The 8051 Microcontroller and Embedded Systems” by Muhammad Ali Mazidi and
Janice Gillispie Mazidi, Pearson Education.
6. Hand book for Digital IC’s from Analogic Devices

WEBSITES VIEWED:

 www.keil.com

 www.atmel.com

 www.beyondlogic.org

 www.dallassemiconductors.com

 www.maxim-ic.com

 www.alldatasheets.com

 www.howstuffworks.com

 www.wikipedia.com

55
APPENDIX

Embedded code:

#include <LPC214X.H>
#define RDA 0x04
#define rly1 0x00010000 //st1
#define rly2 0x00020000 //st2
#define rly3 0x00040000 //st3
#define buz (1<<10);
unsigned int adc_4(void);
unsigned int adc_1(void);
unsigned char pir,ldr,bb;
unsigned int temp,light;
void delay_ms(unsigned int t)
{
unsigned int i;
for(;t>0;t--)
for(i=0;i<5000;i++);
}
void cmd(unsigned char ch)
{
unsigned int x;
x=ch;
IOPIN1 =(x<<18);
IOCLR1 = 0x00010000;
IOSET1= 0x00020000;
delay_ms(1);
IOCLR1=0x00020000;
delay_ms(1);
}
void display(unsigned char ch)
{
unsigned int x;
x=ch;
IOPIN1 =(x<<18);
IOSET1= 0x00030000;
delay_ms(5);
IOCLR1=0x00020000;
delay_ms(5);
}
void disp_str(unsigned char *s)
{
while(*s)
display(*s++);

56
}
void tx_uart0(unsigned char ch)
{
U0THR = ch;
while(!(U0LSR & 0x20));
}
void Print(unsigned char *s)
{
while(*s)
tx_uart0(*s++);
}
void convert(unsigned int q)
{
unsigned char a1,a2,a3,a4;
a1=(q%10000)/1000+48;
a2=(q%1000)/100+48;
a3=(q%100)/10+48;
a4=(q%10)+48;
display(a1);
display(a2);
display(a3);
display(a4);
}
void send_adc(unsigned int q)
{
unsigned char a1,a2,a3,a4;
a1=(q%10000)/1000+48;
a2=(q%1000)/100+48;
a3=(q%100)/10+48;
a4=(q%10)+48;
tx_uart0(a1);
tx_uart0(a2);
tx_uart0(a3);
tx_uart0(a4);
}
void uart0() __irq
{
unsigned char ch;
if(U0IIR & RDA)
{
ch = U0RBR;
switch(ch)
{
case '1':
IOSET0 |=rly1;
break;

57
case '2':
IOSET0 |=rly2;
break;
case '3':
IOSET0 |=rly3;
break;
case 'a':
IOCLR0 |=rly1;
break;
case 'b':
IOCLR0 |=rly2;
break;
case 'c':
IOCLR0 |= rly3;
break;
case '0':
IOSET0 |= rly1 | rly2 | rly3;
break;
case '5':
IOCLR0 |= rly1 | rly2 | rly3;
break;
case '$':
tx_uart0('#');
tx_uart0(pir);
tx_uart0(ldr);
send_adc(temp);
tx_uart0('@');
delay_ms(500);
tx_uart0(0x0D);
tx_uart0(0x0A);
break;
case '~':
IOSET0 |= buz;
break;
case '!':
IOCLR0 |= buz;
break;
} }
VICVectAddr = 0x00;
}
void uart0_init()
{
PINSEL0 |= 0x00000005;
U0LCR = 0X83;
// U0FDR = 0xa1;
U0DLL = 98;

58
U0DLM = 0;
/*fdiv = ((12000000 * 10)/(16 * 9600 * 11)); //uart0_interrupt
U0DLM= fdiv/256;
U0DLL = fdiv%256; */
U0LCR = 0x03;
U0FCR = 0x01;
U0IER = 0x00000003;
VICVectCntl0 = 0x26;
VICVectAddr0 = (unsigned long)uart0;
VICIntEnable |= (1<<6);
}
int main()
{
unsigned int z;
IODIR1=0x03ff0000;
IODIR0 |= rly1 | rly2 | rly3;
IOCLR0 |= rly1 | rly2 | rly3;
IODIR0 |= buz;
IOCLR0 |= buz;
uart0_init();
cmd(0x80);
cmd(0x01);
cmd(0x06);
cmd(0x0E);
cmd(0x38);

while(1)
{
z=IOPIN0; //7 pin pir
z &= 0x00000080;
if(z==0)
{
pir='n';
}
else if(z==0x00000080)
{
pir='d';
}
light=adc_4();
cmd(0x80);
disp_str("LIGHT:");
convert(light);
if(light>700)
{
ldr='D';
}

59
else
{
ldr='L';
}
temp=adc_1();
temp=temp/3;
cmd(0xC0);
disp_str("TEMP:");
convert(temp);
delay_ms(500);
tx_uart0('#');
tx_uart0(pir);
tx_uart0(ldr);
send_adc(temp);
tx_uart0('@');
delay_ms(500);
tx_uart0(0x0D);
tx_uart0(0x0A);
}
}
unsigned int adc_1()
{
unsigned int p,adc_val;
PINSEL1 |= 0x01000000;
AD0CR = 0x00200000;
adc_val = 0;
for(p=0;p<5;p++)
delay_ms(1);
p = 0;
AD0CR |= 0x01000002;
while(p==0x00)
{
p = AD0DR1;
p = p & 0x80000000;
}
adc_val = AD0DR1 >> 6;
adc_val = adc_val & 0x03FF;
AD0CR &= 0xFFFFFFFD;
return adc_val;
}
unsigned int adc_4()
{
unsigned int p,adc_val;
PINSEL1 |= 0x00040000;
AD0CR = 0x00200000;
adc_val = 0;

60
for(p=0;p<5;p++)
delay_ms(1);
p = 0;
AD0CR |= 0x01000010;
while(p==0x00)
{
p = AD0DR4;
p = p & 0x80000000;
}
adc_val = AD0DR4 >> 6;
adc_val = adc_val & 0x03FF;
AD0CR &= 0xFFFFFFFD;
return adc_val;
}

Matlab code:

61

Das könnte Ihnen auch gefallen