Sie sind auf Seite 1von 54

1

Chapter 1

1.1 Main Features of the projects:

The Home automation project is divided into two parts:


1. The electrical appliances with computer parallel port interfacing
2. The remote external on/off of the whole system

The first part contains a interfacing circuits which should be connected with the PC
via a parallel port. The computer should need a high definition language such as C,
C+, C++, QuickBasic, visual c, c# etc according to user’s choice. The program will
define the address of the LPT port for the computer as well as function and status of
the devices whether the devices are on or off.

The second part contains a setup which could turn on/off the whole system externally.
Here we use cell phone as it is used widely in modern life. The setup contains a
mobile set, a decoder and programmable microcontroller. The decoder will decode the
signal from mobile to microcontroller and the microcontroller trigger the relay which
is connected to the interfacing unit.

1.2 Objective/Task of the project:


The main objective of the project is:

· To generate and develop a circuit that will accept the signals from a
computer interface via a port and control the switching of the relays
which in turn will control the appliances running on mains power.
· To analyze and develop the instruction codes utilized by the interface
to interact with the device using a high-level programming language.
· To design a DTMF decoder circuit which decodes the frequency of the
button assigned to mobile phone.
· To connect the decoder with a PIC microcontroller and programming it
with necessary condition.
· Finally Implement and combine the whole system.
2

1.3 Historical background:

Automation has had a notable impact in a wide range of highly visible industries,
independent systems and general public services. Medical processes are also carried
out at much greater speed and accuracy by automated systems. Automated teller
machines have reduced the need for bank visits to obtain cash and carry out
transactions. In general, automation has been responsible for the shift in the world
economy from agrarian to industrial in the 19th century and from industrial to
services in the 20th century.
The widespread impact of industrial automation raises social issues one of which is
the impact on labor employment. Historical concerns about the effects of automation
date back to the beginning of the industrial revolution, when a social movement of
English textile machine operators in the early 1800s protested by destroying such
textile machines, which they felt threatened their jobs. When automation was first
introduced, it caused widespread fear. It was thought that the displacement of human
operators by computerized systems would lead to severe unemployment – this
situation might be vague but in certain cases it has been true. Automation might
appear to diminish labor through its replacement with less-expensive machines.
Since the 1960s, the nature of automation has undergone dramatic changes as a result
of the availability of computers. For many years, automated machines were limited by
the amount of feedback data they could collect and interpret. Thus, their operation
was limited to a relatively small number of alternatives. When an automated machine
is placed under the control of a computer, however, that disadvantage disappears. The
computer can analyze a vast number of sensory inputs from a system and decide
which of many responses it should make.
Today, the field of automation is quite advanced, and continues to advance
increasingly more rapidly throughout the world and is influencing on more skilled and
complicated tasks, yet during the same period the general well-being and quality of
life of most people in the world have improved radically.

1.4 Types of Automation:


Automated machines can be divided into two major divisions, open-loop machines
and closed-loop machines. Open-loop machines are devices that, once started, go
3

through a cycle and then stop. A dishwashing machine, microwave oven, a coffee
maker, and a CD player are examples of open-loop machine devices. Closed-loop
machines are devices capable of responding to new instructions at some point in their
operation.
The instructions may come from the operation being performed itself, known as a
feedback or from a human operator. Some closed-loop machines contain sensors, but
are unable to make necessary adjustments on their own. Instead, sensor readings are
sent to human operators who monitor the machine's operation and input any changes
it may need to make in its functioning. Other closed-loop machines contain feedback
mechanisms.
The results of the operation determine what changes, if any, the machine has to make.
Papermaking making machines, steel manufacturing machines, any major
manufacturing machine, etc.

1.5 Advantages of Automation:


· Improves operator productivity and accuracy as it diminishes the
possibility of duplicating the same human (operator) error over and
over again.
· Automating operator tasks simplifies procedures, reduces operator
input and hence increases efficiency and speeds up a process.
· Accelerates problem determination. An operator's primary job is to
bypass or fix problems quickly. If adequate information about a
problem is not available, it might not be possible for the operator to fix
it quickly. Automated operations are especially suited for problem
determination.

1.6 Principles and theory of Automation – Home Automation:


Home automation can range in complexity from the simple gadgets and gizmos that
provide control over individual components to individual home sub-systems and
integrated whole house systems. . Home automation can encompass lighting, security,
telecommunications, access and safety, information and entertainment systems, and
thermal comfort systems.
4

The metaphor of a tree with branches reaching into different locations is a good image
for an integrated full home automation system. Each branch of the tree performs a
different function. One branch of the tree might include home entertainment, such as
television and audio. A second branch could include security, including video
surveillance. A third branch could include telecommunications, like telephone and
intercoms and a fourth branch could include energy and environmental management
including air and water quality, lighting and thermal-comfort.

1.7 Some common devices used in home automation systems are:

· burglar alarms
· video entry systems
· programmed thermostats with zoned heating and cooling
· intercoms
· entertainment systems with many speaker and video connections
· central vacuums hazardous gas detectors
· electronic air cleaners water filtration systems
· Fire alarms.

As implied above, there are different levels of home automation. While the more
advanced systems are comprehensive, many households elect not to have a could
notify the occupant at work, if they’re not at home.
The more intelligent system might also automatically activate a back-up pump if the
main pump failed. While many "occupancy sensors" exist to turn on and off lights and
appliances as individuals move through a house, higher level controls can adjust to
individual preferences. For example, Bill Gates’ widely publicized new home has a
system that adjusts the lighting, multi-media displays and other features automatically
to individual user preferences.
5

Chapter 2

Design of the Proposed System


2.1 Introduction:
This chapter discusses about the concept of the project. The basic design of the
system and the outline of the approach to the different sectors of the project are also
presented. Nowadays almost everyone is somewhat familiar with computer interface
controlled real world applications and the idea of this project is to find an easier and
more effective technique of interfacing with real world application.

2.2 Ideology of the System:


The nature of the device is to automate electrical home appliances in order to
maximize the flexibility of their operation. The basic methodology of the device is
very simple. The hardware is designed to have several terminals to which different
types of electrical appliances such as TV, microwave, fan, air-condition, lighting, etc.
are connected. The device has a Line Printer Terminal (LPT) port in order to connect
with the computer.
The computer then interacts with the device using a GUI (Graphical User Interface)
based software program written specifically for this device. The software contains
control signals through which the device receives specific instructions to carry out and
operate the external appliances connected to it.
Then to control the interface unit a mobile phone along with decoder and programmed
microcontroller is connected in series to the supply main of the devices connected
via interface unit through a relay. The mobile Unit will act as a switch to the whole
automation system.

2.3 Analysis of Automation products:


There has been a few companies manufacturing automation systems and one of the
most famous consumer products is the Home Automation Inc. (HAI). This company
has been one of the leading manufacturers of home control products providing
6

comfort, convenience and safety for homeowners and businesses around the world
since 1985. HAI products are sold in over 80 countries through HAI’s worldwide
network of Distribution Partners and installed by trained dealers.
Since 1992, Smarthome has been considered as one of the world's largest home
automation retailer, with a vast collection of lighting, security, and home
entertainment products that the average customer can safely install with the help of
their Do-It-Yourself instruction kits. They are mostly known for the INSTEON and
X10 SmartHome Systems.
The analysis showed that most of the people are now very familiar to automation
systems. This survey has helped the project to get a benchmark on similar products
and set a target range of applications for which the device can be used. It is now
certain that the proposed system can be designed to have capabilities that can compete
with the current systems available on the market with a much cheaper price tag!

2.4 Design of the device:


The design of the system is rather much easier when relay control is used. A layout of
the system has been shown in Fig.. The basic ideology behind the device is to control
a relay switch with the help of control signals from a computer. A relay is a
mechanical switching device. It has a wide range of applications. It involves a
switching system containing a relay. The system is triggered by another system when
a specific condition is initiated. The control signals from the computer are generated
using a method known as interfacing. The device interacts with custom designed
software which in turn sends the control signals to the LPT port (in the computer
mainboard) which is connected to the device using a LPT/Parallel cable, thus
triggering the relay switch.
The system is designed to have numerous applications but mostly it is more
convenient in daily use if the device is used as a home automation. For ease of home
monitoring and much wider range of appliances to control, this device can be a very
efficient and inexpensive piece of equipment that everyone would prefer for their
personal lives.
7

Relay Switching

Mobile on/off
system

Figure 2.1: Diagram representing the basic ideology of the proposed system

The approach to the design of the proposed system was divided into following parts:
· The relay controller main board – Hardware component.
· The software to drive the controller – Firmware/software component.
· The mobile decoder circuit and microcontroller circuit.
· The program of the microcontroller

