You are on page 1of 95

Introduction to Embedded Systems:

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 means that removing the bugs,
making modifications, or adding new features are only matters 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 used 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 your organization.

An embedded system is a system which is going to do a predefined specified task is the


embedded system and is even defined as combination of both software and hardware. A general-purpose
definition of embedded systems is that they are devices used to control, monitor or assist the operation
of equipment, machinery or plant. "Embedded" reflects the fact that they are an integral part of the
system. At the other extreme a general-purpose computer may be used to control the operation of a large
complex processing plant, and its presence will be obvious.
All embedded systems are including computers or microprocessors. Some of these computers are
however very simple systems as compared with a personal computer.
The very simplest embedded systems are capable of performing only a single function or set of functions
to meet a single predetermined purpose. In more complex systems an application program that enables
the embedded system to be used for a particular purpose in a specific application determines the
functioning of the embedded system. The ability to have programs means that the same embedded
system can be used for a variety of different purposes. In some cases a microprocessor may be designed
in such a way that application software for a particular purpose can be added to the basic software in a
second process, after which it is not possible to make further changes. The applications software on such
processors is sometimes referred to as firmware.
The simplest devices consist of a single microprocessor (often called a "chip”), which may itself be
packaged with other chips in a hybrid system or Application Specific Integrated Circuit (ASIC). Its input
comes from a detector or sensor and its output goes to a switch or activator which (for example) may
start or stop the operation of a machine or, by operating a valve, may control the flow of fuel to an
engine.

As the embedded system is the combination of both software and hardware

Embedded

System

Software Hardware

ALP Processor
C Peripherals
VB memory
Etc.,

Figure: Block diagram of Embedded System

Software deals with the languages like ALP, C, and VB etc., and Hardware deals with Processors,
Peripherals, and Memory.

Memory: It is used to store data or address.


Peripherals: These are the external devices connected
Processor: It is an IC which is used to perform some task
Applications of embedded systems
 Manufacturing and process control
 Construction industry

 Transport

 Buildings and premises

 Domestic service

 Communications
 Office systems and mobile equipment
 Banking, finance and commercial
 Medical diagnostics, monitoring and life support
 Testing, monitoring and diagnostic systems

Processors are classified into four types like:


 Micro Processor (µp)
 Micro controller (µc)
 Digital Signal Processor (DSP)
 Application Specific Integrated Circuits (ASIC)

Micro Processor (µp)


A silicon chip that contains a CPU. In the world of personal computers, the terms microprocessor and
CPU are used interchangeably. At the heart of all personal computers and most workstations sits a
microprocessor. Microprocessors also control the logic of almost all digital devices, from clock radios to
fuel-injection systems for automobiles.

Three basic characteristics differentiate microprocessors


 Instruction set: The set of instructions that the microprocessor can execute.
 Bandwidth : The number of bits processed in a single instruction.
 Clock speed : Given in megahertz (MHz), the clock speed determines how many instructions per
second the processor can execute.
In both cases, the higher the value, the more powerful the CPU. For example, a 32-bit microprocessor
that runs at 50MHz is more powerful than a 16-bit microprocessor that runs at 25MHz. In addition to
bandwidth and clock speed, microprocessors are classified as being either RISC (reduced instruction set
computer) or CISC (complex instruction set computer).
A microprocessor has three basic elements, as shown above. The ALU performs all arithmetic
computations, such as addition, subtraction and logic operations (AND, OR, etc). It is controlled by the
Control Unit and receives its data from the Register Array. The Register Array is a set of registers used
for storing data. These registers can be accessed by the ALU very quickly. Some registers have specific
functions - we will deal with these later. The Control Unit controls the entire process. It provides the
timing and a control signal for getting data into and out of the registers and the ALU and it synchronizes
the execution of instructions (we will deal with instruction execution at a later date).

Three Basic Elements of a Microprocessor


Micro Controller (µc):
A microcontroller is a small computer on a single integrated circuit containing a processor core,
memory, and programmable input/output peripherals. Program memory in the form of NOR flash or
OTP ROM is also often included on chip, as well as a typically small amount of RAM. Microcontrollers
are designed for embedded applications, in contrast to the microprocessors used in personal
computers or other general purpose applications.

ALU

CU

Memory

Timer, Counter, serial


communication ROM,
ADC, DAC, Timers,
Figure: Block Diagram of Micro Controller (µc)
USART, Oscillators

Etc.,
Digital Signal Processors (DSPs):
Digital Signal Processors is one which performs scientific and mathematical operation. Digital Signal
Processor chips - specialized microprocessors with architectures designed specifically for the types of
operations required in digital signal processing. Like a general-purpose microprocessor, a DSP is a
programmable device, with its own native instruction code. DSP chips are capable of carrying out
millions of floating point operations per second, and like their better-known general-purpose cousins,
faster and more powerful versions are continually being introduced. DSPs can also be embedded within
complex "system-on-chip" devices, often containing both analog and digital circuitry.
Application Specific Integrated Circuit (ASIC)
ASIC is a combination of digital and analog circuits packed into an IC to achieve the desired
control/computation function

ASIC typically contains

 CPU cores for computation and control


 Peripherals to control timing critical functions
 Memories to store data and program
 Analog circuits to provide clocks and interface to the real world which is analog in nature
 I/Os to connect to external components like LEDs, memories, monitors etc.
Computer Instruction Set

There are two different types of computer instruction set there are:

1. RISC (Reduced Instruction Set Computer) and

2. CISC (Complex Instruction Set computer)

Reduced Instruction Set Computer (RISC)

A RISC (reduced instruction set computer) is a microprocessor that is designed to perform a smaller
number of types of computer instruction so that it can operate at a higher speed (perform more million
instructions per second, or millions of instructions per second). Since each instruction type that a
computer must perform requires additional transistors and circuitry, a larger list or set of computer
instructions tends to make the microprocessor more complicated and slower in operation.

Besides performance improvement, some advantages of RISC and related design improvements are:

 A new microprocessor can be developed and tested more quickly if one of its aims is to be less
complicated.
 Operating system and application programmers who use the microprocessor's instructions will
find it easier to develop code with a smaller instruction set.
 The simplicity of RISC allows more freedom to choose how to use the space on a
microprocessor.
Higher-level language compilers produce more efficient code than formerly because they have always
tended to use the smaller set of instructions to be found in a RISC computer.

RISC characteristics

 Simpleinstructionset:
In a RISC machine, the instruction set contains simple, basic instructions, from which more complex
instructions can be composed.
 Samelengthinstructions.
Each instruction is the same length, so that it may be fetched in a single operation.
 1machine-cycleinstructions.
Most instructions complete in one machine cycle, which allows the processor to handle several
instructions at the same time. This pipelining is a key technique used to speed up RISC machines.
Complex Instruction Set Computer (CISC)

CISC, which stands for Complex Instruction Set Computer, is a philosophy for designing chips that
are easy to program and which make efficient use of memory. Each instruction in a CISC instruction set
might perform a series of operations inside the processor. This reduces the number of instructions
required to implement a given program, and allows the programmer to learn a small but flexible set of
instructions.

The advantages of CISC

At the time of their initial development, CISC machines used available technologies to optimize
computer performance.

 Microprogramming is as easy as assembly language to implement, and much less expensive than
hardwiring a control unit.
 The ease of micro-coding new instructions allowed designers to make CISC machines upwardly
compatible: a new computer could run the same programs as earlier computers because the new
computer would contain a superset of the instructions of the earlier computers.
 As each instruction became more capable, fewer instructions could be used to implement a given
task. This made more efficient use of the relatively slow main memory.
 Because micro program instruction sets can be written to match the constructs of high-level
languages, the compiler does not have to be as complicated.

Disadvantages of CISC

Still, designers soon realized that the CISC philosophy had its own problems, including:

 Earlier generations of a processor family generally were contained as a subset in every new
version --- so instruction set & chip hardware become more complex with each generation of computers.
 So that as many instructions as possible could be stored in memory with the least possible wasted
space, individual instructions could be of almost any length---this means that different instructions will
take different amounts of clock time to execute, slowing down the overall performance of the machine.
 Many specialized instructions aren't used frequently enough to justify their existence ---
approximately 20% of the available instructions are used in a typical program.
 CISC instructions typically set the condition codes as a side effect of the instruction. Not only
does setting the condition codes take time, but programmers have to remember to examine the condition
code bits before a subsequent instruction changes them.

Memory Architecture

There two different type’s memory architectures there are:

 Harvard Architecture
 Von-Neumann Architecture
Harvard Architecture

Computers have separate memory areas for program instructions and data. There are two or more
internal data buses, which allow simultaneous access to both instructions and data. The CPU fetches
program instructions on the program memory bus.

The Harvard architecture is a computer architecture with physically separate storage and signal
pathways for instructions and data. The term originated from the Harvard Mark I relay-based computer,
which stored instructions on punched tape (24 bits wide) and data in electro-mechanical counters. These
early machines had limited data storage, entirely contained within the central processing unit, and
provided no access to the instruction storage as data. Programs needed to be loaded by an operator, the
processor could not boot itself.

Figure: Harvard Architecture

Modern uses of the Harvard architecture:


The principal advantage of the pure Harvard architecture - simultaneous access to more than one
memory system - has been reduced by modified Harvard processors using modern CPU cache systems.
Relatively pure Harvard architecture machines are used mostly in applications where tradeoffs, such as
the cost and power savings from omitting caches, outweigh the programming penalties from having
distinct code and data address spaces.
 Digital signal processors (DSPs) generally execute small, highly-optimized audio or video
processing algorithms. They avoid caches because their behavior must be extremely reproducible. The
difficulties of coping with multiple address spaces are of secondary concern to speed of execution. As a
result, some DSPs have multiple data memories in distinct address spaces to facilitate SIMD and VLIW
processing. Texas Instruments TMS320 C55x processors, as one example, have multiple parallel data
busses (two write, three read) and one instruction bus.
 Microcontrollers are characterized by having small amounts of program (flash memory) and data
(SRAM) memory, with no cache, and take advantage of the Harvard architecture to speed processing by
concurrent instruction and data access. The separate storage means the program and data memories can
have different bit depths, for example using 16-bit wide instructions and 8-bit wide data. They also mean
that instruction pre-fetch can be performed in parallel with other activities. Examples include, the AVR by
Atmel Corp, the PIC by Microchip Technology, Inc. and the ARM Cortex-M3 processor (not all ARM chips
have Harvard architecture).
Even in these cases, it is common to have special instructions to access program memory as data for
read-only tables, or for reprogramming.
Von-Neumann Architecture

A computer has a single, common memory space in which both program instructions and data are stored.
There is a single internal data bus that fetches both instructions and data. They cannot be performed at
the same time

The von Neumann architecture is a design model for a stored-program digital computer that uses a
central processing unit (CPU) and a single separate storage structure ("memory") to hold both
instructions and data. It is named after the mathematician and early computer scientist John von
Neumann. Such computers implement a universal Turing machine and have a sequential architecture.

A stored-program digital computer is one that keeps its programmed instructions, as well as its data, in
read-write, random-access memory (RAM). Stored-program computers were advancement over the
program-controlled computers of the 1940s, such as the Colossus and the ENIAC, which were
programmed by setting switches and inserting patch leads to route data and to control signals between
various functional units. In the vast majority of modern computers, the same memory is used for both
data and program instructions. The mechanisms for transferring the data and instructions between the
CPU and memory are, however, considerably more complex than the original von Neumann
architecture.

The terms "von Neumann architecture" and "stored-program computer" are generally used
interchangeably, and that usage is followed in this article.

Figure: Schematic of the Von-Neumann Architecture.

Basic Difference between Harvard and Von-Neumann Architecture

 The primary difference between Harvard architecture and the Von Neumann architecture is in the
Von Neumann architecture data and programs are stored in the same memory and managed by the same
information handling system.
 Whereas the Harvard architecture stores data and programs in separate memory devices and they
are handled by different subsystems.
 In a computer using the Von-Neumann architecture without cache; the central processing unit
(CPU) can either be reading and instruction or writing/reading data to/from the memory. Both of these
operations cannot occur simultaneously as the data and instructions use the same system bus.
 In a computer using the Harvard architecture the CPU can both read an instruction and access
data memory at the same time without cache. This means that a computer with Harvard architecture can
potentially be faster for a given circuit complexity because data access and instruction fetches do not
contend for use of a single memory pathway.
 Today, the vast majority of computers are designed and built using the Von Neumann architecture
template primarily because of the dynamic capabilities and efficiencies gained in designing,
implementing, operating one memory system as opposed to two. Von Neumann architecture may be
somewhat slower than the contrasting Harvard Architecture for certain specific tasks, but it is much
more flexible and allows for many concepts unavailable to Harvard architecture such as self
programming, word processing and so on.
 Harvard architectures are typically only used in either specialized systems or for very specific
uses. It is used in specialized digital signal processing (DSP), typically for video and audio processing
products. It is also used in many small microcontrollers used in electronics applications such as
Advanced RISK Machine (ARM) based products for many vendors.

Characteristics
Two major areas of differences are cost and power consumption. Since many embedded systems
are produced in the 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.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 must 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 stricter 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 as of this writing (2003) is limited to just a few competing
architectures, mainly the Intel/AMD x86, and the Apple/Motorola/IBM PowerPC, 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.

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. This feature was pioneered on the PDP-11.

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.

Design of embedded systems


The electronics usually uses either a microprocessor or a micro controller. 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 LEDs 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
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 simply 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 exokernel.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. That's about once a year with modern hardware. With a million mass-
produced devices, leaving out a software timer is a business disaster 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 weakness 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.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
User interfaces for embedded systems vary wildly, and thus deserve some special
comment. Designers recommend testing the user interface for usability at the earliest possible
instant. A quick, dirty test is to ask an executive secretary to use cardboard models drawn with
magic markers, and manipulated by an engineer. The videotaped result is likely to be both
humorous and very educational. In the tapes, every time the engineer talk, the interface has
failed: It would cause a service call.

Exactly one person should approve the user interface. Ideally, this should be a customer, the
major distributor or someone directly responsible for selling the system. The decision maker should be
able to decide. The problem is that a committee will never make up its mind, and neither will some
people. Not doing this causes avoidable, expensive delays. A usability test is more important than any
number of opinions. 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. For another
example, look at a small computer printer. You might have one next to your computer. Notice
that the lights are labeled with stick-on labels that can be printed in any language. Really look at
it.

Designers use colors. Red means the users can get hurt- think of blood. Yellow means
something might be wrong. Green means 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. If a design needs a screen, many designers use plain text. It can
be sold as a temporary expedient. Why is it better than pictures? Users have been reading signs
for years. A GUI is pretty and can do anything, but typically adds a year from artist, approval and
translator delays and one or two programmers to a project's cost, without adding any value.
Often, a clever GUI actually confuses users. If a design needs to point to parts of the machine (as
in copiers), these are labeled with numbers on the actual machine, that are visible with the doors
closed. A network interface is just a remote screen. It needs the same caution as any other user
interface. 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. Right now this is English. French and Spanish follow.

Most designers recommend that one use the native character sets, no matter how painful.
People with peculiar character sets feel coddled and loved when their language shows up on
machinery they use. Text should be translated by professional translators, even if native speakers
are on staff. Marketing staff have to be able to tell foreign distributors that the translations are
professional.

A foreign organization should give the highest-volume distributor the duty to review and
correct any translations in his native language. This stops critiques by other native speakers, who
tend to believe that no foreign organization will ever know their language as well as they.

AT89C51 MICROCONTROLLER

FEATURES
 80C51 based architecture
 4-Kbytes of on-chip Reprogrammable Flash Memory
 128 x 8 RAM
 Two 16-bit Timer/Counters
 Full duplex serial channel
 Boolean processor
 Four 8-bit I/O ports, 32 I/O lines
 Memory addressing capability
– 64K ROM and 64K RAM
 Power save modes:
– Idle and power-down
 Six interrupt sources
 Most instructions execute in 0.3 us
 CMOS and TTL compatible
 Maximum speed: 40 MHz @ Vcc = 5V
 Industrial temperature available
 Packages available:
– 40-pin DIP

– 44-pin PLCC

– 44-pin PQFP

GENERAL DESCRIPTION:
THE MICROCONTROLLER:

A microcontroller is a general purpose device, but that is meant to read data, perform limited
calculations on that data and control its environment based on those calculations. The prime use of a
microcontroller is to control the operation of a machine using a fixed program that is stored in ROM and
that does not change over the lifetime of the system. The microcontroller design uses a much more
limited set of single and double byte instructions that are used to move data and code from internal
memory to the ALU. The microcontroller is concerned with getting data from and to its own pins; the
architecture and instruction set are optimized to handle data in bit and byte size.

The AT89C51 is a low-power, high-performance CMOS 8-bit microcontroller with 4k bytes of


Flash Programmable and erasable read only memory (EROM). The device is manufactured using
Atmel’s high-density nonvolatile memory technology and is functionally compatible with the industry-
standard 80C51 microcontroller instruction set and pin out. By combining versatile 8-bit CPU with Flash
on a monolithic chip, the Atmel’s AT89c51 is a powerful microcomputer, which provides a high flexible
and cost- effective solution to many embedded control applications.
Pin configuration of AT89c51 Microcontroller
AT89C51 Block Diagram
PIN DESCRIPTION:
VCC

Supply voltage

GND

Ground

Port 0

Port 0 is an 8-bit open drain bi-directional I/O port. As an output port, each pin can sink eight TTL
inputs. When 1s are written to port 0 pins, the pins can be used as high impedance inputs.

Port 0 can also be configured to be the multiplexed low order address/data bus during access to
external program and data memory. In this mode, P 0 has internal pull-ups. Port 0 also receives the code
bytes during Flash programming and outputs the code bytes during program verification. External pull-
ups are required during program verification.

Port 1

Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The port 1output buffers can
sink/source four TTL inputs. When 1s are written to port 1 pins, they are pulled high by the internal pull-
ups can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current
(1) because of the internal pull-ups.

Port 2

Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The port 2 output buffers can
sink/source four TTL inputs. When 1s are written to port 2 pins, they are pulled high by the internal
pull-ups can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source
current because of the internal pull-ups.

Port 2 emits the high-order address byte during fetches from external program memory and
during access to DPTR. In this application Port 2 uses strong internal pull-ups when emitting 1s. During
accesses to external data memory that use 8-bit data address (MOVX@R1), Port 2 emits the contents of
the P2 Special Function Register. Port 2 also receives the high-order address bits and some control
signals during Flash programming and verification.
Port 3

Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. The port 3 output buffers can
sink/source four TTL inputs. When 1s are written to port 3 pins, they are pulled high by the internal pull-
ups can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current
because of the internal pull-ups.

Port 3 also receives some control signals for Flash Programming and verification

Port pin Alternate Functions

P3.0 RXD(serial input port)

P3.1 TXD(serial input port)

P3.2 INT0(external interrupt 0)

P3.3 INT1(external interrupt 1)

P3.4 T0(timer 0 external input)

P3.5 T1(timer 1 external input)

P3.6 WR(external data memory write strobe)

P3.7 RD(external data memory read strobe)

RST

Rest input A on this pin for two machine cycles while the oscillator is running resets the device.

ALE/PROG:

Address Latch Enable is an output pulse for latching the low byte of the address during access to
external memory. This pin is also the program pulse input (PROG) during Flash programming.
In normal operation ALE is emitted at a constant rate of 1/16 the oscillator frequency and may be
used for external timing or clocking purpose. Note, however, that one ALE pulse is skipped during each
access to external Data memory.

_____

PSEN

Program Store Enable is the read strobe to external program memory when the AT89c51 is
executing code from external program memory PSEN is activated twice each machine cycle, except that
two PSEN activations are skipped during each access to external data memory.

__

EA /VPP

External Access Enable (EA) must be strapped to GND in order to enable the device to fetch
code from external program memory locations starting at 0000h up to FFFFH. Note, however, that if
lock bit 1 is programmed EA will be internally latched on reset. EA should be strapped to Vcc for
internal program executions. This pin also receives the 12-volt programming enable voltage (Vpp)
during Flash programming when 12-volt programming is selected.

XTAL1

Input to the inverting oscillator amplifier and input to the internal clock operating circuit.

XTAL 2

Output from the inverting oscillator amplifier.

OPERATING DESCRIPTION
The detail description of the AT89C51 included in this description is:

• Memory Map and Registers

• Timer/Counters

• Interrupt System
MEMORY MAP AND REGISTERS
Memory

The AT89C51 has separate address spaces for program and data memory. The program and data
memory can be up to 64K bytes long. The lower 4K program memory can reside on-chip. The AT89C51
has 128 bytes of on-chip RAM. The lower 128 bytes can be accessed either by direct addressing or by
indirect addressing. The lower 128 bytes of RAM can be divided into 3 segments as listed below

1. Register Banks 0-3: locations 00H through 1FH (32 bytes). The device after reset defaults to register
bank 0. To use the other register banks, the user must select them in software. Each register bank
contains eight 1-byte registers R0-R7. Reset initializes the stack point to location 07H, and is
incremented once to start from 08H, which is the first register of the second register bank.

2. Bit Addressable Area: 16 bytes have been assigned for this segment 20H-2FH. Each one of the 128
bits of this segment can be directly addressed (0-7FH). Each of the 16 bytes in this segment can also be
addressed as a byte.

3. Scratch Pad Area: 30H-7FH are available to the user as data RAM. However, if the data pointer has
been initialized to this area, enough bytes should be left aside to prevent SP data destruction.
SPECIAL FUNCTION REGISTERS
The Special Function Registers (SFR's) are located in upper 128 Bytes direct addressing area.
The SFR Memory Map in shows that. Not all of the addresses are occupied. Unoccupied addresses are
not implemented on the chip. Read accesses to these addresses in general return random data, and write
accesses have no effect. User software should not write 1s to these unimplemented locations, since they
may be used in future microcontrollers to invoke new features. In that case, the reset or inactive values
of the new bits will always be 0, and their active values will be 1.

The functions of the SFR’s are outlined in the following sections.

Accumulator (ACC)

ACC is the Accumulator register. The mnemonics for Accumulator-specific instructions, however, refer
to the Accumulator simply as A.

B Register (B)

The B register is used during multiply and divide operations. For other instructions it can be treated as
another scratch pad register.

Program Status Word (PSW)

The PSW register contains program status information.

Stack Pointer (SP)

The Stack Pointer Register is eight bits wide. It is incremented before data is stored during PUSH and
CALL executions. While the stack may reside anywhere in on chip RAM, the Stack Pointer is initialized
to 07H after a reset. This causes the stack to begin at location 08H.

Data Pointer (DPTR)

The Data Pointer consists of a high byte (DPH) and a low byte (DPL). Its function is to hold a 16-bit
address. It may be manipulated as a 16-bit register or as two independent 8-bit registers.

Serial Data Buffer (SBUF)

The Serial Data Buffer is actually two separate registers, a transmit buffer and a receive buffer register.
When data is moved to SBUF, it goes to the transmit buffer, where it is held for serial transmission.
(Moving a byte to SBUF initiates the transmission.) When data is moved from SBUF, it comes from the
receive buffer.

Timer Registers

Register pairs (TH0, TL0) and (TH1, TL1) are the 16-bit Counter registers for Timer/Counters 0 and 1,
respectively.

Control Registers

Special Function Registers IP, IE, TMOD, TCON, SCON, and PCON contain control and status bits for
the interrupt system, the Timer/Counters, and the serial port.

TIMER/COUNTERS

The IS89C51 has two 16-bit Timer/Counter registers: Timer 0 and Timer 1. All two can be
configured to operate either as Timers or event counters. As a Timer, the register is incremented every
machine cycle. Thus, the register counts machine cycles. Since a machine cycle consists of 12 oscillator
periods, the count rate is 1/12 of the oscillator frequency.

As a Counter, the register is incremented in response to a 1-to-0 transition at its corresponding


external input pin, T0 and T1. The external input is sampled during S5P2 of every machine cycle. When
the samples show a high in one cycle and a low in the next

cycle, the count is incremented. The new count value appears in the register during S3P1 of the cycle
following the one in which the transition was detected. Since two machine cycles (24 oscillator periods)
are required to recognize a 1-to-0 transition, the maximum count rate is 1/24 of the oscillator frequency.
There are no restrictions on the duty cycle of the external input signal, but it should be held for at least
one full machine cycle to ensure that a given level is sampled at least once before it changes.In addition
to the Timer or Counter functions, Timer 0 and Timer 1 have four operating modes: 13-bit timer, 16-bit
timer, 8-bit auto-reload, split timer.

TIMERS:

OSCILLATOR
FREQUENCY 12D

TLX THX TFX


TR
SFR’S USED IN TIMERS

The special function registers used in timers are,

 TMOD Register
 TCON Register
 Timer(T0) & timer(T1) Registers

(i) TMOD Register:

TMOD is dedicated solely to the two timers (T0 & T1).

 The timer mode SFR is used to configure the mode of operation of each of the two timers. Using
this SFR your program may configure each timer to be a 16-bit timer, or 13 bit timer, 8-bit auto
reload timer, or two separate timers. Additionally you may configure the timers to only count
when an external pin is activated or to count “events” that are indicated on an external pin.
 It can consider as two duplicate 4-bit registers, each of which controls the action of one of the
timers.
(ii) TCON Register

 The timer control SFR is used to configure and modify the way in which the 8051’s two timers
operate. This SFR controls whether each of the two timers is running or stopped and contains a
flag to indicate that each timer has overflowed. Additionally, some non-timer related bits are
located in TCON SFR.
 These bits are used to configure the way in which the external interrupt flags are activated,
which are set when an external interrupt occurs.

(iii) TIMER 0 (T0):

 TO (Timer 0 low/high, address 8A/8C h)


These two SFR’s taken together represent timer 0. Their exact behavior depends on how
the timer is configured in the TMOD SFR; however, these timers always count up. What is
configurable is how and when they increment in value.

T H0 T L0

(iv) TIMER 1 (T1):

 T1 (Timer 1 Low/High, address 8B/ 8D h)


These two SFR’s, taken together, represent timer 1. Their exact behavior depends on how the timer is
configured in the TMOD SFR; however, these timers always count up. What is Configurable is how and
when they increment in value.

The Timer or Counter function is selected by control bits C/T in the Special Function Register TMOD.
These two Timer/Counters have four operating modes, which are selected by bit pairs (M1, M0) in
TMOD. Modes 0, 1, and 2 are the same for both Timer/Counters, but Mode 3 is different.

The four modes are described in the following sections.

Mode 0:

Both Timers in Mode 0 are 8-bit Counters with a divide-by-32 pre scalar. Figure 8 shows the
Mode 0 operation as it applies to Timer 1. In this mode, the Timer register is configured as a 13-bit
register. As the count rolls over from all 1s to all 0s, it sets the Timer interrupt flag TF1. The counted
input is enabled to the Timer when TR1 = 1 and either GATE = 0 or INT1 = 1. Setting GATE = 1 allows
the Timer to be controlled by external input INT1, to facilitate pulse width measurements. TR1 is a
control bit in the Special Function Register TCON. Gate is in TMOD.

The 13-bit register consists of all eight bits of TH1 and the lower five bits of TL1. The upper
three bits of TL1 are indeterminate and should be ignored. Setting the run flag (TR1) does not clear the
registers.
Mode 0 operation is the same for Timer 0 as for Timer 1, except that TR0, TF0 and INT0 replace
the corresponding Timer 1 signals. There are two different GATE bits, one for Timer 1 (TMOD.7) and
one for Timer 0 (TMOD.3).

Mode 1

Mode 1 is the same as Mode 0, except that the Timer register is run with all 16 bits. The clock is
applied to the combined high and low timer registers (TL1/TH1). As clock pulses are received, the timer
counts up: 0000H, 0001H, 0002H, etc. An overflow occurs on the FFFFH-to-0000H overflow flag. The
timer continues to count. The overflow flag is the TF1 bit in TCON that is read or written by software

Mode 2

Mode 2 configures the Timer register as an 8-bit Counter (TL1) with automatic reload, as shown in
Figure 10. Overflow from TL1 not only sets TF1, but also reloads TL1 with the contents of TH1, which
is preset by software. The reload leaves the TH1 unchanged. Mode 2 operation is the same for
Timer/Counter 0.

Mode 3

Timer 1 in Mode 3 simply holds its count. The effect is the same as setting TR1 = 0. Timer 0 in
Mode 3 establishes TL0and TH0 as two separate counters. The logic for Mode 3 on Timer 0 is shown in
Figure 11. TL0 uses the Timer 0 control bits: C/T, GATE, TR0, INT0, and TF0. TH0 is locked into a
timer function (counting machine cycles) and over the use of TR1 and TF1 from Timer 1. Thus, TH0
now controls the Timer 1 interrupt.

Mode 3 is for applications requiring an extra 8-bit timer or counter. With Timer 0 in Mode 3, the
AT89C51 can appear to have three Timer/Counters. When Timer 0 is in Mode 3, Timer 1 can be turned
on and off by switching it out of and into its own Mode 3. In this case, Timer 1 can still be used by the
serial port as a baud rate generator or in any application not requiring an interrupt.

INTERRUPT SYSTEM

An interrupt is an external or internal event that suspends the operation of micro controller to
inform it that a device needs its service. In interrupt method, whenever any device needs its service, the
device notifies the micro controller by sending it an interrupt signal. Upon receiving an interrupt signal,
the micro controller interrupts whatever it is doing and serves the device. The program associated with
interrupt is called as interrupt service subroutine (ISR).Main advantage with interrupts is that the micro
controller can serve many devices.

Baud Rate

The baud rate in Mode 0 is fixed as shown in the following equation. Mode 0 Baud Rate =
Oscillator Frequency /12 the baud rate in Mode 2 depends on the value of the SMOD bit in Special
Function Register PCON. If SMOD = 0 the baud rate is 1/64 of the oscillator frequency. If SMOD = 1,
the baud rate is 1/32 of the oscillator frequency.

Mode 2 Baud Rate = 2SMODx (Oscillator Frequency)/64.

In the IS89C51, the Timer 1 overflow rate determines the baud rates in Modes 1 and 3.

NUMBER OF INTERRUPTS IN 89C51:


There are basically five interrupts available to the user. Reset is also considered as an interrupt.
There are two interrupts for timer, two interrupts for external hardware interrupt and one interrupt for
serial communication.

Memory location Interrupt name

0000H Reset

0003H External interrupt 0

000BH Timer interrupt 0

0013H External interrupt 1

001BH Timer interrupt 1

0023H Serial COM interrupt

Lower the vector, higher the priority. The External Interrupts INT0 and INT1 can each be either
level-activated or transition-activated, depending on bits IT0 and IT1 in Register TCON. The flags that
actually generate these interrupts are the IE0 and IE1 bits in TCON. When the service routine is
vectored, hardware clears the flag that generated an external interrupt only if the interrupt was transition-
activated. If the interrupt was level-activated, then the external requesting source (rather than the on-chip
hardware) controls the request flag.

The Timer 0 and Timer 1 Interrupts are generated by TF0and TF1, which are set by a rollover in
their respective Timer/Counter registers (except for Timer 0 in Mode 3).When a timer interrupt is
generated, the on-chip hardware clears the flag that is generated.

The Serial Port Interrupt is generated by the logical OR of RI and TI. The service routine
normally must determine whether RI or TI generated the interrupt, and the bit must be cleared in
software. All of the bits that generate interrupts can be set or cleared by software, with the same result as
though they had been set or cleared by hardware. That is, interrupts can be generated and pending
interrupts can be canceled in software.

Each of these interrupt sources can be individually enabled or disabled by setting or clearing a bit
in Special Function Register IE (interrupt enable) at address 0A8H. There is a global enable/disable bit
that is cleared to disable all interrupts or to set the interrupts.

IE (Interrupt enable register)

Steps in enabling an interrupt

Bit D7 of the IE register must be set to high to allow the rest of register to take effect. If EA=1,
interrupts are enabled and will be responded to if their corresponding bits in IE are high. If EA=0, no
interrupt will be responded to even if the associated bit in the IE register is high.

Description of each bit in IE register

D7 bit: Disables all interrupts. If EA =0, no interrupt is acknowledged, if EA=1 each interrupt
source is individually enabled or disabled by setting or clearing its enable bit.

D6 bit: Reserved.

D5 bit: Enables or disables timer 2 over flow interrupt (in 8052).

D4 bit: Enables or disables serial port interrupt.

D3 bit: Enables or disables timer 1 over flow interrupt.

D2 bit: Enables or disables external interrupt 1.

D1 bit: Enables or disables timer 0 over flow interrupt.


D0 bit: Enables or disables external interrupt 0.

Interrupt priority in 89C51

There is one more SRF to assign priority to the interrupts which is named as interrupt priority
(IP). User has given the provision to assign priority to one interrupt. Writing one to that particular bit in
the IP register fulfils the task of assigning the priority.

Description of each bit in IP register

D7 bit: Reserved.

D6 bit: Reserved.

D5 bit: Timer 2 interrupt priority bit (in 8052).

D4 bit: Serial port interrupt priority bit.

D3 bit: Timer 1 interrupt priority bit.

D2 bit: External interrupt 1 priority bit.

D1 bit: Timer 0 interrupt priority bit.

D0 bit: External interrupt 0 priority bit.

POWER SUPPLY
In this project we have power supplies with +5V & -5V option normally +5V is enough for total
circuit. Another (-5V) supply is used in case of OP amp circuit .Transformer primary side has 230/50HZ
AC voltage whereas at the secondary winding the voltage is step downed to 12/50hz and this voltage is
rectified using two full wave rectifiers .the rectified output is given to a filter circuit to fiter the
unwanted ac in the signal After that the output is again applied to a regulator LM7805(to provide +5v)
regulator. Whereas LM7905 is for providing –5V regulation.

(+12V circuit is used for stepper motors, Fan and Relay by using LM7812 regulator same process like
above supplies.)

3.2 Description of Transformer


A transformer is a device that transfers electrical energy from one circuit to another
through inductively coupled conductors—the transformer's coils. A varying current in the
first or primary winding creates a varying magnetic flux in the transformer's core, and
thus a varying magnetic field through the secondary winding. This varying magnetic field
induces a varying electromotive force (EMF) or "voltage" in the secondary winding. This
effect is called mutual induction.

Figure: Transformer Symbol

Transformer is a device that converts the one form energy to another form of energy like
a transducer.

Figure: Transformer

3.3 Basic Principle of Transformer :


A transformer makes use of Faraday's law and the ferromagnetic properties of an iron
core to efficiently raise or lower AC voltages. It of course cannot increase power so that if
the voltage is raised, the current is proportionally lowered and vice versa.

Figure: Basic Principle Transformer

3.4 Transformer Working:

A transformer consists of two coils (often called 'windings') linked by an iron core,
as shown in figure below. There is no electrical connection between the coils, instead they
are linked by a magnetic field created in the core.
Figure: Basic Transformer

Transformers are used to convert electricity from one voltage to another with
minimal loss of power. They only work with AC (alternating current) because they
require a changing magnetic field to be created in their core. Transformers can increase
voltage (step-up) as well as reduce voltage (step-down).

Alternating current flowing in the primary (input) coil creates a continually


changing magnetic field in the iron core. This field also passes through the secondary
(output) coil and the changing strength of the magnetic field induces an alternating
voltage in the secondary coil. If the secondary coil is connected to a load the induced
voltage will make an induced current flow. The correct term for the induced voltage is
'induced electromotive force' which is usually abbreviated to induced e.m.f.

The iron core is laminated to prevent 'eddy currents' flowing in the core. These are
currents produced by the alternating magnetic field inducing a small voltage in the core,
just like that induced in the secondary coil. Eddy currents waste power by needlessly
heating up the core but they are reduced to a negligible amount by laminating the iron
because this increases the electrical resistance of the core without affecting its magnetic
properties.

Transformers have two great advantages over other methods of changing voltage:
1. They provide total electrical isolation between the input and output, so they can be
safely used to reduce the high voltage of the mains supply.
2. Almost no power is wasted in a transformer. They have a high efficiency (power
out / power in) of 95% or more.

3.5 Classification of Transformer:

 Step-Up Transformer
 Step-Down Transformer

Step-Down Transformer:

Step down transformers are designed to reduce electrical voltage. Their primary
voltage is greater than their secondary voltage. This kind of transformer "steps down" the
voltage applied to it. For instance, a step down transformer is needed to use a 110v
product in a country with a 220v supply.

Step down transformers convert electrical voltage from one level or phase configuration
usually down to a lower level. They can include features for electrical isolation, power
distribution, and control and instrumentation applications. Step down transformers
typically rely on the principle of magnetic induction between coils to convert voltage
and/or current levels.

Step down transformers are made from two or more coils of insulated wire wound around
a core made of iron. When voltage is applied to one coil (frequently called the primary or
input) it magnetizes the iron core, which induces a voltage in the other coil, (frequently
called the secondary or output). The turn’s ratio of the two sets of windings determines
the amount of voltage transformation.
Figure: Step-Down Transformer

An example of this would be: 100 turns on the primary and 50 turns on the secondary, a
ratio of 2 to 1.

Step down transformers can be considered nothing more than a voltage ratio device:

With step down transformers the voltage ratio between primary and secondary will
mirror the "turn’s ratio" (except for single phase smaller than 1 kva which have
compensated secondary). A practical application of this 2 to 1 turn’s ratio would be a 480
to 240 voltage step down. Note that if the input were 440 volts then the output would be
220 volts. The ratio between input and output voltage will stay constant. Transformers
should not be operated at voltages higher than the nameplate rating, but may be operated
at lower voltages than rated. Because of this it is possible to do some non-standard
applications using standard transformers.

Single phase step down transformers 1 kva and larger may also be reverse
connected to step-down or step-up voltages. (Note: single phase step up or step down
transformers sized less than 1 KVA should not be reverse connected because the
secondary windings have additional turns to overcome a voltage drop when the load is
applied. If reverse connected, the output voltage will be less than desired.)

Step-Up Transformer:
A step up transformer has more turns of wire on the secondary coil, which makes a
larger induced voltage in the secondary coil. It is called a step up transformer because the
voltage output is larger than the voltage input.

Step-up transformer 110v 220v design is one whose secondary voltage is greater
than its primary voltage. This kind of transformer "steps up" the voltage applied to it. For
instance, a step up transformer is needed to use a 220v product in a country with a 110v
supply.

A step up transformer 110v 220v converts alternating current (AC) from one
voltage to another voltage. It has no moving parts and works on a magnetic induction
principle; it can be designed to "step-up" or "step-down" voltage. So a step up
transformer increases the voltage and a step down transformer decreases the voltage.

The primary components for voltage transformation are the step up transformer
core and coil. The insulation is placed between the turns of wire to prevent shorting to
one another or to ground. This is typically comprised of Mylar, nomex, Kraft paper,
varnish, or other materials. As a transformer has no moving parts, it will typically have a
life expectancy between 20 and 25 years.

Figure: Step-Up Transformer

Applications

Generally these Step-Up Transformers are used in industries applications only.


Turns Ratio and Voltage

The ratio of the number of turns on the primary and secondary coils determines the
ratio of the voltages...

...where Vp is the primary (input) voltage, Vs is the secondary (output) voltage, Np is the
number of turns on the primary coil, and Ns is the number of turns on the secondary coil.

Diodes:

Diodes allow electricity to flow in only one direction. The arrow of the circuit
symbol shows the direction in which the current can flow. Diodes are the electrical
version of a valve and early diodes were actually called valves.

Figure: Diode Symbol

A diode is a device which only allows current to flow through it in one direction.
In this direction, the diode is said to be 'forward-biased' and the only effect on the signal
is that there will be a voltage loss of around 0.7V. In the opposite direction, the diode is
said to be 'reverse-biased' and no current will flow through it.

Rectifier

The purpose of a rectifier is to convert an AC waveform into a DC waveform (OR)


Rectifier converts AC current or voltages into DC current or voltage. There are two
different rectification circuits, known as 'half-wave' and 'full-wave' rectifiers. Both use
components called diodes to convert AC into DC.

The Half-wave Rectifier:

The half-wave rectifier is the simplest type of rectifier since it only uses one diode,
as shown in figure .

Figure: Half Wave Rectifier

Figure 2 shows the AC input waveform to this circuit and the resulting output. As
you can see, when the AC input is positive, the diode is forward-biased and lets the
current through. When the AC input is negative, the diode is reverse-biased and the diode
does not let any current through, meaning the output is 0V. Because there is a 0.7V
voltage loss across the diode, the peak output voltage will be 0.7V less than Vs.

Figure: Half-Wave Rectification


While the output of the half-wave rectifier is DC (it is all positive), it would not be
suitable as a power supply for a circuit. Firstly, the output voltage continually varies
between 0V and Vs-0.7V, and secondly, for half the time there is no output at all.

HEAT SINK:
More often transistors gets heated when the circuit is ON for long time. In order to avoid
heating up of transistors we use heat sinks.

BLOCK DIAGRAM OF POWER SUPPLY


DFD is the power supply pin for the circuit. A step down transformer is used to convert 230V
50HZ line voltage 12-0-12V ac input to the supply pin of the circuit. The ac voltage is converted to
pulsated dc using a center tapped full wave rectifier. Any ripples if present are eliminated using a
capacitive filter at the output of the full wave rectifier. The capacitive filter output is input to 7805-
voltage regulator, which produces a dc equivalent of ac 5V. This 5V dc acts as VCC to the micro
controller. The excess voltage is dissipated as heat via an Aluminum heat sink attached to the voltage
regulator.

TAPPED FULL WAVE RECTIFIER:


The circuit employs two diodes D1 and D2 as shown in the figure below. A center
tapped secondary winding AB is used with two diodes connected so that each uses one- half cycle of the
input ac voltage. In other words, D1 utilizes the ac voltage appearing across the upper half (OA) of
secondary winding for rectification while D2 uses the lower half winding OB.

D1

1 5
RL
AC Supply 6

4 8

D2

Centertap full wave rectifier

OPERATION
During the positive half cycle of secondary voltage, the end A of the secondary winding
becomes positive and end B negative. This makes the diode D1 forward biased and D2 reverse biased.
Therefore D1 conducts while D2 does not. The conventional current flow is through diode D1, load
resistor RL and upper half of secondary winding as shown by the dotted arrows. During the negative half
cycle, end A of the secondary winding becomes negative and end B positive. Therefore D2 conducts
while D1 does not. The conventional current flow is through D2, load RL and lower half winding as
shown by solid arrows in the figure above .It is seen that current in the load RL is in the same direction
for both half cycles of input ac voltage. Therefore dc is obtained across the load RL. Also the polarities
of the output across the load should be noted

PEAK INVERSE VOLTAGE

Suppose Vm is the maximum voltage across the half secondary winding at the instant
secondary voltage reaches its maximum value in the positive direction. At this instant D1 is conducting
while D2 is not conducting. Therefore whole of the secondary voltage appears across the non-
conducting diode. Consequently the peak inverse voltage is twice the maximum voltage across the half
secondary winding.

FILTER CIRCUIT

A filter circuit is a device which removes the ac component of rectifier output but allows
the dc component to the load. The most commonly used filter circuits are capacitor filter, choke input
filter and capacitor input filter or pi-filter. We used capacitor filter here.

CAPACITOR FILTER

This consists of a capacitor C placed across the rectifier output in parallel with the load
RL. The pulsating direct voltage of the rectifier is applied across the capacitor. As the rectifier voltage
increases, it charges the capacitor and also supplies current to the load. At the end of quarter cycle the
capacitor is charged to the peak value Vm of the rectifier voltage. Now the rectifier voltage starts to
decrease. As this occurs the capacitor discharges through the load and the voltage across it decrease. The
voltage across load will decrease only slightly because immediately the next voltage peak comes and
recharges the capacitor. This process is repeated again and again. At the output very little ripple is left.
moreover output voltage is higher as it remains substantially near the peak value of rectifier output
voltage.
The capacitor filter circuit is extremely popular because of its low cost, small size,little weight and
good characteristics. For small load currents this type of filter is preferred. it is commonly used in
transistor radio battery eliminators.

Rectifier O/P C RL

Capacitor Filter

POWER SUPPLY

Description

A variable regulated power supply, also called a variable bench power supply, is one where you can
continuously adjust the output voltage to your requirements. Varying the output of the power supply is
the recommended way to test a project after having double checked parts placement against circuit
drawings and the parts placement guide.

This type of regulation is ideal for having a simple variable bench power supply. Actually this is quite
important because one of the first projects a hobbyist should undertake is the construction of a variable
regulated power supply. While a dedicated supply is quite handy e.g. 5V or 12V, it's much handier to
have a variable supply on hand, especially for testing.

Most digital logic circuits and processors need a 5 volt power supply. To use these parts we need to build
a regulated 5 volt source. Usually you start with an unregulated power supply ranging from 9 volts to 24
volts DC To make a 5 volt power supply, we use a LM7805 voltage regulator IC (Integrated Circuit).
The IC is shown below.
Fig: 5.2.1

The LM7805 is simple to use. You simply connect the positive lead of your unregulated DC power
supply (anything from 9VDC to 24VDC) to the Input pin, connect the negative lead to the common pin
and then when you turn on the power, you get a 5 volt supply from the Output pin.

Block Diagram:

Fig 5.2.2: - Block Diagram of Power supply

Circuit Features:

Brief description of operation: Gives out well regulated +5V output, output current capability of
100 mA .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 Design testing: Based on datasheet example circuit, I have used this circuit successfully as
part of many electronics projects

Applications: Part of electronics devices, small laboratory power supply


Power supply voltage: Unregulated DC 8-18V power supply

Power supply current: Needed output current + 5 mA

Component costs: Few dollars for the electronics components + the input transformer cost.

LM35 TEMPERATURE SENSOR:

Description:

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 ±¼°C at room temperature and ±¾°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. 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). The LM35 series is available packaged
in hermetic TO-46 transistor packages, while the LM35C, LM35CA, and LM35D are also available in
the plastic TO-92 transistor package. The LM35D is also available in an 8-lead surface mount small
outline package and a plastic TO-220 package

A sensor is a device that measures a physical quantity and converts it into a

signal which can be read by an observer or by an instrument. For example, a mercury-in-glass

thermometer converts the measured temperature into expansion and contraction of a liquid which can be

read on a calibrated glass tube. A thermocouple converts temperature to an output voltage which can be

read by a voltmeter. For accuracy, most sensors are calibrated against known standards.

FIG: LM35

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°Cat room temperature and ±3⁄4°C over a full −55 to +150°Ctemperature 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.

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).

