You are on page 1of 29

CHAPTER-3

HARDWARE DESCRIPTION
3.1 RESISTORS
The flow of charge (or current) through any material, encounters an opposing force
similar in many respect to mechanical friction. This opposing force is calLCD resistance
of the material. It is measured in ohms. In some electric circuits resistance is deliberately
introduced in the form of the resistor.
Resistors are of following types:
1. Wire wound resistors.
2. Carbon resistors.
3. Metal film resistors.

3.2 CAPACITORS
A capacitor can store charge, and its capacity to store charge is calLCD capacitance.
Capacitors consist of two conducting plates, separated by an insulating material (known
as dielectric). The two plates are joined with two leads. The dielectric could be air, mica,
paper, ceramic, polyester, polystyrene, etc. This dielectric gives name to the capacitor.
Like paper capacitor, mica capacitor etc.
3.3 ATMEGA16A
A microcontroller often serves as the brain of a mechatronic system. Like a mini, selfcontained computer, it can be programmed to interact with both the hardware of the
system and the user. Even the most basic microcontroller can perform simple math
operations, control digital outputs, and monitor digital inputs. As the computer industry
has evolved, so has the technology associated with microcontrollers. Newer
microcontrollers are much faster, have more memory, and have a host of input and output
features that dwarf the ability of earlier models. Most modern controllers have analog-todigital converters, high-speed timers and counters, interrupt capabilities, outputs that can
be pulse-width modulated, serial communication ports, etc.

The ATmega16 microcontroller used in this lab is a 40-pin wide DIP (Dual In Line)
package chip. This chip was selected because it is robust, and the DIP package interfaces
with prototyping Introduction to the ATmega16 Atmel - 2 San Jos State University
Dept. of Mechanical and Aerospace Engineering rev. 3.4 06SEP2010 supplies like
solderless bread boards and solder-type perf-boards. This same microcontroller is
available in a surface mount package, about the size of a dime. Surface mount devices are
more useful for circuit boards built for mass production. Figure 1 below shows the pinout diagram of the ATmega16. This diagram is very useful, because it tells you where
power and ground should be connected, which pins tie to which functional hardware, etc.

FIG-3.1
3.3.1 Pin Descriptions

VCC Digital supply voltage.

GND Ground.

Port A (PA7:PA0) Port A serves as the analog inputs to the A/D Converter. Port A
also serves as an 8-bit bi-directional I/O port, if the A/D Converter is not used. Port
pins can provide internal pull-up resistors (selected for each bit). The Port A output
buffers have symmetrical drive characteristics with both high sink and source
capability. When pins PA0 to PA7 are used as inputs and are externally pulled low,
they will source current if the internal pull-up resistors are activated. The Port A pins
are tri-stated when a reset condition becomes active, even if the clock is not running.

Port B (PB7:PB0) Port B is an 8-bit bi-directional I/O port with internal pull-up
resistors (selected for each bit). The Port B output buffers have symmetrical drive
characteristics with both high sink and source capability. As inputs, Port B pins that
are externally pulled low will source current if the pull-up resistors are activated. The
Port B pins are tri-stated when a reset condition becomes active, even if the clock is
not running. Port B also serves the functions of various special features of the
ATmega16A.

Port C (PC7:PC0) Port C is an 8-bit bi-directional I/O port with internal pull-up
resistors (selected for each bit). The Port C output buffers have symmetrical drive
characteristics with both high sink and source capability. As inputs, Port C pins that
are externally pulled low will source current if the pull-up resistors are activated. The
Port C pins are tri-stated when a reset condition becomes active, even if the clock is
not running. If the JTAG interface is enabled, the pull-up resistors on pins PC5(TDI),
PC3(TMS) and PC2(TCK) will be activated even if a reset occurs. Port C also serves
the functions of the JTAG interface.

Port D (PD7:PD0) Port D is an 8-bit bi-directional I/O port with internal pull-up
resistors (selected for each bit). The Port D output buffers have symmetrical drive
characteristics with both high sink and source capability. As inputs, Port D pins that
are externally pulled low will source current if the pull-up resistors are activated. The

Port D pins are tri-stated when a reset condition becomes active, even if the clock is
not running.

RESET Reset Input. A low level on this pin for longer than the minimum pulse
length will generate a reset, even if the clock is not running.. Shorter pulses are not
guaranteed to generate a reset.

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

XTAL2 Output from the inverting Oscillator amplifier.

AVCC AVCC is the supply voltage pin for Port A and the A/D Converter. It should be
externally connected to VCC, even if the ADC is not used. If the ADC is used, it
should be connected to VCC through a low-pass filter.

AREF AREF is the analog reference pin for the A/D Converter.

3.3.1 BLOCK DIAGRAM

FIG-3.2
3.3.2 AVR CPU
This section discusses the AVR core architecture in general. The main function of the
CPU core is to ensure correct program execution. The CPU must therefore be able to
access memories, perform calculations, control peripherals, and handle interrupts.

Figure 3.3 Block Diagram of the AVR MCU Architecture


