Вы находитесь на странице: 1из 42

1.

Block Diagram:

2. Circuit Diagram:
3. Components Description
Power Supply-
1. Voltage Regulator
2. Resistor
3. Led
4. Battery 9V
Input Devices-
1. Fire Sensor
2. Light Sensor
3. Soil Sensor
4. Bluetooth Module
Microcontroller-
1. Atmega16 Microcontroller
Output Devices-
1. LED
2. DC Motor
3. Water Pump
4. Buzzer
5. Bulb
Driver & Relays-
1. SPST Relay
2. Motor Driver IC L293D
Other Hardware-
1. Screw Connector
2. CD Tray (Gate)
3. PCB
4. AC Bulb and Holders

Power Supply-
1. Voltage Regulator
7805 is a three terminal linear voltage regulator IC with a fixed output voltage of 5V which is
useful in a wide range of applications. Currently, the 7805 Voltage Regulator IC is
manufactured by Texas Instruments, ON Semiconductor, STMicroelectronics, Diodes
incorporated, Infineon Technologies, etc.

They are available in several IC Packages like TO-220, SOT-223, TO-263 and TO-3. Out of
these, the TO-220 Package is the most commonly used one (it is the one shown in the above
image).

Some of the important features of the 7805 IC are as follows:


 It can deliver up to 1.5 A of current (with heat sink).
 Has both internal current limiting and thermal shutdown features.
 Requires very minimum external components to fully function.

Pin Diagram of 7805 Voltage Regulator IC

As mentioned earlier, 7805 is a three terminal device with the three pins being 1. INPUT, 2.
GROUND and 3. OUTPUT. The following image shows the pins on a typical 7805 IC in To-220
Package.

The pin description of the 7805 is described in the following table:

PIN NO. PIN DESCRIPTION

1 INPUT Pin 1 is the INPUT Pin. A positive unregulated voltage is given as input to this pin.

2 GROUND Pin 2 is the GROUND Pin. It is common to both Input and Output.
PIN NO. PIN DESCRIPTION

3 OUTPUT Pin 3 is the OUTPUT Pin. The output regulated 5V is taken at this pin of the IC.

2. Resistor:

Resistors are considered to be the most used and the most important
component of all the electronic circuits. Take a look at the working, types and
also use of resistors in the field of electronics.
We know that the basic idea of any electronic circuit is the flow of electricity.
This also is further categorized into two – conductors and insulators. Conductors
allow the flow of electrons, while insulators do not. But the amount of electricity
that we want to pass through them depends on the resistors. If a high voltage is
passed through a conductor such as a metal, the whole voltage passes through it.
If resistors are introduced, the amount of voltage and current can be controlled.
Thus “resistance can be defined as the ease with which something will let
electricity flow through it”.
A conductor has lower resistance than an insulator. The amount used by the
resistor to control the electrical circuit is termed as the resistance.
What is Resistance?
The definition of resistance is based upon the Ohm’s law given by the German
physicist Georg Simon Ohm.
The Ohm’s Law states that the voltage [V] across a resistor is directly
proportional to the current [I] flowing through it. Here, its resistance [R] is
the constant of proportionality.
Therefore, V = I * R
Unit of resistance
The SI-unit of resistance is Ohm [Ω]. The higher multiple and sub-multiple values
of ohm is kilo ohms [KΩ], mega ohms [MΩ], milli ohm and so on.
Thus, the resistance can be defined as the voltage required for making a
current of 1 ampere to flow through the circuit. If the circuit requires 100 Volts
to make 1 ampere flow, then the resistance is 100 Ohms.
Symbol of Resistor
Resistor is a 2 terminal passive device. The symbol is given below.