2.5 The controller board for Interfacing Unit:


The controller board provides real-time controls for each of the eight onboard
mains rated relay devices. The relay outputs can be used to automatically turn On/Off
electronic appliances running on 120v~240v AC mains supply around the home,
office, laboratory or factory. The components used to build the board are cheap and
readily available in any electronics hardware store. Some features of the device are
listed below:

· The controller can be used with any PC parallel port.


· Each channel has an AC mains rated relay output.
· Each channel relay can be controlled independently to define an on/off
sequence.
· Contains LED relay status indicator for each relay.
8

Nevertheless, these are some of the basic capabilities of the very dynamic system. A
more detailed working principle of the device and the components used are
elaborately discussed in the following chapters of this thesis.

2.6 The software to drive the Interfacing Unit:


A customized software interface is used to interact with the relay controller to
program the On/Off sequences. The real-time based system is used to program each
individual relay to switch it on/off at a particular date and time. Moreover, the
software can also override the automatic sequence and use manual controls to switch
each relay. Finally, a web interface can be designed to control the server-pc which is
connected to the device. The web interface will give high flexibility to the system,
giving wireless access to each appliance connected to the device. Thus, when the user
needs to control the appliance, he/she can simply access the internet using pc or
mobile phone and logon to the restricted site using username and password. The page
will then load an interface which will contain all the information of the current state
of the device and the controls to operate the device. Nonetheless, the software portion
is discussed in much more detail using diagrams/flowcharts and code snippets in later
chapters in this paper.

2.7 The program to Load the Microcontroller:

Microcontroller can not run if it is not programmed. There are several ways of
programming the microcontroller - using BASIC, C, or Assembly Language. In this
project we use c+ to program the microcontroller. The programming of
microcontroller will be discussed in later chapter.
9

Chapter 3

Description of Electronic Component:


3.1 Introduction:
This chapter describes all the electronic components that have been used to develop
the circuit of both interfacing and mobile on/off unit . The components used are relay
switches, BJT transistors and opto-couplers, DTMF decoder, oscillators, PIC
microcontrollers etc. Here we shall discuss in detail of these components.

3.2 Relay Switches:


A relay is an electronic component that is operated by an electromagnet to open or
close one or many sets of contacts similar to the function of an electrical switch. A
relay can also be called a form of amplifier because it is able to control an output
circuit of higher power than the input circuit using a connection that is purely
magnetic and mechanical without having any significant electrical connection
between the two circuits.

3.3 Relay Operating Principle:


Relays are constructed having two circuits. A control circuit marked with pins 1 and 3
and a load circuit marked with pins 2 and 4, shown in Fig(a). The control circuit has a
small control coil while the load circuit has a switch. The coil controls the operation
of the switch. Relays normally have two states of operation as mentioned below:
· Relay Energized (ON): Current flowing through the control circuit coil
pins 1 and 3 creates a small magnetic field which causes the switch to
close at pins 2 and 4, shown in Fig.(b). The switch in the load circuit is
used to control an external electrical circuit connected to it. So, when the
relay is energized, current flows through pins 2 and 4.
· Relay De-energized (OFF): When current stops flowing through the
control circuit, pins 1 and 3, the relay becomes de-energized. Without the
magnetic field, the switch opens and current is prevented from flowing
through pins 2 and 4, shown in Fig . So, the relay is turned OFF.
10

(a) (b) (c)

Figure 3.1: Schematic of the circuits inside a Relay switch

3.31 Relay Design:


Relays are either normally open or normally closed. This can be identified by the
position of the switches in the two relays shown below . Normally open relays have a
switch that remains open until energized (ON) while normally closed relays remains
closed until energized.

Figure 3.2: Schematic of two types of relay designs

3.32 Actual Relay Operation:


Fig. illustrates the actual process inside a relay. Current flows through the control coil,
which is wrapped around an iron core. The iron core intensifies the magnetic field.
The magnetic field attracts the upper contact arm and pulls it down, closing the
contacts and allowing power from the supply to the load.
11

Figure 3.3: Schematic of actual relay operation

When a current flows through the control coil , the resulting magnetic field attracts an
armature that is mechanically linked to a moving contact. The movement either makes
or breaks a connection between switch contacts. When the current to the control coil
is switched off, the armature is returned by a force approximately half as strong as the
magnetic force to its relaxed position.

Figure 3.4: Components of a Relay switch

3.33 Types of Relays:


Relays come in a variety of form factors, styles, and technologies. Depending on the
application, relays are selected. Relays are chosen depending upon their
12

characteristics. The comparisons presented here are between relays with similar
voltage, current, and power ratings in the form factors that are found in typical switch
modules.
The most common types of relays used in automated applications are:
· Electromechanical Relays.
· Reed Relays.
· Solid State Relays (SSRs).
· FET Switches.
In this project, the input voltage rating is 6v DC and the output rating is 120v AC. The
type of relay chosen to handle this specification was dependent on the availability of
relays in the market. So, a survey was conducted to choose the right one for this
application. The following sections explain how these relays operate and identify their
relative strengths and weaknesses.

3.34 Electromechanical Relays:


Electromechanical relays are perhaps the most widely used relays in
automated applications today. They are made of a coil, an armature mechanism, and
electrical contacts. When the coil is energized, the induced magnetic field moves the
armature that opens or closes the contacts .

(b) – Schematic of Electromechanical Relay


(a) – Structure of
Electromechanical Relay

Figure 3.5 : Diagrams of Electromechanical Relay


Electromechanical relays support a wide range of signal characteristics, from low
voltage/current to high voltage/current and from DC to GHz frequencies. For this
13

reason, it is easier to find an electromechanical relay with signal characteristics that


match given system requirements. The drive circuitry in electromechanical relays is
galvanically isolated from the relay contacts, and the contacts themselves are also
isolated from one another. This isolation makes electromechanical relays an excellent
choice for situations where galvanic isolation is required.

3.40 Transistors:
In electronics, a transistor is a semiconductor device commonly used to amplify or
switch electronic signals. The transistor is the fundamental building block of
computers, and all other modern electronic devices.
A Bipolar Junction Transistor (BJT) is a type of transistor. It is a three-terminal
device constructed of doped semiconductor material and may be used in amplifying or
switching applications. Bipolar transistors are so named because their operation
involves both electrons and holes. Although a small part of the transistor current is
due to the flow of majority carriers, most of the transistor current is due to the flow of
minority carriers and so BJTs are classified as 'minority-carrier' devices.

3.41 Structure of NPN Transistor:


NPN is one of the two types of bipolar transistors, in which the letters "N" and "P"
refer to the majority charge carriers inside the different regions of the transistor. Most
bipolar transistors used today are NPN, because electron mobility is higher than hole
mobility in semiconductors, allowing greater currents and faster operation.
NPN transistors consist of a layer of P-doped semiconductor (the "base") between two
N-doped layers . A small current entering the base in common-emitter mode is
amplified in the collector output. In other terms, an NPN transistor is "on" when its
base is pulled High relative to the emitter.

Figure 3.6: Structure of NPN Transistor


14

The arrow in the NPN transistor symbol is on the emitter leg and points in the
direction of the conventional current flow when the device is in forward active mode.
In this project, NPN transistors were used instead of PNP. The model was NPN
2N2222 transistor.

3.42 Structure of PNP Transistor :

The other type of BJT is the PNP with the letters "P" and "N" referring to the majority
charge carriers inside the different regions of the transistor.
PNP transistors consist of a layer of N-doped semiconductor between two layers of P-
doped material . A small current leaving the base in common-emitter mode is
amplified in the collector output. In other terms, a PNP transistor is "on" when its base
is pulled low relative to the emitter.

Figure 3.7: Structure of PNP Transistor

The arrow in the PNP transistor symbol is on the emitter leg and points in the
direction of the conventional current flow when the device is in forward active mode.

3.43 Operation of NPN Transistor:

An NPN transistor can be considered as two diodes with a shared anode region. In
typical operation, the emitter–base junction is forward biased and the base–collector
junction is reverse biased . In an NPN transistor, when a positive voltage is applied to
the emitter-base junction, the equilibrium between thermally generated carriers and
the repelling electric field of the depletion region becomes unbalanced, allowing
15

thermally excited electrons to inject into the base region. These electrons diffuse
through the base from the region of high concentration near the emitter towards the
region of low concentration near the collector. The electrons in the base are called
minority carriers because the base is doped p-type which would make holes the
majority carriers in the base.

Figure 3.8: Operation of NPN Transistor