In order to maximize performance and parallelism, the AVR uses a Harvard architecture
with separate memories and buses for program and data. Instructions in the program
memory are executed with a single level pipelining. While one instruction is being
executed, the next instruction is pre-fetched from the program memory. This concept
enables instructions to be executed in every clock cycle. The program memory is In
System Reprogrammable Flash memory. The fast-access Register File contains 32 x 8-bit
general purpose working registers with a single clock cycle access time. This allows
single-cycle Arithmetic Logic Unit (ALU) operation. In a typical ALU operation, two
operands are output from the Register File, the operation is executed, and the result is
stored back in the Register File in one clock cycle. Six of the 32 registers can be used as
three 16-bit indirect address register pointers for Data Space addressing enabling
efficient address calculations. One of the these address pointers can also be used as an
address pointer for look up tables in Flash Program memory. These added function
registers are the 16-bit X-, Y-, and Z-register, described later in this section.
The ALU supports arithmetic and logic operations between registers or between a
constant and a register. Single register operations can also be executed in the ALU. After
an arithmetic operation, the Status Register is updated to reflect information about the

result of the operation. Program flow is provided by conditional and unconditional jump
and call instructions, able to directly address the whole address space. Most AVR
instructions have a single 16-bit word format. Every program memory address contains a
16- or 32-bit instruction. Program Flash memory space is divided in two sections, the
Boot program section and the Application Program section. Both sections have dedicated
Lock bits for write and read/write protection. The SPM instruction that writes into the
Application Flash memory section must reside in the Boot Program section. During
interrupts and subroutine calls, the return address Program Counter (PC) is stored on the
Stack. The Stack is effectively allocated in the general data SRAM, and consequently the
Stack size is only limited by the total SRAM size and the usage of the SRAM. All user
programs must initialize the SP in the reset routine (before subroutines or interrupts are
executed). The Stack Pointer SP is read/write accessible in the I/O space. The data SRAM
can easily be accessed through the five different addressing modes supported in the AVR
architecture.
3.3.2.1 ALU Arithmetic Logic Unit
The high-performance AVR ALU operates in direct connection with all the 32 general
purpose working registers. Within a single clock cycle, arithmetic operations between
general purpose registers or between a register and an immediate are executed. The ALU
operations are divided into three main categories arithmetic, logical, and bit-functions.
Some implementations of the architecture also provide a powerful multiplier supporting
both signed/unsigned multiplication and fractional format. See the Instruction Set
section for a detailed description.
3.3.2.2 Status Register
The Status Register contains information about the result of the most recently executed
arithmetic instruction. This information can be used for altering program flow in order to
perform conditional operations. Note that the Status Register is updated after all ALU
operations, as specified in the Instruction Set Reference. This will in many cases remove
the need for using the dedicated compare instructions, resulting in faster and more
compact code. The Status Register is not automatically stored when entering an interrupt
routine and restored when returning from an interrupt. This must be handled by software.

3.3.2.3 SREG AVR Status Register

Fig-3.4 SREG-AVR Status Register


Bit 7 I: Global Interrupt Enable
The Global Interrupt Enable bit must be set for the interrupts to be enabled. The
individual interrupt enable control is then performed in separate control registers. If the
Global Interrupt Enable Register is cleared, none of the interrupts are enabled
independent of the individual interrupt enable settings. The I-bit is cleared by hardware
after an interrupt has occurred, and is set by the RETI instruction to enable subsequent
interrupts. The I-bit can also be set and cleared by the application with the SEI and CLI
instructions, as described in the instruction set reference.
Bit 6 T: Bit Copy Storage
The Bit Copy instructions BLD (Bit LoaD) and BST (Bit STore) use the T-bit as source or
destination for the operated bit. A bit from a register in the Register File can be copied
into T by the BST instruction, and a bit in T can be copied into a bit in a register in the
Register File by the BLD instruction.
Bit 5 H: Half Carry Flag
The Half Carry Flag H indicates a Half Carry in some arithmetic operations. Half Carry is
useful in BCD arithmetic. See the Instruction Set Description for detailed information.

Bit 4 S: Sign Bit, S = N V

10

The S-bit is always an exclusive or between the Negative Flag N and the Twos
Complement Overflow Flag V. See the Instruction Set Description for detailed
information.
Bit 3 V: Twos Complement Overflow Flag
The Twos Complement Overflow Flag V supports twos complement arithmetics. See the
Instruction Set Description for detailed information.
Bit 2 N: Negative Flag
The Negative Flag N indicates a negative result in an arithmetic or logic operation. See
the Instruction Set Description for detailed information.
Bit 1 Z: Zero Flag
The Zero Flag Z indicates a zero result in an arithmetic or logic operation. See the
Instruction Set Description for detailed information.
Bit 0 C: Carry Flag
The Carry Flag C indicates a carry in an arithmetic or logic operation. See the
Instruction Set Description for detailed information.
3.3.2.3 Stack Pointer
The Stack is mainly used for storing temporary data, for storing local variables and for
storing return addresses after interrupts and subroutine calls. Note that the Stack is
implemented as growing from higher to lower memory locations. The Stack Pointer
Register always points to the top of the Stack. The Stack Pointer points to the data SRAM
Stack area where the Subroutine and Interrupt Stacks are located. A Stack PUSH
command will decrease the Stack Pointer. The Stack in the data SRAM must be defined
by the program before any subroutine calls are executed or interrupts are enabled. Initial
Stack Pointer value equals the last address of the internal SRAM and the Stack Pointer
must be set to point above start of the SRAM.
3.3.2.4 Instruction Execution Timing:

