Introduction
The project uses the simple concept of OHMs law where a low DC voltage is applied at
the feeder end through a series resistor. The current would vary depending upon the length of
fault of the cable in case there is a short circuit of LL or 3L or LG etc. The series resistor voltage
drop changes accordingly which is then fed to an ADC to develop precise digital data which the
programmed microcontroller would display the same in Kilo meters. The project is assembled
with a set of resistors representing cable length in KMs and fault creation is made by a set of
switches at every known KM to cross check the accuracy of the same.
Digital
Electronic design
Operating
Systems
Integrated
design
Analog
Electronic design
Sensors and
measurements
Electric motors
and actuators
Embedded
Systems
Control
Engineering
Dat
Commun
System Definition
System Testing
Hardware-in-the-Loop Testing
Rapid Prototyping
Targeting
Figure 1.2 V Diagram
An embedded system is any computer system hidden inside a product other than a
computer.
They will encounter a number of difficulties when writing embedded system software in
addition to those we encounter when we write applications.
Throughput Our system may need to handle a lot of data in a short period of
time.
Memory space Memory is limited on embedded systems, and you must make
the software and the data fit into whatever memory exists.
Program installation you will need special tools to get your software into
embedded systems.
Power consumption Portable systems must run on battery power, and the
software in these systems must conserve power.
Processor hogs computing that requires large amounts of CPU time can
complicate the response problem.
Cost Reducing the cost of the hardware is a concern in many embedded system
projects; software often operates on hardware that is barely adequate for the job.
Applications:
1)
2)
3)
4)
5)
6)
7)
RTS Classification:
"Soft" real-time systems have reduced constrains on "lateness" but still must operate very
quickly and repeatable.
Example: Railway reservation system takes a few extra seconds the data remains valid.
Chapter 2
5
Chapter 3
Hardware Requirements
6
Hardware Components
1. TRANSFORMER (230 12 V AC)
2. VOLTAGE REGULATOR (LM 7805)
3. RECTIFIER
4. FILTER
5. MICROCONTROLLER (AT89S52/AT89C51)
6. LIQUID CRYSTAL DISPLAY
7. ADC0804
8. ULN2003
9. RELAYS
10. 1N4007
11. RESISTORS
12. CAPACITORS
3.1 Transformer
Transformers convert AC electricity from one voltage to another with a little loss of power. Stepup transformers increase voltage, step-down transformers reduce voltage. Most power supplies
use a step-down transformer to reduce the dangerously high voltage to a safer low voltage. The
input coil is called the primary and the output coil is called the secondary. There is no electrical
connection between the two coils; instead they are linked by an alternating magnetic field created
in the soft-iron core of the transformer. The two lines in the middle of the circuit symbol
represent the core.
Description
The LM78XX/LM78XXA series of three-terminal positive regulators are available in the
TO-220/D-PAK package and with several fixed output voltages, making them useful in a Wide
range of applications. Each type employs internal current limiting, thermal shutdown and safe
operating area protection, making it essentially indestructible. If adequate heat sinking is
provided, they can deliver over 1A output Current. Although designed primarily as fixed voltage
10
regulators, these devices can be used with external components to obtain adjustable voltages and
currents.
11
3.3 Rectifier
A rectifier is an electrical device that converts alternating current (AC), which periodically
reverses direction, to direct current (DC), current that flows in only one direction, a process
12
known as rectification. Rectifiers have many uses including as components of power supplies
and as detectors of radio signals.
3.4 FILTER
Capacitive filter is used in this project. It removes the ripples from the output of rectifier and
smoothens the D.C. Output received from this filter is constant until the mains voltage and load
is maintained constant. However, if either of the two is varied, D.C. voltage received at this point
changes. Therefore a regulator is applied at the output stage.
The simple capacitor filter is the most basic type of power supply filter. The use of this
filter is very limited. It is sometimes used on extremely high-voltage, low-current power supplies
for cathode-ray and similar electron tubes that require very little load current from the supply.
13
This filter is also used in circuits where the power-supply ripple frequency is not critical and can
be relatively high. Below figure can show how the capacitor changes and discharges.
Features
Compatible with MCS-51 Products
8K Bytes of In-System Programmable (ISP) Flash Memory
Endurance: 10,000 Write/Erase Cycles
4.0V to 5.5V Operating Range
Fully Static Operation: 0 Hz to 33 MHz
Three-level Program Memory Lock
256 x 8-bit Internal RAM
32 Programmable I/O Lines
Three 16-bit Timer/Counters
Eight Interrupt Sources
Full Duplex UART Serial Channel
Low-power Idle and Power-down Modes
Interrupt Recovery from Power-down Mode
Watchdog Timer
Dual Data Pointer
Power-off Flag
Fast Programming Time
Flexible ISP Programming (Byte and Page Mode)
Green (Pb/Halide-free) Packaging Option
15
16
Pin Description:
VCC:
Supply voltage.
GND:
Ground
Port 0:
Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin can sink eight
17
TTL inputs. When 1s are written to port 0 pins, the pins can be used as high-impedance inputs.
Port 0 can also be configured to be the multiplexed low-order address/data bus during accesses to
external program and data memory. In this mode, P0 has internal pull-ups. Port 0 also receives
the code bytes during Flash programming and outputs the code bytes during program
verification. External pull-ups are required during program verification.
Port 1:
Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1 output buffers can
sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high by the
internal pull-ups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled
low will source current (IIL) because of the internal pull-ups. In addition, P1.0 and P1.1 can be
configured to be the timer/counter 2 external count input (P1.0/T2) and the timer/counter 2
trigger input (P1.1/T2EX).
Port 2:
Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 2 output buffers can
sink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled high by the
internal pull-ups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled
low will source current (IIL) because of the internal pull-ups. Port 2 emits the high-order address
byte during fetches from external program memory and during accesses to external data memory
that uses 16-bit addresses (MOVX @ DPTR). In this application, Port 2 uses strong internal pullups when emitting 1s. During accesses to external data memory that uses 8-bit addresses
(MOVX @ RI), Port 2 emits the contents of the P2 Special Function Register.
Port 3:
Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3 output buffers can
sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high by the
internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled
low will source current (IIL) because of the pull-ups.
RST:
18
Reset input. A high on this pin for two machine cycles while the oscillator is running resets the
device. This pin drives high for 98 oscillator periods after the Watchdog times out. The DISRTO
bit in SFR AUXR (address 8EH) can be used to disable this feature. In the default state of bit
DISRTO, the RESET HIGH out feature is enabled.
ALE/PROG:
Address Latch Enable (ALE) is an output pulse for latching the low byte of the address during
accesses to external memory. This pin is also the program pulse input (PROG) during Flash
programming.
In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator frequency and
may be used for external timing or clocking purposes. Note, however, that one ALE pulse is
skipped during each access to external data memory.
PSEN:
Program Store Enable (PSEN) is the read strobe to external program memory. When the
AT89S52 is executing code from external program memory, PSEN is activated twice each
machine cycle, except that two PSEN activations are skipped during each access to external data
memory.
EA/VPP:
External Access Enable. EA must be strapped to GND in order to enable the device to fetch code
from external program memory locations starting at 0000H up to FFFFH. Note, however, that if
lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC
for internal program executions. This pin also receives the 12-volt programming enable voltage
(VPP) during Flash programming.
XTAL1:
Input to the inverting oscillator amplifier and input to the internal clock operating circuit.
XTAL2:
Output from the inverting oscillator amplifier
19
Oscillator Characteristics
XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier
which can be configured for use as an on-chip oscillator, as shown in Figure 1. Either a quartz
crystal or ceramic resonator may be used. To drive the device from an external clock source,
XTAL2 should be left unconnected while XTAL1 is driven as shown in Figure 6.2. There are no
requirements on the duty cycle of the external clock signal, since the input to the internal
clocking circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage high
and low time specifications must be observed.
Idle Mode
In idle mode, the CPU puts itself to sleep while all the on chip peripherals remain active. The
mode is invoked by software. The content of the on-chip RAM and all the special functions
registers remain unchanged during this mode. The idle mode can be terminated by any enabled
interrupt or by a hardware reset.
hardware reset. Reset redefines the SFRs but does not change the on-chip RAM. The reset should
not be activated before VCC is restored to its normal operating level and must be held active
long enough to allow the oscillator to restart and stabilize.
Advantages
No geometric distortion
LCD Background
21
Frequently, an 8051 program must interact with the outside world using input and output devices
that communicate directly with a human being. One of the most common devices attached to an
8051 is an LCD display. Some of the most common LCDs connected to the 8051 are 16x2 and
20x2 displays. This means 16 characters per line by 2 lines and 20 characters per line by 2 lines,
respectively.
Fortunately, a very popular standard exists which allows us to communicate with the vast
majority of LCDs regardless of their manufacturer. The standard is referred to as HD44780U,
which refers to the controller chip which receives data from an external source (in this case, the
8051) and communicates directly with the LCD.
22
The three control lines are referred to as EN, RS, and RW.
The EN line is called "Enable." This control line is used to tell the LCD that you are
sending it data. To send data to the LCD, your program should make sure this line is low (0) and
then set the other two control lines and/or put data on the data bus. When the other lines are
completely ready, bring EN high (1) and wait for the minimum amount of time required by the
LCD datasheet (this varies from LCD to LCD), and end by bringing it low (0) again.
The RS line is the "Register Select" line. When RS is low (0), the data is to be treated as a
command or special instruction (such as clear screen, position cursor, etc.). When RS is high (1),
the data being sent is text data which should be displayed on the screen. For example, to display
the letter "T" on the screen you would set RS high.
The RW line is the "Read/Write" control line. When RW is low (0), the information on
the data bus is being written to the LCD. When RW is high (1), the program is effectively
querying (or reading) the LCD. Only one instruction ("Get LCD status") is a read command. All
others are write commands--so RW will almost always be low .Finally, the data bus consists of 4
23
or 8 lines (depending on the mode of operation selected by the user). In the case of an 8-bit data
bus, the lines are referred to as DB0, DB1, DB2, DB3, DB4, DB5, DB6, and DB7.
3.7 ADC0804
Analog to Digital converters find huge application as an intermediate device to convert the
signals from analog to digital form. These digital signals are used for further processing by the
digital processors. Various sensors like temperature, pressure, force etc. convert the physical
characteristics into electrical signals that are analog in nature.
ADC0804 is a very commonly used 8-bit analog to digital convertor. It is a single channel
IC, i.e., it can take only one analog signal as input. The digital outputs vary from 0 to a
maximum of 255. The step size can be adjusted by setting the reference voltage at pin9. When
this pin is not connected, the default reference voltage is the operating voltage, i.e., Vcc. The step
size at 5V is 19.53mV (5V/255), i.e., for every 19.53mV rise in the analog input, the output
varies by 1 unit. To set a particular voltage level as the reference value, this pin is connected to
half the voltage. For example, to set a reference of 4V (Vref), pin9 is connected to 2V (Vref/2),
thereby reducing the step size to 15.62mV (4V/255).
ADC0804 needs a clock to operate. The time taken to convert the analog value to digital
value is dependent on this clock source. An external clock can be given at the Clock IN pin. ADC
0804 also has an inbuilt clock which can be used in absence of external clock. A suitable RC
circuit is connected between the Clock IN and Clock R pins to use the internal clock.
Features
Operates ratio metrically or with 5 VDC, 2.5 VDC, or analog span adjusted voltage
reference.
Description
The ADC0801, ADC0802, ADC0803, ADC0804 and ADC0805 are CMOS 8-bit successive
approximation A/D converters that use a differential potentiometric ladder-similar to the 256R
products. These converters are designed to allow operation with the NSC800 and INS8080A
derivative control bus with TRI-STATE output latches directly driving the data bus. These A/Ds
appear like memory locations or I/O ports to the microprocessor and no interfacing logic is
needed.
Differential analog voltage inputs allow increasing the common-mode rejection and
offsetting the analog zero input voltage value. In addition, the voltage reference input can be
adjusted to allow encoding any smaller analog voltage span to the full 8 bits of resolution.
4.8 ULN2003
Relay Driver
ULN2003 is a high voltage and high current Darlington transistor array.
Description
25
The ULN2003 is a monolithic high voltage and high current Darlington transistor arrays. It
consists of seven NPN Darlington pairs that feature high-voltage outputs with common-cathode
Clamp diode for switching inductive loads. The collector-current rating of a single Darlington
pair is 500mA. The Darlington pairs may be paralleled for higher current capability. Applications
include relay drivers, hammer drivers, lamp drivers, display drivers (LED gas discharge), line
drivers, and logic buffers.
The ULN2003 has a 2.7kW series base resistor for each Darlington pair for operation
directly with TTL or 5V CMOS devices.
26
Features
27
PIN Diagram
28
Features of Driver
Figure shows the Darlington pair connection of transistor. The circuit above is a Darlington
Pair driver. The first transistors emitter feeds into the second transistors base and as a result the
input signal is amplified by the time it reaches the output. The important point to remember is
that the Darlington Pair is made up of two transistors.
Features
4.9 Relay
A relay is an electrically operated switch. Many relays use an electromagnet to operate a
switching mechanism mechanically, but other operating principles are also used. Relays are used
where it is necessary to control a circuit by a low-power signal (with complete electrical isolation
between control and controlled circuits), or where several circuits must be controlled by one
signal.
circuit. There is no electrical connection inside the relay between the two circuits; the link is
magnetic and mechanical.
The coil of a relay passes a relatively large current, typically 30mA for a 12V relay, but it can
be as much as 100mA for relays designed to operate from lower voltages. Most ICs (chips)
cannot provide this current and a transistor is usually used to amplify the small IC current to the
larger value required for the relay coil. The maximum output current for the popular 555 timer IC
is 200mA so these devices can supply relay coils directly without amplification.
Relays are usually SPDT or DPDT but they can have many more sets of switch contacts, for
example relays with 4 sets of changeover contacts are readily available. For further information
about switch contacts and the terms used to describe them please see the page on switches.
Most relays are designed for PCB mounting but you can solder wires directly to the pins
providing you take care to avoid melting the plastic case of the relay.
The supplier's catalogue should show you the relay's connections. The coil will be obvious
and it may be connected either way round. Relay coils produce brief high voltage 'spikes' when
they are switched off and this can destroy transistors and ICs in the circuit. To prevent damage
you must connect a protection diode across the relay coil.
The figure 3.19 shows a relay with its coil and switch contacts. You can see a lever on the left
being attracted by magnetism when the coil is switched on. This lever moves the switch contacts.
There is one set of contacts (SPDT) in the foreground and another behind them, making the relay
DPDT.
The relay's switch connections are usually labelled COM, NC and NO:
COM = Common, always connect to this; it is the moving part of the switch.
NC = Normally Closed, COM is connected to this when the relay coil is off.
NO = Normally Open, COM is connected to this when the relay coil is on.
Applications of relays
32
Detect and isolate faults on transmission and distribution lines by opening and closing
circuit breakers.
Time delay functions. Relays can be modified to delay opening or delay closing a set of
contacts. A very short (a fraction of a second) delay would use a copper disk between the
armature and moving blade assembly. Current flowing in the disk maintains magnetic field
for a short time, lengthening release time. For a slightly longer (up to a minute) delay, a
dashpot is used. A dashpot is a piston filled with fluid that is allowed to escape slowly. The
time period can be varied by increasing or decreasing the flow rate. For longer time
periods, a mechanical clockwork timer is installed.
4.10 1N4007
Diodes are used to convert AC into DC these are used as half wave rectifier or full wave rectifier.
Three points must he kept in mind while using any type of diode.
1.
2.
3.
The number and voltage capacity of some of the important diodes available in the market
are as follows:
1. Diodes of number IN4001, IN4002, IN4003, IN4004, IN4005, IN4006 and IN4007 have
maximum reverse bias voltage capacity of 50V and maximum forward current capacity
of 1 Amp.
2. Diode of same capacities can be used in place of one another. Besides this diode of more
capacity can be used in place of diode of low capacity but diode of low capacity cannot
be used in place of diode of high capacity. For example, in place of IN4002; IN4001 or
IN4007 can be used but IN4001 or IN4002 cannot be used in place of IN4007.The diode
BY125made by company BEL is equivalent of diode from IN4001 to IN4003. BY 126 is
equivalent to diodes IN4004 to 4006 and BY 127 is equivalent to diode IN4007.
PN Junction Operation
Now that we are familiar with P- and N-type materials, how these materials are joined together
to form a diode, and the function of the diode, let us continue our discussion with the operation
of the PN junction. But before we can understand how the PN junction works, we must first
consider current flow in the materials that make up the junction and what happens initially within
the junction when these two materials are joined together.
34
battery and move through the crystal toward the positive side of the battery.
3.11 Resistors
A resistor is a two-terminal electronic component designed to oppose an electric current by
producing a voltage drop between its terminals in proportion to the current, that is, in accordance
with Ohm's law:
V = IR
Resistors are used as part of electrical networks and electronic circuits. They are
extremely commonplace in most electronic equipment. Practical resistors can be made of various
compounds and films, as well as resistance wire (wire made of a high-resistivity alloy, such as
nickel/chrome).
The primary characteristics of resistors are their resistance and the power they can
dissipate. Other characteristics include temperature coefficient, noise, and inductance. Less well35
known is critical resistance, the value below which power dissipation limits the maximum
permitted current flow, and above which the limit is applied voltage. Critical resistance depends
upon the materials constituting the resistor as well as its physical dimensions; it's determined by
design. Resistors can be integrated into hybrid and printed circuits, as well as integrated circuits.
Size, and position of leads (or terminals) are relevant to equipment designers; resistors must be
physically large enough not to overheat when dissipating their power.
A resistor is a two-terminal passive electronic component which implements electrical
resistance as a circuit element. When a voltage V is applied across the terminals of a resistor, a
current I will flow through the resistor in direct proportion to that voltage. The reciprocal of the
constant of proportionality is known as the resistance R, since, with a given voltage V, a larger
value of R further "resists" the flow of current I as given by Ohm's law:
Resistors are common elements of electrical networks and electronic circuits and are
ubiquitous in most electronic equipment. Practical resistors can be made of various compounds
and films, as well as resistance wire (wire made of a high-resistivity alloy, such as nickelchrome). Resistors are also implemented within integrated circuits, particularly analog devices,
and can also be integrated into hybrid and printed circuits.
The electrical functionality of a resistor is specified by its resistance: common
commercial resistors are manufactured over a range of more than 9 orders of magnitude. When
specifying that resistance in an electronic design, the required precision of the resistance may
require attention to the manufacturing tolerance of the chosen resistor, according to its specific
application. The temperature coefficient of the resistance may also be of concern in some
precision applications. Practical resistors are also specified as having a maximum power rating
which must exceed the anticipated power dissipation of that resistor in a particular circuit: this is
mainly of concern in power electronics applications. Resistors with higher power ratings are
physically larger and may require heat sinking. In a high voltage circuit, attention must
sometimes be paid to the rated maximum working voltage of the resistor.
36
The series inductance of a practical resistor causes its behaviour to depart from ohms law;
this specification can be important in some high-frequency applications for smaller values of
resistance. In a low-noise amplifier or pre-amp the noise characteristics of a resistor may be an
issue. The unwanted inductance, excess noise, and temperature coefficient are mainly dependent
on the technology used in manufacturing the resistor. They are not normally specified
individually for a particular family of resistors manufactured using a particular technology. A
family of discrete resistors is also characterized according to its form factor, that is, the size of
the device and position of its leads (or terminals) which is relevant in the practical manufacturing
of circuits using them.
Units
The ohm (symbol: ) is the SI unit of electrical resistance, named after Georg Simon
Ohm. An ohm is equivalent to a volt per ampere. Since resistors are specified and manufactured
over a very large range of values, the derived units of milliohm (1 m = 10 3 ), kiloohm (1 k
= 103 ), and megohm (1 M = 106 ) are also in common usage.
The reciprocal of resistance R is called conductance G = 1/R and is measured in Siemens
(SI unit), sometimes referred to as a mho. Thus a Siemens is the reciprocal of an ohm: S = 1.
Although the concept of conductance is often used in circuit analysis, practical resistors are
always specified in terms of their resistance (ohms) rather than conductance.
3.12 Capacitors
A capacitor or condenser is a passive electronic component consisting of a pair of conductors
separated by a dielectric. When a voltage potential difference exists between the conductors, an
electric field is present in the dielectric. This field stores energy and produces a mechanical force
between the plates. The effect is greatest between wide, flat, parallel, narrowly separated
conductors.
An ideal capacitor is characterized by a single constant value, capacitance, which is
measured in farads. This is the ratio of the electric charge on each conductor to the potential
difference between them. In practice, the dielectric between the plates passes a small amount of
37
leakage current. The conductors and leads introduce an equivalent series resistance and the
dielectric has an electric field strength limit resulting in a breakdown voltage.
The properties of capacitors in a circuit may determine the resonant frequency and
quality factor of a resonant circuit, power dissipation and operating frequency in a digital logic
circuit, energy capacity in a high-power system, and many other important aspects.
Theory of Operation
Figure 3.23 Figure Showing the Operation and Existence of Electric Field Between Parallel
Plates of a Capacitor
Charge separation in a parallel-plate capacitor causes an internal electric field. A dielectric
(orange) reduces the field and increases the capacitance.
A capacitor consists of two conductors separated by a non-conductive region. The nonconductive region is called the dielectric or sometimes the dielectric medium. In simpler terms,
the dielectric is just an electrical insulator. Examples of dielectric mediums are glass, air, paper,
vacuum, and even a semiconductor depletion region chemically identical to the conductors. A
39
capacitor is assumed to be self-contained and isolated, with no net electric charge and no
influence from any external electric field. The conductors thus hold equal and opposite charges
on their facing surfaces, and the dielectric develops an electric field. In SI units, a capacitance of
one farad means that one coulomb of charge on each conductor causes a voltage of one volt
across the device.
The capacitor is a reasonably general model for electric fields within electric circuits. An
ideal capacitor is wholly characterized by a constant capacitance C, defined as the ratio of charge
Q on each conductor to the voltage V between them:
Sometimes charge build-up affects the capacitor mechanically, causing its capacitance to vary. In
this case, capacitance is defined in terms of incremental changes:
Energy storage
Work must be done by an external influence to "move" charge between the conductors in a
capacitor. When the external influence is removed the charge separation persists in the electric
field and energy is stored to be released when the charge is allowed to return to its equilibrium
position. The work done in establishing the electric field, and hence the amount of energy stored,
is given by:
Current-Voltage Relation
The current i(t) through any component in an electric circuit is defined as the rate of flow of a
charge q(t) passing through it, but actual charges, electrons, cannot pass through the dielectric
40
layer of a capacitor, rather an electron accumulates on the negative plate for each one that leaves
the positive plate, resulting in an electron depletion and consequent positive charge on one
electrode that is equal and opposite to the accumulated negative charge on the other. Thus the
charge on the electrodes is equal to the integral of the current as well as proportional to the
voltage as discussed above. As with any antiderivative, a constant of integration is added to
represent the initial voltage v (t0). This is the integral form of the capacitor equation,
.
Taking the derivative of this, and multiplying by C, yields the derivative form,
.
The dual of the capacitor is the inductor, which stores energy in the magnetic field rather
than the electric field. Its current-voltage relation is obtained by exchanging current and voltage
in the capacitor equations and replacing C with the inductance L.
41
Chapter 4
Software Requirements
Compilers are programs used to convert a High Level Language to object code. Desktop
compilers produce an output object code for the underlying microprocessor, but not for other
microprocessors. I.E the programs written in one of the HLL like C will compile the code to
run on the system for a particular processor like x86 (underlying microprocessor in the
computer). For example compilers for Dos platform is different from the Compilers for Unix
platform So if one wants to define a compiler then compiler is a program that translates source
code into object code.
The compiler derives its name from the way it works, looking at the entire piece of
source code and collecting and reorganizing the instruction. See there is a bit little difference
between compiler and an interpreter. Interpreter just interprets whole program at a time while
compiler analyses and execute each line of source code in succession, without looking at the
entire program.
The advantage of interpreters is that they can execute a program immediately. Secondly
programs produced by compilers run much faster than the same programs executed by an
interpreter. However compilers require some time before an executable program emerges. Now
as compilers translate source code into object code, which is unique for each type of computer,
many compilers are available for the same language.
43
Keil is a German based Software development company. It provides several development tools
like
Project Manager
Simulator
Debugger
The Keil ARM tool kit includes three main tools, assembler, compiler and linker. An
assembler is used to assemble the ARM assembly program. A compiler is used to compile the C
source code into an object file. A linker is used to create an absolute object module suitable for
our in-circuit emulator.
Select Project - Select Device and select an 8051, 251, or C16x/ST10 device from the
Device Database.
44
Select Project - Targets, Groups, Files. Add/Files, select Source Group1, and add the
source files to the project.
Select Project - Options and set the tool options. Note when you select the target device
from the Device Database all special options are set automatically. You typically only
need to configure the memory map of your target hardware. Default memory model
settings are optimal for most applications.
Use the Step toolbar buttons to single-step through your program. You may enter G, main
in the Output Window to execute to the main C function.
Open the Serial Window using the Serial #1 button on the toolbar.
Debug your program using standard options like Step, Go, Break, and so on.
selection sets necessary tool Options for the 80C51RD+ device and simplifies in this way the
tool Configuration.
You start the debug mode of Vision2 with the Debug Start/Stop Debug Session Command.
Depending on the Options for Target Debug Configuration, Vision2 will load the application
program and run the startup code Vision2 saves the editor screen layout and restores the screen
layout of the last debug session. If the program execution stops, Vision2 opens an editor
window with the source text or shows CPU instructions in the disassembly window. The next
executable statement is marked with a yellow arrow. During debugging, most editor features are
still available.
For example, you can use the find command or correct program errors. Program source
text of your application is shown in the same windows. The Vision2 debug mode differs from
the edit mode in the following aspects:
The Debug Menu and Debug Commands are available as described in 4.7. The
additional debug windows are discussed in the following sections.
The project structure or tool parameters cannot be modified. All build commands are
disabled.
47
The Keil Vision Debugger accurately simulates on-chip peripherals (IC, CAN, UART,
SPI, Interrupts, I/O Ports, A/D Converter, D/A Converter, and PWM Modules) of 8051 device.
Simulation helps to understand hardware configurations and avoids time wasted on setup
problems. Additionally, with simulation, we can write and test applications before target
hardware is available.
4.15 Embedded C
Use of embedded processors in passenger cars, mobile phones, medical equipment, aerospace
systems and defense systems is widespread, and even everyday domestic appliances such as dish
washers, televisions, washing machines and video recorders now include at least one such
device.
Because most embedded projects have severe cost constraints, they tend to use low-cost
processors like the 8051 family of devices considered in this book. These popular chips have
very limited resources available most such devices have around 256 bytes (not megabytes!) of
RAM, and the available processor power is around 1000 times less than that of a desktop
processor.
48
Chapter 5
Schematic Diagram and Operation
5.1 Schematic Diagram
49
50
The circuit uses standard power supply comprising of a step-down transformer from 230Vto 12V
and 4 diodes forming a Bridge Rectifier that delivers pulsating dc which is then filtered by an
electrolytic capacitor of about 470F to 1000F. The filtered dc being unregulated, IC LM7805
is used to get 5V DC constant at its pin no 3 irrespective of input DC varying from 9V to 14V.
The input dc shall be varying in the event of input ac at 230volts section varies in the ratio of
V1/V2=N1/N2.
The regulated 5V DC is further filtered by a small electrolytic capacitor of 10F for any
noise so generated by the circuit. One LED is connected of this 5V point in series with a resistor
of 330 to the ground i.e., negative voltage to indicate 5V power supply availability. The 12V
point is used for other applications as on when required.
Reset
Pin no 9 is provided with an RESET arrangement by a combination of an electrolytic capacitor
and a register forming RC time constant. At the time of switch on, the capacitor gets charged,
after charging it behaves as a full short circuit from the positive to the pin number 9. After the
capacitor gets fully charged the current stops flowing and pin number 9 is pulled down by a 10k
51
resistor to the ground. This arrangement of reset pin 9 going high initially and then to logic 0 i.e.,
low helps the program execution to start from the beginning. In absence of this the program
execution could have taken place habitually anywhere from the program cycle. A pushbutton
switch is connected across the capacitor so that at any given time as desired it can be pressed that
discharges the capacitor and while released the capacitor starts charging again and then pin
number 9 goes to high and then back to low, to enable the program execution from the
beginning. This operation of high to low of the reset pin takes place in fraction of a second as
decided by the time constant R and C.
ULN2003
ULN2003 is an IC which is used to interface relay with the microcontroller. Since the output of
the micro controller is 5V and is not practicable to operate relay with that voltage. ULN2003 is
nothing but a set of inverters, if logic high is given to the IC as input then its output will be logic
low and vice-versa .Here in ULN2003 pin 1 to 7 are IC inputs and 10 to 16 are IC outputs.For
example let us operate a load using a relay which is interfaced with microcontroller by a
ULN2003 IC.
Working
The project uses a set of resistances in series i.e. R10,R11,R12,R13 and R17,R16,R14,R21,
R20,R19,R18,R25,R22 as shown in the circuit diagram, one set for each phase. Each series
resistors represents the resistance of the underground cable for a specific distance thus 4 such
resistances in series represent 1-4kms. 3 relays are used to common point of their contacts are
grounded while the NO points are connected to the input of the R17, R21 & R25 being the 3
phase cable input. R10 is fed with a series resistor R1 to 5v supply. The common point of R10 &
R1 is given to input pin of 6 of ADC0804 duely wired as explained in the above section.
Operating Procedure
While any of the 12 switches are operated they impose conditions like LG, LL, 3L fault as per
the switch operation. The program while executed continuously scans by operating the 3relays
in sequence of 1sec interval. Thus any NO point while driven to GND through the common
contact point of the relay develops a current flow through R1, R10 & any other switch depending
on the created fault. Thus the voltage drop at the ADC pin varies depending on the current flow
which is inversely proportional to the resistance value representing the length of cable in
kilometres. This varying voltage passes through the ADC to develop a 8 bit data to the
microcontroller port1 that while executed displays an output in the LCD display the fault
occurring km. In a fault situation it displays R=3km if the 3kms switch is made ON.
Accordingly all other faults are indicated.
53
Chapter 6
Layout Diagram
54
Chapter 7
Algorithm and Flowchart
55
56
Chapter 8
57
Coding
8.1 Compiler
1.
2.
3.
4.
58
5.
Save the Project by typing suitable project name with no extension in u r own folder
sited in either C:\ or D:\
6.
7.
8.
9.
10.
Then Click on OK
11.
60
12.
13.
14.
Now double click on the Target1, you would get another option Source group 1 as
shown in next page.
61
15.
Click on the file option from menu bar and select new.
16.
The next screen will be as shown in next page, and just maximize it by double
clicking on its blue boarder.
17.
62
18.
For a program written in Assembly, then save it with extension . asm and for
EMBEDDED C based program save it with extension .C
19.
Now right click on Source group 1 and click on Add files to Group Source.
20.
Now you will get another window, on which by default EMBEDDED C files will
appear.
63
21.
Now select as per your file extension given while saving the file.
22.
23.
Now Press function key F7 to compile. Any error will appear if so happen.
24.
25.
26.
27.
Now click on the Peripherals from menu bar, and check your required port as shown
in fig below.
28.
29.
30.
#define LCDDATA P2
#define ADCDATA P1
#define MINIMUM 5
TF0 = 0;
}
SC = 1;
temp = ADCDATA;
OE = 1;
return temp;
// RS =0 FOR COMMAND
RW = 1;
// RW = 1 FOR READING
while(BUSY)
{
EN = 0;
EN = 1;
// ENABLE IS HIGH
68
}
}
// RS =0 FOR COMMAND
RW = 0;
// RW = 0 FOR WRITING
EN = 1;
// ENABLE IS HIGH
EN = 0;
// RS =1 FOR DATA
RW = 0;
// RW = 0 FOR WRITING
EN = 1;
// ENABLE IS HIGH
EN = 0;
{
while(*str)
{
LCDData(*str);
str++;
}
void Init_T0( )
{
TMOD = 0x01;
TH0 = 0x4B;
TL0 = 0xFF;
ET0 = 1;
EA = 1;
TR0 = 1;
70
/*Command to shift the cursor to next position when Data is send in LCD */
LCDCMD(0x06);
LCDString("NF ");
break;
default:
break;
}
}
void main( )
{
P0 = 0x0F;
Buff[0] = 0xFF;
Init_T0();
Init_LCD( );
while(1)
{
P0 = 0x01;
LCDCMD(0x80);
LCDString("R: ");
Display(Read_ADC( ));
LCDCMD(0x87);
LCDString("B: ");
Display(Read_ADC( ));
P0 = 0x02;
LCDCMD(0xC0);
72
LCDString("Y: ");
Display(Read_ADC( ));
P0 = 0x04;
LCDCMD(0xC7);
LCDString("N: ");
Display(Read_ADC( ));
}
}
Chapter 9
73
Hardware Testing
9.1 Continuity Test
In electronics, a continuity test is the checking of an electric circuit to see if current flows (that it
is in fact a complete circuit). A continuity test is performed by placing a small voltage (wired in
series with an LED or noise-producing component such as a piezoelectric speaker) across the
chosen path. If electron flow is inhibited by broken conductors, damaged components, or
excessive resistance, the circuit is "open".
Devices that can be used to perform continuity tests include multi meters which measure
current and specialized continuity testers which are cheaper, more basic devices, generally with a
simple light bulb that lights up when current flows.
An important application is the continuity test of a bundle of wires so as to find the two ends
belonging to a particular one of these wires; there will be a negligible resistance between the
"right" ends, and only between the "right" ends.
This test is the performed just after the hardware soldering and configuration has been
completed. This test aims at finding any electrical open paths in the circuit after the soldering.
Many a times, the electrical continuity in the circuit is lost due to improper soldering, wrong and
rough handling of the PCB, improper usage of the soldering iron, component failures and
presence of bugs in the circuit diagram. We use a multi meter to perform this test. We keep the
multi meter in buzzer mode and connect the ground terminal of the multi meter to the ground.
We connect both the terminals across the path that needs to be checked. If there is continuation
then you will hear the beep sound.
Then we apply this voltage to the power supply circuit. Note that we do this test without
microcontroller because if there is any excessive voltage, this may lead to damaging the
controller. We check for the input to the voltage regulator i.e., are we getting an input of 12v and
an output of 5v. This 5v output is given to the microcontrollers 40 th pin. Hence we check for the
voltage level at 40th pin. Similarly, we check for the other terminals for the required voltage. In
this way we can assure that the voltage at all the terminals is as per the requirement.
Results
75
Conclusion
76
Future scope
77
References
78
79