You are on page 1of 66

CHAPTER 1

EMBEDDED SYSTEMS

INTRODUCTION TO EMBEDDED SYSTEMS

Each day, our lives become more dependent on 'embedded systems', digital information
technology that is embedded in our environment. More than 98% of processors applied
today are in embedded systems, and are no longer visible to the customer as 'computers'
in the ordinary sense. An embedded system is a special-purpose system in which the
computer is completely encapsulated by or dedicated to the device or system it controls.
Unlike a general-purpose computer, such as a personal computer, an embedded system
performs one or a few pre-defined tasks, usually with very specific requirements. Since
the system is dedicated to specific tasks, design engineers can optimize it, reducing the
size and cost of the product. Embedded systems are often mass-produced, benefiting from
economies of scale. The increasing use of pc hardware is one of the most important
developments in high-end embedded systems in recent years. Hardware costs of high-end
systems have dropped dramatically as a result of this trend, making feasible some
projects which previously would not have been done because of the high cost of non-pc-
based embedded hardware. But software choices for the embedded pc platform are not
nearly as attractive as the hardware.

Typically, an embedded system is housed on a single microprocessor board with the


programs stored in rom. Virtually all appliances that have a digital interface -- watches,
microwaves, vcrs, cars -- utilize embedded systems. Some embedded systems include an
operating system, but many are so specialized that the entire logic can be implemented as
a single program.

Physically, embedded systems range from portable devices such as digital watches and
mp3 players, to large stationary installations like traffic lights, factory controllers, or the
systems controlling nuclear power plants.

1
In terms of complexity embedded systems can range from very simple with a single
microcontroller chip, to very complex with multiple units, peripherals and networks
mounted inside a large chassis or enclosure.

Definition of an embedded system

Embedded system is defined as, for a particular/specific application implementing the


software code to interact directly with that particular hardware what we built. Software is
used for providing features and flexibility, hardware = {processors, asics, memory,...} Is
used for performance (& sometimes security)

There are many definitions of embedded system but all of these can be combined into a
single concept. An embedded system is a special purpose computer system that is used
for particular task.

Features of embedded systems

The versatility of the embedded computer system lends itself to utility in all kinds of
enterprises, from the simplification of deliverable products to a reduction in costs in their
development and manufacture. Complex systems with rich functionality employ special
operating systems that take into account major characteristics of embedded systems.
Embedded operating systems have minimized footprint and may follow real-time
operating system specifics.

The special computers system is usually less powerful than general-purpose systems,
although some expectations do exist where embedded systems are very powerful and
complicated. Usually a low power consumption cpu with a limited amount of memory is
used in embedded systems. Many embedded systems use very small operating systems;
most of these provide very limited operating system capabilities.

Since the embedded system is dedicated to specific tasks, design engineers can optimize
it, reducing the size and cost of the product, or increasing the reliability and performance.
Some embedded systems are mass-produced, benefiting from economies of scale.

2
Some embedded systems have to operate in extreme environment conditions such as very
high temperature & humidity.

For high volume systems such as portable music players or mobile phones, minimizing
cost is usually the primary design consideration. Engineers typically select hardware that
is just “good enough” to implement the necessary functions.

For low volume or prototype embedded systems, general purpose computers may be
adapted by limiting the programs or by replacing the operating system with a real-time
operating system.

Characteristics of embedded systems

Embedded computing systems generally exhibit rich functionality—complex


functionality is usually the reason for introducing cpus into the design. However, they
also exhibit many non-functional requirements that make the task especially challenging:

• real-time deadlines that will cause system failure if not met;

• multi-rate operation;

• in many cases, low power consumption;

• low manufacturing cost, which often means limited code size.

Workstation programmers often concentrate on functionality. They may consider the


performance characteristics of a few computational kernels of their software, but rarely
analyze the total application. They almost never consider power consumption and
manufacturing cost. The need to juggle all these requirements makes embedded system
programming very challenging and is the reason why embedded system designers need to
understand computer architecture.

Overview of an embedded system architecture

3
Every embedded system consists of a custom-built hardware built around a central
processing unit. This hardware also contains memory chips onto which the software is
loaded.

The operating system runs above the hardware and the application software runs above
the operating system. The same architecture is applicable to any computer including
desktop computer. However these are significant differences. It is not compulsory to have
an operating system in every embedded system. For small applications such as remote
control units, air conditioners, toys etc.

Applications of embedded systems

Some of the most common embedded systems used in everyday life are

Small embedded controllers: 8-bit cpus dominate, simple or no operating system

(e.g., thermostats)

Control systems: often use dsp chip for control computations

(e.g., automotive engine control)

4
Distributed embedded control: mixture of large and small nodes on a real-time

embedded networks

(e.g., cars, elevators, factory automation)

System on chip: asic design tailored to application area

(e.g., consumer electronics, set-top boxes)

Network equipment: emphasis on data movement/packet flow

(e.g., network switches; telephone switches)

Critical systems: safety and mission critical computing

(e.g., pacemakers, automatic trains)

Signal processing: often use dsp chips for vision, audio, or other signal

processing (e.g., face recognition)

Robotics: uses various types of embedded computing (especially

vision and control) (e.g., autonomous vehicles)

Computer peripherals: disk drives, keyboards, laser printers, etc.

Wireless systems: wireless network-connected “sensor networks” and

“motes” to gather and report information

Embedded pcs: palmtop and small form factor pcs embedded into

equipment

Command and control: often huge military systems and “systems of systems”

(e.g., a fleet of warships with interconnected

computers)

5
Home appliances, intercom, telephones, security systems, garage door openers,
answering machines, fax machines, home computers, tvs, cable tv tuner, vcr, camcorder,
remote controls, video games, cellular phones, musical instruments, sewing machines,
lighting control, paging, camera, pinball machines, toys, exercise equipment

Office telephones, computers, security systems, fax machines, microwave, copier, laser
printer, color printer, paging

Auto trip computer, engine control, air bag, abs, instrumentation, security system,
transmission control, entertainment, climate control, cellular phone, keyless entry

Types of embedded systems

Based on functionality and performance embedded systems categorized as 4 types

1. Stand alone embedded systems

2. Real time embedded systems

3. Networked information appliances

4. Mobile devices

1. Stand alone embedded systems:-

As the name implies, stand alone systems work in stand alone mode. They take i/p,
process them and produce the desire o/p. The i/p can be an electrical signal from
transducer or temperature signal or commands from human being. The o/p can be
electrical signal to drive another system an led or lcd display

Ex digital camera, microwave oven, cd player, air conditioner etc

6
2. Real time embedded systems:-

in this type of an embedded system a specific work has to be complete in a particular


period of time.

Hard real time systems: - embedded real time used in missiles

Soft real time systems: - dvd players

3. Networked information appliances:-

embedded systems that are provided with n/w interfaces and accessed by n/w such as
local area n/w or internet are called network information appliances

Ex a web camera is connected to the internet. Camera can send pictures in real time to
any computers connected to the internet

4. Mobile devices:-

Actually it is a combination of both vlsi and embedded system

Mobile devices such as mobile phone, personal digital assistants, smart phones etc are
special category of embedded systems

7
CHAPTER 2

ARM PROCESSOR

2.1: ARM7 FAMILY:

The ARM7 family includes the ARM7TDMI, ARM7TDMI-S, ARM720T, and


ARM7EJ-S processors. The ARM7TDMI core is the industry’s most widely used 32-bit
embedded RISC microprocessor solution. Optimized for cost and power-sensitive
applications, the ARM7TDMI solution provides the low power consumption, small size,
and high performance needed in portable, embedded applications.