11

This section describes the general access timing concepts for instruction execution. The
AVR CPU is driven by the CPU clock clk CPU, directly generated from the selected
clock source for the chip. No internal clock division is used.

3.3.2.5 Reset and Interrupt Handling


The AVR provides several different interrupt sources. These interrupts and the separate
reset vector each have a separate program vector in the program memory space. All
interrupts are assigned individual enable bits which must be written logic one together
with the Global Interrupt Enable bit in the Status Register in order to enable the interrupt.
Depending on the Program Counter value, interrupts may be automatically disabled when
Boot Lock bits BLB02 or BLB12 are programmed. This feature improves software
security.
The lowest addresses in the program memory space are by default defined as the Reset
and Interrupt Vectors. The lower the address the higher is the priority level. RESET has
the highest priority, and next is INT0 the External Interrupt Request 0. The Interrupt
Vectors can be moved to the start of the Boot Flash section by setting the IVSEL bit in the

12

General Interrupt Control Register (GICR). When an interrupt occurs, the Global
Interrupt Enable I-bit is cleared and all interrupts are disabled. The user software can
write logic one to the I-bit to enable nested interrupts. All enabled interrupts can then
interrupt the current interrupt routine. The I-bit is automatically set when a Return from
Interrupt instruction RETI is executed. There are basically two types of interrupts.
The first type is triggered by an event that sets the Interrupt Flag. For these interrupts, the
Program Counter is vectored to the actual Interrupt Vector in order to execute the
interrupt handling routine, and hardware clears the corresponding Interrupt Flag. Interrupt
Flags can also be cleared by writing a logic one to the flag bit position(s) to be cleared. If
an interrupt condition occurs while the corresponding interrupt enable bit is cleared, the
Interrupt Flag will be set and remembered until the interrupt is enabled, or the flag is
cleared by software. Similarly, if one or more interrupt conditions occur while the Global
Interrupt Enable bit is cleared, the corresponding Interrupt Flag(s) will be set and
remembered until the global interrupt enable bit is set, and will then be executed by order
of priority. The second type of interrupts will trigger as long as the interrupt condition is
present. These interrupts do not necessarily have Interrupt Flags. If the interrupt condition
disappears before the interrupt is enabled, the interrupt will not be triggered. When the
AVR exits from an interrupt, it will always return to the main program and execute one
more instruction before any pending interrupt is served. Note that the Status Register is
not automatically stored when entering an interrupt routine, nor restored when returning
from an interrupt routine. This must be handled by software. When using the CLI
instruction to disable interrupts, the interrupts will be immediately disabled. No interrupt
will be executed after the CLI instruction, even if it occurs simultaneously with the CLI
instruction. The following example shows how this can be used to avoid interrupts during
the timed EEPROM write sequence.
3.4 L293D
The L293D works on the concept of typical H-bridge, a circuit which allows the high
voltage to be flown in either direction. In a single L293D IC there are two H-bridge
circuits which can rotate two DC motors independently. Due to its size and voltage
requirement, it is frequently used in robotics applications for controlling DC motors,
including in Arduino projects. The L293D is also a key component in larger 'motor driver'
boards available premade for hobbyists.

13

L293D is a dual H-bridge motor driver integrated circuit (IC). Motor drivers act as
current amplifiers since they take a low-current control signal and provide a highercurrent signal. This higher current signal is used to drive the motors.
L293D contains two inbuilt H-bridge driver circuits. In its common mode of operation,
two DC motors can be driven simultaneously, both in forward and reverse direction. The
motor operations of two motors can be controlled by input logic at pins 2 & 7 and 10 &
15. Input logic 00 or 11 will stop the corresponding motor. Logic 01 and 10 will rotate it
in clockwise and anticlockwise directions, respectively.
Enable pins 1 and 9 (corresponding to the two motors) must be high for motors to start
operating. When an enable input is high, the associated driver gets enabled. As a result,
the outputs become active and work in phase with their inputs. Similarly, when the enable
input is low, that driver is disabled, and their outputs are off and in the high-impedance
state.[9]
3.4.1 WORKING OF L293D
There are two drive pins on L293D. Pin 1 (left H-bridge) and pin 9 (right H-bridge). To
turn ON the corresponding motor, pin 1 or 9 need to be set to HIGH. If either pin 1 or pin
9 goes low then the motor in the corresponding section will go OFF (high impedance).
These inputs (1 and 9) are the ones that should be used to control motor START/STOP
and motor speed under PWM, since there would be high impedance output during low
semiperiod of PWM, it would not provoke overload of the L293D when the motor is
turning. Thus, PWM or motor ON/OFF control should never be input to pins 2, 7, 15, 10,
which should only be used to control direction (Clockwise - CounterClockwise).
The direction-defining four Input pins for the L293D are pin 2 and 7 on the left and pin
15 and 10 on the right as shown on the pin diagram. Left input pins will determine the
rotation of motor connected on the left side and right input for motor on the right hand
side. The motors are rotated on the basis of the inputs provided at the input pins as
LOGIC 1 or LOGIC 0.[9]
3.4.2 L293D LOGIC TABLE

14

Assuming a motor connected on left side output pins (pin 3,6).

Pin 2 = Logic 1 and Pin 7 = Logic 0 | Clockwise Direction