Symbol of resistor
Working of Resistor
The working of a resistor can be explained with the similarity of water flowing
through a pipe. Consider a pipe through which water is allowed to flow. If the
diameter of the pipe is reduced, the water flow will be reduced. If the force of
the water is increased by increasing the pressure, then the energy will be
dissipated as heat. There will also be an enormous difference in pressure in the
head and tail ends of the pipe. In this example, the force applied to the water is
similar to the current flowing through the resistance. The pressure applied can
be resembled to the voltage.
Resistor Series and Parallel Circuits
There may be cases where two or more resistors should be connected in a
circuit. The simplest way of connecting them is in the series and parallel ways.
In a series connection, the resistors will be connected in a series path and the
current flowing through the resistors will be the same. The voltage across the
resistors will be equal to the sum of voltages across each resistor. Here is a figure
of resistors connected in series. Three resistors R1, R2, and R3 are connected in
series. The total resistance Rtotal is given by
Rtotal = R1 + R2 + R3
resistors in series and parallel
In a parallel connection, the resistors will be in a parallel path and the voltage
applied across each component will be the same. The current across the resistors
will be equal to the sum of currents across each resistor. The above figure shows
a parallel connection of resistors. Three resistors R1, R2, and R3 are connected in
parallel. The total resistance Rtotal is given by
1/Rtotal = 1/ R1 + 1/ R2 + 1/ R3.
Therefore, Rtotal = R1 * R2 * R3 / R1 + R2 + R3
Power Dissipated in a Resistor
The power dissipation of a resistor is given by the equation
Power, P = I2 * R = V * I = V2 /R
The first equation was obtained from Joule’s first law, while the other two were
derived from Ohm’s law.
Types of resistors
The most commonly used resistors all look the same. They look like a small worm
with coloured stripes on the side. There are many types of resistors available.
The most common one ceramic rod wound by copper wires on the inside. The
number of copper turns and the thickness of the copper determine the
resistance of the component. The more the turns and lesser the thickness, the
more the resistance. There are also resistors with spiral patterns of carbon,
instead of the copper winding. Such resistors are used for making smaller value
resistors. Let us take a closer look at all the resistors.
1. Wire-wound Resistors
The resistors with a ceramic rod wound up with copper wires are called wire-
wound resistors. Such resistors have the effect of inductance as they have
copper windings. Even though the wires are wound in sections with alternate
reversed condition an inductance is produced. Thus, different types of windings
are used. One type of winding is called the flat thin former method which helps
in reducing the cross-sectional area of the coil to a great extent. There are also
other types of windings called Ayrton-Perry winding and bifilar winding. Some
wire-wound resistors have an aluminium case so that they can be connected to
heat sinks which dissipate heat.
2. Carbon Composition Resistors
They are usual resistors with a resistive element in the shape of a cylinder. The
resistive element is a mixture of carbon powder and ceramic. This mixture is held
together with the help of a resin. This mixture is embedded with wire leads. This
is then attached to wires made of lead. The value of the resistor can be found out
by a method called colour coding, which is painted onto the outer body of the
resistor.
If the concentration of carbon increases, the resistance of the component
decreases. This type of resistor is not used so commonly now. Though this
resistor was highly reliable, their overheating and overvoltage characteristics are
not so reliable.
3. Carbon film
This type of resistor is applicable for circuits working under a range of
temperatures. The resistor is made by depositing a carbon film onto an insulating
substrate. They can operate at a range from -55 °C to 155 °C. The voltage range
varies from 100 Volts to 650 Volts with a resistance from 1Ω to 10 MΩ.
4. Thin and Thick Film Resistors
This type of resistor was the backbone of the popular surface mount device
resistors used now. The names differentiate in the manner in which the film is
applied onto the cylinder. The
For a thin film resistor, vacuum deposition method is used to include the resistive
material onto the insulating substrate. This type of resistor is commonly used for
making printed circuit boards. This type of resistor produces accurate resistance
as the whole process of its making can be controlled.
Thick films are also produced in the same manner as a thin film. But they also
have some additional compounds like glass and also a screen printing liquid.
Both of them vary in their temperature ranges as well as prices. Thin films are
more expensive than thick films.
5. Metal Film Resistors
This type of resistor is made by coating with nickel chromium [NiCr]. The process
of making this resistor is similar to that of thin film resistors. The difference will
be in the compounds used.
6. Ammeter Shunt Resistor
This is the most unique type of resistor which is used for current sensing. It has
four terminals and is used in the milliohms and microohms range. Though they
are used for measuring small currents, if the current is allowed to pass through a
shunt mechanism, they can be used for measuring high currents as well. Through
this mechanism the current is measured with accordance to the voltage drop
across it.
The shunt mechanism consists of two brass blocks. Inbetween them are strips of
low temperature co-efficient of resistance alloys. Large bolts threaded into the
blocks make the current connections.
There are also other types of resistors like lead arrangement resistors, grid
resistors and so on. There are also variable resistors like the tapped resistors,
metal oxide varistor (MOV) and strain gauge. To know more click on the
following links.
TAKE A LOOK : POTENTIOMETER AND RHEOSTAT – WORKING AND
COMPARISON
TAKE A LOOK : VARIABLE RESISTORS – WORKING AND APPLICATIONS
TAKE A LOOK : METAL OXIDE VARISTOR (MOV)
Colour Coding
The value of the resistance is found out by colour coding. The resistors have a
band of colours shown in their outer covering. Here are the steps to determine
the value of the resistor.
 All resistors have three bands of colours, followed by a space and then a fourth band
of colour. The fourth band of colour will be brown, red, gold or silver.
 To read the colours turn it to the position such as the three consecutive colours
come on the left and then the space and the rest of the colours.
 The first two colours from the left indicate the first two digits of the value. The third
colour represents the digital multiplier. That is, it indicates how much you have to
multiply the first two numbers with. Thus if you have a resistance with the first three
colours being brown, black and red, the value of resistance is 10*100 = 1000 ohms or
1K.
 The last band, after the space indicates the tolerance of the resistor. This indicates
the range of accuracy of the resistor. Thus, along with the three colours above, if the
fourth colour is gold, it means you have a tolerance between +/-5%. Thus the actual
value of the resistance can be between 950 Ohms and 1K.
 There can also be resistors with five colours. If so, the first three represents the
digits, the fourth will be the multiplier and the fifth will be the percentage of
tolerance. This indicates that a more precise value of the resistor used can be
obtained from a 5-colour resistor.
Take a look at the colours and their associated numbers given below.
Colour coding of resistors
Uses of Resistors
Though resistors can cause wastage of electricity, it has a lot of advantages and
applications in our daily life.
 Resistance is one of the main ingredient in the working of a light bulb. When
electricity passes through the filament of the bulb, it burns bright as it turns
extremely hot due to its smaller size. Though this mechanism wastes a lot of
electricity, we are forced to use it to obtain light. The light used nowadays are highy
efficient than the older incandascent lamps.
 The similar filament working is the main ingredient in the working of some of our
usual household stuffs like electric kettles, electric radiators, electric showers, coffee
makers, toasters, and so on.
 The application of variable resistance is also helpful to us. Our TV’s, radios, loud
speakers and so on work on this principle.