The ARM7EJ-S processor is a synthesizable core that provides all the benefits of
the ARM7TDMI – low power consumption, small size, and the thumb instruction set –
while also incorporating ARM’s latest DSP extensions and enabling acceleration of java-
based applications. Compatible with the ARM9™, ARM9E™, and ARM10™ families,
and Strong-Arm® architecture software written for the ARM7TDMI processor is 100%
binary-compatible with other members of the ARM7 family and forwards-compatible
with the ARM9, ARM9E, and ARM10 families, as well as products in Intel’s Strong
ARM and x scale architectures. This gives designers a choice of software-compatible
processors with strong price-performance points. Support for the ARM architecture today
includes:

• Operating systems such as Windows CE, Linux, palm OS and SYMBIAN OS.
• More than 40 real-time operating systems, including qnx, Wind River’s
vxworks and mentor graphics’ vrtx.
• Co simulation tools from leading eda vendors
• A variety of software development tools.

8
2.2: ARM7TDMI:

Figure 2.2: ARM7TDMI Core Diagram.

Figure 2.2 shows the ARM7TDMI Core Diagram. The ARM7TDMI core is
based on the Von- Neumann architecture with a 32-bit data bus that carries both
instructions and data. Load, store, and swap instructions can access data from memory.
Data can be 8-bit, 16-bit, and 32-bit.

2.2.1: Instruction pipeline:

The ARM7TDMI core uses a three-stage pipeline to increase the flow of


instructions to the processor. This allows multiple simultaneous operations to take place

9
and continuous operation of the processing and memory systems. The instructions are
executed in three stages:fetch,decode and execute.

2.2.2: Memory interface:

The ARM7TDMI memory interface is designed to allow optimum performance


potential and minimize memory usage. Speed critical control signals are pipelined to
allow system control functions to exploit the fast-burst access modes supported by many
memory technologies. The ARM7TDMI has four basic types of memory cycle: Internal,
Non sequential, Sequential, Coprocessor registers transfer. There is also the option to use
either a single bidirectional data bus or two separate unidirectional data input and output
buses.

2.2.3: Memory formats:

The ARM7TDMI can be configured to treat stored words in either big-endian or


little-endian format.

2.2.4: Performance, code density and operating states:

The ARM7TDMI core supports two operating states and instruction sets:

• ARM state for 32-bit, word-aligned instructions

• Thumb state for 16-bit, half word-aligned instructions.

The ARM instruction set allows a program to achieve maximum performance


with the minimum number of instructions. The simpler thumb instruction set offers much
increased code density reducing memory requirement. Code can switch between the
ARM and thumb instruction sets on any procedure call.

2.2.5: Operating modes:

The ARM7TDMI core has seven modes of operation:

• User mode is the usual program execution state


• allow very fast interrupt processing and to preserve values across

10
• interrupt calls
• System mode is a privileged user mode for the operating system
• Undefined mode is entered when an undefined instruction is
executed.

2.2.6: Coprocessors:

Up to 16 coprocessors can be connected to an ARM7TDMI system.

2.2.7: Debug features:

Internal state of the ARM core can be examined using a JTAG interface to
allow the insertion of instructions into core pipeline and avoid using external data bus.
ARM7TDMI core includes an internal functional unit known as the Embedded ICE logic.

2.3: ARM7TDMI PROCESSOR CORE:

The ARM7TDMI processor core implements the ARMv4T Instruction Set


Architecture (ISA).This is a superset of the ARMv4 ISA which adds support for the 16-
bit Thumb instruction set. Software using the Thumb instruction set is compatible with all
members of the ARM Thumb family, including ARM9, ARM9E, and ARM10 families.

2.3.1: Registers:

The ARM7TDMI core consists of a 32-bit data path and associated control
logic. This data path contains 31 general-purpose 32-bit registers, 7 dedicated 32-bit
registers coupled to a barrel-shifter, Arithmetic Logic Unit, and multiplier.

2.3.2: Modes and exceptions:


The ARM7TDMI supports seven modes of operation:
• User mode
• Fast Interrupt (FIQ)
• Interrupt (IRQ)
• Supervisor mode
• Abort mode

11
• Undefined mode and System mode.
All modes other than User are privileged modes. These are used to service
hardware interrupts, exceptions, and software interrupts. Each privileged mode has an
associated Saved Program Status Register (SPSR). This register is use to save the state of
the Current Program Status Register (CPSR) of the task immediately before the exception
occurs. System mode does not have any banked registers. It uses the User mode registers.
System mode runs tasks that require a privileged processor mode and allows them to
invoke all classes of exception.
2.3.3: Processor states:
The ARM7TDMI processor can be in one of two states:
 ARM state
In ARM state, 16 general registers and one or two status registers are accessible at
any one time. The ARM state register set contains 16 directly accessible registers:
R0 to R15. All of these except R15 are general-purpose, and may be used to hold
either data or address values. The registers available to the programmer in each
mode, in ARM state, are illustrated in Figure 3.3.3.1 Register Organization in
ARM state.
 THUMB state
The THUMB state register set is a subset of the ARM state set. The programmer
has direct access to eight general registers, R0-R7, as well as the Program Counter
(PC), a stack pointer register (SP), a link register (LR), and the CPSR. There are
banked Stack Pointers, Link Registers and Saved Process Status Registers
(SPSRs) for each privileged mode. The registers available to the programmer in each
mode, in THUMB state, are illustrated in Figure 2.3.3.2 Register organization in THUMB
state.

12
Figure 2.3.3. Register Organization in ARM state and in THUMB state.
2.3.4: Exceptions:
The ARM7TDMI supports seven types of exception:
• FIQ – fast interrupt
• IRQ – normal interrupt
• Data abort
• Pre fetch abort
• Undefined instruction
• Reset.
All exceptions have banked registers for R14 and R13. After an exception, R14
holds the return address for exception processing. This address is used both to return after
the exception is processed and to address the instruction that caused the exception. R13 is
banked across exception modes to provide each exception handler with a private stack

13
pointer. The fast interrupt mode also banks registers 8 to 12 so that interrupt processing
can begin without the need to save or restore these registers.
2.3.5: Status registers:
All other processor states are held in status registers.
The current operating processor status in the CPSR. The CPSR holds:
• Four ALU flags (Negative, Zero, Carry, and Overflow)
• An interrupt disable bit for each of the FIQ and IRQ interrupts
• A bit to indicate ARM or Thumb execution state
• Five bits to encode the current processor mode.
2.3.6: Conditional execution:
All ARM instructions are conditionally executed and can optionally update the
four condition code flags (Negative, Zero, Carry, and Overflow) according to their result.
Fifteen conditions are implemented.
2.3.7: Classes of instructions:
The ARM and Thumb instruction sets can be divided into four broad classes of
instruction:
• Data processing instructions
• Load and store instructions
• Branch instructions
2.3.8: Data processing instructions:
The data processing instructions operate on data held in general-purpose registers
of the two source operands, one is always a register.
The other has two basic forms:
• An immediate value
• A register value optionally shifted.

If the operand is a shifted register the shift amount can have an immediate value
or the value of another register. Four types of shift can be specified. Most data processing
instructions can perform a shift followed by a logical or arithmetic operation.