The LM35 series is available packaged in hermetic TO-46 transistor packages, while theLM35C,
LM35CA, and LM35D are also available in the plastic TO-92 transistor package. The LM35D is also
available in an 8-lead surface mount small outline package and a plastic TO-220
package.M35 temperature sensor is used to co

1. Can be calibrated directly to the Celsius scale.

2. Linear scale factor + 10mV / ° C

3. The accuracy of 0.5 ° C. at room temperature (25 ° C).

4. Range of temperature between -55 ° C to 150 ° C.

5. Work on the voltage 4 volts to 30 volts.

6. Operating current less than 60μA.

7. Low output impedance 0.1 Ω for 1 mA load


LM35 works by changing the temperature into voltage. Ideal voltage coming out of the LM35
has a ratio of 100 ° C is equal to 1 volt. This sensor has a self-heating (self heating) of less than 0.1 °
C, can be operated using a single power supply.

Although the voltage sensor can reach 30 volts but given to sensor is at 5 volts, so it can be
used with single power supply with the provision that the LM35 only require a current
of 60 μA this means that LM35 has the ability to produce heat (self-heating) of the
sensor which can cause a low reading error is less than 0.5 º C at a temperature of25 º C.

USE:-

Sensors are used in everyday objects such as touch-sensitive elevator buttons (tactile sensor) and lamps
which dim or brighten by touching the base. There are also innumerable applications for sensors of which most
people are never aware. Applications include cars, machines, aerospace, medicine, manufacturing and robotics.

