Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 97

INDUSTRIAL TRAINNING REPORT

EMBEDDED SYSTEMS

A Dissertation Submitted in the Partial Fulfilment of the Academic

Requirements For the Award of

Diploma

In

ELECTRONICS AND COMMUNICATION


Engineering

D.MAADHAV 19271-EC-239

Under the Guidance of


K.SANDEEP KUMAR

Department of Electronics and


Communication Engineering

VIJAY RURAL ENGINEERING COLLEGE


2nd SHIFT POLYTECHNIC
(Affiliated to SBTET, Hyderabad)
Rochies Valley, Manikbhandar, Nizamabad 503003– TS

2021-2022
CERTIFICATE

This is to certify that the dissertation work entitled “EMBEDDED SYSTEMS"


was carried out by D.MAADHAV,bearing 19271-EC-239 , in partial fulfillment of the
requirements for Electronics and Communication Engineering of the Vijay Rural
engineering college 2nd Shift Polytechnic, Nizamabad, during the academic year
2021-22, is a bonafide record of work carried out under our guidance and
supervision.

The results embodied in this report have not been submitted to any other
University or Institution for the award of any degree or diploma.

Mr.K.SANDEEP KUMAR Mr.K.SANDEEP KUMAR


Internalguide
HOD-ECE

Dr. P. Sampath Rao Mrs. A.Swapna


Principal Vice Principal

External Examiner
ACKNOWLEDGMENT
Saluation to our beloved and highly esteemed institute “Vijay Rural Engineering college”
for having well qualified staff and labs furnished with necessary equipment and computer

First of all we would like to express our deep sense of gratitude towards our project guide
mr . K .S a n d e e p k u m a r lecturer in civil Engineering Department of Vijay Rural
Engineering college always being available when were quire her guidance as well as for
motivating us throughout the Industrial training.

We are very much thankful to K. Sandeep kumar HOD ,Department of ECE ,VREC for
allowing us to do the Industrial training in depth of ECE

We would like to thank all our friends for their help and constructive criticism during our
project period .finally we are very much indebted to our parents for their moral support and
Encouragement to achieve higher goals .we have no words to express our gratitude and still
we are thankful to our parents who have shown us this world and for every support they gave
us.

PRESENTED BY:

19271-EC-239

( D.MAADHAV )
DECLARATION
We wish to express profound sense gratitude to SRI K.NARENDHAR REDDY SIR
GARU, direction , VREC and DR.SAMPATH RAO SIR GARU, principal for their
encouragement and for all faculties to complete the project

We also express our special thanks to mr . K.SANDEEP KUMAR, head of the department
V.R.E.C for her encouragement during .we are also thankful to all the working staff of
Electronics and Communication engineering department and our peers for the helping us to get
better conceptual knowledge

We have pleasure in expressing your thanks and deep sense have gratitude to your guidance
in completing the Industrial training " EMBEDDED SYSTEMS . “ successfully

Finally we thanks all the unmentioned names and invisible hands who helped us in this
INDUSTRIAL TRAINING report to this present form

This project is submitted to in the partial fulfillment of requirements for the award of degree
of diploma in Electronics and Communication engineering.

The results embodied in this is have not been submitted to any other university of institute for
the award of any degree or diploma
Industrial Training – Embedded systems.
MICROCONTROLLERS:

Microprocessors and microcontrollers are widely used in embedded systems


products. Microcontroller is a programmable device. A microcontroller has a CPU in
addition to a fixed amount of RAM, ROM, I/O ports and a timer embedded all on a single
chip. The fixed amount of on-chip ROM, RAM and number of I/O ports in microcontrollers
makes them ideal for many applications in which cost and space are critical.

The Intel 8051 is Harvard architecture, single chip microcontroller (µC) which was
developed by Intel in 1980 for use in embedded systems. It was popular in the 1980s and
early 1990s, but today it has largely been superseded by a vast range of enhanced devices
with 8051-compatible processor cores that are manufactured by more than 20 independent
manufacturers including Atmel, Infineon Technologies and Maxim Integrated Products.

8051 is an 8-bit processor, meaning that the CPU can work on only 8 bits of data at a
time. Data larger than 8 bits has to be broken into 8-bit pieces to be processed by the CPU.
8051 is available in different memory types such as UV- EPROM, Flash and NV-RAM.

The present project is implemented on Keil Uvision. In order to program the device,
Proteus tool has been used to burn the program onto the microcontroller.

The features, pin description of the microcontroller and the software tools used are
discussed in the following sections.
FEATURES OF AT89C51:

 4K Bytes of Re-programmable Flash Memory.


 RAM is 128 bytes.
 2.7V to 6V Operating Range.
 Fully Static Operation: 0 Hz to 24MHz.
 Two-level Program Memory Lock.
 128 x 8-bit Internal RAM.
 32 Programmable I/O Lines.
 Two 16-bit Timer/Counters.
 Six Interrupt Sources.
 Programmable Serial UART Channel.
 Low-power Idle and Power-down Modes.

Description:

The AT89C51 is a low-voltage, high-performance CMOS 8-bit microcomputer with


4K bytes of Flash programmable memory. The device is manufactured using Atmel’s high-
density nonvolatile memory technology and is compatible with the industry-standard MCS-
51 instruction set. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the
Atmel AT89C51 is a powerful microcomputer, which provides a highly flexible and cost-
effective solution to many embedded control applications.
In addition, the AT89C51 is designed with static logic for operation down to zero
frequency and supports two software selectable power saving modes. The Idle Mode stops
the CPU while allowing the RAM, timer/counters, serial port and interrupt system to continue
functioning. The power-down mode saves the RAM contents but freezes the oscillator
disabling all other chip functions until the next hardware reset.

Fig: Pin diagram


Fig: Block diagram
PIN DESCRIPTION:

Vcc

Pin 40 provides supply voltage to the chip. The voltage source is +5V.

GND

Pin 20 is the ground.

XTAL1 and XTAL2

XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier
that can be configured for use as an on-chip oscillator, as shown in Figure 11. 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 the below figure.
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.
Fig: Oscillator Connections

C1, C2 = 30 pF ± 10 pF for Crystals


= 40 pF ± 10 pF for Ceramic Resonators
Fig: External Clock Drive Configuration

RESET

Pin9 is the reset pin. It is an input and is active high. Upon applying a high pulse to this pin,
the microcontroller will reset and terminate all the activities. This is often referred to as a
power-on reset.

EA (External access)

Pin 31 is EA. It is an active low signal. It is an input pin and must be connected to either Vcc
or GND but it cannot be left unconnected.

The 8051 family members all come with on-chip ROM to store programs. In such
cases, the EA pin is connected to Vcc. If the code is stored on an external ROM, the EA pin
must be connected to GND to indicate that the code is stored externally.
PSEN (Program store enable)

This is an output pin.

ALE (Address latch enable)

This is an output pin and is active high.

Ports 0, 1, 2 and 3

The four ports P0, P1, P2 and P3 each use 8 pins, making them 8-bit ports. All the ports
upon RESET are configured as input, since P0-P3 have value FFH on them.

Port 0(P0)

Port 0 is also designated as AD0-AD7, allowing it to be used for both address and data. ALE
indicates if P0 has address or data. When ALE=0, it provides data D0- D7, but when ALE=1,
it has address A0-A7. Therefore, ALE is used for demultiplexing address and data with the
help of an internal latch.

When there is no external memory connection, the pins of P0 must be connected to a


10K-ohm pull-up resistor. This is due to the fact that P0 is an open drain. With external pull-
up resistors connected to P0, it can be used as a simple I/O, just like P1 and P2. But the ports
P1, P2 and P3 do not need any pull-up resistors since they already have pull-up resistors
internally. Upon reset, ports P1, P2 and P3 are configured as input ports.
Port 1 and Port 2

With no external memory connection, both P1 and P2 are used as simple I/O. With external
memory connections, port 2 must be used along with P0 to provide the 16-bit address for the
external memory. Port 2 is designated as A8-A15 indicating its dual function. While P0
provides the lower 8 bits via A0-A7, it is the job of P2 to provide bits A8-A15 of the address.

Port 3

Port 3 occupies a total of 8 pins, pins 10 through 17. It can be used as input or output. P3
does not need any pull-up resistors, the same as port 1 and port 2. Port 3 has an additional
function of providing some extremely important signals such as interrupts.