3. Led:
A light emitting diode (LED) is known to be one of the best optoelectronic
devices out of the lot. The device is capable of emitting a fairly narrow
bandwidth of visible or invisible light when its internal diode junction attains a
forward electric current or voltage. The visible lights that an LED emits are
usually orange, red, yellow, or green. The invisible light includes the infrared
light. The biggest advantage of this device is its high power to light conversion
efficiency. That is, the efficiency is almost 50 times greater than a simple
tungsten lamp. The response time of the LED is also known to be very fast in the
range of 0.1 microseconds when compared with 100 milliseconds for a tungsten
lamp. Due to these advantages, the device wide applications as visual indicators
and as dancing light displays.
We know that a P-N junction can connect the absorbed light energy into its
proportional electric current. The same process is reversed here. That is, the P-N
junction emits light when energy is applied on it. This phenomenon is generally
called electroluminance, which can be defined as the emission of light from a
semi-conductor under the influence of an electric field. The charge carriers
recombine in a forward P-N junction as the electrons cross from the N-region and
recombine with the holes existing in the P-region. Free electrons are in the
conduction band of energy levels, while holes are in the valence energy band.
Thus the energy level of the holes will be lesser than the energy levels of the
electrons. Some part of the energy must be dissipated in order to recombine the
electrons and the holes. This energy is emitted in the form of heat and light.
The electrons dissipate energy in the form of heat for silicon and germanium
diodes. But in Galium- Arsenide-phosphorous (GaAsP) and Galium-phosphorous
(GaP) semiconductors, the electrons dissipate energy by emitting photons. If the
semiconductor is translucent, the junction becomes the source of light as it is
emitted, thus becoming a light emitting diode (LED). But when the junction is
reverse biased no light will be produced by the LED, and, on the contrary the
device may also get damaged.
The constructional diagram of a LED is shown below.

LED Construction
All the semiconductors listed above can be used. An N-type epitaxial layer is
grown upon a substrate, and the P-region is produced by diffusion. The P-region
that includes the recombination of charge carriers is shown is the top. Thus the
P-region becomes the device surface. Inorder to allow more surface area for the
light to be emitted the metal anode connections are made at the outer edges of
the P-layer. For the light t be reflected as much as possible towards the surface
of the device, a gold film s applied to the surface bottom. This setting also
enables to provide a cathode connection. The reabsorption problem is fixed by
including domed lenses for the device. All the wires in the electronic circuits of
the device is protected by encasing the device. The light emitted by the device
depends on the type of semiconductor material used. Infrared light is produced
by using Gallium Arsenide (GaAs) as semiconductor. Red or yellow light is
produced by using Gallium-Arsenide-Phosphorus (GaAsP) as semiconductor. Red
or green light is produced by using Gallium-Phosphorus (GaP) as semiconductor.
LED Circuit Symbol
The circuit symbol of LED consists of two arrow marks which indicate the
radiation emitted by the diode.

LED Circuit Symbol


LED Characteristics

LED Characteristics
The forward bias Voltage-Current (V-I) curve and the output characteristics curve
is shown in the figure above. The V-I curve is practically applicable in burglar
alarms. Forward bias of approximately 1 volt is needed to give significant
forward current. The second figure is used to represent a radiant power-forward
current curve. The output power produced is very small and thus the efficiency in
electrical-to-radiant energy conversion is very less.
The figure below shows a series resistor Rseries connected to the LED. Once the
forward bias of the device exceeds, the current will increase at a greater rate in
accordance to a small increase in voltage. This shows that the forward resistance
of the device is very low. This shows the importance of using an external series
current limiting resistor. Series resistance is determined by the following
equation.
Rseries = (Vsupply – V)/I
Vsupply – Supply Voltage
V – LED forward bias voltage
I – Current

LED Circuit
The commercially used LED’s have a typical voltage drop between 1.5 Volt to 2.5
Volt or current between 10 to 50 milliamperes. The exact voltage drop depends
on the LED current, colour, tolerance, and so on.
LED as an Indicator
The circuit shown below is one of the main applications of LED. The circuit is
designed by wiring it in inverse parallel with a normal diode, to prevent the
device from being reverse biased. The value of the series resistance should be
half, relative to that o f a DC circuit.
LED as an Indicator
LEDS displays are made to display numbers from segments. One such design is
the seven-segment display as shown below. Any desired numerals from 0-9 can
be displayed by passing current through the correct segments. To connect such
segment a common anode or common cathode cathode configuration can be
used. Both the connections are shown below. The LED’s are switched ON and
OFF by using transistors.
Advantages of LED’s
 Very low voltage and current are enough to drive the LED.
 Voltage range – 1 to 2 volts.
 Current – 5 to 20 milliamperes.
 Total power output will be less than 150 milliwatts.
 The response time is very less – only about 10 nanoseconds.
 The device does not need any heating and warm up time.
 Miniature in size and hence light weight.
 Have a rugged construction and hence can withstand shock and vibrations.
 An LED has a life span of more than 20 years.
Disadvantages
 A slight excess in voltage or current can damage the device.
 The device is known to have a much wider bandwidth compared to the laser.
 The temperature depends on the radiant output power and wavelength.

4. Battery 9V
Input Devices-
1. Fire Sensor:
Description
The Fire sensor is used to detect fire flames . The module makes use of Fire sensor and
comparator to detect fire up to a range of 1 meters.

Feature

 Allows your robot to detect flames from upto 1 M away


 Typical Maximum Range :1 m .
 Calibration preset for range adjustment.
 Indicator LED with 3 pin easy interface connector.
 Input Voltage +5VDC

2. Light Sensor:

Circuit Diagram

Components Required
 LM358 OP – Amp IC
 Small LDR
 10 KΩ Resistor
 10 KΩ Potentiometer
 White LED
 220 Ω Resistor
 Connecting wires
 Power supply (9V Battery)