A sensor is a device which receives and responds to a signal. A sensor's sensitivity indicates how much
the sensor's output changes when the measured quantity changes. For instance, if the mercury in a
thermometer moves 1 cm when the temperature changes by 1 °C, the sensitivity is 1 cm/°C (it is basically the
slope Dy/Dx assuming a linear characteristic). Sensors that measure very small changes must have very high
sensitivities. Sensors also have an impact on what they measure; for instance, a room temperature
thermometer inserted into a hot cup of liquid cools the liquid while the liquid heats the thermometer. Sensors
need to be designed to have a small effect on what is measured, making the sensor smaller often improves this
and may introduce other advantages. Technological progress allows more and more sensors to be
manufactured on a microscopic scale as micro sensors using MEMS technology. In most cases, a micro sensor
reaches a significantly higher speed and sensitivity compared with macroscopic approaches.

Thermistors are the most common temperature sensors you'll run across they're just temperature-sensitive
resistors (resistance goes down as temperature goes up). The internal chemistry of thermistors is quite tailor
able -- this allows manufacturers to make thermistors with a wide selection of temperature sensing ranges.

Note that thermistors tend to exhibit a fair amount of variability from unit to unit. So if you're using a pair of
thermistors to give your 'bot the ability to find warm or cool areas, you'll want to incorporate a potentiometer to
allow you to "tune" their response a bit (or else, buy a number of thermistors and attempt to find a "matching"
pair).