Table: Port 3 Alternate Functions

Machine cycle for the 8051

The CPU takes a certain number of clock cycles to execute an instruction. In the 8051 family,
these clock cycles are referred to as machine cycles. The length of the machine cycle
depends on the frequency of the crystal oscillator. The crystal
oscillator, along with on-chip circuitry, provides the clock source for the 8051 CPU.

The frequency can vary from 4 MHz to 30 MHz, depending upon the chip rating and
manufacturer. But the exact frequency of 11.0592 MHz crystal oscillator is used to make the
8051 based system compatible with the serial port of the IBM PC.

In the original version of 8051, one machine cycle lasts 12 oscillator periods. Therefore, to
calculate the machine cycle for the 8051, the calculation is made as 1/12 of the crystal
frequency and its inverse is taken.

The assembly language program is written and this program has to be dumped into the
microcontroller for the hardware kit to function according to the software. The program
dumped in the microcontroller is stored in the Flash memory in the microcontroller. Before
that, this Flash memory has to be programmed and is discussed in the next section.

ALE/PROG
Address Latch Enable 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. If desired,
ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE
is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled
high. Setting the ALE- disable bit has no effect if the microcontroller is in external
execution mode.
PSEN (Program Store Enable)
It is the read strobe to external program memory. When the AT89S8252 is executing
code from external program memory, PSEN is acti-vated twice each machine cycle, except
that two PSEN activations are skipped during each access to external data memory.

EA/VPP (External Access Enable)


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

Ports 0, 1, 2 and 3

The four ports P0, P1, P2 and P3 each use 8 pins, making them 8-bit ports. All the ports
upon RESET are configured as input, since P0-P3 have value FFH on them.

Port 0(P0)

Port 0 is also designated as AD0-AD7, allowing it to be used for both address and data. ALE
indicates if P0 has address or data. When ALE=0, it provides data D0- D7, but when ALE=1,
it has address A0-A7. Therefore, ALE is used for demultiplexing address and data with the
help of an internal latch.
When there is no external memory connection, the pins of P0 must be connected to a
10K-ohm pull-up resistor. This is due to the fact that P0 is an open drain. With external pull-
up resistors connected to P0, it can be used as a simple I/O, just like P1 and P2. But the ports
P1, P2 and P3 do not need any pull-up resistors since they already have pull-up resistors
internally. Upon reset, ports P1, P2 and P3 are configured as input ports.

Port 1

Port 1 is an 8-bit bi-directional 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 because of the internal pull-ups.

Some Port 1 pins provide additional functions. 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), respectively. Furthermore, P1.4, P1.5, P1.6, and P1.7 can be configured as the
SPI slave port select, data input/output and shift clock input/output pins. Port 1 also
receives the low-order address bytes during Flash programming and verification.
Table: Port1 Alternate functions

Programmable Clock Out:


A 50% duty cycle clock can be programmed to come out on P1.0. This pin, besides
being a regular I/0 pin, has two alternate functions. It can be programmed to input the
external clock for Timer/Counter 2 or to output a 50% duty cycle clock ranging from 61 Hz
to 4 MHz (for a 16-MHz operating frequency).

Port 2
With no external memory connection, P2 are used as simple I/O. With
external memory connections, port 2 must be used along with P0 to provide the 16-bit
address for the external memory. Port 2 is designated as A8-A15 indicating its dual function.
While P0 provides the lower 8 bits via A0-A7, it is the job of P2 to provide bits A8-A15 of
the address.
Port 2 also receives the high-order address bits and some control signals during Flash
programming and verification.

Port 3

Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 3 output
buffers can sink/source four TTL inputs. When 1s are written to Port 3
pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 3
pins that are externally being pulled low will source current because of the pull-ups. Port 3
receives some control signals for Flash programming and verification.
Port 3 also serves the functions of various special features of the AT89S8252, as
shown in the following table.

Table: Port 3 Alternate functions

Data Memory – EEPROM and RAM

The AT89S8252 implements 2K bytes of on-chip EEPROM for data storage and
256 bytes of RAM. The upper 128 bytes of RAM occupy a parallel space to the Special
Function Registers i.e., the upper 128 bytes have the same addresses as the SFR space but
are physically separate from SFR space.
When an instruction accesses an internal location above address 7FH, the
address mode used in the instruction specifies whether the CPU accesses the upper 128 bytes
of RAM or the SFR space.

Instructions that use direct addressing access SFR space. For example, the following
direct addressing instruction accesses the SFR at location 0A0H (which is P2).

MOV 0A0H, #data

Instructions that use indirect addressing access the upper 128 bytes of RAM. For
example, the following indirect addressing instruction, where R0 contains 0A0H, accesses
the data byte at address 0A0H, rather than P2 (whose address is 0A0H).

MOV @R0, #data

It should be noted that stack operations are examples of indirect addressing, so the
upper 128 bytes of data RAM are available as stack space.

The on-chip EEPROM data memory is selected by setting the EEMEN bit in the
WMCON register at SFR address location 96H. The EEPROM address range is from 000H
to 7FFH. The MOVX instructions are used to access the EEPROM. To access off-chip data
memory with the MOVX instructions, the EEMEN bit needs to be set to “0”.
Machine cycle for the 8051

The CPU takes a certain number of clock cycles to execute an instruction. In the 8051 family,
these clock cycles are referred to as machine cycles. The length of the machine cycle
depends on the frequency of the crystal oscillator. The crystal oscillator, along with on-chip
circuitry, provides the clock source for the 8051 CPU.

The frequency can vary from 4 MHz to 30 MHz, depending upon the chip rating and
manufacturer. But the exact frequency of 11.0592 MHz crystal oscillator is used to make the
8051 based system compatible with the serial port of the IBM PC.

In the original version of 8051, one machine cycle lasts 12 oscillator periods. Therefore, to
calculate the machine cycle for the 8051, the calculation is made as 1/12 of the crystal
frequency and its inverse is taken.
POWER SUPPLY:

The input to the circuit is applied from the regulated power supply. The a.c. input i.e.,
230V from the mains supply is step down by the transformer to 12V and is fed to a rectifier.
The output obtained from the rectifier is a pulsating d.c voltage. So in order to get a pure
d.c voltage, the output voltage from the rectifier is fed to a filter to remove any a.c
components present even after rectification. Now, this voltage is given to a voltage regulator
to obtain a pure constant dc voltage.

230V AC
50Hz D.C
Output

Step down Bridge


transformer Rectifier Regulator

Fig: Power supply


Transformer:

Usually, DC voltages are required to operate various electronic equipment and these
voltages are 5V, 9V or 12V. But these voltages cannot be obtained directly. Thus the a.c
input available at the mains supply i.e., 230V is to be brought down to the required voltage
level. This is done by a transformer. Thus, a step down transformer is employed to decrease
the voltage to a required level.

Rectifier:

The output from the transformer is fed to the rectifier. It converts A.C. into pulsating
D.C. The rectifier may be a half wave or a full wave rectifier. In this
project, a bridge rectifier is used because of its merits like good stability and full wave
rectification.

The Bridge rectifier is a circuit, which converts an ac voltage to dc voltage using both half
cycles of the input ac voltage. The Bridge rectifier circuit is shown in the figure. The circuit
has four diodes connected to form a bridge. The ac input voltage is applied to the diagonally
opposite ends of the bridge. The load resistance is connected between the other two ends of
the bridge.

For the positive half cycle of the input ac voltage, diodes D1 and D3 conduct, whereas diodes
D2 and D4 remain in the OFF state. The conducting diodes will be in series with the load
resistance RL and hence the load current flows through RL.

For the negative half cycle of the input ac voltage, diodes D2 and D4 conduct whereas, D1
and D3 remain OFF. The conducting diodes D2 and D4 will be in series with the load
resistance RL and hence the current flows through RL in the
same direction as in the previous half cycle. Thus a bi-directional wave is converted into a
unidirectional wave.

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.
Voltage regulator:

As the name itself implies, it regulates the input applied to it. A voltage regulator is an
electrical regulator designed to automatically maintain a constant voltage level. In this
project, power supply of 5V and 12V are required. In order to obtain these voltage levels,
7805 and 7812 voltage regulators are to be used. The first number 78 represents positive
supply and the numbers 05, 12 represent the required output voltage levels. The L78xx series
of three-terminal positive regulators is available in TO-220, TO-220FP, TO-3, D2PAK and
DPAK packages and several fixed output voltages, making it useful in a wide range of
applications. These regulators can provide local on-card regulation, eliminating the
distribution problems associated with single point regulation.
Each type employs internal current limiting, thermal shut-down and safe area
protection, making it essentially indestructible. If adequate heat sinking is provided, they can
deliver over 1 A output current. Although designed primarily as fixed voltage regulators,
these devices can be used with external components to obtain adjustable voltage and
currents.