Working of the Circuit
The main components of the project are LM358 Op – Amp and LDR. First let us see
about LDR (Light Dependent Resistor). An LDR, as the name suggests, is a type of
resistor, whose resistance changes depending on the intensity of the light
surrounding it.
Typically, when light is incident directly on the LDR, its resistance will be very low
and when there is no light i.e. in darker conditions, its resistance jumps to few mega
Ohms.
We will use this feature of the LDR is our project to detect light and turn on an LED.
For this we have used an Operational Amplifier. The Op – Amp is configured in
Comparator mode i.e. it will compare the voltages at inverting and non – inverting
terminals and correspondingly generate a HIGH or LOW output.
We have connected the wiper terminal of the 10 KΩ Potentiometer to the inverting
terminal of the OP – Amp. To the non – inverting terminal, we have connected the
junction of a 10 KΩ Resistor and the LDR. These two will form a potential divider
feeding its output to the OP – Amp.
When the light is incident on the LDR, its resistance decreases. Hence, the non –
inverting voltage is lower than the inverting voltage and as a result, the LED remains
OFF.
When there is no light falling on the LDR, the resistance of the LDR becomes very
high and as a result, the voltage at the non – inverting terminal will be more than the
voltage at inverting terminal. The output of the Op – Amp will be high and the LED is
turned ON.

3. Soil Sensor

The soil moisture sensor consists of two probes which are used to measure the
volumetric content of water. The two probes allow the current to pass through
the soil and then it gets the resistance value to measure the moisture value.
When there is more water, the soil will conduct more electricity which means
that there will be less resistance. Therefore, the moisture level will be higher. Dry
soil conducts electricity poorly, so when there will be less water, then the soil will
conduct less electricity which means that there will be more resistance.
Therefore, the moisture level will be lower.
This sensor can be connected in two modes; Analog mode and digital mode.
First, we will connect it in Analog mode and then we will use it in Digital mode.
Specifications
The specifications of the soil moisture sensor FC-28 are as follows
Input Voltage 3.3 – 5V

Output Voltage 0 – 4.2V

Input Current 35mA


Output Signal Both Analog and Digital

Pin Out – Soil Moisture Sensor


The soil Moisture sensor FC-28 has four pins
 VCC: For power
 A0: Analog output
 D0: Digital output
 GND: Ground
The Module also contains a potentiometer which will set the threshold value and
then this threshold value will be compared by the LM393 comparator. The
output LED will light up and down according to this threshold value.

Pin Out – Diagram

4. Bluetooth Module:

Introduction
 It is used for many applications like wireless headset, game controllers, wireless
mouse, wireless keyboard and many more consumer applications.
 It has range up to <100m which depends upon transmitter and receiver,
atmosphere, geographic & urban conditions.
 It is IEEE 802.15.1 standardized protocol, through which one can build wireless
Personal Area Network (PAN). It uses frequency-hopping spread spectrum (FHSS)
radio technology to send data over air.
 It uses serial communication to communicate with devices. It communicates with
microcontroller using serial port (USART).
HC-05 Bluetooth Module
 HC-05 is a Bluetooth module which is designed for wireless communication. This
module can be used in a master or slave configuration.

HC-05 Bluetooth Module

Pin Description
Bluetooth serial modules allow all serial enabled devices to communicate with
each other using Bluetooth.
It has 6 pins,
1. Key/EN: It is used to bring Bluetooth module in AT commands mode. If
Key/EN pin is set to high, then this module will work in command mode.
Otherwise by default it is in data mode. The default baud rate of HC-05 in
command mode is 38400bps and 9600 in data mode.
HC-05 module has two modes,
1. Data mode: Exchange of data between devices.
2. Command mode: It uses AT commands which are used to change setting
of HC-05. To send these commands to module serial (USART) port is used.
2. VCC: Connect 5 V or 3.3 V to this Pin.
3. GND: Ground Pin of module.
4. TXD: Transmit Serial data (wirelessly received data by Bluetooth module
transmitted out serially on TXD pin)
5. RXD: Receive data serially (received data will be transmitted wirelessly by
Bluetooth module).
6. State: It tells whether module is connected or not.

HC-05 module Information


 HC-05 has red LED which indicates connection status, whether the Bluetooth is
connected or not. Before connecting to HC-05 module this red LED blinks
continuously in a periodic manner. When it gets connected to any other Bluetooth
device, its blinking slows down to two seconds.
 This module works on 3.3 V. We can connect 5V supply voltage as well since the
module has on board 5 to 3.3 V regulator.
 As HC-05 Bluetooth module has 3.3 V level for RX/TX and microcontroller can detect
3.3 V level, so, no need to shift transmit level of HC-05 module. But we need to shift
the transmit voltage level from microcontroller to RX of HC-05 module.
Bluetooth communication between Devices

E.g. Send data from Smartphone terminal to HC-05 Bluetooth module and see
this data on PC serial terminal and vice versa.
To communicate smartphone with HC-05 Bluetooth module, smartphone
requires Bluetooth terminal application for transmitting and receiving data. You
can find Bluetooth terminal applications for android and windows in respective
app. store.
Bluetooth Module Serial Interface
So, when we want to communicate through smartphone with HC-05 Bluetooth
module, connect this HC-05 module to the PC via serial to USB converter.
Before establishing communication between two Bluetooth devices, 1st we need
to pair HC-05 module to smartphone for communication.
Pair HC-05 and smartphone:
1. Search for new Bluetooth device from your phone. You will find Bluetooth device
with “HC-05” name.
2. Click on connect/pair device option; default pin for HC-05 is 1234 or 0000.
After pairing two Bluetooth devices, open terminal software (e.g. Teraterm,
Realterm etc.) in PC, and select the port where we have connected USB to serial
module. Also select default baud rate of 9600 bps.
In smart phone, open Bluetooth terminal application and connect to paired
device HC-05.
It is simple to communicate, we just have to type in the Bluetooth terminal
application of smartphone. Characters will get sent wirelessly to Bluetooth
module HC-05. HC-05 will automatically transmit it serially to the PC, which will
appear on terminal. Same way we can send data from PC to smartphone.
Command Mode
 When we want to change settings of HC-05 Bluetooth module like change password
for connection, baud rate, Bluetooth device’s name etc.
 To do this, HC-05 has AT commands.
 To use HC-05 Bluetooth module in AT command mode, connect “Key” pin to High