AD-590s are temperature sensing integrated circuits which output a current proportional to temperature.
While more expensive than thermistors (about $5 US each, vs. a few cents for a thermistor), they are also much
more accurate. This allows you to dispense with matching and tuning should you be using temperature sensors
as a "homing" device.

There are four main temperature-sensing devices available: thermocouples,


resistance temperature detectors (RTDs), thermistors, and temperature-transducing ICs. These sensors
translate the temperature into a reference voltage, resistance or current, which is then measured and
processed and a numerical temperature value is computed.

Types of temperature sensor

Thermocouples

Thermocouples are a physically simple sensor, though how they function is more complex. Figure 1
shows the basic wiring of a thermocouple. A thermocouple is comprised of two dissimilar alloys (wires
A and B) joined at one end, called the “hot junction” (T1). The other leads are connected to a voltmeter
or other input device that measures the voltage (V1) across the '“cold junction” (T2).
The hot junction is the sensing element, and the cold junction is kept at a constant reference
temperature. A voltage is produced as the hot junction is heated, which is proportional to the
temperature difference between the two junctions. This principle, called the thermocouple effect was
discovered by Thomas See beck in 1821 (Awtrey, 2001). And so, the electromotive force (EMF)
produced when the junctions of dissimilar alloys are maintained at different temperatures is known as
the See beck EMF. The theory behind the thermocouple and thermoelectric effect is based upon the
atomic structure of the alloys and is beyond the scope of this report. The voltage is also dependent
upon the type of conductors used. Different alloys produce distinct voltages; therefore standards have
been established to facilitate reliability and repeatability. There exist eight standardized alloy
combinations, each referenced by a letter: B, E, J, K, R, S, T, and N.