Light Emitting Diodes (LED’s)

Light Emitting Diodes (LED’s)

Example: Circuit symbol:

Function
LED’s emit light when an electric current passes through them.
Connecting and soldering
LED’s must be connected the correct way round, the diagram may be
labeled a or + for anode and k or - for cathode (yes, it really is k, not c, for
cathode!). The cathode is the short lead and there may be a slight flat on the
body of round LED’s. If you can see inside the LED the cathode is the larger electrode (but this
is not an official identification method).

LED’s can be damaged by heat when soldering, but the risk is small unless you are very
slow. No special precautions are needed for soldering most LED’s.

Testing an LED:

Never connect an LED directly to a battery or power supply!


It will be destroyed almost instantly because too much current will pass through and burn it out.

LED’s must have a resistor in series to limit the current to a safe value, for quick testing
purposes a 1k resistor is suitable for most LED’s if your supply voltage is 12V or less.
Remember to connect the LED the correct way round!

Colors of LED’s
LED’s are available in red, orange,
amber, yellow, green, blue and white. Blue and
white LED’s are much more expensive than the
other colors.

The color of an LED is determined by


the semiconductor material, not by the coloring of the 'package' (the plastic body). LED’s of all
colors are available in uncolored packages which may be diffused (milky) or clear (often
described as 'water clear'). The colored packages are also available as diffused (the standard
type) or transparent.

Light-emitting diode

Red, green and blue LED’s of the 5mm type

Type Passive, optoelectronic

Working principle Electroluminescence

Invented Nick Holonyak Jr. (1962)

Electronic symbol

Pin configuration Anode and Cathode

Internal Diagram of LED:


A light-emitting diode (LED) (pronounced /ɛl idi/, L-E-D) is a semiconductor light
source. LED’s are used as indicator lamps in many devices, and are increasingly used for
lighting. Introduced as a practical electronic component in 1962, [2] early LED’s emitted low-
intensity red light, but modern versions are available across the visible, ultraviolet and infrared
wavelengths, with very high brightness.

When a light-emitting diode is forward biased (switched on), electrons are able to
recombine with electron holes within the device, releasing energy in the form of photons. This
effect is called electroluminescence and the color of the light (corresponding to the energy of
the photon) is determined by the energy gap of the semiconductor. An LED is often small in
area (less than 1 mm2), and integrated optical components may be used to shape its radiation
pattern. LED’s present many advantages over incandescent light sources including lower energy
consumption, longer lifetime, improved robustness, smaller size, faster switching, and greater
durability and reliability. LED’s powerful enough for room lighting are relatively expensive and
require more precise current and heat management than compact fluorescent lamp sources of
comparable output.

Light-emitting diodes are used in applications as diverse as replacements for aviation


lighting, automotive lighting (particularly brake lamps, turn signals and indicators) as well as in
traffic signals. The compact size, the possibility of narrow bandwidth, switching speed, and
extreme reliability of LED’s has allowed new text and video displays and sensors to be
developed, while their high switching rates are also useful in advanced communications
technology. Infrared LED’s are also used in the remote control units of many commercial
products including televisions, DVD players, and other domestic appliances.

The first commercial LED’s were commonly used as replacements for incandescent and
neon indicator lamps, and in seven-segment displays, first in expensive equipment such as
laboratory and electronics test equipment, then later in such appliances as TVs, radios,
telephones, calculators, and even watches (see list of signal uses). These red LED’s were bright
enough only for use as indicators, as the light output was not enough to illuminate an area.
Readouts in calculators were so small that plastic lenses were built over each digit to make them
legible. Later, other colors grew widely available and also appeared in appliances and
equipment. As LED materials technology grew more advanced, light output rose, while
maintaining efficiency and reliability at acceptable levels. The invention and development of the
high power white light LED to use for illumination (see list of illumination applications). Most
LED’s were made in the very common 5 mm T1¾ and 3 mm T1 packages, but with rising
power output, it has grown increasingly necessary to shed excess heat to maintain reliability, so
more complex packages have been adapted for efficient heat dissipation. Packages for state-of-
the-art high power LED’s bear little resemblance to early LED’s.
Illustration of Haitz's Law. Light output per LED as a function of production year, note
the logarithmic scale on the vertical axis.

Technology:

The inner workings of an LED


diagram for a diode. An LED will begin to emit light when the on-
voltage is exceeded. Typical on voltages are 2–3 volts

Like a normal diode, the LED consists of a chip of semi conducting material doped with
impurities to create a p-n junction. As in other diodes, current flows easily from the p-side, or
anode, to the n-side, or cathode, but not in the reverse direction. Charge-carriers—electrons and
holes—flow into the junction from electrodes with different voltages. When an electron meets a
hole, it falls into a lower energy level, and releases energy in the form of a photon.

The wavelength of the light emitted, and thus its color, depends on the band gap energy
of the materials forming the p-n junction. In silicon or germanium diodes, the electrons and
holes recombine by a non-radiative transition which produces no optical emission, because
these are indirect band gap materials. The materials used for the LED have a direct band gap
with energies corresponding to near-infrared, visible or near-ultraviolet light.

LED development began with infrared and red devices made with gallium arsenide.
Advances in materials science have enabled making devices with ever-shorter wavelengths,
emitting light in a variety of colors.

LED’s are usually built on an n-type substrate, with an electrode attached to the p-type
layer deposited on its surface. P-type substrates, while less common, occur as well. Many
commercial LED’s, especially GaN/InGaN, also use sapphire substrate.
Most materials used for LED production have very high refractive indices. This means
that much light will be reflected back into the material at the material/air surface interface.
Thus, light extraction in LED’s is an important aspect of LED production, subject to much
research and development.

Generally a flat-surfaced uncoated LED semiconductor chip will only emit light
perpendicular to the semiconductor's surface, and a few degrees to the side, in a cone shape
referred to as the light cone, cone of light, or the escape cone. The maximum angle of incidence
is referred to as the critical angle. When this angle is exceeded photons no longer penetrate the
semiconductor, but are instead reflected both internally inside the semiconductor crystal, and
externally off the surface of the crystal as if it were a mirror. Internal reflections can escape
through other crystalline faces, if the incidence angle is low enough and the crystal is
sufficiently transparent to not re-absorb the photon emission. But for a simple square LED with
90-degree angled surfaces on all sides, the faces all act as equal angle mirrors. In this case the
light can not escape and is lost as waste heat in the crystal. A convoluted chip surface with
angled facets similar to a jewel or Fresnel lens can increase light output by allowing light to be
emitted perpendicular to the chip surface while far to the sides of the photon emission point.

The ideal shape of a semiconductor with maximum light output would be a micro sphere
with the photon emission occurring at the exact center, with electrodes penetrating to the center
to contact at the emission point. All light rays emanating from the center would be
perpendicular to the entire surface of the sphere, resulting in no internal reflections. A
hemispherical semiconductor would also work, with the flat back-surface serving as a mirror to
back-scattered photons.

Transition coatings:

Many LED semiconductor chips are potted in clear or colored molded plastic shells. The
plastic shell has three purposes:

1. Mounting the semiconductor chip in devices is easier to accomplish.


2. The tiny fragile electrical wiring is physically supported and protected from damage
3. The plastic acts as a refractive intermediary between the relatively high-index
semiconductor and low-index open air.
4. The third feature helps to boost the light emission from the semiconductor by acting as
a diffusing lens, allowing light to be emitted at a much higher angle of incidence from
the light cone, than the bare chip is able to emit alone.

Efficiency and operational parameters:

Typical indicator LED’s are designed to operate with no more than 30–60 milli-watts
[mW] of electrical power. Around 1999, Philips Lumi LED’s introduced power LED’s capable
of continuous use at one watt [W]. These LED’s used much larger semiconductor die sizes to
handle the large power inputs. Also, the semiconductor dies were mounted onto metal slugs to
allow for heat removal from the LED die.