14
Multiply instructions come in two classes:
• Normal, 32-bit result
• Long, 64-bit result variants.
Both types of multiply instruction can optionally perform an accumulate operation.
2.3.9: Load and store instructions:
Single or multiple registers can be loaded and stored at one time. Load and store
single register instructions can transfer a 32-bit word, a 16-bit half word, or an 8-bit byte
between memory and a register. Byte and half word loads can be automatically zero
extended or sign extended as they are loaded. Load and store instructions have three
primary addressing modes:
• offset
• pre-indexed
• post-indexed.
The address is formed by adding or subtracting an immediate or register- based
offset to or from a base register. Register-based offsets can also be scaled with shift
operations. Pre-indexed and post-indexed addressing modes update the base register with
the result of the offset calculation. As the PC is a general-purpose register, a 32-bit value
can be loaded directly into the PC to perform a jump to any address in the 4GB memory
space. Load and store multiple instructions perform a block transfer of any number of the
general purpose registers to or from memory. Four addressing modes are provided:
• Pre-increment addressing
• Post-increment addressing
• Pre-decrement addressing
• Post-decrement addressing

15
Figure 2.3.9. Load and store instructions.
2.3.10: Branch instructions:
As well as allowing any data processing or load instruction to change control
flow (by modifying the PC) a standard branch instruction is provided with 24-bit signed
offset, allowing forward and backward branches of up to 32MB. Branch with Link (BL)
allows efficient subroutine calls, and preserves the address of the instruction after the
branch in R14 (the Link Register or LR).
2.4: SYSTEM ISSUES AND THIRD PARTY SUPPORT:
This section contains:
• JTAG debug
• AMBA bus architecture
• AMBA Design Kit
• Current support
2.4.1: JTAG debug:
The internal state of the ARM7TDMI is examined through a JTAG-style serial
interface. This allows instructions to be serially inserted into the pipeline of the core
without using the external data bus. For example, when in debug state, a Store-Multiple
(STM) instruction can be inserted into the pipeline.
2.4.2: AMBA bus architecture:
The ARM7 Thumb family processors are designed for use with the Advanced
Microcontroller Bus Architecture (AMBA) multi-master on-chip bus architecture.
AMBA is an open standard that describes a strategy for the interconnection and
management of functional blocks that makes up a System-on-Chip (SoC). The AMBA
specification defines three buses:
• Advanced System Bus (ASB)
• Advanced High-performance Bus (AHB)
• Advanced Peripheral Bus (APB).
2.5: ADVANTAGES:
 Simple hardware
 Small die size
 Low power consumption

16
 Simple decoding
 Higher performance
 Easy to implement an effective pipelined structure.
2.6: DISADVANTAGES:
 Performance depends on compiler
 Poor code density
 RISC has a fixed size of instruction format
2.7: APPLICATIONS:
Using the ARMv7 architecture, ARM can strengthen its position as a low-
power/performance leader while conquering new markets to carry its cores up in high
performance and down in the low-cost high-volume domain of the microcontroller ARM
designs the technology that lies at the heart of advanced digital products, from wireless,
networking and consumer entertainment solutions to imaging, automotive, security and
storage devices.
ARM's comprehensive product offering includes 16/32-bit RISC
microprocessors, data engines, 3D processors, digital libraries, embedded memories,
peripherals, software and development tools, as well as analog functions and high-speed
connectivity products.

17
CHAPTER3
LPC2148 MICRO CONTROLLER

3.1: LPC2148 MICROCONTROLLER:


LPC2148 microcontroller board based on a 16-bit/32-bit ARM7TDMI-S CPU
with real-time emulation and embedded trace support, that combine microcontrollers with
embedded high-speed flash memory ranging from 32 KB to 512 KB. A 128-bit wide
memory interface and 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. The meaning
of LPC is Low Power Low Cost microcontroller. This is 32 bit microcontroller
manufactured by Philips semiconductors (NXP). Due to their tiny size and low power
consumption, LPC2148 is ideal for applications where miniaturization is a key
requirement, such as access control and point-of-sale.
3.2: FEATURES OF LPC2148 MICROCONTROLLER:
 16-bit/32-bit ARM7TDMI-S microcontroller in a tiny LQFP64 package.
 8 KB to 40 KB of on-chip static RAM and 32 KB to 512 KB of on-chip flash
memory; 128-bit wide interface/accelerator enables high-speed 60 MHz
operation.
 USB 2.0 Full-speed compliant device controller with 2 KB of endpoint RAM. In
addition, the LPC2148 provides 8 KB of on-chip RAM accessible to USB by
DMA.
 One or two (LPC2141/42 Vs, LPC2144/46/48) 10-bit ADCs provide a total of
6/14 analog inputs, with conversion times as low as 2.44 ms per channel.
 Single 10-bit DAC provides variable analog output (LPC2148 only)
 Two 32-bit timers/external event counters (with four capture and four compare
channels each), PWM unit (six outputs) and watchdog.
 Low power Real-Time Clock (RTC) with independent power and 32 kHz
clock input

18
3.3: LPC2148 MICROCONTROLLER ARCHITECTURE:

Fig 3.3: LPC2148 Microcontroller Architecture.

19
3.4: PIN DIAGRAM:

Fig 3.4: LPC2148 Microcontroller Pin Diagram.

3.5: ARCHITECTURAL OVERVIEW:


Figure 4.3 shows the LPC2148 Microcontroller Architecture. The ARM7TDMI-
S is a general purpose 32-bit microprocessor, which offers high performance and very
low power consumption. The ARM architecture is based on Reduced Instruction Set
Computer (RISC) principles, and the instruction set and related decode mechanism are
much simpler than those of micro programmed Complex Instruction Set Computers
(CISC). This simplicity results in a high instruction throughput and impressive real-time
interrupt response from a small and cost-effective processor core.

20
Pipeline techniques are employed so that all parts of the processing and
memory systems can operate continuously. The ARM7TDMI-S processor also employs a
unique architectural strategy known as Thumb, which makes it ideally suited to high-
volume applications with memory restrictions, or applications where code density is an
issue.
3.5.1: On-chip flash program memory:
The LPC2141/42/44/46/48 incorporates a 32 KB, 64 KB, 128 KB, 256 KB and
512 KB flash memory system respectively. This memory may be used for both code and
data storage. Programming of the flash memory may be accomplished in several ways. It
may be programmed In System via the serial port Due to the architectural solution chosen
for an on-chip boot loader, flash memory available for user’s code on
LPC2141/42/44/46/48 is 32 KB, 64 KB, 128 KB, 256 KB and 500 KB respectively.
3.5.2: On-chip static RAM:
On-chip static RAM may be used for code and/or data storage. The SRAM may
be accessed as 8-bit, 16-bit, and 32-bit. The LPC2141, LPC2142/44 and LPC2146/48
provide 8 KB, 16 KB and 32 KB of static RAM respectively. In case of LPC2146/48
only, an 8 KB SRAM block intended to be utilized mainly by the USB can also be used
as a general purpose RAM for data storage and code storage and execution.
3.5.3: Memory map:
The LPC2141/42/44/46/48 memory map incorporates several distinct regions,
as shown in Figure 4.5.3 Memory map. In addition, the CPU interrupt vectors may be
remapped to allow them to reside in either flash memory (the default) or on-chip static
RAM.

21
Figure 3.5.3: Memory map.

3.5.4: Interrupt controller:


The Vectored Interrupt Controller (VIC) accepts all of the interrupt request
inputs and categorizes them as Fast Interrupt Request (FIQ), vectored Interrupt Request
(IRQ), and non-vectored IRQ as defined by programmable settings. If more than one
request is assigned to the FIQ class, the FIQ service routine will read a word from the. If
any of the vectored IRQs are pending, the VIC provides the address of the highest-
priority requesting IRQs service routine, otherwise it provides the address of a default
routine that is shared by all the non-vectored IRQs. The default routine can read another
VIC register to see what IRQs are active.