The See beck EMF produced by a thermocouple is of such small scale that the voltage must be
amplified and processed by a specialized thermocouple input module.

Thermocouples are calibrated with a cold junction temperature of 0°C. However, two problems arise
when connecting thermocouples to their input device: firstly, the input terminals, which are
constructed with a different type of metal, create their own See beck voltage which alters the actual
thermocouple voltage; and second, the device has to be recalibrated for an operational cold
junction temperature. With the advancements in technology over the past few decades, these input
modules have been designed to be self-calibrating and self-compensating and are able to be configured
for a variety of thermocouple types.
Resistance temperature detectors (RTDs)

Resistance temperature devices, known as RTDs, are constructed by winding a fine metal wire around
a glass or ceramic cylinder, then a coating of glass or ceramic is applied to insulate the coil. RTDs
function on the principle that as the sensing element is heated, the resistance of the metal wire
increases proportionally. RTDs are commonly made with copper, nickel, or nickel-iron, but platinum
RTDs are the most linear, repeatable, and stable. The resistance is almost a linear function
of temperature for very pure platinum, which is the primary reason for this metal’s pervasiveness in
RTDs.

RTDs are calibrated to exhibit a resistance of 100 Ω at 0°C. Their resistance at other temperatures
depends on the value of the mean slope of the metal’s resistance-temperature plot, known as
the constant alpha. Alpha is dependent upon the platinum’s purity. Although RTDs are fairly linear,
advanced RTD input devices use software with curve fitting and software processing to increase
their accuracy at higher temperatures.

Thermistors:

Thermistors, like RTDs, vary their resistance as the ambient temperature is changed. Unlike RTDs,
which use pure metals, the material used in a thermistor is generally a ceramic or polymer.
Positive temperature coefficient (PTC) thermistors will show an increase of resistance with
increasing temperature, while negative temperature coefficient (NTC) thermistors will show a decrease
of resistance with increasing of temperature. Comprised of a metal oxide ceramic semiconductor
sensing element, thermistors are notorious for their non-linearity, which engineers often dampen by
implementing pairs of offsetting thermistors, providing a more linear output.
These temperature dependent resistors are highly sensitive to temperature change. Thermistors vary
their resistance about -4.4% at 25°C when heated by one degree Celsius (Ogden, 2000). Since
thermistors are resistive devices, in operation an electrical current is passed through the sensor. Some
of this electricity is converted into heat, which may cause slightly higher than ambient
temperature readings. Thermistors can operate without significant error with long lead wires, because
of their high base resistance. Thus they can be installed at long distances, upwards of one hundred
metres, from the input module. Thermistor resistances are non-standardized and vary from 100 to
1,000,000 Ω at 25°C (Ogden, 2000).

Temperature-transducer ICs:

Semiconductor temperature sensors are produced in the form of ICs. Their design results from the
fact that semiconductor diodes have temperature-sensitive voltage vs. current characteristics. When
two identical transistors are operated at a constant ratio of collector current densities, the difference in
base-emitter voltages is directly proportional to the absolute temperature.

The use of IC temperature sensors is limited to applications where the temperature is within a –55° to
150°C range. The measurement range of IC temperature sensors may be small compared to that of
thermocouples and RTDs, but they have several advantages: they are small, accurate, and inexpensive.

Temperature sensing ICs are available either in analog form, which output a voltage or current which
is proportional to the temperature, or digital, which communicate temperature over a digital
communication line, such as one-wire PWM, two-wire I2C, or a multiple wire SPI connection.

Projects That Use Temperature Sensors

The Sonic City project developed a wearable system that creates music based on data from sensors
measuring bodily and environmental factors. This includes environmental temperature measurements.
A video summarizing the project is linked to in the media section below, and Viktoria site for the
project has a more detailed description.

Sound Kitchen includes temperature sensors and uses voltage changes in liquids to create music. The
liquids include wine, soda and other items you might find in a kitchen, and the over all aesthetic
connects strongly with cooking.
Comparison of temperature sensor types

The following table offers a comparison of the different characteristics of the various
temperature sensor types.

Temperature
Characteristic Platinum RTD Thermistor Thermocouple
IC

Active Metal Oxide Silicon


Platinum Wire Two Dissimilar Metals
Material Ceramic Transistors

Changing Voltage or
Resistance Resistance Voltage
Parameter Current

Temperature
-200°C to 500°C -40°C to 260°C -270°C to 1750°C -55°C to 150°C
Range

~1 mv/°C or ~1
Sensitivity 2 mv/°C 40 mV/°C 0.05 mV/°C
uA/°C

-45 to 100°C: ±0.5°C; -45 to 100°C: 0 to 275°C: ±1.5 °C to


Accuracy 100 to 500°C: ±1.5°C; ±0.5°C; degrades ±4°C; 275 to 1260°C: ±2 °C
500 to 1200°C: ±3°C rapidly over 100°C ±0.5 to ±0.75%

Linearity Excellent Logarithmic, Poor Moderate Excellent

Response Time 2-5 s 1-2 s 2-5 s

Stability Excellent Moderate Poor Excellent

Base Value 100 Ω to 2 kΩ 1 kΩ to 1 MΩ < 10 mV Various

Noise
Low Low High High
Susceptibility

+/- 0.2 to 0.5°F per