One of the key advantages of LED-based lighting is its high efficiency, as measured by
its light output per unit power input. White LED’s quickly matched and overtook the efficiency
of standard incandescent lighting systems. In 2002, Lumi LED’s made five-watt LED’s
available with a luminous efficacy of 18–22 lumens per watt [lm/W]. For comparison, a
conventional 60–100 W incandescent light bulb emits around 15 lm/W, and standard
fluorescent lights emit up to 100 lm/W. A recurring problem is that efficiency falls sharply with
rising current. This effect is known as droop and effectively limits the light output of a given
LED, rising heating more than light output for higher current.

In September 2003, a new type of blue LED was demonstrated by the company Cree
Inc. to provide 24 mW at 20 milli amperes [mA]. This produced a commercially packaged
white light giving 65 lm/W at 20 mA, becoming the brightest white LED commercially
available at the time, and more than four times as efficient as standard incandescent. In 2006,
they demonstrated a prototype with a record white LED luminous efficacy of 131 lm/W at 20
mA. Also, Seoul Semiconductor plans for 135 lm/W by 2007 and 145 lm/W by 2008, which
would be nearing an order of magnitude improvement over standard incandescent and better
than even standard fluorescents. Nichia Corporation has developed a white LED with luminous
efficacy of 150 lm/W at a forward current of 20 mA.
Practical general lighting needs high-power LED’s, of one watt or more. Typical
operating currents for such devices begin at 350 mA.

Note that these efficiencies are for the LED chip only, held at low temperature in a lab.
Lighting works at higher temperature and with drive circuit losses, so efficiencies are much
lower. United States Department of Energy (DOE) testing of commercial LED lamps designed
to replace incandescent lamps or CFLs showed that average efficacy was still about 46 lm/W in
2009 (tested performance ranged from 17 lm/W to 79 lm/W).

Lifetime and failure:

Solid state devices such as LED’s are subject to very limited wear and tear if operated at
low currents and at low temperatures. Many of the LED’s made in the 1970s and 1980s are still
in service today. Typical lifetimes quoted are 25,000 to 100,000 hours but heat and current
settings can extend or shorten this time significantly.

The most common symptom of LED (and diode laser) failure is the gradual lowering of
light output and loss of efficiency. Sudden failures, although rare, can occur as well. Early red
LED’s were notable for their short lifetime. With the development of high-power LED’s the
devices are subjected to higher junction temperatures and higher current densities than
traditional devices. This causes stress on the material and may cause early light output
degradation. To quantitatively classify lifetime in a standardized manner it has been suggested
to use the terms L75 and L50 which is the time it will take a given LED to reach 75% and 50%
light output respectively.

Like other lighting devices, LED performance is temperature dependent. Most


manufacturers’ published ratings of LED’s are for an operating temperature of 25°C. LED’s
used outdoors, such as traffic signals or in-pavement signal lights, and that are utilized in
climates where the temperature within the luminaries gets very hot, could result in low signal
intensities or even failure.
SERIAL COMMUNICATION

SERIAL COMMUNICATION:

The main requirements for serial communication are:

1. Microcontroller

2. PC

3. RS 232 cable

4. MAX 232 IC

5. HyperTerminal

When the pins P3.0 and P3.1 of microcontroller are set, UART, which is inbuilt in the
microcontroller, will be enabled to start the serial communication.

Fig: Architecture for Serial Communication


TIMERS:

The 8051 has two timers: Timer 0 and Timer 1. They can be used either as timers to
generate a time delay or as counters to count events happening outside the microcontroller.

Both Timer 0 and Timer 1 are 16-bit wide. Since the 8051 has an 8-bit architecture, each
16-bit timer is accessed as two separate registers of low byte and high byte. Lower byte register
of Timer 0 is TL0 and higher byte is TH0. Similarly lower byte register of Timer1 is TL1 and
higher byte register is TH1.

TMOD (timer mode) register:

Both timers 0 and 1 use the same register TMOD to set the various operation modes.TMOD is
an 8-bit register in which the lower 4 bits are set aside for Timer 0 and the upper 4 bits for
Timer 1. In each case, the lower 2 bits are used to set the timer mode and the upper 2 bits to
specify the operation.

(MSB) (LSB)

GATE C/T M1 M0 GATE C/T M1 M0

TIMER 1 TIMER 0

GATE:
Every timer has a means of starting and stopping. Some timers do this by software,
some by hardware and some have both software and hardware controls. The timers in the 8051
have both. The start and stop of the timer are controlled by the way of software by the TR (timer
start) bits TR0 and TR1. These instructions start and stop the timers as long as GATE=0 in the
TMOD register. The hardware way of starting and stopping the timer by an external source is
achieved by making GATE=1 in the TMOD register.

C/T:

Timer or counter selected. Cleared for timer operation and set for counter operation.

M1 :

Mode bit 1

M0 :

Mode bit 0

M1 M0 Mode Operating Mode

0 0 0 13-bit timer mode

8-bit timer/counter THx with TLx as 5-bit prescaler

0 1 1 16-bit timer mode

16-bit timer/counters THx and TLx are cascaded

1 0 2 8-bit auto reload timer/counter

THx holds a value that is to be reloaded into TLx each time

it overflows

1 1 3 Split timer mode


The mode used here to generate a time delay is MODE 2.

This mode 2 is an 8-bit timer and therefore it allows only values of 00H to FFH to be
loaded into the timer’s register TH. After TH is loaded with the 8-bit value, the 8051 give a
copy of it to TL. When the timer starts, it starts to count up by incrementing the TL register. It
counts up until it reaches its limit of FFH. When it rolls over from FFH to 00H, it sets high the
TF (timer flag). If Timer 0 is used, TF0 goes high and if Timer 1 is used, TF1 goes high. When
the TL register rolls from FFH to 0 and TF is set to 1, TL is reloaded automatically with the
original value kept by the TH register.

ASYNCHRONOUS AND SYNCHRONOUS SERIAL COMMUNICATION

Computers transfer data in two ways: parallel and serial. In parallel data transfers, often
8 or more lines are used to transfer data to a device that is only a few feet away. Although a lot
of data can be transferred in a short amount of time by using many wires

Fig:
communication
using cables between pc to microcontroller

in parallel, the distance cannot be great. To transfer to a device located many meters
away, the serial method is best suitable. In serial communication, the data is sent one bit at a
time. The 8051 has serial communication capability built into it, thereby making possible fast
data transfer using only a few wires.
The fact that serial communication uses a single data line instead of the 8-bit data
line instead of the 8-bit data line of parallel communication not only makes it cheaper but also
enables two computers located in two different cities to communicate over the telephone.
Serial data communication uses two methods, asynchronous and synchronous. The
synchronous method transfers a block of data at a time, while the asynchronous method
transfers a single byte at a time. With synchronous communications, the two devices initially
synchronize themselves to each other, and then continually send characters to stay in sync. Even
when data is not really being sent, a constant flow of bits allows each device to know where the
other is at any given time. That is, each character that is sent is either actual data or an idle
character. Synchronous communications allows faster data transfer rates than asynchronous
methods, because additional bits to mark the beginning and end of each data byte are not
required. The serial ports on IBM-style PCs are asynchronous devices and therefore only
support asynchronous serial communications.
Asynchronous means "no synchronization", and thus does not require sending and
receiving idle characters. However, the beginning and end of each byte of data must be
identified by start and stop bits. The start bit indicates when the data byte is about to begin and
the stop bit signals when it ends. The requirement to send these additional two bits causes
asynchronous communication to be slightly slower than synchronous however it has the
advantage that the processor does not have to deal with the additional idle characters.
There are special IC chips made by many manufacturers for serial data communications.
These chips are commonly referred to as UART(universal asynchronous receiver-transmitter)
and USART(universal synchronous-asynchronous receiver-transmitter). The 8051 has a built-in
UART.
In the asynchronous method, the data such as ASCII characters are packed between a
start and a stop bit. The start bit is always one bit, but the stop bit can be one or two bits. The
start bit is always a 0 (low) and stop bit (s) is 1 (high). This is called framing.
The rate of data transfer in serial data communication is stated as bps (bits per second).
Another widely used terminology for bps is baud rate. The data transfer rate of a given
computer system depends on communication ports incorporated into that system. And in
asynchronous serial data communication, this baud rate is generally limited to 100,000bps. The
baud rate is fixed to 9600bps in order to interface with the microcontroller using a crystal of
11.0592 MHz.
RS232 CABLE:
To allow compatibility among data communication equipment, an interfacing
standard called RS232 is used. Since the standard was set long before the advent of the TTL
logic family, its input and output voltage levels are not TTL compatible. For this reason, to
connect any RS232 to a microcontroller system, voltage converters such as MAX232 are used
to convert the TTL logic levels to the RS232 voltage levels and vice versa.