Pin 2 = Logic 0 and Pin 7 = Logic 1 | Anticlockwise Direction

Pin 2 = Logic 0 and Pin 7 = Logic 0 | Brake (this is not high impedance) (force
stop rotation using electric brake = same voltage both pins of the motor =
overload while the motor is still running)

Pin 2 = Logic 1 and Pin 7 = Logic 1 | Brake (this is not high impedance) (force
stop rotation using electric brake = same voltage both pins of the motor =
overload while the motor is still running)

In a similar way, the motor can be operated across input pins 15 and 10 to control the
direction of the motor attached to the H-bridges right side. Using pins 2 and 7 ( 15 and
10) to determine motor START/STOP or PWM duties it's dangerous, since there wouldn't
be high impedance outputs: Current would flow back during the low semiperiod of PWM
when the motor is turning. For on/off purposes or PWM speed control , pins 1 and 9
should be used.
3.4.3 VOLTAGE SPECIFICATIONS
The voltage (Vcc) needed to for its own working is 5V but L293d will not use that
Voltage to drive DC Motors. That means you should provide that voltage (36V maximum)
to drive the motors. A maximum current of 600mA per output is allowed.
3.4.4 PIN DIAGRAM

15

FIG-3.5: PIN DIAGRAM L293D


3.5 BLUETOOTH HC-05
The HC-05 Bluetooth Module can be used in a Master or Slave configuration, making it a
great solution for wireless communication.You can use it simply for a serial port
replacement to establish connection between MCU and GPS, PC to your embedded
project, etc.
Bluetooth is a wireless technology standard for exchanging data over short distances
(using short-wavelength UHF radio waves in the ISM band from 2.4 to 2.485 GHz[4])
from fixed and mobile devices, and building personal area networks (PANs). Invented by
telecom vendor Ericsson in 1994,[5] it was originally conceived as a wireless alternative
to RS-232 data cables. It can connect several devices, overcoming problems of
synchronization.
Bluetooth is managed by the Bluetooth Special Interest Group (SIG), which has more
than 25,000 member companies in the areas of telecommunication, computing,
networking, and consumer electronics.[6] The IEEE standardized Bluetooth as IEEE
802.15.1, but no longer maintains the standard. The Bluetooth SIG oversees development
of the specification, manages the qualification program, and protects the trademarks. [7] A
manufacturer must make a device meet Bluetooth SIG standards to market it as a
Bluetooth device. A network of patents apply to the technology, which are licensed to
individual qualifying devices.

FIG-3.6 BLUETOOTH HC-05

HC-05 Bluetooth Module

Protocol: Bluetooth Specification v2.0+EDR

16

Frequency: 2.4GHz ISM band

Modulation: GFSK

Emission power: 4dBm, Class 2

Sensitivity: -84dBm at 0.1% BER

Speed: Asynchronous: 2.1Mbps(Max) / 160 kbps, Synchronous: 1Mbps/1Mbps

Security: Authentication and encryption

Profiles: Bluetooth serial port

Power supply: +3.3VDC 50mA

Working temperature: -20 ~ +75 Centigrade

3.5.1 DESCRIPTION
The HC-05 Bluetooth Module has 6 pins- Vcc, GND, TX, RX, Key, and LED. It comes
pre-programmed as a slave, so there is no need to connect the Key pin, unless you need it
change it to Master Mode.
The major difference between Master and Slave modes is that, in Slave mode the
Bluetooth module cannot initiate a connection, it can however accept incoming
connections. After the connection is established the Bluetooth module can transmit and
receive data regardless of the mode it is running in. If you are using a phone to connect to
the Bluetooth module, you can simply use it in the Slave mode. The default data
transmission rate is 9600kbps.
The range for Bluetooth communication is usually 30m or less. The module has a factory
set pin of 1234 which is used while pairing the module to a phone.

FIG-3.7 HC-05 (Bottom View)


Pin Connections

17

Table-3.1 BLUETOOTH PIN CONNECTIONS