Drift +/- 0.01% for 5 years 1 to 2°F per year 0.1°C per month
year
Special
Lead Compensation Linearization Reference Junction None
Requirements

Device Cost $60 - $215 $10 - $350 $20 - $235 $5 - $50

Relative
Moderate Low to Moderate Moderate Low
System Cost

Features
 Calibrated directly in ° Celsius (Centigrade)
 Linear + 10.0 mV/°C scale factor
 0.5°C accuracy guarantee able (at +25°C)
 Rated for full -55° to +150°C range
 Suitable for remote applications
 Low cost due to wafer-level trimming
 Operates from 4 to 30 volts
 Less than 60 µA current drain
 Low self-heating, 0.08°C in still air
 Nonlinearity only ±¼°C typical
 Low impedance output, 0.1 Ohm for 1 mA load

HC Serial Bluetooth Products


User Instructional Manual

1 Introduction
HC serial Bluetooth products consist of Bluetooth serial interface module and Bluetooth adapter, such
as:
(1) Bluetooth serial interface module:
Industrial level: HC-03, HC-04(HC-04-M, HC-04-S)
Civil level: HC-05, HC-06(HC-06-M, HC-06-S)

HC-05-D, HC-06-D (with baseboard, for test and evaluation)


(2) Bluetooth adapter:
HC-M4
HC-M6
This document mainly introduces Bluetooth serial module. Bluetooth serial module is used for
converting serial port to Bluetooth. These modules have two modes: master and slaver device. The
device named after even number is defined to be master or slaver when out of factory and can’t be
changed to the other mode. But for the device named after odd number, users can set the work mode
(master or slaver) of the device by AT commands.
HC-04 specifically includes:
Master device: HC-04-M, M=master
Slave device: HC-04-S, S=slaver
The default situation of HC-04 is slave mode. If you need master mode, please state it clearly or
place an order for HC-O4-M directly.The naming rule of HC-06 is same.
When HC-03 and HC-05 are out of factory, one part of parameters are set for activating the device.
The work mode is not set, since user can set the mode of HC-03, HC-05 as they want.
The main function of Bluetooth serial module is replacing the serial port line, such as:
1. There are two MCUs want to communicate with each other. One connects to Bluetooth master

device while the other one connects to slave device. Their connection can be built once the pair is made.

This Bluetooth connection is equivalently liked to a serial port line connection including RXD, TXD
signals. And they can use the Bluetooth serial module to communicate with each other.
2. When MCU has Bluetooth salve module, it can communicate with Bluetooth adapter of
computers and smart phones. Then there is a virtual communicable serial port line between MCU and
computer or smart phone.
3. The Bluetooth devices in the market mostly are salve devices, such as Bluetooth printer,
Bluetooth GPS. So, we can use master module to make pair and communicate with them.
Bluetooth Serial module’s operation doesn’t need drive, and can communicate with the other
Bluetooth device who has the serial. But communication between two Bluetooth modules requires at
least two conditions:
(1) The communication must be between master and slave.
(2) The password must be correct.
However, the two conditions are not sufficient conditions. There are also some other conditions
basing on different device model. Detailed information is provided in the following chapters.
In the following chapters, we will repeatedly refer to Linvor’s (Formerly known as Guangzhou HC

Information Technology Co., Ltd.) material and photos.

2 Selection of the Module


The Bluetooth serial module named even number is compatible with each other; The salve module
is also compatible with each other. In other word, the function of HC-04 and HC-06, HC-03 and HC-05
are mutually compatible with each other. HC-04 and HC-06 are former version that user can’t reset the
work mode (master or slave). And only a few AT commands and functions can be used, like reset the
name of Bluetooth (only the slaver), reset the password, reset the baud rate and check the version
number. The command set of HC-03 and HC-05 are more flexible than HC-04 and HC-06’s. Generally,
the Bluetooth of HC-03/HC-05 is recommended for the user.
Here are the main factory parameters of HC-05 and HC-06. Pay attention to the differences:

HC-05 HC-06
Master and slave mode can be switched Master and slave mode can’t be switched
Bluetooth name: HC-05 Bluetooth name: linvor
Password:1234 Password:1234
Master role: have no function to remember the last
paired salve device. It can be made paired to any
slave device. In other words, just set Master role: have paired memory to remember
AT+CMODE=1 when out of factory. If you want last slave device and only make pair with that
HC-05 to remember the last paired slave device device unless KEY (PIN26) is triggered by high
address like HC-06, you can set AT+CMODE=0 level. The default connected PIN26 is low level.
after paired with the other device. Please refer the
command set of HC-05 for the details.
Pairing: The master device can not only make pair
with the specified Bluetooth address, like
cell-phone, computer adapter, slave device, but Pairing: Master device search and make pair with
also can search and make pair with the slave the slave device automatically.
device automatically. Typical method: On some specific conditions,
Typical method: On some specific conditions, master and slave device can make pair with each
master device and slave device can make pair with other automatically.
each other automatically. (This is the default
method.)
Multi-device communication: There is only point Multi-device communication: There is only point
to point communication for modules, but the to point communication for modules, but the
adapter can communicate with multi-modules. adapter can communicate with multi-modules.
AT Mode 1: After power on, it can enter the AT
mode by triggering PIN34 with high level. Then
the baud rate for setting AT command is equal to

the baud rate in communication, for example: AT Mode: Before paired, it is at the AT mode.
9600.
AT mode 2: First set the PIN34 as high level, or After paired it’s at transparent communication.
while on powering the module set the PIN34 to be
high level, the Baud rate used here is 38400 bps.
Notice: All AT commands can be operated only
when the PIN34 is at high level. Only part of the
AT commands can be used if PIN34 doesn’t keep
the high level after entering to the AT mode.
Through this kind of designing, set permissions for
the module is left to the user’s external control
circuit, that makes the application of HC-05 is very
flexible.

During the process of communication, the module


can enter to AT mode by setting PIN34 to be high
level. By releasing PIN34, the module can go back During the communication mode, the module
to communication mode in which user can inquire can’t enter to the AT mode.
some information dynamically. For example, to
inquire the pairing is finished or not.
Default communication baud rate: 9600, Default communication baud rate: 9600,
4800-1.3M are settable. 1200-1.3M are settable.
KEY: PIN34, for entering to the AT mode. KEY: PIN26, for master abandons memory.
LED1: PIN31, indicator of Bluetooth mode. Slow
flicker (1Hz) represents entering to the AT mode2,
while fast flicker(2Hz) represents entering to the LED: The flicker frequency of slave device is
AT mode1 or during the communication pairing. 102ms. If master device already has the memory
Double flicker per second represents pairing is of slave device, the flicker frequency during the
finished, the module is communicable. pairing is 110ms/s. If not, or master has emptied
LED2: PIN32, before pairing is at low level, after the memory, then the flicker frequency is 750m/s.
the pairing is at high level. After pairing, no matter it’s a master or slave
The using method of master and slaver’s indicator device, the LED PIN is at high level.
is the same. Notice: The LED PIN connects to LED+ PIN.
Notice: The PIN of LED1 and LED2 are connected
with LED+.
Consumption: During the pairing, the current is Consumption: During the pairing, the current is
fluctuant in the range of 30-40mA. The mean fluctuant in the range of 30-40 m. The mean
current is about 25mA. After paring, no matter current is about 25mA. After paring, no matter
processing communication or not, the current is processing communication or not, the current is
8mA. There is no sleep mode. This parameter is 8mA. There is no sleep mode. This parameter is
same for all the Bluetooth modules. same for all the Bluetooth modules.
Reset: PIN11, active if it’s input low level. It can Reset: PIN11, active if it’s input low level. It can
be suspended in using. be suspended in using.
Level: Civil Level: Civil
The table above that includes main parameters of two serial modules is a reference for user
selection.
HC-03/HC-05 serial product is recommended.

3. Information of Package
The PIN definitions of HC-03, HC-04, HC-05 and HC-06 are kind of different, but the package size
is the same: 28mm * 15mm * 2.35mm.
The following figure 1 is a picture of HC-06 and its main PINs. Figure 2 is a picture of HC-05 and
its main PINs. Figure 3 is a comparative picture with one coin. Figure 4 is their package size information.
When user designs the circuit, you can visit the website of Guangzhou HC Information Technology Co.,
Ltd. (www.wavesen.com) to download the package library of protle version.
Figure 1 HC-06 Figure 2 HC-05
Figure 3 Comparative picture with one coin
Figure 4 Package size information
4. The Using and Testing Method of HC-06 for the First Time
This chapter will introduce the using method of HC-06 in detail. User can test the module
according to this chapter when he or she uses the module at the first time.
PINs description:

PIN1 UART_TXD , TTL/CMOS level, UART Data output


PIN2 UART_RXD, TTL/COMS level, s UART Data input
RESET, the reset PIN of module, inputting low level can reset the module,
PIN11
when the module is in using, this PIN can connect to air.
VCC, voltage supply for logic, the standard voltage is 3.3V, and can work
PIN12
at 3.0-4.2V
PIN13 GND
PIN22 GND
LED, working mode indicator
Slave device: Before paired, this PIN outputs the period of 102ms square
wave. After paired, this PIN outputs high level.
Master device: On the condition of having no memory of pairing with a
PIN24
slave device, this PIN outputs the period of 110ms square wave. On the
condition of having the memory of pairing with a slave device, this PIN
outputs the period of 750ms square wave. After paired, this PIN outputs
high level.
For master device, this PIN is used for emptying information about
pairing. After emptying, master device will search slaver randomly, then
PIN26
remember the address of the new got slave device. In the next power on,
master device will only search this address.
(1) The circuit 1 (connect the module to 3.3V serial port of MCU) is showed by figure 5.

Figure 5 The circuit 1

In principle, HC-06 can work when UART_TXD, UART_RXD, VCC and GND are connected.
However, for better testing results, connecting LED and KEY are recommended (when testing the
master).
Where, the 3.3V TXD of MCU connects to HC-06’s UART_RXD, the 3.3V RXD of MCU connects
to HC-06’s UART_TXD, and 3.3V power and GND should be connected. Then the minimum system is
finished.
Note that, the PIN2:UART_RXD of Bluetooth module has no pull-up resistor. If the MCU TXD
doesn’t have pull-up function, then user should add a pull-up resistor to the UART_RXD. It may be easy
to be ignored.
If there are two MCU which connect to master and slave device respectively, then before
paired(LED will flicker) user can send AT commands by serial port when the system is power on. Please
refer to HC-04 and HC-06’s data sheet for detailed commands. In the last chapter, the command set will
be introduced. Please pay attention to that the command of HC-04/HC-06 doesn’t have terminator. For
example, consider the call command, sending out AT is already enough, need not add the CRLF
(carriage return line feed).
If the LED is constant lighting, it indicates the pairing is finished. The two MCUs can communicate

with each other by serial port. User can think there is a serial port line between two MCUs.
(2) The circuit 2 (connect the module to 5V serial port of MCU) is showed by figure 6.
Figure 6 is the block diagram of Bluetooth baseboard. This kind of circuit can amplify Bluetooth

module’s operating voltage to 3.1-6.5V. In this diagram, the J1 port can not only be connected with

MCU system of 3.3V and 5V, but also can be connected with computer serial port.

Figure 6 The circuit 2

(3) AT command test