MAX232:

The MAX232 is an integrated circuit that converts signals from an RS-232 serial port
to signals suitable for use in TTL compatible digital logic circuits. The MAX232 is a dual
driver/receiver and typically converts the RX, TX, CTS and RTS signals.

The drivers provide RS-232 voltage level outputs (approx. ± 7.5 V) from a single + 5
V supply via on-chip charge pumps and external capacitors. This makes it useful for
implementing RS-232 in devices that otherwise do not need any voltages outside the 0 V to
+ 5 V range, as power supply design does not need to be made more complicated just for
driving the RS-232 in this case.
The receivers reduce RS-232 inputs (which may be as high as ± 25 V), to standard 5
V TTL levels. These receivers have a typical threshold of 1.3 V, and a typical hysteresis of
0.5 V.

The later MAX232A is backwards compatible with the original MAX232 but may
operate at higher baud rates and can use smaller external capacitors –
μF in place of the 1.0 μF capacitors used with the original device.[1]

The newer MAX3232 is also backwards compatible, but operates at a broader voltage range,
from 3 to 5.5 V.
Voltage levels

It is helpful to understand what occurs to the voltage levels. When a MAX232 IC


receives a TTL level to convert, it changes a TTL Logic 0 to between
+3 and +15 V, and changes TTL Logic 1 to between -3 to -15 V, and vice versa for
converting from RS232 to TTL. This can be confusing when you realize that the RS232
Data Transmission voltages at a certain logic state are opposite from the RS232 Control
Line voltages at the same logic state. To clarify the matter, see the table below. For more
information see RS-232 Voltage Levels.

RS232 Line Type & Logic Level RS232 Voltage TTL Voltage
to/from MAX232
Data Transmission (Rx/Tx) Logic 0 +3 V to +25 V 0V
Data Transmission (Rx/Tx) Logic 1 -3 V to -25 V 5V
Control Signals (RTS/CTS/DTR/DSR) -3 V to -25 V 5V
Logic 0
Control Signals (RTS/CTS/DTR/DSR) +3 V to +25 V 0V
Logic 1

The MAX232 from Maxim was the first IC which in one package contains the
necessary drivers and receivers to adapt the RS-232 signal voltage levels to TTL logic. It
became popular, because it just needs one voltage (+5V or +3.3V) and generates the
necessary RS-232 voltage levels.

The required parts:


 1 x female serial port connector
 1 x max 232
 4 x 1uF capacitor
 1 x 10uF capacitor
 Soldering iron, wires, breadboard etc.

General Description
The MAX232 is a dual driver/receiver that includes a capacitive voltage generator to
supply TIA/EIA-232-F voltage levels from a single 5-V supply. Each receiver converts
TIA/EIA-232-F inputs to 5-V TTL/CMOS levels. These receivers have a typical threshold of
1.3 V, a typical hysteresis of 0.5 V, and can accept ±30-V inputs. Each driver converts
TTL/CMOS input levels into TIA/EIA- 232-F levels. The driver, receiver, and voltage-
generator functions are available as cells in the Texas Instruments.

MAX232 Features

 Meets or Exceeds TIA/EIA-232-F and ITU Recommendation V.28

 Operates From a Single 5-V Power Supply With 1.0-uF Charge-Pump Capacitors

 Operates Up To 120 kbit/s

 Two Drivers and Two Receivers

 ±30-V Input Levels

 Low Supply Current . . . 8 mA Typical

 ESD Protection Exceeds JESD 22

 2000-V Human-Body Model (A114-A)


 Upgrade With Improved ESD (15-kV HBM) and 0.1-uF Charge-Pump
Capacitors is

 Available With the MAX202

 Applications: TIA/EIA-232-F, Battery-Powered Systems, Terminals, Modems,

and Computers

MAX232 Pin Connection Diagram


MAX232 Typical Application Electronic Circuit
Diagram
MAX232 Logic Diagram
RS232 Data Interface

RS-232

RS-232 is simple, universal, well understood and supported but it has some serious
shortcomings as a data interface. The standards to 256kbps or less and line lengths of 15M
(50 ft) or less but today we see high speed ports on our home PC running very high speeds
and with high quality cable maxim distance has increased greatly. The rule of thumb for
the length a data cable depends on speed of the data, quality of the cable.

Electronic data communications between elements will generally fall into two broad
categories: single-ended and differential. RS232 (single-ended) was introduced in 1962, and
despite rumors for its early demise, has remained widely used through the industry.

Independent channels are established for two-way (full-duplex) communications. The


RS232 signals are represented by voltage levels with respect to a system common (power /
logic ground). The "idle" state (MARK) has the signal level negative with respect to
common, and the "active" state (SPACE) has the signal level positive with respect to
common. RS232 has numerous
handshaking lines (primarily used with modems), and also specifies a
communications protocol.

The RS-232 interface presupposes a common ground between the DTE and DCE.
This is a reasonable assumption when a short cable connects the DTE to the DCE, but with
longer lines and connections between devices that may be on different electrical busses with
different grounds, this may not be true.

RS232 data is bi-polar.... +3 TO +12 volts indicates an "ON or 0-state (SPACE)


condition" while A -3 to -12 volts indicates an "OFF" 1-state (MARK) condition.... Modern
computer equipment ignores the negative level and accepts a zero voltage level as the "OFF"
state. In fact, the "ON" state may be achieved with lesser positive potential. This means
circuits powered by 5 VDC are capable of driving RS232 circuits directly, however, the
overall range that the RS232 signal may be transmitted/received may be dramatically
reduced.

The output signal level usually swings between +12V and -12V. The "dead area"
between +3v and -3v is designed to absorb line noise. In the various RS- 232-like definitions
this dead area may vary. For instance, the definition for V.10 has a dead area from +0.3v to -
0.3v. Many receivers designed for RS-232 are sensitive to differentials of 1v or less.

This can cause problems when using pin powered widgets - line drivers, converters,
modems etc. These type of units need enough voltage & current to power them self's up.
Typical URART (the RS-232 I/O chip) allows up to 50ma per output pin - so if the device
needs 70ma to run we would need to use at least 2 pins for power. Some devices are very
efficient and only require one pin (some times the Transmit or DTR pin) to be high - in the
"SPACE" state while idle.
An RS-232 port can supply only limited power to another device. The number of
output lines, the type of interface driver IC, and the state of the output lines are important
considerations.
The types of driver ICs used in serial ports can be divided into three general categories:
Drivers which require plus (+) and minus (-) voltage power supplies such as the 1488
series of interface integrated circuits. (Most desktop and tower PCs use this type of driver.)
Low power drivers which require one +5 volt power supply. This type of driver has an
internal charge pump for voltage conversion. (Many industrial microprocessor controls use
this type of driver.)
Low voltage (3.3 v) and low power drivers which meet the EIA-562 Standard. (Used
on notebooks and laptops.)

Data is transmitted and received on pins 2 and 3 respectively. Data Set Ready (DSR)
is an indication from the Data Set (i.e., the modem or DSU/CSU) that it is on. Similarly,
DTR indicates to the Data Set that the DTE is on. Data Carrier Detect (DCD) indicates that a
good carrier is being received from the remote modem.

Pins 4 RTS (Request To Send - from the transmitting computer) and 5 CTS (Clear To
Send - from the Data set) are used to control. In most Asynchronous situations, RTS and CTS
are constantly on throughout the communication session. However where the DTE is
connected to a multipoint line, RTS is used to turn carrier on the modem on and off. On a
multipoint line, it's imperative that only one station is transmitting at a time (because they
share the return phone pair). When a station wants to transmit, it raises RTS. The
modem turns on carrier,
typically waits a few milliseconds for carrier to stabilize, and then raises CTS. The DTE
transmits when it sees CTS up. When the station has finished its transmission, it drops RTS
and the modem drops CTS and carrier together.

Clock signals (pins 15, 17, & 24) are only used for synchronous communications. The
modem or DSU extracts the clock from the data stream and provides a steady clock signal to
the DTE. Note that the transmit and receive clock signals do not have to be the same, or
even at the same baud rate.