22
3.5.5: Pin connect block:
The pin connect block allows selected pins of the microcontroller to have more
than one function. Configuration registers control the multiplexers to allow connection
between the pin and the on chip peripherals. Peripherals should be connected to the
appropriate pins prior to being activated, and prior to any related interrupt(s) being
enabled. Activity of any enabled peripheral function that is not mapped to a related pin
should be considered undefined.
3.5.6: Fast general purpose parallel I/O (GPIO):
Device pins that are not connected to a specific peripheral function are
controlled by the GPIO registers. Pins may be dynamically configured as inputs or
outputs. Separate registers allow setting or clearing any number of outputs
simultaneously. The value of the output register may be read back, as well as the current
state of the port pins.LPC2141/42/44/46/48 introduces accelerated GPIO functions over
prior LPC2000 devices:
Features:
• Bit-level set and clear registers allow a single instruction set or clear of any
number of bits in one port.
• Direction control of individual bits.
• Separate control of output set and clear.
3.5.7: 10-bit ADC:
The LPC2141/42 contains one and the LPC2144/46/48 contains two analog to
digital converters. These converters are single 10-bit successive approximation analog to
digital converters.
Features:
• 10 bit successive approximation analog to digital converter.
• Measurement range of 0 V to VREF (2.0 V ≤ VREF ≤ VDDA).
• Every analog input has a dedicated result register to reduce interrupt overhead.
• Burst conversion mode for single or multiple inputs.

23
3.5.8: 10-bit DAC:
The DAC enables the LPC2141/42/44/46/48 to generate a variable analog output.
The maximum DAC output voltage is the VREF voltage.
Features:
• 10-bit DAC.
• Buffered output.
• Power-down mode available.
3.5.9: USB 2.0 device controller:
The USB is a 4-wire serial bus that supports communication between a host and
a number (127 max) of peripherals. The host controller allocates the USB bandwidth to
attached devices through a token based protocol. The bus supports hot plugging,
unplugging, and dynamic configuration of the devices. All transactions are initiated by
the host controller
Features:
• Fully compliant with USB 2.0 Full-speed specification.
• Supports 32 physical (16 logical) endpoints.
• Scalable realization of endpoints at run time.
• RAM message buffer size based on endpoint realization and maximum packet
size.
3.5.10: UARTs:
The LPC2141/42/44/46/48 each contains two UARTs. Compared to previous
LPC2000 microcontrollers, UARTs in LPC2141/42/44/46/48 introduce a fractional baud
rate generator for both UARTs, enabling these microcontrollers to achieve standard baud
rate such as 115200 with any crystal frequency above 2 MHz In addition, auto-CTS/RTS
flow-control functions are fully implemented in hardware (UART1 in LPC2144/46/48
only).
Features:
• 16 byte Receive and Transmit FIFO.
• Register locations conform to ‘550 industry standard.
• Receiver FIFO triggers points at 1, 4, 8, and 14 bytes
• Transmission FIFO control enables implementation of software (XON/XOFF)

24
Flow control on both UARTs.
3.5.11: I2C-bus serial I/O controller:
The LPC2141/42/44/46/48 each contains two I2C-bus controllers. The I2C-bus
is bidirectional, for inter-IC control using only two wires: a serial clock line (SCL), and a
serial data line (SDA). Each device is recognized by a unique address and can operate as
either a receiver-only device (e.g., an LCD driver or a transmitter with the capability to
both receive and send information (such as memory)).
Features:
• Compliant with standard I2C-bus interface.
• Bidirectional data transfer between masters and slaves.
• Multi-master bus (no central master).
3.5.12: SPI serial I/O controller:
The LPC2141/42/44/46/48 each contains one SPI controller. The SPI is a full
duplex serial interface, designed to handle multiple masters and slaves connected to a
given bus. 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.
Features:
• Compliant with Serial Peripheral Interface (SPI) specification.
• Synchronous, Serial, Full Duplex, Communication.
• Maximum data bit rate of one eighth of the input clock rate.
3.5.13: SSP serial I/O controller:
The LPC2141/42/44/46/48 each contains one SSP. The SSP controller is
capable of operation on a SPI, 4-wire SSI, or Micro wire bus. It can interact with multiple
masters and slaves on the bus. However, only a single master and a single slave can
communicate on the bus during a given data transfer. The SSP supports full duplex
transfers, with data frames of 4 bits to 16 bits of data flowing from the master to the slave
and from the slave to the master.
Features:
• Synchronous serial communication.
• Master or slave operation.

25
3.5.14: General purpose timers/external event counters:
The Timer/Counter is designed to count cycles of the peripheral clock (PCLK)
or an externally supplied clock and optionally generate interrupts or perform other actions
at specified timer values, based on four match registers
3.5.15: Watchdog timer:
The purpose of the watchdog is to reset the microcontroller within a reasonable
amount of time if it enters an erroneous state. When enabled, the watchdog will generate
a system reset if the user program fails to ‘feed’ (or reload) the watchdog within a
predetermined amount of time.
Features:
• Internally resets chip if not periodically reloaded.
• Debug mode.
• Programmable 32-bit timer with internal pre-scalar.
3.5.16: Real-time clock:
The RTC is designed to provide a set of counters to measure time when normal or
idle operating mode is selected. The RTC has been designed to use little power, making it
suitable for battery powered systems where the CPU is not running continuously.
Features:
• Measures the passage of time to maintain a calendar and clock.
• Provides Seconds, Minutes, Hours, Day of Month, Month, Year, Day of Week,
and Day of Year.

26
CHAPTER 4

Global System for Mobile Communication (GSM)

4.1.Definition:

Global system for mobile communication (GSM) is a globally accepted standard for
digital cellular communication. GSM is the name of a standardization group established
in 1982 to create a common European mobile telephone standard that would formulate
specifications for a pan-European mobile cellular radio system operating at 900 MHz.

A GSM modem is a wireless modem that works with a GSM wireless network. A
wireless modem behaves like a dial-up modem. The main difference between them is that
a dial-up modem sends and receives data through a fixed telephone line while a wireless
modem sends and receives data through radio waves.

A GSM modem can be an external device or a PC Card / PCMCIA Card. Typically, an


external GSM modem is connected to a computer through a serial cable or a USB cable.
A GSM modem in the form of a PC Card / PCMCIA Card is designed for use with a
laptop computer. It should be inserted into one of the PC Card / PCMCIA Card slots of a
laptop computer.
Like a GSM mobile phone, a GSM modem requires a SIM card from a wireless carrier in
order to operate.

As mentioned in earlier sections of this SMS tutorial, computers use AT commands to


control modems. Both GSM modems and dial-up modems support a common set of
standard AT commands. You can use a GSM modem just like a dial-up modem.
In addition to the standard AT commands, GSM modems support an extended set of AT
commands. These extended AT commands are defined in the GSM standards. With the
extended AT commands, you can do things like:

27
• Reading, writing and deleting SMS messages.
• Sending SMS messages.
• Monitoring the signal strength.
• Monitoring the charging status and charge level of the battery.
• Reading, writing and searching phone book entries.

The number of SMS messages that can be processed by a GSM modem per minute is
very low -- only about six to ten SMS messages per minute.

4.2.GSM AT COMMANDS

 AT
 AT&D0
 AT+IFC=00
 ATCMGF=1
 AT+CNMI=22000

4.3.AT commands features

1. Setting up your GSM modem


Most GSM modems comes with a simple manual and necessary drivers. To setup your
T-Modem USB, download the USB GSM Modem Quick Start ( Windows ) guide (460kB
PDF). You would be able to send SMS from the Windows application and also setup
GPRS connectivity. The GSM modem will map itself as a COM serial port on your
computer.

Windows based control panel to setup GSM modem, GPRS and send SMS