(VCC).
 Default Baud rate of HC-05 in command mode is 38400bps.
 Following are some AT command generally used to change setting of Bluetooth
module.
 To send these commands, we have to connect HC-05 Bluetooth module to the PC via
serial to USB converter and transmit these command through serial terminal of PC.
Command Description Response

Checking OK
AT
communication
AT+PSWD=XXXX Set Password OK
e.g. AT+PSWD=4567
Set Bluetooth
Device Name
AT+NAME=XXXX e.g. OK
AT+NAME=MyHC-
05
AT+UART=Baud Change Baud rate
rate, stop bit, e.g. OK
parity bit AT+UART=9600,1,0
Respond version no. +Version: XX OK
AT+VERSION? of Bluetooth e.g. +Version: 2.0
module 20130107 OK

Send detail of Parameters: device type,


AT+ORGL setting done by module mode, serial
manufacturer parameter, passkey,etc.

Microcontroller-
1. Atmega16 Microcontroller
 Atmega16 is a 40-pin low power microcontroller which is developed using CMOS
technology.
 CMOS is an advanced technology which is mainly used for developing integrated
circuits. It comes with low power consumption and high noise immunity.
 Atmega16 is an 8-bit controller based on AVR advanced RISC (Reduced Instruction
Set Computing) architecture. AVR is family of microcontrollers developed by Atmel in
1996.
 It is a single chip computer that comes with CPU, ROM, RAM, EEPROM, Timers,
Counters, ADC and four 8-bit ports called PORTA, PORTB, PORTC, PORTD where each
port consists of 8 I/O pins.
 Atmega16 has built-in registers that are used to make a connection between CPU
and external peripherals devices. CPU has no direct connection with external
devices. It can take input by reading registers and give output by writing registers.
 Atmega16 comes with two 8-bit timers and one 16-bit timer. All these timers can be
used as counters when they are optimized to count the external signal.
 Most of the necessary peripherals required to run automatic functions are
incorporated in this device like ADC (analog to digital converter), Analog
comparator, USART, SPI, which make it economical as compared to a microprocessor
that requires external peripheral to perform various functions.
 Atmega16 comes with 1KB of static RAM which is a volatile memory i.e stores
information for short period of time and highly depends on the constant power
supply. Whereas 16KB of flash memory, also known as ROM, is also incorporated in
the device which is non-volatile in nature and can store information for long period
of time and doesn’t lose any information when the power supply is disconnected.
 Atmega16 works on a maximum frequency of 16MHz where instructions are
executed in one machine cycle.
Architecture of Atmega16
Following figure shows the architecture of Atmega16 that is based on Harvard
Architecture and comes with separate buses and memories. Instructions are
stored in the program memory.
1. CPU
CPU is like a brain of the controller which helps in executing a number of
instructions. It can handle interrupts, perform calculations and control
peripherals with the help of registers. Atmega16 comes with two buses called
instruction bus and data bus.
The CPU reads the instructions in the instruction bus while data bus is used to
read or write the corresponding data. The CPU mainly consists of the program
counter, general purpose registers, stack pointer, instruction register and an
instruction decoder.
2. ROM
The controller program is stored in ROM, also known as non-volatile
programmable flash memory. The flash memory comes with a resolution of at
least 10,000 write/erase cycles. Flash memory is mainly divided into two parts
known as Application flash section and booth flash section.
Program of the controller is stored in the applications flash section. While booth
flash section is optimized to work directly when the controller is powered up.
3. RAM
The SRAM (static random access memory) is used for storing information
temporarily and comes with 8-bit registers. This is just like a regular computer
RAM which is used to supply data through the runtime.
4. EEPROM
The EEPROM (Electronically Erasable Read Only Memory) is non-volatile memory
used as a long time storage. It has no involvement in executing the main
program. It is used for storing the configuration of the system and device
parameters which continues to work in the reset of the application processor.
EEPROM comes with a limited write cycle up to 100,000 while read cycles are
unlimited. While using EEPROM, write minimum instructions as per requirement,
so you can get benefit from this memory for a longer time.
5. Interrupt
The interrupt is used for an emergency which puts the main function on hold and
executes the necessary instructions at that time. Once the interrupt is called and
executed the code switches back to the main program.
6. Analog and Digital I/O Modules
Digital I/O modules are used to set a digital communication between the
controller and external devices. While analog I/O modules are used for
transferring analog information. Analog comparators and ADC fall under the
category of analog I/O modules.
7. Timer/Counter
Timers are used for calculating the internal signal within the controller.
Atmega16 comes with two 8-bit timers and one 16-bit timer. All these timers
work as a counter when they are optimized for external signals.
8. Watchdog Timer
The watchdog timer is a remarkable addition in this controller which is used to
generate the interrupt and reset the timer. It comes with 128kHz distinct CLK
source.
9. Serial Communication
Atmega16 comes with USART and SPI units that are used for developing serial
communication with the external devices.
Atmega16 Pinout
Following figure shows the pin diagram of this AVR microcontroller Atmega16.
 Atmega16 is preferred over other microcontrollers like Atmel 8051 because it comes
with much faster ability to execute instructions and consist of modified RISC
processor.
 It has a built-in flash which comes with features of a bootloader. It has built-in 10-bit
ADC, SPI, PWM, and EEPROM.
Pin Description of Atmega16
Atmega16 comes with 40 pins where each pin is used to perform a specific task.
There are total 32 I/O pins and four ports. Each port consists of 8 I/O pins.
 PORTA = 8 Pins ( Pin 33 – 40 )
 PORTB = 8 Pins ( Pin 1 – 8 )
 PORTC = 8 Pins ( Pin 22 – 29 )
 PORTD = 8 Pins ( Pin 14 – 21 )