Note: Transmit and receive leads (2 or 3) can be reversed depending on the use of the
equipment - DCE Data Communications Equipment or a DTE Data Terminal Equipment.

CTS Clear To Send [DCE --> DTE]


DCD Data Carrier Detected (Tone from a modem) [DCE --> DTE]
DCE Data Communications Equipment eg. modem DSR
Data Set Ready [DCE --> DTE]
DSRS Data Signal Rate Selector [DCE --> DTE] (Not
commonly
used)
DTE Data Terminal Equipment eg. computer, printer DTR
Data Terminal Ready [DTE --> DCE]
FG Frame Ground (screen or chassis)
NC No Connection
RCk Receiver (external) Clock input
RI Ring Indicator (ringing tone detected)
RTS Request To Send [DTE --> DCE] RxD
Received Data [DCE --> DTE]
SG Signal Ground
SCTS Secondary Clear To Send [DCE --> DTE] SDCD
Secondary Data Carrier Detected (Tone from a
modem)
[DCE --> DTE]
SRTS Secondary Request To Send [DTE --> DCE]
SRxD Secondary Received Data [DCE --> DTE] STxD
Secondary Transmitted Data [DTE --> DCE] TxD
Transmitted Data [DTE --> DCE]

Is Your Interface a DTE or a DCE?

One of the stickiest areas of confusion in datacom is over the terms "transmit" and
"receive" as they pertain to DTE (data terminal equipment) and DCE (data communication
equipment). In synchronous communication, this confusion is particularly acute, because
more signals are involved. So why is it that you sometimes send data on TD, and other
times you send data on RD? Is this just a cruel form of mental torture? Not really. The secret
lies in adopting the proper perspective. In data-com, the proper perspective is always from
the point of view of the DTE. When you sit at a PC, terminal or workstation (DTE)
and
transmit data to somewhere far away, you naturally do so on the TD (transmit data) line.
When your modem or CSU/DSU (DCE) receives this incoming data, it receives the data on
the TD line as well. Why? Because the only perspective that counts in data-com is the
perspective of the DTE. It does not matter that the DCE thinks it is receiving data; the line is
still called "TD". Conversely, when the modem or CSU/DSU receives data from the outside
world and sends it to the DTE, it sends it on the RD line. Why? Because from the perspective
of the DTE, the data is being received! So when wondering, "Is this line TD or RD? Is it TC
or RC?" Ask yourself, "What would the DTE say?"

Find out by following these steps: The point of reference for all signals is the terminal (or
PC).

1) Measure the DC voltages between (DB25) pins 2 & 7 and between pins 3 & 7.
Be sure the black lead is connected to pin 7 (Signal Ground) and the red lead to
whichever pin you are measuring.

2) If the voltage on pin 2 is more negative than -3 Volts, then it is a DTE,


otherwise it should be near zero volts.

3) If the voltage on pin 3 is more negative than -3 Volts, then it is a DCE.

4) If both pins 2 & 3 have a voltage of at least 3 volts, then either you are
measuring incorrectly, or your device is not a standard EIA-232 device. Call
technical support.

5) In general, a DTE provides a voltage on TD, RTS, & DTR, whereas a DCE
provides voltage on RD, CTS, DSR, & CD.
X.21 interface on a DB 15 connector

General

Voltages: +/- 0.3Vdc

Max. 100Kbps (X.26)


Speeds:
Max. 10Mbps (X.27)

The X.21 interface was recommended by the CCITT in 1976. It is defined as a


digital signaling interface between customers (DTE) equipment and carrier's equipment
(DCE). And thus primarily used for telecom equipment.
All signals are balanced. Meaning there is always a pair (+/-) for each signal, like
used in RS422. The X.21 signals are the same as RS422, so please refer to RS422 for the
exact details.
Pinning according to ISO 4903

Sub-D15 Male Sub-D15 Female

Pin Signal abbr. DTE DCE


1 Shield - -
2 Transmit (A) Out In
3 Control (A) Out In
4 Receive (A) In Out
5 Indication (A) In Out
6 Signal Timing (A) In Out
7 Unassigned
8 Ground - -
9 Transmit (B) Out In
10 Control (B) Out In
11 Receive (B) In Out
12 Indication (B) In Out
13 Signal Timing (B) In Out
14 Unassigned
15 Unassigned

Functional Description

As can be seen from the pinning specifications, the Signal Element Timing (clock) is
provided by the DCE. This means that your provider (local telco office) is responsible for the
correct clocking and that X.21 is a synchronous interface. Hardware handshaking is done by the
Control and Indication lines. The Control is used by the DTE and the Indication is the DCE one.

Cross-cable pinning

X.21 Cross Cable


X.21 X.21
1 1
2 4
3 5
4 2
5 3
6 7
7 6
8 8
9 11
10 12
11 9
12 10
13 14
14 13
15

RS232D uses RJ45 type connectors


(similar to telephone connectors)

Pin No.Signal Description Abbr. DSR/RI


DTEDCE
DCD DTR SG
DCE Ready, Ring Indicator RxD TxD
Received Line Signal Detector
DTE Ready
Signal Ground
Received Data
Transmitted Data
7 Clear To Send CTS
8 Request To Send RTS

This is a standard 9 to 25 pin cable layout for async data on a PC AT serial


cable

9-pin 25-pin
Description Signal Source DTE or DCE
DTE DCE
Carrier Detect CD 1 8 from Modem
Receive Data RD 2 3 from Modem
Transmit Data TD 3 2 from Terminal/Computer
Data Terminal
DTR 4 20 from Terminal/Computer
Ready
Signal Ground SG 5 7 from Modem
Data Set Ready DSR 6 6 from Modem
Request to Send RTS 7 4 from Terminal/Computer
Clear to Send CTS 8 5 from Modem
Ring Indicator RI 9 22 from Modem

This a DTE port as on the back of a PC Com Port -


EIA-574 RS-232/V.24 pin out on a DB-9 pin
used for Asynchronous Data
25 pin D-shell connector RS232
commonly used for Async. data

PIN SIGNAL DESCRIPTION

1 PGND Protective Ground


2 TXD Transmit Data
3 RXD Receive Data
4 RTS RequestTo Send
5 CTS Clear To Send
6 DSR Data Set Ready
7 SG Signal Ground
8 CD Carrier Detect
20 DTR Data Terminal Ready 22
RI Ring Indicator

Some applications require more pins than a simple A Sync.


Configurations.

Cabling considerations - you should use cabling made for RS-232 data but I have seen
low speed data go over 250' on 2 pair phone cable. Level 5 cable can also be used but for
best distance uses a low capacitance data grade cable.

The standard maxim length is 50' but if data is async you can increase that distance to as
much as 500' with a good grade of cable.

The RS-232 signal on a single cable is impossible to screen effectively for noise. By
screening the entire cable we can reduce the influence of outside noise, but internally
generated noise remains a problem. As the baud rate and line length
increase, the effect of capacitance between the different lines introduces serious crosstalk
(this especially true on synchronous data - because of the clock lines) until a point is reached
where the data itself is unreadable. Signal Crosstalk can be reduced by using low capacitance
cable and shielding each pair

Using a high grade cable (individually shield low capacitance pairs) the distance can be
extended to 4000'At higher frequencies a new problem comes to light. The high frequency
component of the data signal is lost as the cable gets longer resulting in a rounded, rather than
square wave signal. The maxim distance will depend on the speed and noise level around the
cable run. On longer runs a line drive is needed. This is a simple modem used to increase the
maxim distance you can run RS-232 data.

Making sense of the specifications:

Selecting data cable isn't difficult, but often gets lost in the shuffle of larger system
issues. Care should be taken. However, because intermittent problems caused by marginal
cable can be very difficult to troubleshoot.
Beyond the obvious traits such as number of conductors and wire gauge, cable specifications
include a handful of less intuitive terms.

Characteristic Impedance (Ohms): A value based on the inherent conductance, resistance,


capacitance and inductance of a cable that represents the impedance of an infinitely long
cable. When the cable is out to any length and terminated with this Characteristic
Impedance, measurements of the cable will be identical to values obtained from the infinite
length cable. That is to say that the termination of the cable with this impedance gives the
cable the appearance of being infinite length, allowing no reflections of the transmitted
signal. If termination is required
in a system, the termination impedance value should match the Characteristic Impedance of
the cable.