The base region of the transistor must be made thin , so that carriers can diffuse
across it in much less time than the semiconductor's minority carrier lifetime, to
minimize the percentage of carriers that recombine before reaching the base-collector
junction. To ensure this, the thickness of the base is much less than the diffusion
length of the electrons.
The base-collector junction is reverse-biased , so little electron injection occurs from
the collector to the base, but electrons that diffuse through the base towards the
collector are swept into the collector by the electric field in the depletion region of the
base-collector junction.

· Temperature sensors Because of the known temperature and current


dependence of the forward-biased base–emitter junction voltage, the
BJT can be used to measure temperature by subtracting two voltages at
two different bias currents in a known ratio.
16

· Logarithmic converters Since base–emitter voltage varies as the log of


the base–emitter and collector–emitter currents, a BJT can also be used
to compute logarithms and anti-logarithms. A diode can also perform
these nonlinear functions, but the transistor provides more circuit
flexibility.

3.50 Optocouplers:
Optocouplers (or opto-isolators, photocoupler, photoMOS) are useful switching
devices that provide high current gain or drive capability and electrical isolation
between circuit elements. In general, an optocoupler is a hybrid device and consists of
a GaAs-based light-emitting diode (LED) and a photodetector (either a photodiode or
phototransistor) which are optically coupled via an optically-transmitting medium, but
electrically isolated. The basic principle of operation is light emitted from the LED
incident on the photodetector produces a current that switches the output transistor to
conduct current.

(b) – Schematic diagram of


(a) – Structure of Optocoupler
Optocoupler

Figure 3.9: Diagrams of Optocoupler

3.51 Optocoupler Operating Modes:


With a photodiode as the detector, the output current is proportional to the amount of
incident light supplied by the emitter. The diode can be used in a “photovoltaic” mode
or a “photoconductive” mode.
· In photovoltaic mode, the diode acts like a current source in parallel
with a forward-biased diode. The output current and voltage are
dependent on the load impedance and light intensity.
17

· In photoconductive mode, the diode is connected to a supply voltage,


and the magnitude of the current conducted is directly proportional to
the intensity of light.

3.52 Optocoupler Construction:


Optocouplers typically come in a small 6-pin or 8-pin IC package, but are essentially
a combination of two distinct devices: an optical transmitter, typically a gallium
arsenide LED (light-emitting diode) and an optical receiver such as a phototransistor
or light-triggered Diac. The two are separated by a transparent barrier which blocks
any electrical current flow between the two, but does allow the passage of light.
Fig. below shows the basic structure of an optocoupler. Usually, the electrical
connections to the LED section are brought out to the pins on one side of the package
and those for the phototransistor or Diac to the other side, to physically separate them
as much as possible.

Figure 3.10: Internal construction of Optocoupler

3.60 MT8870 DTMF decoder:


The MT8870D -1 is a complete DTMF receiver integrating both the band split filter
and digital decoder functions. The filter section uses switched capacitor techniques for
high and low group filters; the decoder uses digital counting techniques to detect and
decode all 16 DTMF tone airs into a 4-bit code. External component count is
minimized by on chip provision of a differential input amplifier, clock oscillator and
latched three-state bus interface.
18

3.61 Applications of DTMF Decoder:

• Receiver system for British Telecom (BT) or EPT Spec (MT8870D-1)


• Paging systems
• Repeater systems/mobile radio
• Credit card systems
• Remote control
• Personal computers
• Telephone answering machine

3.62 Functional Description of DTMF Decoder:


The MT8870D/MT8870D-1 monolithic DTMF receiver offers small size, low power
consumption and high performance. Its architecture consists of a and split filter
section, which separates the high and low group tones, followed by a digital counting
section which verifies the frequency and duration of the received tones before passing
the corresponding code to the output bus.

3.63 About DTMF:


Dual-tone multi-frequency (DTMF) signaling is used for telephone signaling over the
line in the voice-frequency band to the call switching center. The version of DTMF
used for telephone tone dialing is known by the trademarked term Touch-Tone, and is
standardised by ITU-T Recommendation Q.23. Other multi-frequency systems are
used for signaling internal to the telephone network.
DTMF was developed at Bell Labs in order to allow dialing signals to dial long-
distance numbers, potentially over nonwire links such as microwave radio relay links
or satellites. For a few non crossbar offices, encoder/decoders were added that would
convert the older pulse signals into DTMF tones and play them down the line to the
remote end office. At the remote site another encoder/decoder could decode the tones
and perform pulse dialing, for example for Strowger switches. It was as if you were
connected directly to that end office, yet the signaling would work over any sort of
link. This idea of using the existing network for signaling as well as the message is
known as in-band signaling.
19

3.64 Pin Description of DT8870:

3.65 DTMF Keypad:

The DTMF keypad is laid out in a 4×4 matrix, with each row representing a low
frequency, and each column representing a high frequency. Pressing a single key such as
'1' will send a sinusoidal tone of the two frequencies 697 and 1209 hertz (Hz). The
original keypads had levers inside, so each button activated two contacts. The multiple
tones are the reason for calling the system multi frequency. These tones are then decoded
by the switching center to determine which key was pressed.
20

DTMF keypad frequencies:

1209 Hz 1336 Hz 1477 Hz 1633 Hz


697 Hz 1 2 3 A
770 Hz 4 5 6 B
852 Hz 7 8 9 C
941 Hz * 0 # D

3.70 Crystal Oscillator:

A crystal oscillator is an electronic circuit that uses the mechanical resonance of a


vibrating crystal of piezoelectric material to create an electrical signal with a very precise
frequency. This frequency is commonly used to keep track of time (as in quartz
wristwatches), to provide a stable clock signal for digital integrated circuits, and to
stabilize frequencies for radio transmitters and receivers. The most common type of
piezoelectric resonator used is the quartz crystal, so oscillator circuits designed around
them were called "crystal oscillators".

3.71 Operation of Crystal oscillator:

A crystal is a solid in which the constituent atoms, molecules, or ions are packed in a
regularly ordered, repeating pattern extending in all three spatial dimensions.

Almost any object made of an elastic material could be used like a crystal, with
appropriate transducers, since all objects have natural resonant frequencies of vibration.
For example, steel is very elastic and has a high speed of sound. It was often used in
mechanical filters before quartz. The resonant frequency depends on size, shape,
elasticity, and the speed of sound in the material. High-frequency crystals are typically
cut in the shape of a simple, rectangular plate. Low-frequency crystals, such as those used
in digital watches, are typically cut in the shape of a tuning fork. For applications not
needing very precise timing, a low-cost ceramic resonator is often used in place of a
quartz crystal.

When a crystal of quartz is properly cut and mounted, it can be made to distort in an
electric field by applying a voltage to an electrode near or on the crystal. This property is
21

known as piezoelectricity. When the field is removed, the quartz will generate an electric
field as it returns to its previous shape, and this can generate a voltage. The result is that a
quartz crystal behaves like a circuit composed of an inductor, capacitor and resistor, with
a precise resonant frequency.

Quartz has the further advantage that its elastic constants and its size change in such a
way that the frequency dependence on temperature can be very low. The specific
characteristics will depend on the mode of vibration and the angle at which the quartz is
cut (relative to its crystallographic axes). Therefore, the resonant frequency of the plate,
which depends on its size, will not change much, either. This means that a quartz clock,
filter or oscillator will remain accurate. For critical applications the quartz oscillator is
mounted in a temperature-controlled container, called a crystal oven, and can also be
mounted on shock absorbers to prevent perturbation by external mechanical vibrations.

Figure 3.11: A pierced oscillator

3.80 Microcontroller:

A microcontroller (also microcontroller unit, MCU or µC) is a small computer on a


single integrated circuit consisting of a relatively simple CPU combined with support
functions such as a crystal oscillator, timers, watchdog, serial and analog I/O etc.
Program memory in the form of NOR flash or OTP ROM is also often included on chip,
as well as a, typically small, read/write memory.
22

Microcontrollers are designed for small or dedicated applications. Thus, in contrast to the
microprocessors used in personal computers and other high-performance or general
purpose applications, simplicity is emphasized. Some microcontrollers may operate at
clock frequencies as low as 32kHz, as this is adequate for many typical applications,
enabling low power consumption (milliwatts or microwatts). They will generally have the
ability to retain functionality while waiting for an event such as a button press or other
interrupt; power consumption while sleeping (CPU clock and most peripherals off) may
be just nanowatts, making many of them well suited for long lasting battery applications.
Other microcontrollers may serve performance-critical roles, where they may need to act
more like a Digital signal processor (DSP), using higher clock speeds and not needing
such very low powered operation.

3.81 Embedded design of Microcontroller:

The majority of computer systems in use today are embedded in other machinery, such as
automobiles, telephones, appliances, and peripherals for computer systems. These are
called embedded systems. While some embedded systems are very sophisticated, many
have minimal requirements for memory and program length, with no operating system,
and low software complexity. Typical input and output devices include switches, relays,
solenoids, LEDs, small or custom LCD displays, radio frequency devices, and sensors for
data such as temperature, humidity, light level etc. Embedded systems usually have no
keyboard, screen, disks, printers, or other recognizable I/O devices of a personal
computer, and may lack human interaction devices of any kind.

(i)Interrupts:

Microcontrollers must provide real time (predictable, though not necessarily fast)
response to events in the embedded system they are controlling. When certain events
occur, an interrupt system can signal the processor to suspend processing the current
instruction sequence and to begin an interrupt service routine (ISR, or "interrupt
handler"). The ISR will perform any processing required based on the source of the
interrupt before returning to the original instruction sequence. Possible interrupt sources
are device dependent, and often include events such as an internal timer overflow,
completing an analog to digital conversion, a logic level change on an input such as from
a button being pressed, and data received on a communication link. Where power
consumption is important as in battery operated devices, interrupts may also wake a
23

microcontroller from a low power sleep state where the processor is halted until required
to do something by a peripheral event.

(ii) Programs:

Microcontroller programs must fit in the available on-chip program memory, since it
would be costly to provide a system with external, expandable, memory. Compilers and
assembly language are used to turn high-level language programs into a compact machine
code for storage in the microcontroller's memory. Depending on the device, the program
memory may be permanent, read-only memory that can only be programmed at the
factory, or program memory may be field-alterable flash or erasable read-only memory.

(iii)Other microcontroller features:

Since embedded processors are usually used to control devices, they sometimes need to
accept input from the device they are controlling. This is the purpose of the analog to
digital converter. Since processors are built to interpret and process digital data, i.e. 1s
and 0s, they won't be able to do anything with the analog signals that may be being sent
to it by a device. So the analog to digital converter is used to convert the incoming data
into a form that the processor can recognize. There is also a digital to analog converter
that allows the processor to send data to the device it is controlling.

In addition to the converters, many embedded microprocessors include a variety of timers


as well. One of the most common types of timers is the Programmable Interval Timer, or
PIT for short. A PIT just counts down from some value to zero. Once it reaches zero, it
sends an interrupt to the processor indicating that it has finished counting. This is useful
for devices such as thermostats, which periodically test the temperature around them to
see if they need to turn the air conditioner on, the heater on, etc.

Time Processing Unit or TPU for short is a sophisticated timer. In addition to counting
down, the TPU can detect input events, generate output events, and perform other useful
operations.

3.82 Types of microcontrollers:

As of 2008 there are several dozen microcontroller architectures and vendors including:
24

· 68HC11
· 8051
· ARM processors (from many vendors) using ARM7 or Cortex-M3 cores are
generally microcontrollers
· Atmel AVR (8-bit), AVR32 (32-bit), and AT91SAM
· Freescale ColdFire (32-bit) and S08 (8-bit)
· Hitachi H8, Hitachi SuperH
· MIPS (32-bit PIC32)
· NEC V850
· PIC (8-bit PIC16, PIC18, 16-bit dsPIC33 / PIC24)
· PowerPC ISE
· PSoC (Programmable System-on-Chip)
· Rabbit 2000
· Texas Instruments MSP430 (16-bit), C2000 (32-bit), and Stellaris (32-bit)
· Toshiba TLCS-870
· Zilog eZ8, eZ80

and many others, some of which are used in very narrow range of applications or are
more like applications processors than microcontrollers. The microcontroller market is
extremely fragmented, with numerous vendors, technologies, and markets. Note that
many vendors sell (or have sold) multiple architectures. In mid-2009, some consolidation
is evident, with vendors pruning product lines.

3.83 PIC Microcontroller(PIC16f84a) :

PIC16F84 belongs to a class of 8-bit microcontrollers of RISC architecture. Its general


structure is shown on the following map representing basic blocks. Program memory
(FLASH)- for storing a written program. Since memory made in FLASH technology can
be programmed and cleared more than once, it makes this microcontroller suitable for
device development. EEPROM - data memory that needs to be saved when there is no
supply. It is usually used for storing important data that must not be lost if power supply
suddenly stops. For instance, one such data is an assigned temperature in temperature
regulators. If during a loss of power supply this data was lost, we would have to make
the adjustment once again upon return of supply.
25

3.84 Applications of PIC16F84A:

PIC16F84 perfectly fits many uses, from automotive industries and controlling home
appliances to industrial instruments, remote sensors, electrical door locks and safety
devices. It is also ideal for smart cards as well as for battery supplied devices because of
its low consumption.

EEPROM memory makes it easier to apply microcontrollers to devices where permanent


storage of various parameters is needed (codes for transmitters, motor speed, receiver
frequencies, etc.). Low cost, low consumption, easy handling and flexibility make
PIC16F84 applicable even in areas where microcontrollers had not previously been
considered (example: timer functions, interface replacement in larger systems,
coprocessor applications, etc.).

In System Programmability of this chip (along with using only two pins in data transfer)
makes possible the flexibility of a product, after assembling and testing have been
completed. This capability can be used to create assembly-line production, to store
calibration data available only after final testing, or it can be used to improve programs
on finished products.

3.85 Pin description:

PIC16F84 has a total of 18 pins. It is most frequently found in a DIP18 type of case but
can also be found in SMD case which is smaller from a DIP. DIP is an abbreviation for
Dual In Package. SMD is an abbreviation for Surface Mount Devices suggesting that
holes for pins to go through when mounting aren't necessary in soldering this type of a
component.

Figure 3.12: diagram of OIC 16F84


26

Pins on PIC16F84 microcontroller have the following meaning:


Pin no.1 RA2 Second pin on port A. Has no additional function.
Pin no.2 RA3 Third pin on port A. Has no additional function.
Pin no.3 RA4 Fourth pin on port A. TOCK1 which functions as a timer is also
found on this pin.
Pin no.4 MCLR Reset input and Vpp programming voltage of a microcontroller.
Pin no.5 Vss Ground of power supply.
Pin no.6 RB0 Zero pin on port B. Interrupt input is an additional function.
Pin no.7 RB1 First pin on port B. No additional function.
Pin no.8 RB2 Second pin on port B. No additional function.
Pin no.9 RB3 Third pin on port B. No additional function.
Pin no.10 RB4 Fourth pin on port B. No additional function.
Pin no.11 RB5 Fifth pin on port B. No additional function.
Pin no.12 RB6 Sixth pin on port B. 'Clock' line in program mode.
Pin no.13 RB7 Seventh pin on port B. 'Data' line in program mode.
Pin no.14 Vdd Positive power supply pole.
Pin no.15 OSC2 Pin assigned for connecting with an oscillator.
Pin no.16 OSC1 Pin assigned for connecting with an oscillator.
Pin no.17 RA2 Second pin on port A. No additional function.
Pin no.18 RA1 First pin on port A. No additional function.

3.90 Parallel Port:

Line Print Terminal (LPT) is the usual designation for a parallel port connection. In the
computer world, a port is a set of signal lines that the microprocessor, or CPU, uses to
exchange data with other components. Typical usages of ports are communicating with
printers, modems, keyboards, displays and just about any component or device except
system memory. Most computer ports are digital, where each signal, or bit, is 0 or 1. The
LPT port transfers multiple bits at once, while a serial port transfers a bit at a time.The
original LPT port design had eight outputs, five inputs, and four bidirectional lines. These
are enough for communicating with many types of peripherals. In later versions, the eight
outputs were able to serve also as inputs, for faster communications with scanners, drives,
and other devices that send data to the PC. The LPT port was designed as a printer port,
and many of the original names for the port's signals reflect that use.
27

3.91 Port Types:


As the design of the PC evolved, several manufacturers introduced improved versions of
the LPT port. The new port types are compatible with the original design, but add new
abilities, mainly for higher speed. Speed is important because as computers and
peripherals have gotten faster, the jobs they do have become more complicated, and the
amount of information they need to exchange has increased.
A fast interface also makes it feasible to use portable, external versions of peripherals that
would otherwise have to be installed inside the computer. The following section gives a
summary of the available port types:
· SPP: Emulates the original port. Also called AT-type or ISA-compatible.
· PS/2: Like an SPP, except that the data port is bidirectional.
· EPP: Can do EPP transfers. Emulates an SPP and PS/2-type port.
· ECP: Can do ECP transfers. Emulates an SPP or PS/2-type port. An
additional ECP's buffer is used for faster data transfers with many
peripherals.
· Multi-mode: The most flexible port type, because it can emulate all of the
others.

3.92 Standard Parallel Port (SPP):


Any parallel port that emulates the original port's design is sometimes called the SPP, for
standard parallel port, even though the original port had no written standard beyond the
schematic diagrams and documentation for the IBM PC. Other names used are AT-type
or ISA-compatible. The port in the original PC was based on an existing Centronics
printer interface. Centronics Data Computer Corporation is an early manufacturer of dot-
matrix printers. However, the PC introduced a few differences, which other systems have
continued. SPPs can transfer eight bits at once to a peripheral, using a protocol similar to
that used by the original Centronics interface. The SPP doesn't have a byte-wide input
port, but for PC-to-peripheral transfers, SPPs can use a Nibble mode that transfers each
byte 4 bits at a time. Nibble mode is slow, but has become popular as a way to use the
parallel port for input.
28

3.93 Enhanced Parallel Port (EPP):


The Enhanced Parallel Port (EPP) was originally developed by chip maker Intel, PC
manufacturer Zenith, and Xircom, a maker of parallel-port networking products. As on
the PS/2-type port, the data lines are bidirectional. An EPP can read or write a byte of
data in one cycle of the ISA expansion bus, or about 1 microsecond, including
handshaking, compared to four cycles for an SPP or PS/2-type port. An EPP can switch
directions quickly, so it's very efficient when used with disk and tape drives and other
devices that transfer data in both directions. An EPP can also emulate an SPP, and some
EPPs can emulate a PS/2-type port as well.

3.94 Extended Capabilities Port (ECP):


The Extended Capabilities Port (ECP) was first proposed by Hewlett Packard and
Microsoft. Like the EPP, the ECP is bidirectional and can transfer data at ISA-bus
speeds. Fig.(b), shows the diagram of ECP. ECP have buffers and support for Direct
Memory Access (DMA) transfers and data compression. ECP transfers are useful for
printers, scanners, and other peripherals that transfer large blocks of data. An ECP can
also emulate an SPP or PS/2-type port, and many ECPs can emulate an EPP also.

Figure 3.13(b) : Diagram of


Figure 3.13(a) : Diagram of ECP
EPP

3.10.1 System Resources:


The LPT port uses a variety of the computer's resources. Each port uses a range of
addresses, though the number and location of addresses varies. Many ports have an
assigned Interrupt Request (IRQ) level, and ECPs may have an assigned DMA channel.
The resources assigned to a port cannot conflict with those used by other system
29

components, including other parallel ports. The following sections explain the resources
in a bit more detail.

3.10.2 Addressing:
The standard parallel port uses three adjacent memory address locations, usually in one of
these ranges:
· 3BCh, 3BDh, 3BEh
· 378h, 379h, 37Ah
· 278h, 279h, 27Ah
The first address in the range is the port's base address, also called the Data register or
just the port address. The second address is the port's Status register, and the third is the
Control register. EPPs and ECPs reserve additional addresses for each port.
On early PCs, the parallel port had a base address of 3BCh. On newer systems, the
parallel port’s memory address location is at 378h. If the port's hardware allows, it is
possible to configure a port at any of the addresses.
IBM's Type 3 PS/2 port also had three additional registers. Most often, DOS and
Windows refer to the first port in numerical order as LPTI, the second, LPT2, and the
third, LPT3. LPT1 is most often at 378h, but it may be at any of the three addresses.
LPT2, if it exists, may be at 378h or 278h, and LPT3 can only be at 278h. Various
configuration techniques can change these assignments- however, not all systems will
follow this convention.

3.10.3 Port Hardware:


The LPT port's hardware includes the back-panel connector and the circuits and cabling
between the connector and the system's expansion bus. The PC's microprocessor uses the
expansion bus's data, address, and control lines to transfer information between the
parallel port and the CPU, memory, and other system components.

3.11.1 Connectors:
The PC's back panel has the connector for plugging in a cable to a printer or other device
with a LPT-port interface. Most parallel ports use the 25-contact D-sub connector shown
in Fig.(a). The shell (enclosure that surrounds the contacts) is roughly in the shape of an
upper-case D. Other names for this connector are the subminiature D, DB-25, D-shell, or
just D connector. The IEEE 1284 standard for the parallel port calls it the IEEE 1284-A
connector.
30

Some other LPT ports uses the compact, 36-pin IEEE 1284-C (also called Centronics)
connector as shown in Fig.(b). The connector on the computer is female, where the
individual contacts are sockets. The cable has a mating male connector, whose contacts
are pins, or plugs. The LPT-port connector is usually the only female 25-pin D-sub on the
back panel.
Some serial ports use a 25-contact D-sub, but with few exceptions, a 25-pin serial D-sub
on a PC is male, with the female connector on the cable-the reverse of the LPT-port
convention. (Other serial ports use 9-pin D-subs instead.)
SCSI is another interface whose connector might occasionally be confused with the LPT
port. The SCSI interface used by disk drives, scanners, and other devices usually has a
50-contact connector, but some SCSI devices use a 25-contact D-sub that is identical to
the LPT-port's connector.

Figure 3.14(b): Diagram of 36-


Figure 3.14(a) : Diagram of 25- pin Centronics connector
pin D-sub connector
The port circuits connect to address, data, and control lines on the expansion bus, and
these in turn interface to the microprocessor and other system components. Most printer
cables have a 25-pin male D-sub connector on one end and a male 36-contact connector
on the other end . Many refer to the 36-contact connector as the Centronics connector,
because it's the same type formerly used on Centronics printers.

3.12.1 Accessing Ports:


Windows, DOS, and programming languages like VB, C++, C#, etc. provide several
ways to read and write data to parallel ports. The most direct way is reading and writing
to the port registers. Windows also has API calls for accessing LPT ports, and 16-bit
programs can use BIOS and DOS software interrupts for LPT access. The following
sections introduce the parallel port's signals and ways of accessing them through user-
defined programs.
31

3.13.1 The Signals:


Table 1 shows the functions of each of the 25 contacts at the LPT port's connector, along
with additional information about the signals and their corresponding register bits.

Table 1: Parallel Port Signals, arranged by Pin Numbers:


Register Inverted
Pin:
Pin: at
D- Function Source Bit
Centronics Name Connecto
sub #
r
1 1 Strobe D0-D7 PC1 Contro 0 Y
2 2 Data Bit 0 PC, Data 0 N
3 3 Data Bit 1 pC2 Data 1 N
4 4 Data Bit 2 pC2 Data 2 N
5 5 Data Bit 3 PC, Data 3 N
6 6 Data Bit 4 pC2 Data 4 N
7 7 Data Bit 5 pC Data 5 N
8 8 Data Bit 6 pC2 Data 6 N
9 9 Data Bit 7 pC2 Data 7 N
10 10 Acknowledge Printer Status 6 N
11 11 Printer Busy Printer Status 7 Y
Paper end, empty (out of
12 12 paper) Printer Status 5 N
13 13 Printer Selected(online) Printer Status 4 N
Generate automatic line feeds Contro
14 14 after carriage returns pC1 l 1 Y
15 32 Error Printer Status 3 N
Contro
16 31 Initialize Printer (Reset) PC1 l 2 N
Register Inverted
Pin:
Pin: at
D- Function Source Bit
Centronics Name Connecto
sub #
r
Contro
17 36 Select Printer (Place on line) PC1 l 3 Y
Ground return for nStrobe,
18 19,20 D0
19 21,22 Ground return for D1, D2
20 23,24 Ground return for D3, D4
21 25,26 Ground return for D5, D6
22 27,28 Ground return for D7, nAck
23 33 Ground return for nSelectIn
24 29 Ground return for Busy
25 30 Ground return for nInit
17 Chassis ground
15,18,34 No Connection
16 Signal gound
35 -5V Printer
32

Table 2 shows the information arranged by register rather than by pin number, and
including register bits that does not appear at the connector
Table2: Parallel Port Signals, arranged by Port Registers:
Data Register (Base Address)
Bit Pin: D-sub Pin: Centronics Source Inverted at Connector

0 2 2 PC N
1 3 3 PC N
2 4 4 PC N
3 5 5 PC N
4 6 6 PC N
5 7 7 PC N
6 8 8 PC N
7 9 9 PC N
Sone Data Ports are bidirectional. (See Control register, bit 5)
Status Register(Base Address +1)
Bit Pin: D-sub Pin: Centronics Source Inverted at Connector

3 15 32 Peripheral N
4 13 13 Peripheral N
5 12 12 Peripheral N
6 10 10 Peripheral N
7 11 11 Peripheral Y
Additional bits not available at the connector:
0: may indicate timeout (1=timeout).
1, 2: unused.

Control Register(Base Address +2)


Bit Pin: D-sub Pin: Centronics Source Inverted at Connector

0 1 1 PCI Y
1 14 14 PC1 Y
2 16 31 PC N
3 17 36 PC’ Y
'When high, PC can read external input (SPP only).
Additional bits not available at the connector:
4: Interrupt enable. 1 = IRQs pass from nAck to system's interrupt controller.
0 = IRQs do not pass to interrupt controller.
5: Direction control for bidirectional Data ports. 0 = outputs enabled.
1 = outputs disabled; Data port can read external logic voltages.
6,7: unused
33

3.14.1 The Data Register:


The Data port, or Data register, (DO-D7) holds the byte written to the Data outputs. In
bidirectional Data ports, when the port is configured as input, the Data register holds the
byte read at the connector's Data pins.

3.14.2 The Status Register:


The Status port, or Status register, holds the logic states of five inputs, S3 through S7.
Bits SO-S2 does not appear at the connector. The Status register is read-only, except for
SO, which is a timeout flag on ports that support EPP transfers, and can be cleared by
software. In their conventional uses, the Status bits have the following functions:
· SO: Timeout - In EPP mode, this bit may go high to indicate a timeout of an
EPP data transfer. Otherwise it remains unused.
· Sl: Unused.
· S2: Unused - except for a few ports where this bit indicates parallel port
interrupt status (PIRQ). It becomes Low when parallel-port interrupt has
occurred and High when no interrupt has occurred.
· S3: nError or nFault - Low when the printer detects an error or fault.
· S4: Select - High when the printer is on-line (when the printer's Data inputs are
enabled).
· S5: PaperEnd, PaperEmpty, or PError - High when the printer is out of paper.
· S6: nAck or nAcknowledge - Pulses Low when the printer receives a byte.
Occurs when interrupts are enabled.
· S7: Busy - Low when the printer isn't able to accept new data. Inverted at the
connector.

3.14.3 The Control Register:


The Control port, or Control register, holds the states of four bits, CO through C3.
Typically, the bits are used as outputs. On most SPPs, however, the Control bits may also
function as inputs. To read an external logic signal at a Control bit, when 1 is written to
the corresponding output, it reads from the register bit. However, most ports supporting
EPP and ECP modes, to improve switching speed, the Control outputs are push-pull type
and cannot be used as inputs. Bits C4 through C7 does not appear at the connector. Under
normal operation, the Control bits have the following functions:
34

· CO: nStrobe - The rising edge of this low-going pulse signals the printer to
read DO-D7. Inverted at the connector. After reboot it remains normally high
at the connector.
C1: AutoLF or Automatic line feed - A low tells the printer to automatically
generate a line feed after each Carriage Return. Inverted at the connector. After
reboot it remains normally high at the connector.
C2: nInit or nInitialize - Pulses low to reset the printer and clear its buffer.
Minimum pulse width: 50 microseconds. After reboot it remains normally high at
the connector.
C3: nSelectIn - High to tell the printer to enable its Data inputs. Inverted at the
connector. After reboot it remains normally low at the connector.
C4: Enable interrupt requests - High to allow interrupt requests to pass from nAck
(S6) to the computer's interrupt-control circuits. If C4 is high and the port's IRQ
level is enabled at the interrupt controller, transitions at nAck will cause a hardware
interrupt request. Does not appear at the connector.
· C5: Direction control - In bidirectional ports, it sets the direction of the Data
port. Sets to 0 for output (Data outputs enabled), 1 for input (Data outputs
disabled).
· C6: Unused.
· C7: Unused - except for a few ports where this bit performs the direction
control function which is normally done by C5.

3.15.1 Programming LPT Port:


There are various ways for applications to access the LPT port and other I/O ports in PCs,
including directly accessing port addresses, communicating with a driver that is accessing
port addresses and using Windows built-in drivers. These are some of the techniques that
can be used to enable LPT port control in an application:
Under Windows 3.x/95/98/Me, applications can read and write directly to port addresses.
This method is simple, but it is slow, it cannot protect the port from being accessed by
other applications, and it does not work at all under Windows NT/2000/Xp. Using Visual
C# or any other language that does not have functions for accessing LPT port I/O, a DLL
file or a custom control must be used that allows access to LPT port I/O functions in an
application.
A system-level device driver enables faster port access and can manage access by
multiple applications. Driver types include VxD (virtual device driver) for Windows
35

9x/Me, WDM for Windows 98/NT/2000/Me/Xp, and kernel-mode driver for Windows
NT/2000/Xp. Hardware interrupts must use a system-level driver under Windows
9x/NT/2000/Me/Xp.
A third way to access ports is to use the drivers included with Windows. Windows
3.x/9x/NT have no functions for generic port access, only functions tied to specific uses.
For example, there are API calls for accessing printers and for accessing serial ports
controlled by UARTs. Although, built-in functions and controls like these can be used to
accomplish the functionality of LPT ports in an application, programming languages like
Visual C# does not support this technique.
Almost all programming languages allow programmers to access parallel port using some
library functions. For example, Borland C is providing "Inportb" and "Outportb"
functions to read or write IO mapped peripherals. But the software designed in this
project is written in Visual C# and it does not have any functions or support to access
LPT port directly, but it is possible to add such capabilities by assigning a DLL file called
“inpout32.dll” which lets Windows to enable LPT port access for that specific
application.

3.16.1 Voltage regulator:


A voltage regulator is an electrical regulator designed to automatically maintain a
constant voltage level. It may use an electromechanical mechanism, or passive or active
electronic components. Depending on the design, it may be used to regulate one or more
AC or DC voltages. With the exception of passive shunt regulators, all modern electronic
voltage regulators operate by comparing the actual output voltage to some internal fixed
reference voltage. Any difference is amplified and used to control the regulation element
in such a way as to reduce the voltage error. This forms a negative feedback servo control
loop; increasing the open-loop gain tends to increase regulation accuracy but reduce
stability (avoidance of oscillation, or ringing during step changes). There will also be a
trade-off between stability and the speed of the response to changes. If the output voltage
is too low (perhaps due to input voltage reducing or load current increasing), the
regulation element is commanded, up to a point, to produce a higher output voltage - by
dropping less of the input voltage (for linear series regulators and buck switching
regulators), or to draw input current for longer periods (boost-type switching regulators);
if the output voltage is too high, the regulation element will normally be commanded to
produce a lower voltage. However, many regulators have over-current protection, so
36

entirely stop sourcing current (or limit the current in some way) if the output current is
too high, and some regulators may also shut down if the input voltage is outside a given.
The most common part numbers start with the numbers 78 or 79 and finish with two
digits indicating the output voltage. The number 78 represents positive voltage and 79
negative one. The 78XX series of voltage regulators are designed for positive input. And
the 79XX series is designed for negative input.

Figure 3.15: The schematic Layout of Voltage regulators


37

Chapter 4

Experimental Setup and Description:

4.1 Introduction:
This chapter gives an overview of assembling all the components of this project together
into the entire completed system. It emphasizes on both the hardware and software
sections with elaborate description along with supporting figures and schematics. It
includes the process, necessary tools and supporting software used to design the
schematic and produce the output in bradboard.

4.2 Block Diagram of the System and Description:

Mobile Signal
Decoder

Figure 4.1: The Block Diagram of the System


From the figure we can see the computer is connected to the electrical appliances via an
interfacing device.Here when a user give an instruction to the PC with software then
signal passes through the interfacing device and the devices are turned on or off
according to the signal.Here the mobile is also connected to the appliances via a mobile
38

signal decoder circuit. It can be connected with to the main supply of the electrical
appliances so that a mobile unit can individually turned on or off them. The details of
each unit is described below.

4.2 Circuit Description of the Interfacing Unit:


The operating principle of the circuit is very simple to comprehend . When the software
gives the command to LPT port pin#2 to supply a +5v, the resistor R1, (used to minimize
the current leaving the data port D0 - refers to pin#2 of the DB25 connector), transfers
the signal to turn ON the light emitter inside the optocoupler Opto1.

The light emotter in Opto1 activates the switching device (mostly a transistor) inside the
optocoupler which, through its emitter (pin 4), triggers the Base of the Q1 (2N2222A
transistor) through the resistor R3.

The Vcc is an external DC supply of +6v which is powered by an adapter. This external
supply powers the optocoupler (through pin 5) and it is also connected to the relay switch
Relay1. The relay switch needs to be powered externally since the rating of relay is 6v
but the computer LPT port has the capability to supply only +5v.

A diode D1 is connected across the Relay1 to protect the transistor Q1 from any voltage
spikes that may damage the circuit. Relay1 is only activated when the collector of Q1
(which has been triggered) connects the terminal of the Relay1 to the ground through its
emitter.

The Relay1 is connected with the AC mains supply AC1 and the Electrical Appliance.
Thus, when Relay1 is triggered the Electrical Appliance starts to operate and when
Relay1 is off, it becomes disconnected from the AC mains supply. This is the entire
process for controlling one electrical appliance.
39

1k

Figure 4.2 : Circuit Schematic of a single Relay control interface


Since the schematic in Fig. only shows the setup for one appliance, a block diagram has
been provided for the same arrangement to assist the justification that will complete the
total design of the system.The same process as described in case of controlling one
appliance occurs in case of controlling eight different appliances through eight Data Ports
(D0-D7).

Figure 4.3: Block diagram showing the total system of 8-Relays with LPT Interface
40

Figure 4.4: Diagram representing a single Block of circuit schematic for single
Relay control

4.4 Circuit Description of Mobile on/off Unit:

The circuit diagram of the mobile Unit is shown in the figure. The circuit consists of a
decoder MT8870 which gets input from the mobile phone head phone. Whenever a user
press a key the tone pair DTMF generated by pressing the mobile button it is converted
into the binary values internally in the IC. The binary values are sent to the
microcontroller port A. These ports are a1 ,a2, a3 and a4. Now the program is so
designed that when the keypad tone is pressed the odd number i.e 1,3,5,7 will give high
input to the port b0, b1,b2 and b3 respectively. Therefore the LEDs connected to them
will glow which means they can activate the relay device. Similarly when the even
number such as 2,4, 6 and 8 are pressed than the LEDs will be turned off and thus the
Device connected to them will also turned off. The ‘’ * ” button will activate all devices
And ‘#’ button will off all the devices. Here 7805 is voltage regulator IC which supply
Five volt and 1A current to both IC. The microcontroller program is given later in this
41

Chapter.

Cell Phone
headphone

Figure 4.5: The DTMF Decoder circuit for Mobile

1N4001
7805

1KΩ .1µF .1µF

10
+Vdd PIC16F4a
MT8870 4 CLK Relay

+In 14 1(A0)
B0 Device 1
-In 15 2(A1) B1 Device2
B3 2N2222
1 kΩ
16 17(A2)
B4
7 17 18(A3)
8 3 4MHz
5(Vss) Oscillator
1kΩ

Figure 4.6: Schematic Diagram of Mobile on/off Unit


42

4.5 Programming part for Interfacing Unit:

4.51 Development Platform:


The Interfacing application will be based on Windows platform. The best available
development environment for working with Windows application is Microsoft Visual
Studio 2005 Professional Editions. Therefore, it was chosen for developing the software
for the device.
Microsoft Visual Studio is the main Integrated Development Environment (IDE) from
Microsoft It can be used to develop console and graphical user interface applications
along with Windows’s Forms applications, web sites, web applications, and web services
in both native code as well as managed code for all platforms supported by Microsoft
Windows, Windows Mobile, .NET Framework, .NET Compact Framework and
Microsoft Silverlight.
Visual Studio includes a code editor supporting IntelliSense as well as code refactoring.
The integrated debugger works both as a source-level debugger and a machine-level
debugger. Other built-in tools include a forms designer for building GUI applications,
web designer, class designer, and database schema designer. It allows plug-ins to be
added that enhance the functionality at almost every level.
Visual Studio supports languages by means of language services, which allow any
programming language to be supported (to varying degrees) by the code editor and
debugger, provided a language-specific service has been authored. Built-in languages
include C/C++ (via Visual C++), VB.NET (via Visual Basic .NET), C# (via Visual C#)
and many others.

4.52 Program Structure:


While developing an application, it is of utmost importance to create a scheme of the
steps needed to proceed to the end of a solution. Creating a structure of a program before
writing the code is helpful in the debugging process and test re-runs of the application.
Such methods were implied while designing this project and using the help of diagrams,
the structure of the application can be well defined.
The basic approach to design the code was a mixture of object-oriented and imperative
programming. Both the techniques help in developing the application, such that it
contains a systematic chain of instructions that can simplify the complications in the
43

source codes. Details on the approach of code writing have been discussed later in this
chapter.

4.53 Features of the developed application:


The software has been designed to provide control of the device. The communication
between the hardware and the software is via the LPT port. The software is named as
“Digital Relay Interface” which implies to the entire theme of the project.
The Main Menu of the application opens a GUI interface to manually turn on/off each of
the eight electrical appliances that can be connected to the device by clicking the
corresponding buttons. It consists of a typical strip menu on the top that gives the user the
basic options for the application, like Exit, Set-time, About, etc.

4.60 Programming for the PIC microcontroller:


ICPROG is a free windows program that you can use for PIC Programming. It interfaces
using either serial or parallel port on a PC, via programming hardware, to the ICSP pins
on the PIC micro. CPROG uses the hex file generated either from an assembler such as
MPASM or a compiler such as MikroC.

4.61 Erase device:


The next PIC programming action is to erase the device by hitting the erase device
button. It sends a command to the PIC which erases the whole device including
protection bits (in newer devices). Old devices used to be un-usable after it had the
protection bits.

4.62 Program device:


The program device button does just that it programs the contents loaded from the hex
file (in ICPROG memory) into the program memory of the PIC micro. If there is any
EEPROM in the chip then it programs this as well. Finally it programs the configuration
word.
44

Chapter 5

Discussions and Conclusion:

5.1 Introduction:
This is the concluding chapter of this report and it contains discussions on different
aspects of the project including the problems that were faced during the desing and
construction of both the hardware and software sections. It also emphasizes on further
improvements and possible limitations of this design. It suggests additional functions that
can be added to the current system. It discusses on the budget considerations that might
make this project a lot better with a bigger budget. It highlights the restrains during the
implementation of the system and the ideas that could not have been included at the time
due to different circumstances.

5.2 Discussion:
The project has capabilities that were not fully exploited due to financial and time
limitations. This device is a very basic design of an automated control system which is
very flexible in design. The design can be modified according to the need of the user (like
adding more relays and increasing the number of LPT ports by using extra LPT PCI
cards).
There were some problems in the code as well. In the debug process, a lot of time was
given in checking each and every port address calculation. The calculations were very
important because if an address was interpreted incorrectly, the port hardware could have
been damaged. However, no computer hardware was damaged during the code writing
process as each module was carefully programmed.
The major drawback in the software was that it used up a lot of processor power during
the time comparison logic debugging. Several attempts were made to resolve the problem
but unfortunately no other algorithm was correct enough to replace the existing
algorithm.
The device can connect up to a maximum of eight appliances at a time. The software to
support the device does not contain any option to increase the number of LPT ports even
if the external hardware was added to connect more appliances. A complete modification
in the source code has to be done in order to enable this function which was not possible
due to time constraint. Therefore, this option was not included in the design process. This
45

project is just a small demonstration of how a computer can be used to control real world
applications and that was the primary target which was accomplished.
Another factor is that the signals were generated by the software and the corresponding
function was indicated by the hardware. If something was found incorrect, it was due to
some loose connection or power supply problem. The functionality of each and every
component to develop the circuit was separately tested.
The mobile unit on/off system was quite complicated circuit work . The programming of
microcontroller is also a quite tough job. It did took several times of progrramming. Lots
of modification was needed in programming to fulfill the required output criterion.
Here we also face the unavailability problems of the circuit components. Specially
MT8870 decoder is quite rare in local electronics shop.
The project needed a mobile set and the headphone where the headphone is modified for
the project. It add an extra cost to the budget.

5.3 Suggestions for future works:


The device can be modified for increased functionality and the following suggestions are
recommended for further improvement of the proposed system:
The software of the device does not contain a database to store the time-table or schedule
of each separate appliance which would be an added advantage to the system. If a simple
Access Database is used to store all the schedule information, then it would be easier to
set up each device individually rather than operating manually for a given interval of
time.
The appliation also does not support an online system. If an online web-server
was set up then the device connected with the server would be directly accessible from
anywhere in the world using a webpage with restricted login interface. This functionality
requires Real IP to establish a web-server. Real IPs are usually very expensive in this
country and due to budget constraints, it could not be accomplished. Although, the device
can be controlled remotely by some commercial remote-control application instead of a
web interface but the security is vulnerable for using such methods to access personal
electrical appliances and it can be easily compromised which might put the user in danger
of privacy violation.
Furthermore, the device is based on LPT port interface and this technology is becoming
almost extinct and the USB 2.0 is replacing this method of interfacing. Due to time
limitations the device was designed to be interfaced using LPT rather than USB. Adding
the USB interface will complicate the total system because it has only four connections
46

and Data Registers are not seperately accessible. Therefore, a specific driver is needed to
be developed in order to interact with the device and the entire software application has
to be rewritten due to a change in the interfacing algorithm. Enabling USB method can
increase the overall potential of the device.
The most astounding development would be to build the device independent of software
control. The design will be completely stand-alone, based on microprocessors and
integrated GPRS modem to upload its data on a server. It may include its own remote-
controller with TFT touchscreen functionality to operate the device wirelessly. The GPRS
functionality will help monitor and operate the system remotely from anywhere in the
world. This approach would be very expensive but an attractivly advanced home
automation system.
These were some of the suggestions for improvements that might help other interested
individuals or groups to continue the research on automation technology and provide
further aid to the development of more complex and advanced automation systems.

5.4 Conclusion:
This device can increase the chance for manufacturing afforable automation systems of
different grades that will provide a scale from low to high performance and capability of
such systems. The device is only a prototype and it needs a lot of improvements to
establish itself in the vast competing world of technologically enhanced commercial
products. There are lots of opportunities to help the world be a better place to live and the
automation technology bears a great significance to this cause. The ease it can provide to
an individual’s living style will keep incrementing in the future. For years to come, this
technology will get shaped into something which seems impossible today and the
experience in this field of research has greatly enhanced the perspective of the individuals
who worked behind this project. Technology needs the world, to evolve and the world
needs technology, to survive.

Appendix

The Program Source Code of Interfacing Unit:


47

Port Access:

using System;
using System.Runtime.InteropServices;

public class PortAccess


{
[DllImport("inpout32.dll", EntryPoint = "Out32")]
public static extern void Output(int adress, int value);
}

Main Application Entry:

using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace TestApplication
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}