Following are the main functions associated with pins.
PORTA. Pins from 33 to 40 fall under PORTA. It acts like analog inputs to A/D
converter. However, in the absence of A/D converter, PORTA is used as an 8-bit
bidirectional I/O port. It comes with internal pull-up resistors.
PORTB. Pins from 1 to 8 belong to PORTB. These are I/O bidirectional pins. This
port also consists of internal pull-up resistors.
PORTC. PORTC is an I/O bidirectional port that consists of 8 pins. Pin from 22 to
29 belongs to this port. Similar to other ports, it comes with internal pull-up
resistors.

PORTD. Pin from 14 to 21 belongs to this port. It is a bidirectional port where


each pin can be used as input or output pin. However, there are additional
features associated with this port like interrupts, serial communication, timer,
and PWM.
Reset. Pin9 is an active low reset Pin. A low-level pulse for longer than minimum
pulse length will produce a reset. Short pulses are unlikely to produce reset.
VCC. Pin10 is a power supply pin for this controller. The power supply of 5 V is
required to put this controller in a running condition.
GND. Pin11 is a ground pin.
AREF. Pin32 is an analog reference pin mainly used for A/D converter.
AVCC. Pin30 is an AVCC which is a supply voltage pin for PORTA and ADC. It is
connected to VCC through a low pass filter in the presence of ADC. However, in
the absence of ADC, AVCC is externally connected to VCC.
Pin 12 & 13. A crystal oscillator is connected with these pins. Atmega16 works at
the internal frequency of 1MHZ; the oscillator is added to generate high clock
pulses and frequency.
Applications
AVR controllers come with a wide range of applications where automation is
required. Following are the main applications of Atmega16.
 Medical equipment
 Home automation
 Embedded systems
 Used in automobiles and industrial automation
 Home appliances and security systems
 Temperature and pressure control devices

Output Devices-
1. LED

The lighting emitting diode is a p-n junction diode. It is a specially doped diode and made up
of a special type of semiconductors. When the light emits in the forward biased, then it is
called as a light emitting diode.

Light Emitting Diode


How does the Light Emitting Diode work?

The light emitting diode simply, we know as a diode. When the diode is forward biased, then
the electrons & holes are moving fast across the junction and they are combining constantly,
removing one another out. Soon after the electrons are moving from the n-type to the p-type
silicon, it combines with the holes, then it disappears. Hence it makes the complete atom &
more stable and it gives the little burst of energy in the form of a tiny packet or photon of
light.
Working of Light Emitting Diode

The above diagram shows how the light emitting diode works and the step by step process of
the diagram.

 From the diagram, we can observe that the N-type silicon is in red color and it contains the
electrons, they are indicated by the black circles.
 The P- type silicon is in the blue color and it contains holes, they are indicated by the white
circles.
 The power supply across the p-n junction makes the diode forward biased and pushing the
electrons from n-type to p-type. Pushing the holes in the opposite direction.
 Electron and holes at the junction are combined.
 The photons are given off as the electrons and holes are recombined.

2. DC Motor
3. Water Pump
4. Buzzer
5. Bulb

Driver & Relays-


1. SPST Relay
We know that most of the high end industrial application devices have relays for
their effective working. Relays are simple switches which are operated both
electrically and mechanically. Relays consist of an electromagnet and also a set of
contacts. The switching mechanism is carried out with the help of the
electromagnet. There are also other operating principles for its working. But they
differ according to their applications. Most of the devices have the application of
relays.
Why is a relay used?
The main operation of a relay comes in places where only a low-power signal can
be used to control a circuit. It is also used in places where only one signal can be
used to control a lot of circuits. The application of relays started during the
invention of telephones. They played an important role in switching calls in
telephone exchanges. They were also used in long distance telegraphy. They
were used to switch the signal coming from one source to another destination.
After the invention of computers they were also used to perform Boolean and
other logical operations. The high end applications of relays require high power
to be driven by electric motors and so on. Such relays are called contactors.

Relay Design
There are only four main parts in a relay. They are
 Electromagnet
 Movable Armature
 Switch point contacts
 Spring
The figures given below show the actual design of a simple relay.

Relay Construction
It is an electro-magnetic relay with a wire coil, surrounded by an iron core. A
path of very low reluctance for the magnetic flux is provided for the movable
armature and also the switch point contacts. The movable armature is
connected to the yoke which is mechanically connected to the switch point
contacts. These parts are safely held with the help of a spring. The spring is used
so as to produce an air gap in the circuit when the relay becomes de-energized.
How relay works?
The relay function can be better understood by explaining the following diagram
given below.

Relay Design
The diagram shows an inner section diagram of a relay. An iron core is
surrounded by a control coil. As shown, the power source is given to the
electromagnet through a control switch and through contacts to the load. When
current starts flowing through the control coil, the electromagnet starts
energizing and thus intensifies the magnetic field. Thus the upper contact arm
starts to be attracted to the lower fixed arm and thus closes the contacts causing
a short circuit for the power to the load. On the other hand, if the relay was
already de-energized when the contacts were closed, then the contact move
oppositely and make an open circuit.
As soon as the coil current is off, the movable armature will be returned by a
force back to its initial position. This force will be almost equal to half the
strength of the magnetic force. This force is mainly provided by two factors. They
are the spring and also gravity.
Relays are mainly made for two basic operations. One is low voltage application
and the other is high voltage. For low voltage applications, more preference will
be given to reduce the noise of the whole circuit. For high voltage applications,
they are mainly designed to reduce a phenomenon called arcing.
Relay Basics
The basics for all the relays are the same. Take a look at a 4 – pin relay shown
below. There are two colours shown. The green colour represents the control
circuit and the red colour represents the load circuit. A small control coil is
connected onto the control circuit. A switch is connected to the load. This switch
is controlled by the coil in the control circuit. Now let us take the different steps
that occour in a relay.