28
2. Using the HyperTerminal
Hint :: By developing your AT commands using HyperTerminal, it will be easier for you
to develop your actual program codes in VB, C, Java or other platforms.
Go to START\Programs\Accessories\Communications\HyperTerminal (Win 2000) to
create a new connection, eg. "My USB GSM Modem". Suggested settings ::
- COM Port :: As indicated in the T-Modem Control Tool
- Bits per second :: 230400 ( or slower ) -Data Bits : 8 - Parity : None- Stop Bits Flow
Control: Hardware You are now ready to start working with AT commands. Type in
"AT" and you should get a "OK", else you have not setup your HyperTerminal correctly.
Check your port settings and also make sure your GSM modem is properly connected and
the drivers installed.

3. Initial setup AT commands


We are ready now to start working with AT commands to setup and check the status of
the GSM modem.
AT Returns a "OK" to confirm that modem is working
AT+CPIN="xxxx" To enter the PIN for your SIM ( if enabled )
AT+CREG? A "0,1" reply confirms your modem is connected to GSM network
AT+CSQ Indicates the signal strength, 31.99 is maximum.
4. Sending SMS using AT commands

We suggest try sending a few SMS using the Control Tool above to make sure your
GSM modem can send SMS before proceeding. Let's look at the AT commands
involved ..
AT+CMGF=1 To format SMS as a TEXT message
AT+CSCA="+xxxxx" Set your SMS center's number. Check with your provider.
To send a SMS, the AT command to use is AT+CMGS..
AT+CMGS="+yyyyy"<Enter>> Your SMS text message here <Ctrl-Z>

29
The "+yyyyy" is your recipient’s mobile number. Next, we will look at receiving SMS
via AT commands.
5. Receiving SMS using AT commands
The GSM modem can be configured to response in different ways when it receives a
SMS.
a) Immediate - when a SMS is received, the SMS's details are immediately sent to
the host computer (DTE) via the +CMT command
AT+CMGF=1 To format SMS as a TEXT message
AT+CNMI=1,2,0,0,0 Set how the modem will response when a SMS received

When a new SMS is received by the GSM modem, the DTE will receive the following
+CMT : "+61xxxxxxxx" , , "04/08/30,23:20:00+40"
This the text SMS message sent to the modem
Your computer (DTE) will have to continuously monitor the COM serial port, read and
parse the message.
b) Notification - when a SMS is received, the host computer (DTE) will be notified of the
new message. The computer will then have to read the message from the indicated
memory location and clear the memory location.
AT+CMGF=1 To format SMS as a TEXT message
AT+CNMI=1,1,0,0,0 Set how the modem will response when a SMS is received
When a new SMS is received by the GSM modem, the DTE will receive the following ..
+CMTI: "SM",3 Notification sent to the computer. Location 3 in SIM memory
AT+CMGR=3 <Enter> AT command to send read the received SMS from modem

The modem will then send to the computer details of the received SMS from the
specified memory location ( eg. 3 ) +CMGR: "REC
READ","+61xxxxxx",,"04/08/28,22:26:29+40"
This is the new SMS received by the GSM modem
After reading and parsing the new SMS message, the computer (DTE) should send a AT
command to clear the memory location in the GSM modem..

30
AT+CMGD=3 <Enter> To clear the SMS receive memory location in the GSM modem
If the computer tries to read a empty/cleared memory location, a +CMS ERROR: 321
will be sent to the computer.
GSM INTERFACE WITH MICROCONTROLLER

In this project GSM Modem is interfaced with the microcontroller through rs232
interface. Since the voltage levels of the microcontroller are different with that of the
GSM modem we use a voltage converter or the line driver such as MAX232 to make
them rs232 compatible.
GSM and GPS both communicate through UART. Since microcontroller has only one
inbuilt UART a multiplexer is used to interface GSM and GPS to the microcontroller.

GPS
Introduction
Global Positioning System (GPS) technology is changing the way we work and play. You
can use GPS technology when you are driving, flying, fishing, sailing, hiking, running,
biking, working, or exploring. With a GPS receiver, you have an amazing amount of
information at your fingertips. Here are just a few examples of how you can use GPS
technology.
• Know precisely how far you have run and at what pace while tracking your path
so you can find your way home
• Pinpoint the perfect fishing spot on the water and easily relocate it
• Get the closest location of your favorite restaurant when you are out-of-town
• Find the nearest airport or identify the type of airspace in which you are flying

What is GPS ?
The Global Positioning System (GPS) is a satellite-based navigation system that sends
and receives radio signals. A GPS receiver acquires these signals and provides you with

31
information. Using GPS technology, you can determine location, velocity, and time, 24
hours a day, in any weather conditions anywhere in the world—for free GPS, formally
known as the NAVSTAR (Navigation Satellite Timing and Ranging) Global Positioning
System, originally was developed for the military. Because of its popular navigation
capabilities and because you can access GPS technology using small inexpensive
equipment, the government made the system available for civilian use. The USA owns
GPS technology and the Department of Defense maintains it.
GPS technology requires the following three segments
• Space segment
• Control segment
• User segment

Space Segment
At least 24 GPS satellites orbit the earth twice a day in a specific pattern. They travel at
approximately 7,000 miles per hour about 12,000 miles above the earth’s surface. These
satellites are spaced so that a GPS receiver anywhere in the world can receive signals
from at least four of them.

Each GPS satellite constantly sends coded radio signals to the earth. These GPS satellite
signals contain the following information
• The particular satellite that is sending the information
• Where that satellite should be at any given time (the precise location of the
satellite is called ephemeris data)
• Whether or not the satellite is working properly
• The date and time that the satellite sent the signal

The signals can pass through clouds, glass, and plastic. Most solid objects such as
buildings attenuate (decrease the power of) the signals. These signals cannot pass through
objects that contain a lot of metal or objects that contain water (such as underwater
locations)

32
The GPS satellites are powered by solar energy. If solar energy is unavailable, for
example, when the satellite is in the earth’s shadow, the satellites use backup batteries to
continue running. Each GPS satellite is built to last about 10 years. The Department of
Defense monitors and replaces the satellites to ensure that GPS technology continues to
run smoothly for years to come
Control Segment
The control segment is responsible for constantly monitoring satellite health, signal
integrity, and orbital configuration from the ground. The control segment includes the
following sections.
• Master control station
• Monitor stations
• Ground antennas

Monitor Stations
At least six unmanned monitor stations are located around the world. Each station
constantly monitors and receives information from the GPS satellites and then sends the
orbital and clock information to the master control station (MCS).

Master Control Station (MCS)

The MCS is located near Colorado Springs in Colorado. The MCS constantly receives
GPS satellite orbital and clock information from the monitor stations. The controllers in
the MCS make precise corrections to the data as necessary, and send the information
(known as ephemeris data) to the GPS satellites using the ground antennas
Ground Antennas
Ground antennas receive the corrected orbital and clock information from the MCS, and
then send the corrected information to the appropriate satellites.
User Segment
The GPS user segment consists of your GPS receiver. Your receiver collects and
processes signals from the GPS satellites that are in view and then uses that information

33
to determine and display your location, speed, time, and so forth. Your GPS receiver does
not transmit any information back to the satellites.

How Does GPS Technology Work?


The following points provide a summary of the technology at work:
• The control segment constantly monitors the GPS constellation and uploads
information to satellites to provide maximum user accuracy.
• Your GPS receiver collects information from the GPS satellites that are in view.
• Your GPS receiver accounts for errors. For more information, refer to the Sources
• Your GPS receiver determines your current location, velocity, and time.
• Your GPS receiver can calculate other information, such as bearing, track, trip
distance, distance to destination, sunrise and sunset time, and so forth
• Your GPS receiver displays the applicable information on the screen

APPLICATION OF THE GPS TRACKING SYSTEM