Main Menu Code:


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace TestApplication
{
public partial class Form1 : Form
{
public int i = 0, j = 0, adress = 888,value = 0;
public System.Drawing.Color c1 = Color.Lime, c2 = Color.Transparent;
public Form1()
{
InitializeComponent();
48

Reset_Device();

private void Reset_Device() // Makes all the data pins low so the LED's turned off
{
PortAccess.Output(adress, 0);
}

private void checkBox1_CheckedChanged(object sender, EventArgs e)


{
if (checkBox1.Checked)
{
value += (int)Math.Pow(2, 0);
checkBox1.BackColor = c1;
}
else
{
value -= (int)Math.Pow(2, 0);
checkBox1.BackColor = c2;
}
PortAccess.Output(adress, value);
}

private void checkBox2_CheckedChanged(object sender, EventArgs e)


{
if (checkBox2.Checked)
{
value += (int)Math.Pow(2, 1);
checkBox2.BackColor = c1;
}
else
{
value -= (int)Math.Pow(2, 1);
checkBox2.BackColor = c2;
}
PortAccess.Output(adress, value);
}

private void checkBox3_CheckedChanged(object sender, EventArgs e)


{
if (checkBox3.Checked)
{
value += (int)Math.Pow(2, 2);
checkBox3.BackColor = c1;
}
else
{
value -= (int)Math.Pow(2, 2);
checkBox3.BackColor = c2;
49

}
PortAccess.Output(adress, value);
}

private void checkBox4_CheckedChanged(object sender, EventArgs e)


{
if (checkBox4.Checked)
{
value += (int)Math.Pow(2, 3);
checkBox4.BackColor = c1;
}
else
{
value -= (int)Math.Pow(2, 3);
checkBox4.BackColor = c2;
}
PortAccess.Output(adress, value);
}

private void checkBox5_CheckedChanged(object sender, EventArgs e)


{
if (checkBox5.Checked)
{
value += (int)Math.Pow(2, 4);
checkBox5.BackColor = c1;
}
else
{
value -= (int)Math.Pow(2, 4);
checkBox5.BackColor = c2;
}
PortAccess.Output(adress, value);
}

private void checkBox6_CheckedChanged(object sender, EventArgs e)


{
if (checkBox6.Checked)
{
value += (int)Math.Pow(2, 5);
checkBox6.BackColor = c1;

}
else
{
value -= (int)Math.Pow(2, 5);
checkBox6.BackColor = c2;
}
PortAccess.Output(adress, value);
}

private void checkBox7_CheckedChanged(object sender, EventArgs e)


{
50

if (checkBox7.Checked)
{
value += (int)Math.Pow(2, 6);
checkBox7.BackColor = c1;

}
else
{
value -= (int)Math.Pow(2, 6);
checkBox7.BackColor = c2;
}
PortAccess.Output(adress, value);
}

private void checkBox8_CheckedChanged(object sender, EventArgs e)


{
if (checkBox8.Checked)
{
value += (int)Math.Pow(2, 7);
checkBox8.BackColor = c1;

}
else
{
value -= (int)Math.Pow(2, 7);
checkBox8.BackColor = c2;
}
PortAccess.Output(adress, value);
}

private void exitToolStripMenuItem_Click(object sender, EventArgs e)


{
Application.Exit();

private void resetDeviceToolStripMenuItem_Click(object sender, EventArgs e)


{
j = 0; i = 0;
Reset_Device();
checkBox1.Checked = false;
checkBox2.Checked = false;
checkBox3.Checked = false;
checkBox4.Checked = false;
checkBox5.Checked = false;
checkBox6.Checked = false;
checkBox7.Checked = false;
checkBox8.Checked = false;
}

private void aboutToolStripMenuItem_Click(object sender, EventArgs e)


{
51

AboutBox frmAbout = new AboutBox();


frmAbout.ShowDialog();

private void setTimerToolStripMenuItem_Click(object sender, EventArgs e)


{

Reset_Device();
Form1 mainmenu = new Form1();
mainmenu.Close();
Form2 set_timer = new Form2();
set_timer.ShowDialog();

}
parallel

The main program for Microcontroller:


TRISB = 0x00
TRISA = 0xff
PORTB = 0x00
Dim a As Byte
main: a = PORTA
If a > 0 Then
'WaitMs 200
Goto loop
Endif
Goto main
loop:
If a = 1 Then PORTB.0 = 1
If a = 2 Then PORTB.0 = 0
If a = 3 Then PORTB.1 = 1
If a = 4 Then PORTB.1 = 0
If a = 5 Then PORTB.2 = 1
If a = 6 Then PORTB.2 = 0
If a = 7 Then PORTB.3 = 1
If a = 8 Then PORTB.3 = 0
52

If a = 11 Then PORTB = 15
If a = 12 Then PORTB = 0
Goto main
53

References

1. Mason, C. R., Art & Science of Protective Relaying, Chapter 2, GE Consumer &
Electrical.
2. Gurevich, Vladimir (2005). Electrical Relays: Principles and Applications. London -
New York: CRC Press.
3. Walter A. Elmore. Protective Relaying Theory and Applications. Marcel Dekker,
Inc.. ISBN 0-8247-9152-5.
4. Peter Ashburn (2003). Bipolar Transistors. New York: Wiley, Chapter 10.
5. Herb’s Bipolar Transistors IEEE TRANSACTIONS ON ELECTRON DEVICES,
VOL. 48, NO. 11, NOVEMBER 2001
6. Influence of Mobility and Lifetime Variations on Drift-Field Effects in Silicon-
Junction Devices PDF
7. A.S. Sedra and K.C. Smith (2004). Microelectronic Circuits, Fifth Edition, New
York: Oxford, Eqs. 4.103-4.110, p. 305, 509
8. R S Muller, Kamins TI & Chan M (2003). Device electronics for integrated circuits,
Third Edition, New York: Wiley, pp. 280 ff.
9. Pratt, Terrence W. and Marvin V. Zelkowitz. Programming Languages: Design and
Implementation, 3rd ed. Englewood Cliffs, N.J.: Prentice Hall, 1996.
10. Sebesta, Robert W. Concepts of Programming Languages, 3rd ed. Reading, Mass.:
Addison-Wesley Publishing Company, 1996.
11. Schach, Stephen (2006). Object-Oriented and Classical Software Engineering,
Seventh Edition. McGraw-Hill.
12. http://www.kpsec.freeuk.com/components/relay.htm
13. http://www.gmonline.demon.co.uk/cscene/CS4/CS4-02.html
14. http://www.beyondlogic.org/spp/parallel.htm
15. http://www.nordicdx.com/dxlab/makepcb2.html/
16. http://www.expresspcb.com/ pcb_layout~2.htm
17. http://www.electricstuff.co.uk/crystal-oscillator~`php/index.htm
18. http://www.turnpike.net/~kepro/
54

Das könnte Ihnen auch gefallen