relay operation
 Energized Relay (ON)
As shown in the circuit, the current flowing through the coils represented by pins
1 and 3 causes a magnetic field to be aroused. This magnetic field causes the
closing of the pins 2 and 4. Thus the switch plays an important role in the relay
working. As it is a part of the load circuit, it is used to control an electrical circuit
that is connected to it. Thus, when the electrical relay in energized the current
flow will be through the pins 2 and 4.
Energized Relay (ON)
 De – Energized Relay (OFF)
As soon as the current flow stops through pins 1 and 3, the relay switch opens
and thus the open circuit prevents the current flow through pins 2 and 4. Thus
the relay becomes de-energized and thus in off position.

De-Energized Relay (OFF)


In simple, when a voltage is applied to pin 1, the electromagnet activates,
causing a magnetic field to be developed, which goes on to close the pins 2 and
4 causing a closed circuit. When there is no voltage on pin 1, there will be no
electromagnetic force and thus no magnetic field. Thus the switches remain
open.
Pole and Throw
Relays have the exact working of a switch. So, the same concept is also applied. A
relay is said to switch one or more poles. Each pole has contacts that can be
thrown in mainly three ways. They are
 Normally Open Contact (NO) – NO contact is also called a make contact. It closes the
circuit when the relay is activated. It disconnects the circuit when the relay is
inactive.
 Normally Closed Contact (NC) – NC contact is also known as break contact. This is
opposite to the NO contact. When the relay is activated, the circuit disconnects.
When the relay is deactivated, the circuit connects.
 Change-over (CO) / Double-throw (DT) Contacts – This type of contacts are used to
control two types of circuits. They are used to control a NO contact and also a NC
contact with a common terminal. According to their type they are called by the
names break before make and make before break contacts.
Relays can be used to control several circuits by just one signal. A relay switches
one or more poles, each of whose contacts can be thrown by energizing the coil.
Relays are also named with designations like
 Single Pole Single Throw (SPST) – The SPST relay has a total of four terminals. Out of
these two terminals can be connected or disconnected. The other two terminals are
needed for the coil to be connected.
 Single Pole Double Throw (SPDT) – The SPDT relay has a total of five terminals. Out
of these two are the coil terminals. A common terminal is also included which
connects to either of two others.
 Double Pole Single Throw (DPST) – The DPST relay has a total of six terminals. These
terminals are further divided into two pairs. Thus they can act as two SPST’s which
are actuated by a single coil. Out of the six terminals two of them are coil terminals.
 Double Pole Double Throw (DPDT) – The DPDT relay is the biggest of all. It has
mainly eight relay terminals. Out of these two rows are designed to be change over
terminals. They are designed to act as two SPDT relays which are actuated by a single
coil.
Relay Applications
 A relay circuit is used to realize logic functions. They play a very important role in
providing safety critical logic.
 Relays are used to provide time delay functions. They are used to time the delay
open and delay close of contacts.
 Relays are used to control high voltage circuits with the help of low voltage signals.
Similarly they are used to control high current circuits with the help of low current
signals.
 They are also used as protective relays. By this function all the faults during
transmission and reception can be detected and isolated.
Application of Overload Relay
Overload relay is an electro-mechanical device that is used to safeguard motors
from overloads and power failures. Overload relays are installed in motors to
safeguard against sudden current spikes that may damage the motor. An
overload relay switch works in characteristics with current over time and is
different from circuit breakers and fuses, where a sudden trip is made to turn off
the motor.
The most widely used overload relay is the thermal overload relay where a
bimetallic strip is used to turn off the motor. This strip is set to make contact
with a contactor by bending itself with rising temperatures due to excess current
flow. The contact between the strip and the contactor causes the contactor to
de-energize and restricts the power to the motor, and thus turns it off.
Another type of overload motor is the electronic type which continuously
watches the motor current, whereas the thermal overload relay shuts off the
motor depending on the rise of temperature/heat of the strip.
All overload relays available to buy comes in different specifications, the most
important of them being the current ranges and response time. Most of them
are designed to automatically reset to work after the motor is turned back on.
Relay Selection
You must note some factors while selecting a particular relay. They are
 Protection – Different protections like contact protection and coil protection must be
noted. Contact protection helps in reducing arcing in circuits using inductors. Coil
protection helps in reducing surge voltage produced during switching.
 Look for a standard relay with all regulatory approvals.
 Switching time – Ask for high speed switching relays if you want one.
 Ratings – There are current as well as voltage ratings. The current ratings vary from a
few amperes to about 3000 amperes. In case of voltage ratings, they vary from 300
Volt AC to 600 Volt AC. There are also high voltage relays of about 15,000 Volts.
 Type of contact used – Whether it is a NC or NO or closed contact.
 Select Make before Break or Break before Make contacts wisely.
 Isolation between coil circuit and contacts

2. Motor Driver IC L293D:

Even the simplest robot requires a motor to rotate a wheel or performs particular
action. Since motors require more current then the microcontroller pin can typically generate,
you need some type of a switch which can accept a small current, amplify it and generate a
larger current, which further drives a motor. This entire process is done by what is known as
a Motor driver. With L293D Motor Driver IC, that task is made simple and has helped in a
number of applications with relative ease.
L293D H-bridge driver is the most commonly used driver for Bidirectional motor driving
applications. This L293D IC allows DC motor to drive on either direction. L293D is a 16-pin IC
which can control a set of two DC motors simultaneously in any direction. It means that you
can control two DC motor with a single L293D IC. Because it has two H-Bridge Circuit inside.
The L293D can drive small and quiet big motors as well. There are various ways of making H-
bridge motor control circuit such as using transistor, relays and using L293D/L298. Before
going into detail, first we will see what is H-Bridge circuit.
H-Bridge Circuit Working (L293D Motor Driver Working)
Motor driver is basically a current amplifier which takes a low-current signal from the
microcontroller and gives out a proportionally higher current signal which can control and
drive a motor. In most cases, a transistor can act as a switch and perform this task which
drives the motor in a single direction.