• Fleet control. For example, a delivery or taxi company may put such a tracker in
every of its vehicles, thus allowing the staff to know if a vehicle is on time or late, or is
doing its assigned route. The same applies for armored trucks transporting valuable
goods, as it allows to pinpoint the exact site of a possible robbery.
• Stolen vehicle searching . Owners of expensive cars can put a tracker in it, and
"activate" them in case of theft. "Activate" means that a command is issued to the tracker,
via SMS or otherwise, and it will start acting as a fleet control device, allowing the user
to know where the thieves are.
• Animal control. When put on a wildlife animal (e.g. in a collar), it allows
scientists to study its activities and migration patterns. Vaginal implant transmitters are
used to mark the location where pregnant females give birth. Animal tracking collars may
also be put on domestic animals, to locate them in case they get lost.
• Race control . In some sports, such as gliding, participants are required to have a
tracker with them. This allows, among other applications, for race officials to know if the
participants are cheating, taking unexpected shortcuts or how far apart they are. This use

34
has been featured in the movie "Rat Race", where some millionaires see the position of
the racers in a wall map.
• Espionage/surveillance. When put on a person, or on his personal vehicle, it
allows the person monitoring the tracking to know his/her habits. This application is used
by private investigators, and also by some parents to track their children.
• Internet Fun . Some Web 2.0 pioneers have created their own personal web pages
that show their position constantly, and in real-time, on a map within their website. These
usually use data push from a GPS enabled cell phone.

GPS INTERFACE WITH MICROCONTROLLER

In this project GPS Modem is interfaced with the microcontroller through rs232 interface.
Since the voltage levels of the microcontroller are different with that of the GPS modem
we use a voltage converter or the line driver such as MAX232 to make them rs232
compatible.

CHAPTER 5
SERIAL COMMUNICATION

5.1: INTRODUCTION:

Computers transfer data in two ways: parallel and serial. In parallel data
transfers, often 8 or more lines (wire conductors) are used to transfer data to a device that
is only a few feet away. Examples of parallel transfers are printers and hard disk; each
uses cables with many wire strips. Although in such cases a lot of data can be transferred
in a short amount of time by using many wires in parallel, the distance cannot be great.
To transfer to a device located at many meters away, the serial method is used. In serial

35
communication, the data is sent one bit at a time, in contrast to parallel communication,
in which the data is sent a byte or more at a time.

5.2: SERIAL DATA COMMUICATION:

For serial data communication to work the byte of data must be converted to
serial bits using a parallel-in-serial-out shift register; then it can be transmitted over a
single data line. This also means that at the receiving end there must be a serial-in-
parallel-out shift register to receive the serial data and pack them into a byte. Of course, if
data is to be transferred on the telephone line, it must be converted from 0s and 1s to
audio tones, which are sinusoidal-shaped signals. This conversion is performed by a
peripheral device called a modem, which stands for “modulator/demodulator”.

5.3: RS232 STANDARDS:

To allow compatibility among data communication equipment made by various


manufacturers, an interfacing standard called RS232 was set by the Electronics Industries
Association (EIA) in 1960. Today, RS232 is the most widely used serial I/O interfacing
standard. However, since the standard was set long before the advent of TTL logic
family, its input and output voltage levels are not TTL compatible. In RS232, a 1 is
represented by -3 to -25V, while a 0 bit is +3 to +25V, making -3 to +3 undefined. For
this reason, to connect any RS232 to a microcontroller system we must use voltage
converters such as MAX232 to convert the TTL logic levels to the RS232 voltage levels,
and vice versa. MAX232 IC chips are commonly referred to as line drivers.

5.3.1: DB-25 Connector:

The following table provides the pins and their labels for the RS232 cable, commonly
referred to as the DB-25 connector. In labeling, DB-25P refers to the plug connector (male) and
DB-25S is for the socket connector (female).

PIN DESCRIPTION
1 Protective ground
2 Transmitted data (TxD)

36
3 Received data (RxD)
4 Request to send (RTS)
5 Clear to send (CTS)
6 Data set ready (DSR)
7 Signal ground (GND)
8 Data carrier detect (DCD)
9/10 Reserved for data testing
11 Unassigned
12 Secondary data carrier detect
13 Secondary clear to send
14 Secondary transmitted data
15 Transmit signal element timing
16 Secondary received data
17 Receive signal element timing
18 Unassigned
19 Secondary request to send
20 Data terminal ready (DTR)
21 Signal quality detector
22 Ring indicator
23 Data signal rate select
24 Transmit signal element timing
25 Unassigned
Table 5.3.1: Pin Description of DB-25 Connector.

5.3.2: DB-9 Connector:

Since not all the pins are used in PC cables, IBM introduced the DB-9 version
of the serial I/O standard, which uses 9 pins only, as shown in the following table:

37
PIN DESCRIPTION
1 Data carrier detect (DCD)
2 Received data (RxD)
3 Transmitted data (TxD) Table
7.3.2: Pin 4 Data terminal ready (DTR)
5 Signal ground (GND)
6 Data set ready (DSR)
7 Request to send (RTS)
8 Clear to send (CTS)
9 Ring indicator (RI)
Description of DB-9 Connector.

The D-subminiature or D-sub is a common type of electrical connector used


particularly in computers. At the time of introduction they were some of the smaller
connectors used on computer systems. A D-sub contains two or more parallel rows of
pins or sockets usually surrounded by a D-shaped metal shield that provides mechanical
support, some screening against electromagnetic interference, and ensures correct
orientation.

38
Fig 5.3.2: D-Subminiature.

5.4: MAX232:

The MAX232 is an integrated circuit that converts signals from an RS-


232 serial port to signals suitable for use in TTL compatible digital logic circuits. The
MAX232 is a dual driver/receiver and typically converts the RX, TX, CTS and RTS
signals.

The drivers provide RS-232 voltage level outputs (approx. ± 7.5 V) from
a single + 5 V supply via on-chip charge pumps and external capacitors. This makes it
useful for implementing RS-232 in devices that otherwise do not need any voltages
outside the 0 V to + 5 V range, as power supply design does not need to be made more
complicated just for driving the RS-232 in this case.

5.4.1: Pin Diagram of MAX232:

Fig 5.4.1: Pin Diagram of MAX232.

5.4.2:Voltage Levels:

39
It is helpful to understand what occurs to the voltage levels. When a
MAX232 IC receives a TTL level to convert, it changes a TTL Logic 0 to between +3
and +15V, and changes TTL Logic 1 to between -3 to -15V, and vice versa for converting
from RS232 to TTL. This can be confusing when you realize that the RS232 Data
Transmission voltages at a certain logic state are opposite from the RS232 Control Line
voltages at the same logic state. To clarify the matter, see the table below.

RS232 TTL Voltage


RS232 Line Type & Logic Level
Voltage to/from MAX232
Data Transmission (Rx/Tx) Logic 0 +3V to +15V 0V
Data Transmission (Rx/Tx) Logic 1 -3V to -15V 5V
Control Signals (RTS/CTS/DTR/DSR) Logic
-3V to -15V 5V
0

Control Signals (RTS/CTS/DTR/DSR) Logic


+3V to +15V 0V
1

Table 5.4.2: TTL Logic Levels.

5.5: INTERFACING:

5.5.1: RS232 Interfaced to MAX 232:

J2
C1
U3 1u f
16

9 5
8 4 13 12 P 3. 0 R XD
7 3 T1O U T R 1IN R 1OU T
VCC

8 9
6 2 R 2IN R 2OU T
1 10 14 T1O U T
TXD P 3. 1 11 T2 IN T1 O U T 7
C4 T1 IN T2 O U T
5V 1
3 C 1+
C0.51u f 4 C 1-
5 C 2+
C6 C 2-
0. 1u f 2
0. 1u f V+
GND