3.5.2 Pairing and bonding
Many services offered over Bluetooth can expose private data or let a connecting party
control the Bluetooth device. Security reasons make it necessary to recognize specific
devices, and thus enable control over which devices can connect to a given Bluetooth
device. At the same time, it is useful for Bluetooth devices to be able to establish a
connection without user intervention (for example, as soon as in range).
To resolve this conflict, Bluetooth uses a process called bonding, and a bond is generated
through a process called pairing. The pairing process is triggered either by a specific
request from a user to generate a bond (for example, the user explicitly requests to "Add a
Bluetooth device"), or it is triggered automatically when connecting to a service where
(for the first time) the identity of a device is required for security purposes. These two
cases are referred to as dedicated bonding and general bonding respectively.
Pairing often involves some level of user interaction. This user interaction confirms the
identity of the devices. When pairing successfully completes, a bond forms between the
two devices, enabling those two devices to connect to each other in the future without
repeating the pairing process to confirm device identities. When desired, the user can
remove the bonding relationship.
3.5.2.1 Implementation
During pairing, the two devices establish a relationship by creating a shared secret known
as a link key. If both devices store the same link key, they are said to be paired orbonded.
A

device

that

wants

to

communicate

only

with

bonded

device

can cryptographically authenticate the identity of the other device, ensuring it is the same
device

it

previously

paired

with.

Once

link

key

is

generated,

an

authenticated Asynchronous Connection-Less (ACL) link between the devices may


be encrypted to protect exchanged data against eavesdropping. Users can delete link keys

18

from either device, which removes the bond between the devicesso it is possible for
one device to have a stored link key for a device it is no longer paired with.
Bluetooth services generally require either encryption or authentication and as such
require pairing before they let a remote device connect. Some services, such as the Object
Push Profile, elect not to explicitly require authentication or encryption so that pairing
does not interfere with the user experience associated with the service use-cases.
3.5.2.2 Pairing mechanisms
Pairing mechanisms changed significantly with the introduction of Secure Simple Pairing
in Bluetooth v2.1. The following summarizes the pairing mechanisms:

Legacy pairing: This is the only method available in Bluetooth v2.0 and before.
Each device must enter a PIN code; pairing is only successful if both devices enter
the same PIN code. Any 16-byte UTF-8 string may be used as a PIN code;
however, not all devices may be capable of entering all possible PIN codes.

Limited input devices: The obvious example of this class of device is a


Bluetooth Hands-free headset, which generally have few inputs. These
devices usually have a fixed PIN, for example "0000" or "1234", that are
hard-coded into the device.

Numeric input devices: Mobile phones are classic examples of these


devices. They allow a user to enter a numeric value up to 16 digits in
length.

Alpha-numeric input devices: PCs and smartphones are examples of these


devices. They allow a user to enter full UTF-8 text as a PIN code. If
pairing with a less capable device the user must be aware of the input
limitations on the other device, there is no mechanism available for a
capable device to determine how it should limit the available input a user
may use.

Secure Simple Pairing (SSP): This is required by Bluetooth v2.1, although a


Bluetooth v2.1 device may only use legacy pairing to interoperate with a v2.0 or
earlier device. Secure Simple Pairing uses a form of public key cryptography, and
some types can help protect against man in the middle, or MITM attacks. SSP has
the following authentication mechanisms:

19

Just works: As the name implies, this method just works, with no user
interaction. However, a device may prompt the user to confirm the pairing
process. This method is typically used by headsets with very limited IO
capabilities, and is more secure than the fixed PIN mechanism this limited
set of devices uses for legacy pairing. This method provides no man-inthe-middle (MITM) protection.

Numeric comparison: If both devices have a display, and at least one can
accept a binary yes/no user input, they may use Numeric Comparison. This
method displays a 6-digit numeric code on each device. The user should
compare the numbers to ensure they are identical. If the comparison
succeeds, the user(s) should confirm pairing on the device(s) that can
accept an input. This method provides MITM protection, assuming the
user confirms on both devices and actually performs the comparison
properly.

Passkey Entry: This method may be used between a device with a display
and a device with numeric keypad entry (such as a keyboard), or two
devices with numeric keypad entry. In the first case, the display is used to
show a 6-digit numeric code to the user, who then enters the code on the
keypad. In the second case, the user of each device enters the same 6-digit
number. Both of these cases provide MITM protection.

Out of band (OOB): This method uses an external means of


communication, such as Near Field Communication (NFC) to exchange
some information used in the pairing process. Pairing is completed using
the Bluetooth radio, but requires information from the OOB mechanism.
This provides only the level of MITM protection that is present in the
OOB mechanism.

SSP is considered simple for the following reasons:

In most cases, it does not require a user to generate a passkey.

For use-cases not requiring MITM protection, user interaction can be eliminated.

For numeric comparison, MITM protection can be achieved with a simple equality
comparison by the user.

20

Using OOB with NFC enables pairing when devices simply get close, rather than
requiring a lengthy discovery process.

3.5.2.3 Security concerns


Prior to Bluetooth v2.1, encryption is not required and can be turned off at any time.
Moreover, the encryption key is only good for approximately 23.5 hours; using a single
encryption key longer than this time allows simple XOR attacks to retrieve the encryption
key.

Turning off encryption is required for several normal operations, so it is


problematic to detect if encryption is disabled for a valid reason or for a security
attack.

Bluetooth v2.1 addresses this in the following ways:

Encryption is required for all non-SDP (Service Discovery Protocol) connections

A new Encryption Pause and Resume feature is used for all normal operations that
require that encryption be disabled. This enables easy identification of normal
operation from security attacks.

The encryption key must be refreshed before it expires.

Link keys may be stored on the device file system, not on the Bluetooth chip itself. Many
Bluetooth chip manufacturers let link keys be stored on the devicehowever, if the
device is removable, this means that the link key moves with the device.
3.6 DC MOTOR
A DC motor is any of a class of electrical machines that converts direct current electrical
power into mechanical power. The most common types rely on the forces produced by
magnetic fields. Nearly all types of DC motors have some internal mechanism, either
electromechanical or electronic, to periodically change the direction of current flow in
part of the motor. Most types produce rotary motion; a linear motor directly produces
force and motion in a straight line.[3]
DC motors were the first type widely used, since they could be powered from existing
direct-current lighting power distribution systems. A DC motor's speed can be controlled
over a wide range, using either a variable supply voltage or by changing the strength of
current in its field windings. Small DC motors are used in tools, toys, and appliances. The

21

universal motor can operate on direct current but is a lightweight motor used for portable
power tools and appliances. Larger DC motors are used in propulsion of electric vehicles,
elevator and hoists, or in drives for steel rolling mills. The advent of power electronics
has made replacement of DC motors with AC motors possible in many applications. [3]
3.6.1 ELECTROMAGNETIC MOTORS
A coil of wire with a current running through it generates an electromagnetic field aligned
with the center of the coil. The direction and magnitude of the magnetic field produced by
the coil can be changed with the direction and magnitude of the current flowing through
it.
A simple DC motor has a stationary set of magnets in the stator and an armature with one
or more windings of insulated wire wrapped around a soft iron core that concentrates the
magnetic field. The windings usually have multiple turns around the core, and in large
motors there can be several parallel current paths. The ends of the wire winding are
connected to a commutator. The commutator allows each armature coil to be energized in
turn and connects the rotating coils with the external power supply through brushes.
(Brushless DC motors have electronics that switch the DC current to each coil on and off
and have no brushes.)
The total amount of current sent to the coil, the coil's size and what it's wrapped around
dictate the strength of the electromagnetic field created.
The sequence of turning a particular coil on or off dictates what direction the effective
electromagnetic fields are pointed. By turning on and off coils in sequence a rotating
magnetic field can be created. These rotating magnetic fields interact with the magnetic
fields of the magnets (permanent or electromagnets) in the stationary part of the motor
(stator) to create a force on the armature which causes it to rotate. In some DC motor
designs the stator fields use electromagnets to create their magnetic fields which allow
greater control over the motor.
At high power levels, DC motors are almost always cooled using forced air. [3]
Different number of stator and armature fields as well as how they are connected provide
different inherent speed/torque regulation characteristics. The speed of a DC motor can be
controlled by changing the voltage applied to the armature. The introduction of variable
resistance in the armature circuit or field circuit allowed speed control. Modern DC

22

motors are often controlled by power electronics systems which adjust the voltage by
"chopping" the DC current into on and off cycles which have an effective lower voltage.
Since the series-wound DC motor develops its highest torque at low speed, it is often used
in traction applications such as electric locomotives, and trams. The DC motor was the
mainstay of electric traction drives on both electric and diesel-electric locomotives, streetcars/trams and diesel electric drilling rigs for many years. The introduction of DC motors
and an electrical grid system to run machinery starting in the 1870s started a new second
Industrial Revolution. DC motors can operate directly from rechargeable batteries,
providing the motive power for the first electric vehicles and today's hybrid cars and
electric cars as well as driving a host of cordless tools. Today DC motors are still found in
applications as small as toys and disk drives, or in large sizes to operate steel rolling mills
and paper machines. Large DC motors with separately excited fields were generally used
with winder drives for mine hoists, for high torque as well as smooth speed control using
thyristor drives. These are now replaced with large AC motors with variable frequency
drives.
If external power is applied to a DC motor it acts as a DC generator, a dynamo. This
feature is used to slow down and recharge batteries on hybrid car and electric cars or to
return electricity back to the electric grid used on a street car or electric powered train line
when they slow down. This process is called regenerative braking on hybrid and electric
cars. In diesel electric locomotives they also use their DC motors as generators to slow
down but dissipate the energy in resistor stacks. Newer designs are adding large battery
packs to recapture some of this energy. [3]

23

FIG-3.8: DC MOTOR
3.7 WIRES
A wire is a single, usually cylindrical, flexible strand or rod of metal. Wires are used to
bear mechanical loads or electricity and telecommunications signals. Wire is commonly
formed by drawing the metal through a hole in a die or draw plate. Wire gauges come in
various standard sizes, as expressed in terms of a gauge number. The term wire is also
used more loosely to refer to a bundle of such strands, as in "multistranded wire", which
is more correctly termed a wire rope in mechanics, or a cable in electricity.
3.8 SOLDERING
Soldering is a process in which two or more items (usually metal) are joined together by
melting and putting a filler metal (solder) into the joint, the filler metal having a lower
melting point than the adjoining metal. Soldering differs from welding in that soldering
does not involve melting the work pieces. In brazing, the filler metal melts at a higher
temperature, but the work piece metal does not melt. In the past, nearly all solders
contained lead, but environmental and health concerns have increasingly dictated use of
lead-free alloys for electronics and plumbing purposes.[5]
3.9 SOLDERING WIRE
Soldering filler materials are available in many different alloys for differing applications.
In electronics assembly, the eutectic alloy of 63% tin and 37% lead (or 60/40, which is
almost identical in melting point) has been the alloy of choice. Other alloys are used for
plumbing, mechanical assembly, and other applications. Some examples of soft-solder are
tin-lead for general purposes, tin-zinc for joining aluminium, lead-silver for strength at
higher than room temperature, cadmium-silver for strength at high temperatures, zincaluminium for aluminium and corrosion resistance, and tin-silver and tin-bismuth for
electronics.
A eutectic formulation has advantages when applied to soldering: the liquidus and solidus
temperatures are the same, so there is no plastic phase, and it has the lowest possible
melting point. Having the lowest possible melting point minimizes heat stress on
electronic components during soldering. And, having no plastic phase allows for quicker
wetting as the solder heats up, and quicker setup as the solder cools. A non-eutectic

24

formulation must remain still as the temperature drops through the liquidus and solidus
temperatures. Any movement during the plastic phase may result in cracks, resulting in an
unreliable joint.[4]
Common solder formulations based on tin and lead are listed below. The fraction
represent percentage of tin first, then lead, totaling 100%:

63/37: melts at 183 C (361 F) (eutectic: the only mixture that melts at a point,
instead of over a range)

60/40: melts between 183190 C (361374 F)

50/50: melts between 183215 C (361419 F)

For environmental reasons (and the introduction of regulations such as the European
RoHS (Restriction of Hazardous Substances Directive)), lead-free solders are becoming
more widely used. They are also suggested anywhere young children may come into
contact with (since young children are likely to place things into their mouths), or for
outdoor use where rain and other precipitation may wash the lead into the groundwater.
Unfortunately, most lead-free solders are not eutectic formulations, melting at around
250 C (482 F), making it more difficult to create reliable joints with them.

FIG-3.9: SOLDERING WIRE


3.10 SOLDERING IRON
A soldering iron is a hand tool used in soldering. It supplies heat to melt solder so that it
can flow into the joint between two workpieces.
A soldering iron is composed of a heated metal tip and an insulated handle. Heating is
often achieved electrically, by passing an electric current (supplied through an electrical
cord or battery cables) through a resistive heating element. Cordless irons can be heated
by combustion of gas stored in a small tank, often using a catalytic heater rather than a
flame. Simple irons less commonly used than in the past were simply a large copper bit
on a handle, heated in a flame.[6]

25

Soldering irons are most often used for installation, repairs, and limited production work
in electronics assembly. High-volume production lines use other soldering methods.
Large irons may be used for soldering joints in sheet metal objects. Less common uses
include pyrography (burning designs into wood) and plastic welding.

FIG-3.10 SOLDERING IRON


3.11 ULN2003A
The ULN2003A is an array of seven NPN Darlington transistors capable of 500mA, 50V
output. It features common-cathode flyback diodes for switching inductive loads. It can
come in PDIP, SOIC, SOP or TSSOP packaging. In the same family are ULN2002A,
ULN2004A, as well as ULQ2003A and ULQ2004A, designed for different logic input
levels.

Fig-3.11 ULN2003A pin layout

26

3.11.1 Darlington Transistor


A Darlington transistor (also known as Darlington pair) achieves very high current
amplification by connecting two bipolar transistors in direct DC coupling so the current
amplified by the first transistor is amplified further by the second one. The resultant
current gain is the product of those of the two component transistors:

The seven Darlington pairs in ULN2003 can operate independently except the common
cathode diodes that connect to their respective collectors.
3.11.2 Features
The ULN2003 is known for its high-current, high-voltage capacity. The drivers can be
paralleled for even higher current output. Even further, stacking one chip on top of
another, both electrically and physically, has been done. Generally it can also be used for
interfacing with a stepper motor, where the motor requires high ratings which cannot be
provided by other interfacing devices.
Main specifications:

500 mA rated collector current (single output)

50 V output (there is a version that supports 100 V output)

Includes output flyback diodes

Inputs compatible with TTL and 5-V CMOS logic

Fig-3.12 internal structure


3.12 RELAY
A relay is

an electrically operated switch.

Many

relays

use

an electromagnet to

mechanically operate a switch, but other operating principles are also used, such as solidstate relays. Relays are used where it is necessary to control a circuit by a low-power

27

signal (with complete electrical isolation between control and controlled circuits), or
where several circuits must be controlled by one signal. The first relays were used in long
distance telegraph circuits as amplifiers: they repeated the signal coming in from one
circuit and re-transmitted it on another circuit. Relays were used extensively in telephone
exchanges and early computers to perform logical operations.
A type of relay that can handle the high power required to directly control an electric
motor or other loads is called a contactor. Solid-state relays control power circuits with
no moving parts, instead using a semiconductor device to perform switching. Relays with
calibrated operating characteristics and sometimes multiple operating coils are used to
protect electrical circuits from overload or faults; in modern electric power systems these
functions are performed by digital instruments still called "protective relays".
Magnetic latching relays require one pulse of coil power to move their contacts in one
direction, and another, redirected pulse to move them back. Repeated pulses from the
same input have no effect. Magnetic latching relays are useful in applications where
interrupted power should not be able to transition the contacts.
Magnetic latching relays can have either single or dual coils. On a single coil device, the
relay will operate in one direction when power is applied with one polarity, and will reset
when the polarity is reversed. On a dual coil device, when polarized voltage is applied to
the reset coil the contacts will transition. AC controlled magnetic latch relays have single
coils that employ steering diodes to differentiate between operate and reset commands.
3.12.1 Basic operation
A simple electromagnetic relay consists of a coil of wire wrapped around a soft iron core,
an iron yoke which provides a low reluctance path for magnetic flux, a movable
iron armature, and one or more sets of contacts (there are two contacts in the relay
pictured). The armature is hinged to the yoke and mechanically linked to one or more sets
of moving contacts. It is held in place by a spring so that when the relay is de-energized
there is an air gap in the magnetic circuit. In this condition, one of the two sets of contacts
in the relay pictured is closed, and the other set is open. Other relays may have more or
fewer sets of contacts depending on their function. The relay in the picture also has a wire
connecting the armature to the yoke. This ensures continuity of the circuit between the
moving contacts on the armature, and the circuit track on the printed circuit board (PCB)
via the yoke, which is soldered to the PCB.

28

When an electric current is passed through the coil it generates a magnetic field that
activates the armature, and the consequent movement of the movable contact(s) either
makes or breaks (depending upon construction) a connection with a fixed contact. If the
set of contacts was closed when the relay was de-energized, then the movement opens the
contacts and breaks the connection, and vice versa if the contacts were open. When the
current to the coil is switched off, the armature is returned by a force, approximately half
as strong as the magnetic force, to its relaxed position. Usually this force is provided by a
spring, but gravity is also used commonly in industrial motor starters. Most relays are
manufactured to operate quickly. In a low-voltage application this reduces noise; in a high
voltage or current application it reduces arcing.
When the coil is energized with direct current, a diode is often placed across the coil to
dissipate the energy from the collapsing magnetic field at deactivation, which would
otherwise generate a voltage spike dangerous to semiconductor circuit components. Such
diodes were not widely used before the application of transistors as relay drivers, but soon
became ubiquitous as early germanium transistors were easily destroyed by this surge.
Some automotive relays include a diode inside the relay case.
If the relay is driving a large, or especially a reactive load, there may be a similar problem
of surge currents around the relay output contacts. In this case a snubber circuit (a
capacitor and resistor in series) across the contacts may absorb the surge. Suitably rated
capacitors and the associated resistor are sold as a single packaged component for this
commonplace use.
If the coil is designed to be energized with alternating current (AC), some method is used
to split the flux into two out-of-phase components which add together, increasing the
minimum pull on the armature during the AC cycle. Typically this is done with a small
copper "shading ring" crimped around a portion of the core that creates the delayed, outof-phase component, which holds the contacts during the zero crossings of the control
voltage.
3.13 REGULATOR IC
The 78xx (sometimes L78xx, LM78xx, MC78xx...)

is

family

of

self-contained

fixed linear voltage regulator integrated circuits. The 78xx family is commonly used in
electronic circuits requiring a regulated power supply due to their ease-of-use and low
cost. For ICs within the family, the xx is replaced with two digits, indicating the

29

output voltage (for example, the 7805 has a 5-volt output, while the 7812 produces
12 volts). The 78xx line are positive voltage regulators: they produce a voltage that is
positive relative to a common ground. There is a related line of 79xx devices which are
complementary negative voltage regulators. 78xx and 79xx ICs can be used in
combination to provide positive and negative supply voltages in the same circuit.
78xx ICs have three terminals and are commonly found in the TO-220 form factor,
although they are available in surface-mount, TO-92, and TO-3 packages. These devices
support an input voltage anywhere from around 2.5 volts over the intended output voltage
up to a maximum of 35 to 40 volts depending on the model, and typically provide 1 or
1.5 amperes of current (though smaller or larger packages may have a lower or higher
current rating).
Advantages
78xx series ICs do not require additional components to provide a constant, regulated
source of power, making them easy to use, as well as economical and efficient uses of
space. Other voltage regulators may require additional components to set the output
voltage level, or to assist in the regulation process. Some other designs (such as a
switched-mode power supply) may need substantial engineering expertise to implement.

78xx series ICs have built-in protection against a circuit drawing too much
current. They have protection against overheating and short-circuits, making them
quite robust in most applications. In some cases, the current-limiting features of
the 78xx devices can provide protection not only for the 78xx itself, but also for
other parts of the circuit.

Disadvantages
The input voltage must always be higher than the output voltage by some minimum
amount (typically 2.5 volts). This can make these devices unsuitable for powering some
devices from certain types of power sources (for example, powering a circuit that requires
5 volts using 6-volt batteries will not work using a 7805).

As they are based on a linear regulator design, the input current required is always
the same as the output current. As the input voltage must always be higher than
the output voltage, this means that the total power (voltage multiplied by current)
going into the 78xx will be more than the output power provided. The difference
is dissipated as heat. This means both that for some applications an
adequate heatsink must be provided, and also that a (often substantial) portion of

30

the input power is wasted during the process, rendering them less efficient than
some other types of power supplies. When the input voltage is significantly higher
than the regulated output voltage (for example, powering a 7805 using a 24 volt
power source), this inefficiency can be a significant issue. Buck converters may be
preferred over 78xx regulators because they are more efficient and do not require
heat sinks, but they are more expensive.
3.14 BUZZER
A buzzer or beeper is an audio signaling device, which may
be mechanical, electromechanical, or piezoelectric. Typical uses of buzzers and beepers
include alarm devices, timers and confirmation of user input such as a mouse click or
keystroke.
3.14.1 Type of buzzers

Electromechanical
Early devices were based on an electromechanical system identical to an electric
bell without the metal gong. Similarly, a relay may be connected to interrupt its own
actuating current, causing the contacts to buzz. Often these units were anchored to a
wall or ceiling to use it as a sounding board. The word "buzzer" comes from the
rasping noise that electromechanical buzzers made.

Mechanical
A joy buzzer is an example of a purely mechanical buzzer. They require drivers.

Piezoelectric
A piezoelectric element may be driven by an oscillating electronic circuit or
other audio signal source, driven with a piezoelectric audio amplifier. Sounds
commonly used to indicate that a button has been pressed are a click, a ring or a beep

31