Shunt Capacitance (pF/ft): The amount of equivalent capacitive load of the cable,
typically listed in a per foot basis One of the factors limiting total cable length is the
capacitive load. Systems with long lengths benefits from using low capacitance cable.
Software Tools
KEIL SOFTWARE:

Keil compiler is a software used where the machine language code is written and
compiled. After compilation, the machine source code is converted into hex code which is
to be dumped into the microcontroller for further processing. Keil compiler also supports C
language code.

STEPS TO WRITE AN ASSEMBLY LANGUAGE PROGRAM IN KEIL


AND HOW TO COMPILE IT:

1. Install the Keil Software in the PC in any of the drives.


2. After installation, an icon will be created with the name “Keil uVision3”.
Just drag this icon onto the desktop so that it becomes easy whenever you
try to write programs in keil.
3. Double click on this icon to start the keil compiler.
4. A page opens with different options in it showing the project workspace at
the leftmost corner side, output window in the bottom and an ash coloured
space for the program to be written.
5. Now to start using the keil, click on the option “project”.
6. A small window opens showing the options like new project, import
project, open project etc. Click on “New project”.
7. A small window with the title bar “Create new project” opens. The window
asks the user to give the project name with which it should be created and
the destination location. The project can be created in any of the drives
available. You can create a new folder and then a new file or can create
directly a new file.
8. After the file is saved in the given destination location, a window opens
where a list of vendors will be displayed and you have to select the device
for the target you have created.
9. The most widely used vendor is Atmel. So click on Atmel and now the
family of microcontrollers manufactured by Atmel opens. You can select
any one of the microcontrollers according to the requirement.
10.When you click on any one of the microcontrollers, the features of that
particular microcontroller will be displayed on the right side of the page.
The most appropriate microcontroller with which most of the projects can
be implemented is the AT89C51. Click on this microcontroller and have a
look at its features. Now click on “OK” to select this microcontroller.
11.A small window opens asking whether to copy the startup code into the file
you have created just now. Just click on “No” to proceed further.
12.Now you can see the TARGET and SOURCE GROUP created in the
project workspace.
13.Now click on “File” and in that “New”. A new page opens and you can start
writing program in it.
14.After the program is completed, save it with any name but with the .asm
extension. Save the program in the file you have created earlier.
15.You can notice that after you save the program, the predefined keywords
will be highlighted in bold letters.
16.Now add this file to the target by giving a right click on the source group. A
list of options open and in that select “Add files to the source group”. Check
for this file where you have saved and add it.
17.Right click on the target and select the first option “Options for target”. A
window opens with different options like device, target, output etc. First
click on “target”.
18.Since the set frequency of the microcontroller is 11.0592 MHz to interface
with the PC, just enter this frequency value in the Xtal (MHz) text area and
put a tick on the Use on-chip ROM. This is because the program what we
write here in the keil will later be dumped into the microcontroller and will
be stored in the inbuilt ROM in the microcontroller.
19.Now click the option “Output” and give any name to the hex file to be
created in the “Name of executable” text area and put a tick to the “Create
HEX file” option present in the same window. The hex file can be created
in any of the drives. You can change the folder by clicking on “Select folder
for Objects”.
20.Now to check whether the program you have written is errorless or not,
click on the icon exactly below the “Open file” icon which is nothing but
Build Target icon. You can even use the shortcut key F7 to compile the
program written.
21.To check for the output, there are several windows like serial window,
memory window, project window etc. Depending on the program you have
written, select the appropriate window to see the output by entering into
debug mode.
22.The icon with the letter “d” indicates the debug mode.
23.Click on this icon and now click on the option “View” and select the
appropriate window to check for the output.
24.After this is done, click the icon “debug” again to come out of the debug
mode.
25.The hex file created as shown earlier will be dumped into the
microcontroller with the help of another software called Proteus.
PROTEUS:

Proteus is a software which accepts only hex files. Once the machine code is
converted into hex code, that hex code has to be dumped into the microcontroller placed in
the programmer kit and this is done by the Proteus. Programmer kit contains a
microcontroller on it other than the one which is to be programmed. This microcontroller has
a program in it written in such a way that it accepts the hex file from the keil compiler and
dumps this hex file into the microcontroller which is to be programmed. As this programmer
kit requires power supply to be operated, this power supply is given from the power supply
circuit designed above. It should be noted that this programmer kit contains a power supply
section in the board itself but in order to switch on that power supply, a source is required.
Thus this is accomplished from the power supply board with an output of 12volts or from an
adapter connected to 230 V AC.

1. Install the Proteus Software in the PC.


2. Now connect the Programmer kit to the PC (CPU) through serial cable.
3. Power up the programmer kit from the ac supply through adapter.
4. Now place the microcontroller in the GIF socket provided in the
programmer kit.
5. Click on the Proteus icon in the PC. A window appears providing the
information like Hardware model, com port, device type, Flash size etc.
Click on browse option to select the hex file to be dumped into the
microcontroller and then click on “Auto program” to program the microcontroller
with that particular hex file.
6. The status of the microcontroller can be seen in the small status window in
the bottom of the page.After this process is completed, remove the
microcontroller from the programmer kit and place it in your system board.
Now the system board behaves according to the program written in the
microcontroller.

Applications
Leds Funtain shape:

Source code:

mov p2,#00h
rep:mov r0,#08
mov a,#01h
loop:mov p2,a
acall delay
setb c
rlc a
djnz r0,loop
mov r0,#08h
loop1: clr c
rrc a
mov p2,a
acall delay
djnz r0,loop1
ajmp rep
delay: mov r1,#01
loop3: mov r2,#255
loop2: mov r3,#255
djnz r3,$
djnz r2, loop2
djnz r1,loop3
ret
end

Traffic signal:

Source code:
mov p2,#00h
mov p3,#0f0h
main:mov p2,#4ch
mov p3,#0f2h
acall delay
mov p2,#52h
acall delay1
mov p2,#61h
acall delay
mov p2,#91h
acall delay1
mov p2,#09h
mov p3,#0f3h
acall delay
mov p2,#89h
mov p3,#0f4h
acall delay1
mov p2,#49h
mov p3,#0f8h
acall delay
mov p2,#4ah
mov p3,#0f4h
acall delay1
ajmp main
delay:mov r0,#40
loop1: mov r1,#255
loop: mov r2,#255
djnz r2,$
djnz r1,loop
djnz r0,loop1
ret
delay1:mov r0,#20
loop2: mov r1,#200
loop3: mov r2,#200
djnz r2,$
djnz r1,loop3
djnz r0,loop2
ret
end

2.seven segment display


Source code:
main:mov r0,#16
mov p1,#00h
mov dptr,#400h
back:movc a,@a+dptr
mov p1,a
acall delay
inc dptr
clr a
djnz r0,back
ajmp main
delay:mov r3,#2
loop1: mov r1,#255
loop: mov r2,#255
djnz r2,$
djnz r1,loop
djnz r3,loop1
ret
org 400h
db
0c0h,0f9h,0a4h,0b0h,99h,92h,82h,0f8h,80h,90h,88h,80h,0c6h,0c0h,86h,8eh
end

Date display:

Source code:
mov p1,#00h
mov p2,#00h
back:setb p2.0 // com1 activate
mov p1,#0a4h //to display 2'
acall delay
clr p2.0
setb p2.1 // com2
mov p1,#12h //5.
acall delay
clr p2.1
setb p2.2 //com3
mov p1,#0f9h //1
acall delay
clr p2.2
setb p2.3 //com4
mov p1,#79h //1.
acall delay
clr p2.3
setb p2.4 //com5
mov p1,#0a4h
acall delay
clr p2.4
setb p2.5 //com6
mov p1,#0c0h
acall delay
clr p2.5
setb p2.6 //com7
mov p1,#0f9h //1
acall delay
clr p2.6
setb p2.7 // com8
mov p1,#80h
acall delay
clr p2.7
ajmp back
delay: mov r1,#200
djnz r1,$
ret end

DC Motor
Source code:
back:setb p2.0
acall delay
clr p2.0
acall delay
sjmp back
delay:mov r0,#71
mov tmod,#10h
loop:mov th1,#02h
mov tl1,#81h
setb tr1
jnb tf1,$
clr tf1
djnz r0,loop
clr tr1
ret
end