6
V-
C7
MA X32 32
15

0. 1uf

40
Fig 5.5.1: RS232 Interfaced to MAX232.

RS232 is 9 pin db connector, only three pins of this are used ie 2,3,5 the
transmit pin of RS232 is connected to Rx pin of MAX232.

41
CHAPTER 6

LIQUID CRYSTAL DISPLAY

6.1: INTRODUCTION:

Liquid Crystal Display also called as LCD is very helpful in providing user
interface as well as for debugging purpose. The most commonly used Character based
LCDs are based on Hitachi's HD44780 controller or other which are compatible with
HD44580. The most commonly used LCDs found in the market today are 1 Line, 2 Line
or 4 Line LCDs which have only 1 controller and support at most of 80 characters,
whereas LCDs supporting more than 80 characters make use of 2 HD44780 controllers.

6.2: PIN DESCRIPTION OF THE LCD:

Fig 6.1 Pin Diagram

42
43
6.3: INTERFACING LCD TO MICROCONTROLLER:

Microcontroller

E communication
R/WW s bus
LPC RS

2148 DB7–DB0

8
LCD
control

8051
Fig 6.3(a): Interfacing LCD to microcontroller

A typical LCD write operation takes place as shown in the following timing waveform:

Fig 6.3(b): LCD Data waveform

The interface is either a 4-bit or 8-bit parallel bus that allows fast reading/writing of data to
and from the LCD. This waveform will write an ASCII Byte out to the LCD's screen. The

44
ASCII code to be displayed is eight bits long and is sent to the LCD either four or eight bits
at a time. If 4-bit mode is used, two nibbles of data (First high four bits and then low four bits
with an E Clock pulse with each nibble) are sent to complete a full eight-bit transfer. The E
Clock is used to initiate the data transfer within the LCD.8-bit mode is best used when speed
is required in an application and at least ten I/O pins are available. 4-bit mode requires a
minimum of six bits. In 4-bit mode, only the top 4 data bits (DB4-7) are used. The R/S pin is
used to select whether data or an instruction is being transferred between the microcontroller
and the LCD. If the pin is high, then the byte at the current LCD Cursor Position can be read
or written. If the pin is low, either an instruction is being sent to the LCD or the execution
status of the last instruction is read back (whether or not it has completed).

Light Emitting Diodes:

Light Emitting Diodes or LEDs, are among the most widely used of all the types
of diodes available. They are the most visible type of diode that emits a fairly narrow
bandwidth of either visible coloured light, invisible infra-red or laser type light when a
forward current is passed through them. A "Light Emitting Diode" or LED as it is more
commonly called, is basically just a specialized type of PN-junction diode, made from a
very thin layer of fairly heavily doped semiconductor material. When the diode is
Forward Biased, electrons from the semiconductors conduction band combine with holes
from the valence band, releasing sufficient energy to produce photons of light. Because
of this thin layer a reasonable number of these photons can leave the junction and radiate
away producing a coloured light output.

Unlike normal diodes which are made for detection or power rectification, and
which are generally made from either Germanium or Silicon semiconductor material,
Light Emitting Diodes are made from compound type semiconductor materials such as
Gallium Arsenide (GaAs), Gallium Phosphide (GaP), Gallium Arsenide Phosphide
(GaAsP), Silicon Carbide (SiC) or Gallium Indium Nitride (GaInN). The exact choice of
the semiconductor material used will determine the overall wavelength of the photon

45
light emissions and therefore the resulting colour of the light emitted, as in the case of the
visible light coloured LEDs, (RED, AMBER, GREEN etc).

Typical LED Characteristics

Semiconductor
Wavelength Colour VF @ 20mA
Material

GaAs 850-940nm Infra-Red 1.2v

GaAsP 630-660nm Red 1.8v

GaAsP 605-620nm Amber 2.0v

GaAsP:N 585-595nm Yellow 2.2v

GaP
550-570nm Green 3.5v

SiC 430-505nm Blue 3.6v

GaInN 450nm White 4.0v

From the table above we can see that the main P-type dopant used in the
manufacture of Light Emitting Diodes is Gallium (Ga, atomic number 31) and the main
N-type dopant used is Arsenic (As, atomic number 31) giving the resulting Gallium
Arsenide (GaAs) crystal structure, which has the characteristics of radiating significant
amounts of infrared radiation from its junction when a forward current is flowing through
it. By also adding Phosphorus (P, atomic number 15), as a third dopant the overall
wavelength of the emitted radiation is reduced to give visible red light to the human eye.
Further refinements in the doping process of the PN-junction have resulted in a range of
colours available from red, orange and amber through to yellow, and the recently

46
developed blue LED which is achieved by injecting nitrogen atoms into the crystal
structure during the doping process.

Light Emitting Diodes I-V Characteristics:

Before a light emitting diode can "emit" any form of light it needs a current to
flow through it, as it is a current dependant device. As the LED is to be connected in a
forward bias condition across a power supply it should be Current Limited using a series
resistor to protect it from excessive current flow. From the table above we can see that
each LED has its own forward voltage drop across the PN-junction and this parameter
which is determined by the semiconductor material used is the forward voltage drop for a
given amount of forward conduction current, typically for a forward current of 20mA. In
most cases LEDs are operated from a low voltage DC supply, with a series resistor to
limit the forward current to a suitable value from say 5mA for a simple LED indicator to
30mA or more where a high brightness light output is needed.

LED Series Resistance:

47
The series resistor value RS is calculated by simply using Ohm´s Law, knowing
the required forward current IF, the supply voltage VS and the expected forward voltage
drop of the LED, VF at this current level as shown below:

LED Typical Applications:

The following figure shows how to interface the LED to microcontroller. As you can see
the Anode is connected through a resistor to Vcc and the Cathode is connected to the
Microcontroller pin. So when the Port Pin is HIGH the LED is OFF and when the Port
Pin is LOW the LED is turned ON.

48
CHAPTER 7

POWER SUPPLY

7.1: TYPES OF POWER SUPPLY:

There are many types of power supply. Most are designed to convert high
voltage AC mains electricity to a suitable low voltage supply for electronics circuits and
other devices. A power supply can by broken down into a series of blocks, each of which
performs a particular function. For example a 5V regulated supply:

Each of the blocks is described in more detail below:

 Transformer - steps down high voltage AC mains to low voltage AC.


 Rectifier - converts AC to DC, but the DC output is varying.

 Smoothing - smoothes the DC from varying greatly to a small ripple.

 Regulator - eliminates ripple by setting DC output to a fixed voltage.

Power supplies made from these blocks are described below with a circuit diagram and a
graph of their output:

 Transformer only
 Transformer + Rectifier

 Transformer + Rectifier + Smoothing

49
 Transformer + Rectifier + Smoothing + Regulator

Dual Supplies:

Some electronic circuits require a power supply with positive and negative
outputs as well as zero volts (0V). This is called a 'dual supply' because it is like two
ordinary supplies connected together as shown in the diagram.

Dual supplies have three outputs, for example a ±9V supply has +9V, 0V and -9V
outputs.
Transformer only:

The low voltage AC output is suitable for lamps, heaters and special AC motors. It is not
suitable for electronic circuits unless they include a rectifier and a smoothing capacitor.
Transformer + Rectifier:

50
The varying DC output is suitable for lamps, heaters and standard motors. It is not
suitable for electronic circuits unless they include a smoothing capacitor.

Transformer + Rectifier + Smoothing:

The smooth DC output has a small ripple. It is suitable for most electronic circuits.
Transformer + Rectifier + Smoothing + Regulator:

51
The regulated DC output is very smooth with no ripple. It is suitable for all electronic
circuits. Transformer:

Transformers convert AC electricity from one voltage to another with little loss
of power. Transformers work only with AC and this is one of the reasons why mains
electricity is AC. Step-up transformers increase voltage, step-down transformers reduce
voltage. Most power supplies use a step-down
transformer to reduce the dangerously high mains
voltage (230V in UK) to a safer low voltage.

The input coil is called the primary and the output


coil is called the secondary. There is no electrical
connection between the two coils, instead they are
linked by an alternating magnetic field created in
the soft-iron core of the transformer. The two lines
in the middle of the circuit symbol represent the
core.

Transformers waste very little power so the power out is (almost) equal to the power in.
Note that as voltage is stepped down current is stepped up.

The ratio of the number of turns on each coil, called the turns ratio, determines the ratio
of the voltages. A step-down transformer has a large number of turns on its primary
(input) coil which is connected to the high voltage mains supply, and a small number of
turns on its secondary (output) coil to give a low output voltage.

Vp Np power out = power in   
  turns ratio =   =     and   
Vs Ns Vs × Is = Vp × Ip

52
7.2: RECTIFIER:

There are several ways of connecting diodes to make a rectifier to convert AC to DC. The
bridge rectifier is the most important and it produces full-wave varying DC. A full-wave
rectifier can also be made from just two diodes if a centre-tap transformer is used, but this
method is rarely used now that diodes are cheaper.

Vp = primary (input) voltage Vs = secondary (output) voltage


Np = number of turns on primary coil     Ns = number of turns on secondary coil
Ip  = primary (input) current Is  = secondary (output) current

Bridge rectifier:

A bridge rectifier can be made using four individual diodes, but it is also available in
special packages containing the four diodes required. It is called a full-wave rectifier
because it uses all the AC wave (both positive and negative sections). 1.4V is used up in
the bridge rectifier because each diode uses 0.7V when conducting and there are always
two diodes conducting, as shown in the diagram below. Bridge rectifiers are rated by the
maximum current they can pass and the maximum reverse voltage they can withstand
(this must be at least three times the supply RMS voltage so the rectifier can withstand
the peak voltages). Please see the Diodes page for more details, including pictures of
bridge rectifiers.

Fig 7.2(a):Bridge Rectifier and


Fullwave varying output DC.

Alternate pairs of diodes conduct,


changing over(using all the AC wave) the
connections. so the

Alternating directions of AC are converted to one directions of DC.

53
Single diode rectifier:

A single diode can be used as a rectifier but this produces half-wave varying
DC which has gaps when the AC is negative. It is hard to smooth this sufficiently well to
supply electronic circuits unless they require a very small current so the smoothing
capacitor does not significantly discharge during the gaps. Please see the Diodes page for
some examples of rectifier diodes.

54
Fig 7.2(b):Single Diode Rectifier and Half-wave varying Output DC.

7.3: SMOOTHING:

Smoothing is performed by a large value electrolytic capacitor connected across


the DC supply to act as a reservoir, supplying current to the output when the varying DC
voltage from the rectifier is falling. The diagram shows the unsmoothed varying DC
(dotted line) and the smoothed DC (solid line). The capacitor charges quickly near the
peak of the varying DC, and then discharges as it supplies current to the output.

Note that smoothing significantly increases the average DC voltage to almost the peak
value (1.4 × RMS value). For example 6V RMS AC is rectified to full wave DC of about
4.6V RMS (1.4V is lost in the bridge rectifier), with smoothing this increases to almost
the peak value giving 1.4 × 4.6 = 6.4V smooth DC.

Smoothing is not perfect due to the capacitor voltage falling a little as it discharges,
giving a small ripple voltage. For many circuits a ripple which is 10% of the supply
voltage is satisfactory and the equation below gives the required value for the smoothing
capacitor. A larger capacitor will give less ripple. The capacitor value must be doubled
when smoothing half-wave DC.

55
There is more information
about smoothing on the
Electronics in Meccano
website.

5 × Io   
 Smoothing capacitor for 10% ripple, C =
Vs × f

C =smoothing capacitance in farads (F)


Io =output current from the supply in amps (A)
Vs=supply voltage in volts (V), this is the peak value of the unsmoothed DC
f  =frequency of the AC supply in hertz (Hz), 50Hz in the UK
7.4: REGULATOR:

Voltage regulator ICs are


available with fixed (typically 5, 12 and
15V) or variable output voltages. They are
also rated by the maximum current they
can pass. Negative voltage regulators are
available, mainly for use in dual supplies.
Most regulators include some automatic protection
from excessive current ('overload protection') and
overheating ('thermal protection').

Many of the fixed voltage regulator ICs have 3 leads


and look like power transistors, such as the 7805 +5V
1A regulator shown on the right. They include a
hole for attaching a heatsink if necessary.

7.5: CIRCUIT FEATURES:

 Brief description of operation: Gives out well


Zenerdiode
regulated +5V output, output current
a = anode, k = cathode
capability of 100 mA

56
 Circuit protection: Built-in overheating protection shuts down output when
regulator IC gets too hot

 Circuit complexity: Very simple and easy to build

 Circuit performance: Very stable +5V output voltage, reliable operation

 Availability of components: Easy to get, uses only very common basic


components

BLOCK DIAGRAM:

CHAPTER 8

SCHEMATIC DIAGRAMS

57
 

58
CHAPTER 9

KEIL SOFTWARE

KEIL SOFWARE WORKING:

Step1: Click for KEIL μVISION4 Icon. Which appearing after Installing KEIL
μVISION4.

Step2: Click on Project Menu, Then New μVison Project.

59
Step3: Create New Project Folder named as “Keil Test”.

Step 4: Select Target Device Vendor (i.e.).

Step 5: Then select specific chip LPC2148.

60
Step 6: Then you will see following window.

Step 7: Now you see Startup.s is already added which is necessary for running code for
Keil.
Note: Code wills Not Run without Startup.s
Startup.s is available in C:\Keil\ARM\Startup\Philips.

61
The startup-code executes immediately upon reset of the target system and performs the
following operations:
1. Defines interrupt and exception vectors.
2. Configures the CPU clock source (on some devices).
3. Initializes the external bus controller.
4. Copies the exception vectors from ROM to RAM for systems with memory
remapping.
5. Initializes other low level peripherals, if necessary.
6. Reserves and initializes the stack for all modes.
7. Reserves the heap.
8. Transfers control to the main C function.

Step 8: Now Click on File Menu and Click on New.

62
Step 9: Write Code in C and Filename Save.
Note: Don’t forget to save .c Extension.

Step 10: Now you Window in C Syntax.

Step 11: Now you add FileName.c file by adding Source Group 1 Add files to Group
‘Source Group 1’.

Step 12: Filename file.

63
Step 13: Now Click on Options for Target ‘Target 1’.

Step 14: Go to Options for Target ‘Target 1’. Click on Check Box Create HEX File.

Step 15: Then go to Linker. Click on Use Memory Layout for Target Dialog.

64
Step 16: Then Click on Rebuild All Target Files.

Step 17: Now you see 0 Error(s), 0 Warning (s). Then Hex File will create in Specific
Folder..

Step 18: Now to download it for you target hardware using LPC2000 Flash Utility.

STEPS TO VIEW THE OUTPUT:

 Click on “START”
 Go to “All Programs”
 Go to “Accessories”
 Go to “Communications”
 Go to “Hyper Terminal”, click on phone symbol.
 Give any name and click on COM1 and click on “ok”
 Now click on “Restore Defaults” and then “ok”
 Now based on the i/p we can view desired o/p on Hyper Terminal Window.

65
66

You might also like