Before paired, the mode of HC-04 and HC-06 are AT mode.
On the condition of 9600N81, OK will be received when user send the two letters AT. Please refer to the
last chapter of datasheet for other commands of HC-06. Please pay attention to that sending out AT is
already enough, need not add the CRLF (carriage return line feed).
The command set of Version V1.4 doesn’t include parity. The version V1.5 and its later version
have parity function. Moreover, there are three more commands of V1.5 than V1.4. They are:
No parity (default) AT+PN
Odd parity AT+PO

Even parity AT+PE

Do not let the sending frequency of AT command of HC-06 exceed 1Hz, because the command of

HC-06 end or not is determined by the time interval.

(4) Pairing with adapter


User can refer to the download center of the company’s website for “The Introduction of IVT” that
introduces the Bluetooth module makes pair with computer adapter. That document taking HC-06-D for
example introduces how the serial module makes pair with the adapter. That method is like to make pair
with cell-phone. But the difference is that cell-phone need a third-party communication software to help.
It’s liked the kind of PC serial helper of and the hyper terminal. A software named “PDA serial helper”
provided by our company is suitable for WM system. It has been proven that this serial module is
supported by many smart phone systems’ Bluetooth, such as, sybian, android, windows mobile and etc.

(5) Pairing introduction


HC-06 master device has no memory before the first use. If the password is correct, the mater
device will make pair with the slave device automatically in the first use. In the following use, the
master device will remember the Bluetooth address of the last paired device and search it. The searching
won’t stop until the device is found. If master device’s PIN26 is input high level, the device will lose the
memory. In that occasion, it’ll search the proper slave device like the first use. Based on this function,
the master device can be set to make pair with the specified address or any address by user.

(6) Reset new password introduction


User can set a new password for the HC-06 through AT+PINxxxx command. But the new password will

become active after discharged all the energy of the module. If the module still has any energy, the old one is

still active. In the test, for discharging all the system energy and activating the new password, we can connect

the power supply PIN with GND about 20 seconds after the power is cut off. Generally, shutting down the

device for 30 minutes also can discharge the energy, if there is no peripheral circuit helps discharge energy.

User should make the proper way according to the specific situation.
(7) Name introduction
If the device has no name, it’s better that user doesn’t try to change the master device name. The
name should be limited in 20 characters.
Summary: The character of HC-06: 1 not many command 2 easy for application 3 low price. It’s
good for some specific application. HC-04 is very similar with HC-06. Their only one difference is HC-
04 is for industry, HC-06 is for civil. Except this, they don’t have difference.
The following reference about HC-04 and HC-06 can be downloaded from company website
www.wavesen.com:
HC-06 datasheet .pdf (the command set introduction is included)
HC-04 datasheet .pdf (the command set introduction is included)
IVT BlueSoleil-2.6 (IVT Bluetooth drive test version)
Bluetooth FAQ.pdf
HC-04-D(HD-06-D)datasheet(English).pdf
HC-06-AT command software (test version) (some commands in V1.5 is not supported by V1.4)

PCB package of Bluetooth key modules (PCB package lib in protel)


IVT software manual.pdf (introduce how to operate the modern and make pair
with Bluetooth module)
PDA serial test helper.exe (serial helper used for WM system)

5 manual for the first use of HC-05


This chapter will introduce how to test and use the HC-05 if it’s the first time for user to operate it.
(1) PINs description

PIN1 UART_TXD, Bluetooth serial signal sending PIN, can connect with MCU’s RXD PIN
UART_RXD, Bluetooth serial signal receiving PIN, can connect with the MCU’s TXD PIN,
PIN2
there is no pull-up resistor in this PIN. But It needs to be added an eternal pull-up resistor.
RESET, the reset PIN of module, inputting low level can reset the module, when the module
PIN11
is in using, this PIN can connect to air.
PIN12 VCC, voltage supply for logic, the standard voltage is 3.3V, and can work at 3.0-4.2V
PIN13 GND
LED1, indicator of work mode. Has 3 modes:
When the module is supplied power and PIN34 is input high level, PIN31 output 1Hz square
wave to make the LED flicker slowly. It indicates that the module is at the AT mode, and the
baud rate is 38400;
When the module is supplied power and PIN34 is input low level, PIN31 output 2Hz square
wave to make the LED flicker quickly. It indicates the module is at the pairable mode. If
PIN31
PIN34 is input high level, then the module will enter to AT mode, but the output of PIN31 is
still 2Hz square wave.
After the pairing, PIN31 output 2Hz square ware.
Note: if PIN34 keep high level, all the commands in the AT command set can be in
application. Otherwise, if just excite PIN34 with high level but not keep, only some command
can be used. More information has provided at chapter 2.
Output terminal. Before paired, it output low level. Once the pair is finished, it output high
PIN32
level.
Mode switch input. If it is input low level, the module is at paired or communication mode. If
it’s input high level, the module will enter to AT mode. Even though the module is at
PIN34
communication, the module can enter to the AT mode if PIN34 is input high level. Then it will
go back to the communication mode if PIN34 is input low level again.
(2) Application circuit 1 (connect to the 3.3V system)
Figure 7 Application 1
(3) Application circuit 2 (connect to 5V serial system or PC serial)

Figure 8 Application circuit 2

(4) AT command test


This chapter introduces some common commands in use. The detail introduction about HC-05
command is in HC-0305 AT command set.
Enter to AT mode:
Way1: Supply power to module and input high level to PIN34 at the same time, the module will enter to
AT mode with the baud rate-38400.
Way2: In the first step, supply power to module; In the second step, input high level to PIN34. Then the
module will enter to AT mode with the baud rate-9600. Way1 is recommended.
Command structure: all command should end up with “\r\n” (Hex: 0X0D X0A) as the terminator. If
the serial helper is installed, user just need enter “ENTER” key at the end of command.

Reset the master-slave role command:


AT+ROLE=0 ----Set the module to be salve mode. The default mode is salve.
AT+ROLE=1 ----Set the module to be master mode.

Set memory command:


AT+CMODE=1
Set the module to make pair with the other random Bluetooth module (Not specified address). The
default is this mode.
AT+CMODE=1
Set the module to make pair with the other Bluetooth module (specified address). If set the module

to make pair with random one first, then set the module to make pair with the Bluetooth module has

specified address. Then the module will search the last paired module until the module is found.

Reset the password command


AT+PSWD=XXXX
Set the module pair password. The password must be 4-bits.

Reset the baud rate


AT+UART== <Param>,<Param2>,<Param3>.
More information is provided at HC-0305 command set
Example:
AT+UART=9600,0,0 ----set the baud rate to be 9600N81
Reset the Bluetooth name
AT+NAME=XXXXX

Summary:
HC-05 has many functions and covers all functions of HC-06. The above commands are the most

common ones. Besides this, HC-05 leaves lots of space for user. So HC-05 is better than HC-06 and
(the command set introduction is included)
(the command set introduction is included)
(IVT Bluetooth drive test version)

(PCB package lib in protel)

(introduce how to operate the modern and make pair with


Bluetooth module)

(serial helper used for WM system)

recommended. HC-03 is similar with HC-05. The above introduction also suits HC-03
The following reference about HC-03 and HC-05 can be downloaded from company website
www.wavesen.com:

HC-03 datasheet .pdf

HC-05 datasheet .pdf

IVT BlueSoleil-2.6

Bluetooth FAQ.pdf

PCB package of Bluetooth key modules

IVT software manual.pdf

PDA serial test helper.exe


HC-03/05 Bluetooth serial command set.pdf

6. Ordering information
The website of Guangzhou HC Information Technology Co., Ltd is www.wavesen.com The contact
information is provided at the company website.
Order Way: If you want our product, you can give order to the production center of our company
directly or order it in Taobao. There is a link to Taobao in our company website.
Package: 50 pieces chips in an anti-static blister package. The weight of a module is about 0.9g.

The weight of a package is about 50g.


Please provide the product’s model when you order: HC-04-M HC-04
master module
HC-04-S HC-04 slave module HC-06-M HC-06 master

module HC-06-S HC-06 slave module HC-03

HC-05 HC-03/05 can be preset to be master module or slave module.

Here is a simple project to control your Robot/Robo Car using Bluetooth Module HC-05 &
89c2051 Microcontroller with your Android Smartphone device.

Circuit diagram of Wireless Android Based Remote Control to control Robot / Robo Car
using 89C2051 and HC-05 Bluetooth Module

Download HEX File


(To save on your PC, right click on file choose "Save link as...")
LIQUID CRYSTAL DISPLAY:
LCD stands for Liquid Crystal Display. LCD is finding wide spread use replacing
LEDs (seven segment LEDs or other multi segment LEDs) because of the
following reasons:

1. The declining prices of LCDs.


2. The ability to display numbers, characters and graphics. This is in contrast to
LEDs, which are limited to numbers and a few characters.

3. Incorporation of a refreshing controller into the LCD, thereby relieving the


CPU of the task of refreshing the LCD. In contrast, the LED must be
refreshed by the CPU to keep displaying the data.

4. Ease of programming for characters and graphics.

These components are “specialized” for being used with the microcontrollers,
which means that they cannot be activated by standard IC circuits. They are used
for writing different messages on a miniature LCD.
A model described here is for its low price and great possibilities most frequently
used in practice. It is based on the HD44780 microcontroller (Hitachi) and can
display messages in two lines with 16 characters each. It displays all the alphabets,
Greek letters, punctuation marks, mathematical symbols etc. In addition, it is
possible to display symbols that user makes up on its own. Automatic shifting
message on display (shift left and right), appearance of the pointer, backlight etc.
are considered as useful characteristics.

Pins Functions

There are pins along one side of the small printed board used for connection to the
microcontroller. There are total of 14 pins marked with numbers (16 in case the background light
is built in). Their function is described in the table below:

Pin Logic
Function Name Description
Number State

Ground 1 Vss - 0V

Power supply 2 Vdd - +5V

Contrast 3 Vee - 0 – Vdd

Control of D0 – D7 are interpreted as


operating 0 commands
4 RS
1 D0 – D7 are interpreted as
data

5 R/W 0 Write data (from controller


1 to LCD)
Read data (from LCD to
controller)
0 Access to LCD disabled
1 Normal operating
6 E
From 1 Data/commands are
to 0 transferred to LCD

7 D0 0/1 Bit 0 LSB

8 D1 0/1 Bit 1

9 D2 0/1 Bit 2

Data / 10 D3 0/1 Bit 3


commands 11 D4 0/1 Bit 4

12 D5 0/1 Bit 5

13 D6 0/1 Bit 6

14 D7 0/1 Bit 7 MSB


LCD screen:

LCD screen consists of two lines with 16 characters each. Each character consists
of 5x7 dot matrix. Contrast on display depends on the power supply voltage and
whether messages are displayed in one or two lines. For that reason, variable
voltage 0-Vdd is applied on pin marked as Vee. Trimmer potentiometer is usually
used for that purpose. Some versions of displays have built in backlight (blue or
green diodes). When used during operating, a resistor for current limitation should
be used (like with any LE diode).
LCD Basic Commands
All data transferred to LCD through outputs D0-D7 will be interpreted as
commands or as data, which depends on logic state on pin RS:

RS = 1 - Bits D0 - D7 are addresses of characters that should be displayed.


Built in processor addresses built in “map of characters” and displays
corresponding symbols. Displaying position is determined by DDRAM
address. This address is either previously defined or the address of
previously transferred character is automatically incremented.

RS = 0 - Bits D0 - D7 are commands which determine display mode. List of


commands which LCD recognizes are given in the table below:

Execution
Command RS RW D7 D6 D5 D4 D3 D2 D1 D0
Time

Clear display 0 0 0 0 0 0 0 0 0 1 1.64Ms

Cursor home 0 0 0 0 0 0 0 0 1 x 1.64mS

Entry mode set 0 0 0 0 0 0 0 1 I/D S 40uS


Display on/off control 0 0 0 0 0 0 1 D U B 40uS

Cursor/Display Shift 0 0 0 0 0 1 D/C R/L x x 40uS

Function set 0 0 0 0 1 DL N F x x 40uS

Set CGRAM address 0 0 0 1 CGRAM address 40uS

Set DDRAM address 0 0 1 DDRAM address 40uS

Read “BUSY” flag (BF) 0 1 BF DDRAM address -

Write to CGRAM or
1 0 D7 D6 D5 D4 D3 D2 D1 D0 40uS
DDRAM

Read from CGRAM or


1 1 D7 D6 D5 D4 D3 D2 D1 D0 40uS
DDRAM
LCD Connection

Depending on how many lines are used for connection to the microcontroller, there
are 8-bit and 4-bit LCD modes. The appropriate mode is determined at the
beginning of the process in a phase called “initialization”. In the first case, the data
are transferred through outputs D0-D7 as it has been already explained. In case of
4-bit mode, for the sake of saving valuable I/O pins of the microcontroller, there
are only 4 higher bits (D4-D7) used for communication, while other may be left
unconnected.

Consequently, each data is sent to LCD in two steps: four higher bits are sent first
(that normally would be sent through lines D4-D7), four lower bits are sent
afterwards. With the help of initialization, LCD will correctly connect and interpret
each data received. Besides, with regards to the fact that data are rarely read from
LCD (data mainly are transferred from microcontroller to LCD) one more I/O pin
may be saved by simple connecting R/W pin to the Ground. Such saving has its
price.

Even though message displaying will be normally performed, it will not be


possible to read from busy flag since it is not possible to read from display.

LCD Initialization

Once the power supply is turned on, LCD is automatically cleared. This process
lasts for approximately 15mS. After that, display is ready to operate. The mode of
operating is set by default. This means that:

1. Display is cleared

2. Mode

DL = 1 Communication through 8-bit interface

N = 0 Messages are displayed in one line

F = 0 Character font 5 x 8 dots


3. Display/Cursor on/off

D = 0 Display off

U = 0 Cursor off

B = 0 Cursor blink off

4. Character entry

ID = 1 Addresses on display are automatically incremented by 1

S = 0 Display shift off

Automatic reset is mainly performed without any problems. If for any reason
power supply voltage does not reach full value in the course of 10mS, display will
start to perform completely unpredictably.

If voltage supply unit cannot meet this condition or if it is needed to provide


completely safe operating, the process of initialization by which a new reset
enabling display to operate normally must be applied.

Algorithm, according to the initialization, is being performed depends on whether


connection to the microcontroller is through 4- or 8-bit interface. All left over to be
done after that is to give basic commands and of course- to display messages.
Contrast control:
To have a clear view of the characters on the LCD, contrast should be
adjusted. To adjust the contrast, the voltage should be varied. For this, a
preset is used which can behave like a variable voltage device. As the
voltage of this preset is varied, the contrast of the LCD can be adjusted.
Potentiometer

Variable resistors used as potentiometers have all three terminals connected. This
arrangement is normally used to vary voltage, for example to set the switching
point of a circuit with a sensor, or control the volume (loudness) in an amplifier
circuit. If the terminals at the ends of the track are connected across the power
supply, then the wiper terminal will provide a voltage which can be varied from
zero up to the maximum of the supply.

Presets

These are miniature versions of the standard variable resistor. They are designed to
be mounted directly onto the circuit board and adjusted only when the circuit is
built. For example, to set the frequency of an alarm tone or the sensitivity of a
light-sensitive circuit, a small screwdriver or similar tool is required to adjust
presets.

Presets are much cheaper than standard variable resistors so they are sometimes
used in projects where a standard variable resistor would normally be used.
Multiturn presets are used where very precise adjustments must be
made. The screw must be turned many times (10+) to move the slider from
one end of the track to the other, giving very fine control.
J10
C O N 16

VC C
lcd
12
13
14
15
1
2
3
4
5
6

11

16

10K .

VC C LPC2148
0 U 1

1 6 4
2 P 0 .2 1 /P W M 5 /A D 1 .6 /C A P 1 .3 P 1 .2 7 /T D 0 6 2
3 P 0 .2 2 /A D 1 .7 /C A P 0 .0 /M A T 0 .0 VR EF 6 2 Y 1
4 R TC X1 XTA L1 6 1
5 P 1 .1 9 /T R A C E P K T 3 XTA L2 6 0
6 R TC X2 P 1 .2 8 /T D 5 9
7 v ss VSSA 5 8
8 v dd P 0 .2 3 /V B U S 5 7
33 pF 12Mhz
VC C
9 P 1 .1 8 /T R A C E P K T 2 R ESET 5 6
1 0 P 0 .2 5 /A D 0 .4 /A O U T P 1 .2 9 /T C K 5 5 33 pF
1 1 D + P 0 .2 0 /M A T1 .3 /S S E L 1 /E IN T 3 5 4
1 2 D - P 0 .1 9 /M A T 1 .2 /M O S I1 /C A P 1 .2 5 3 SW 2
1 3 P 1 .1 7 /T R A C E P K T 1 P 0 .1 8 /C A P 1 .3 /M IS O 1 /M A T 1 .3 5 2 1 0 u F /1 6 V
1 4 P 0 .2 8 /A D 0 .1 /C A P 0 .2 /M A T 0 .2 P 1 .3 0 /T M S 5 1
1 5 P 0 .2 9 /A D 0 .2 /C A P 0 .3 /M A T 0 .3 VD D 5 0
1 6 P 0 .3 0 /A D 0 .3 /E IN T 3 /C A P 0 .0 VSS 4 9
1 7 P 1 .1 6 /T R A C E P K T 0 VBAT 4 8
1 8 P 0 .3 1 /U P _ L E D /C O N N E C T P 1 .2 0 /T R A C E S Y N C 4 7
1 9 V SS P 0 .1 7 /C A P 1 .2 /S C K 1 /M A T1 .2 4 6
8.2k
2 0 P 0 .0 /T X D 0 /P W M 1 P 0 .1 6 /E IN T 0 /M A T 0 .2 /C A P 0 .2 4 5
2 1 P 1 .3 1 /T R S T P 0 .1 5 /R I1 /E IN T 2 /A D 1 .5 4 4
2 2 P 0 .1 /R XD 0 /P W M 3 /E IN T 0 P 1 .2 1 /P IP E S T A T 0 4 3
2 3 P 0 .2 /S C L 0 /C A P 0 .0 VD D 4 2
2 4 V D D VSS 4 1
2 5 P 1 .2 6 /R T C K P 0 .1 4 /D C D 1 /E IN T 1 /S D A 1 4 0
2 6 V SS P 1 .2 2 /P IP E S T A T 1 3 9
2 7 P 0 .3 /S D A 0 /M A T 0 .0 /E IN T 1 P 0 .1 3 /D T R 1 /M A T 1 .1 /A D 1 .4 3 8
2 8 P 0 .4 /S C K 0 /C A P 0 .1 /A D 0 .6 P 0 .1 2 /D S R 1 /M A T 1 .0 /A D 1 .3 3 7
2 9 P 1 .2 5 /E X T IN 0 P 0 .1 1 /C T S 1 /C A P 1 .1 /S C L 1 3 6
3 0 P 0 .5 /M IS O 0 /M A T 0 .1 /A D 0 .7 P 1 .2 3 /P IP E S T A T 2 3 5
3 1 P 0 .6 /M O S I0 /C A P 0 .2 /A D 1 .0 P 0 .1 0 /R T S 1 /C A P 1 .0 /A D 1 .2 3 4
3 2 P 0 .7 /S S E L 0 /P W M 2 /E IN T 2 P 0 .9 /R XD 1 /P W M 6 /E IN T 3 3 3
P 1 .2 4 /T R A C E C L K P 0 .8 /T X D 1 /P W M 4 /A D 1 .1

Fig. LCD Interfacing with LPC2148 (4-bit mode)

SOFTWAR EXPLANATION
6.1 ABOUT KEIL SOFTWARE
Software’s used are:
*Keil software for c programming

*Express PCB for lay out design

*Express SCH for schematic design

What's New in µVision4?

µVision3 adds many new features to the Editor like Text Templates, Quick
Function Navigation, and Syntax Coloring with brace high lighting Configuration
Wizard for dialog based startup and debugger setup. µVision3 is fully compatible
to µVision4 and can be used in parallel with µVision4.

What is µVision4?

µVision3 is an IDE (Integrated Development Environment) that helps you write,


compile, and debug embedded programs. It encapsulates the following
components:

 A project manager.
 A make facility.
 Tool configuration.
 Editor.
 A powerful debugger.
To help you get started, several example programs (located in the
\C51\Examples, \C251\Examples, \C166\Examples, and \ARM\...\Examples) are
provided.
 HELLO is a simple program that prints the string "Hello World" using the
Serial Interface.
 MEASURE is a data acquisition system for analog and digital systems.
 TRAFFIC is a traffic light controller with the RTX Tiny operating system.
 SIEVE is the SIEVE Benchmark.
 DHRY is the Dhrystone Benchmark.
 WHETS is the Single-Precision Whetstone Benchmark.
Additional example programs not listed here are provided for each device
architecture.

Building an Application in µVision4

To build (compile, assemble, and link) an application in µVision4, you must:

1. Select Project -(forexample,166\EXAMPLES\HELLO\HELLO.UV4).


2. Select Project - Rebuild all target files or Build target.
µVision4 compiles, assembles, and links the files in your project.

KEIL SOFTWARE TOOL (STEPS)

Click on the Keil uVision Icon on DeskTop

1. The following fig will appear


2. Click on the Project menu from the title bar

3. Then Click on New Project

4. Save the Project by typing suitable project name with no extension in u r own folder
sited in either C:\ or D:\
5. Then Click on Save button above.

6. Select the component for u r project. i.e. Atmel……

7. Click on the + Symbol beside of Atmel

8. Select AT89C52 as shown below


9. Then Click on “OK”

10. The Following fig will appear

11. Then Click either YES or NO………mostly “NO”

12. Now your project is ready to USE


13. Now double click on the Target1, you would get another option “Source group 1” as
shown in next page.

14. Click on the file option from menu bar and select “new”

15. The next screen will be as shown in next page, and just maximize it by double
clicking on its blue boarder.
16. Now start writing program in either in “C” or “ASM”

17. For a program written in Assembly, then save it with extension “. asm” and for “C”
based program save it with extension “ .C”

18. Now right click on Source group 1 and click on “Add files to Group Source”
19. Now you will get another window, on which by default “C” files will appear.

20. Now select as per your file extension given while saving the file

21. Click only one time on option “ADD”

22. Now Press function key F7 to compile. Any error will appear if so happen.
23. If the file contains no error, then press Control+F5 simultaneously.

24. The new window is as follows

25. Then Click “OK”

26. Now Click on the Peripherals from menu bar, and check your required port as shown
in fig below
27. Drag the port a side and click in the program file.

28. Now keep Pressing function key “F11” slowly and observe.
29. You are running your program successfully

You might also like