Turning a motor ON and OFF requires only one switch to control a single motor in a single
direction. What if you want your motor to reverse its direction? The simple answer is to
reverse its polarity. This can be achieved by using four switches that are arranged in an
intelligent manner such that the circuit not only drives the motor, but also controls its
direction. Out of many, one of the most common and clever design is a H-bridge circuit
where transistors are arranged in a shape that resembles the English alphabet “H”.

A H bridge is an electronic circuit that allows a voltage to be applied across a load in any
direction. H-bridge circuits are frequently used in robotics and many other applications to
allow DC motors to run forward & backward. These motor control circuits are mostly used
in different converters like DC-DC, DC-AC, AC-AC converters and many other types of power
electronic converters. In specific, a bipolar stepper motor is always driven by a motor
controller having two H-bridges.

A H-bridge is fabricated with four switches like S1, S2, S3 and S4. When the S1 and S4
switches are closed, then a +ve voltage will be applied across the motor. By opening the
switches S1 and S4 and closing the switches S2 and S3, this voltage is inverted, allowing
invert operation of the motor.

Generally, the H-bridge motor driver circuit is used to reverse the direction of the motor and
also to brake the motor. When the motor comes to a sudden stop, as the terminals of the
motor’s are shorted. Or let the motor run free to a stop, when the motor is detached from
the circuit. The table below gives the different operations with the four switches
corresponding to the above circuit.
L293D IC
L293D IC generally comes as a standard 16-pin DIP (dual-in line package). This motor driver
IC can simultaneously control two small motors in either direction; forward and reverse with
just 4 microcontroller pins (if you do not use enable pins).

PIN Diagram
Pin Description
PIN PIN
DESCRIPTION
NO NAME

ENABLE When the enable pin is high, then the left part of the IC will work otherwise it won’t
1
1 work. This pin is also called as a master control pin of left side.

2 INPUT 1 When the input pin is high, then the flow of current will be through output 1

OUTPUT
3 This output-1 pin must be connected to one of the terminals of the motor
1

4 GND Connected to Ground

5 GND Connected to Ground

OUTPUT
6 This pin must be connected to one of the terminals of the motor
2

7 INPUT 2 When this pin is HIGH then the flow of current will be though output 2
PIN PIN
DESCRIPTION
NO NAME

8 VS This is the voltage pin which is used to supply the voltage to the motor (12v)

When this pin is high, then the right part of the IC will work & when it is low the right
ENABLE
9 part of the IC won’t work. This pin is also called as a master control pin for the right
2
part of the IC.

10 INPUT 3 When this pin is high, then the flow of current will through output-3

OUTPUT
11 This pin must be connected to one of the terminals of the motor
3

12 GND Connected to Ground

13 GND Connected to Ground

OUTPUT
14 This pin must be connected to one of the terminals of the motor
4

15 INPUT 4 When this pin is high, then the flow of current will be through output-4

16 VSS This pin is the power source to the integrated circuit (5v)

Connection Diagram
The circuit shown to the right is the most basic implementation of L293D IC. There are 16
pins sticking out of this IC and we have to understand the functionality of each pin before
implementing this in a circuit.

1. Pin1 and Pin9 are “Enable” pins. They should be connected to +5V for the drivers to
function. If they pulled low (GND), then the outputs will be turned off regardless of the
input states, stopping the motors. If you have two spare pins in your microcontroller,
connect these pins to the microcontroller, or just connect them to regulated positive 5
Volts.

2. Pin4, Pin5, Pin12 and Pin13 are ground pins which should ideally be connected to
microcontroller’s ground.
3. Pin2, Pin7, Pin10 and Pin15 are logic input pins. These are control pins which should be
connected to microcontroller pins. Pin2 and Pin7 control the first motor (left); Pin10 and
Pin15 control the second motor(right).

4. Pin3, Pin6, Pin11, and Pin14 are output pins. Tie Pin3 and Pin6 to the first motor, Pin11
and Pin14 to second motor

5. Pin16 powers the IC and it should be connected to regulated +5Volts

6. Pin8 powers the two motors and should be connected to positive lead of a secondary
battery. As per the datasheet, supply voltage can be as high as 36 Volts.

I have shown you where to connect the motors, battery and the microcontroller. But how
do we control the direction of these motors? Let us take an example:
Suppose you need to control the left motor which is connected to Pin3 (O1) and Pin6 (O2).
As mentioned above, we require three pins to control this motor – Pin1 (E1), Pin2 (I1) and
Pin7 (I2). Here is the truth table representing the functionality of this motor driver.

ENABLE 1 INPUT 1 INPUT2 FUNCTION

1 1 0 Rotates Anti-clockwise (Reverse)

1 0 1 Rotates Clockwise (Forward)

1 1 1 OFF
ENABLE 1 INPUT 1 INPUT2 FUNCTION

1 0 0 OFF

0 X X OFF

X= Either high or low (don't care)


In the above truth table you can observe that if ENABLE 1 is low then the motor stops,
irrespective of the states on INPUT 1 and INPUT 2. Hence it is essential to hold ENABLE 1
high for the driver to function, or simply connect enable pins to positive 5 volts.

With ENABLE 1 high, if INPUT 1 is set high and INPUT 2 is pulled low, then current flows
from INPUT 1 to INPUT 2 driving the motor in anti-clockwise direction. If the states of INPUT
1 and INPUT 2 are flipped, then current flows from INPUT 2 to INPUT 1 driving the motor in
clockwise direction.

Вам также может понравиться