Robot design using switches


Source code:
clr p2.0
clr p2.1
clr p2.2
clr p2.3
back:jnb p1.0, forward
jnb p1.1, left
jnb p1.2, reverse
jnb p1.3,right
jnb p1.4,stop
sjmp back
forward: setb p2.0
clr p2.1
setb p2.2
clr p2.3
jnb p1.0,$
sjmp back
left: setb p2.0
clr p2.1
clr p2.2
setb p2.3
jnb p1.1,$
sjmp back
reverse: clr p2.0
setb p2.1
clr p2.2
setb p2.3
jnb p1.2,$
sjmp back
right: clr p2.0
setb p2.1
setb p2.2
clr p2.3
jnb p1.3,$
sjmp back
stop: clr p2.0
clr p2.1
clr p2.2
clr p2.3
jnb p1.4,$
sjmp back
end
Electrical load control

Source code:
back:clr p2.0
clr p2.1
acall delay
setb p2.0
setb p2.1
acall delay
sjmp back
delay:mov r0,#04
loop1:mov r1,#240
mov tmod,#10h
loop:mov th1,#1fh
mov tl1,#06h
setb tr1
jnb tf1,$
clr tf1
djnz r1,loop
djnz r0,loop1
clr tr1
ret
end

PC based home automation


mov r0,#25
mov scon,#50h
mov tmod,#20h
mov th1,#-3
setb tr1
mov dptr,#600h
back:movc a,@a+dptr
mov sbuf,a
jnb ti,$
clr ti
inc dptr
clr a
djnz r0,back
loop:jnb ri,$
mov a,sbuf
mov sbuf,a
jnb ti,$
clr ti
clr ri
cjne a,#'1',load1
clr p2.0 //load 1 on
ajmp loop
load1:cjne a,#'2',load2
setb p2.0 //load1 off
ajmp loop
load2: cjne a,#'3',load
clr p2.1 //load2 on
ajmp loop
load: cjne a,#'4',load3
setb p2.1 //load2 off
ajmp loop
load3: cjne a,#'5',load3off
clr p2.2 //load3 on
ajmp back
load3off:cjne a,#'6',load4
setb p2.2 // load3 off
ajmp loop
load4: cjne a,#'7',load4off
clr p2.3 //load4 on
ajmp loop
load4off:cjne a,#'8',allon
setb p2.3 //load4 off
ajmp loop
allon: cjne a,#'9',alloff
clr p2.0
clr p2.1
clr p2.2
clr p2.3
ajmp loop
alloff: cjne a,#'0',loop
setb p2.0
setb p2.1
setb p2.2
setb p2.3
ajmp loop
org 600h
db "PC BASED HOME AUTOMATION",0dh
end
LCD Name & roll number display

Source Code:
#include<reg51.h>
sbit rs=P1^0;
sbit rw=P1^1;
sbit en=P1^2;
void main()
{
unsigned char name[8]={"SAIMEDHA"};
unsigned char roll[6]={"ECE999"} ;
unsigned char comm[4]={0x38,0x10,0x0c,0x80};
unsigned char v1;
unsigned int v3;
P2=0x00;
for(v1=0;v1<4;v1++)
{
P2=comm[v1];
rs=0;
rw=0;
en=1;
for(v3=0;v3<2000;v3++);
en=0;
}
for(v1=0;v1<8;v1++)
{
P2=name[v1];
rs=1;
en=1;
for(v3=0;v3<2000;v3++);
en=0;
}
P2=0xc0;
rs=0;
en=1;
for(v3=0;v3<2000;v3++);
en=0;
for(v1=0;v1<6;v1++)
{
P2=roll[v1];
rs=1;
en=1;
for(v3=0;v3<2000;v3++);
en=0;
}

}
Password protected system
Source code:

#include<reg51.h>
// Keypad connections//
sbit row1=P1^0;
sbit row2=P1^1;
sbit row3=P1^2;
sbit row4=P1^3;
sbit col1=P1^4;
sbit col2=P1^5;
sbit col3=P1^6;
//lcd connections//
sbit rs=P2^0;
sbit rw=P2^1;
sbit en=P2^2;
//motor inputs//
sbit motp=P2^3;
sbit motn=P2^4;
void delay();
void check();
unsigned char comm[4]={0x38,0x0c,0x10,0x80};
unsigned char msg[15]={"ENTER PASSWORD"};
unsigned char password[4]={"9676"};
unsigned char read[4]; //used to store keys given from keypad
unsigned char v1,v2=0x00;
unsigned int v3;
void main()
{
motp=motn=0;
P3=0x00;
for(v1=0;v1<4;v1++)
{
P3=comm[v1];
rs=0;
rw=0;
en=1;
for(v3=0;v3<2000;v3++);
en=0;
} for(v1=0;v1<15;v1+
+)
{
P3=msg[v1];
rs=1;
en=1;
for(v3=0;v3<2000;v3++);
en=0;
}
P3=0xc0;
rs=0;
en=1;
for(v3=0;v3<2000;v3++);
en=0;
while(1)
{
row1=0;
if(col1==0)
{
read[v2]='1';
P3='*';
rs=1;
en=1;
for(v3=0;v3<2000;v3++);
en=0;
delay();
v2=v2+1;
}
if(col2==0)
{
read[v2]='2';
P3='*';
rs=1;
en=1;
for(v3=0;v3<2000;v3++);
en=0;
delay();
v2=v2+1;
}
if(col3==0)
{
read[v2]='3';
P3='*';
rs=1;
en=1;
for(v3=0;v3<2000;v3++);
en=0;
delay();
v2=v2+1;
}
row1=1;row2=0;
if(col1==0)
{
read[v2]='4';
P3='*';
rs=1;
en=1;
for(v3=0;v3<2000;v3++);
en=0;
delay();
v2=v2+1;
}
if(col2==0)
{
read[v2]='5';
P3='*';
rs=1;
en=1;
for(v3=0;v3<2000;v3++);
en=0;
delay();
v2=v2+1;
}
if(col3==0)
{
read[v2]='6';
P3='*';
rs=1;
en=1;
for(v3=0;v3<2000;v3++);
en=0;
delay();
v2=v2+1;
}
row2=1;row3=0;
if(col1==0)
{
read[v2]='7';
P3='*';
rs=1;
en=1;
for(v3=0;v3<2000;v3++);
en=0;
delay();
v2=v2+1;
}
if(col2==0)
{
read[v2]='8';
P3='*';
rs=1;
en=1;
for(v3=0;v3<2000;v3++);
en=0;
delay();
v2=v2+1;
}
if(col3==0)
{
read[v2]='9';
P3='*';
rs=1;
en=1;
for(v3=0;v3<2000;v3++);
en=0;
delay();
v2=v2+1;
}
row3=1;row4=0;
if(col1==0)
{
read[v2]='*';
P3='*';
rs=1;
en=1;
for(v3=0;v3<2000;v3++);
en=0;
delay();
v2=v2+1;
}
if(col2==0)
{
read[v2]='0';
P3='*';
rs=1;
en=1;
for(v3=0;v3<2000;v3++);
en=0;
delay();
v2=v2+1;
}
if(col3==0)
{
check();
delay();
}
row4=1;
}
}
void check()
{
unsigned char msg2[16]={"PASSWORD MATCHED"};
unsigned char msg3[14]={"WRONG PASSWORD"};
unsigned char v4;

if(password[0]==read[0]&&password[1]==read[1]&&password[2]==read[2]
&&password[3]==read[3])
{
motp=1;
motn=0;
P3=0x01;
rs=0;
en=1;
for(v3=0;v3<2000;v3++);
en=0;
for(v4=0;v4<16;v4++)
{
P3=msg2[v4];
rs=1;
en=1;
for(v3=0;v3<2000;v3++);
en=0;
}
delay();
motp=motn=0;
}
else
{
m
o
t
p
=
0
;
m
o
t
n
=
0
;
P
3
=
0
x
0
1
;
r
s
=
0
;

e
n
=
1
;
for(v3=0;v3<2000;v3++);
en=0;
for(v4=0;v
4<14;v4+
+)
{
P
3
=
m
s
g
3
[
v
4
]
;

r
s
=
1
;
en=1;
for(v3=0;v3<
2000;v3++);
en=0;
}
delay();
}
}
void delay()
{
unsigned int v5;
for(v5=0;v5<60000;v5
++);
}

You might also like