You are on page 1of 55

Acknowledgement

I have completed my six week industrial training


from ATECH LABS, CHANDIGARH. Those days I have spent there were very
knowledgeable to me and I have learnt lot of thing about the various practical
applications of my study.
My training was on embedded systems and I have
studied there about 8051 microcontroller and its interfacing with various devices
utilized in making an embedded system.
I would like to thanks Er. Lakhbir Singh who
had guide us there very intelligently and teach us about the microcontroller.

I am deeply indebted to my HOD Dr. P.K.SHARMA


and to coordinator Er. ANMOL GOYAL whose help, stimulating suggestions and
encouragements were always with me.

1
Preface
This training report is all about the embedded
systems and it application in various fields of real world. We are living in the
Embedded World. We are surrounded with many embedded products and our daily
life largely depends on the proper functioning of these gadgets. Television , Radio,
CD player , Washing Machine or Microwave Oven in our kitchen , Card Readers ,
Access Controllers , Palm devices of our work space enable us to do many of our
tasks very effectively . Apart from all these, many controllers embedded in our car
take care of car operations between the bumpers. All kinds of magazines and journals
regularly dish out details about latest technologies, new devices; fast applications
which make us believe that our basic survival is controlled by these embedded
products. Now we can agree to the fact that these embedded products have
successfully invaded into our world.

What is the Embedded System?

Theoretically, an embedded system is a combination of piece of micro- processor


based hardware and the suitable software to perform a specific task.

I have made a Project based on Microcontroller that is a RF BASED LIGHT


CONTROL & VISITOR COUNTER . This training report covers all about the
microcontroller and project description.

2
I. PROFILE OF THE COMPANY-
ATECH

I.1 About Fateh Technologies

Fateh Technologies is a leading provider of High Quality TELECOM Services and offers world-class
Embedded System Development programs. Employing latest advanced software technologies and
innovations, Fateh offers a variety of products and solutions that allow individuals and businesses
around the world to start a telecom and embedded system business or to expand an existing one.
Company harnesses the unique combinations of Telecom And Embedded Systems expertise which
culminated in evolution of many unique techniques to focus on extended development centre and
turn-key projects. Fateh’s vision of achieving performance excellence and creating standards is
pushing the limits each time and paving way for more exciting things across the nation. The present
projects underway in south zone of India are the minute examples of Fateh's global impact. With its
fast growth in diverse industries viz. Telecom, Embedded system & Software development, it is
moving in the right direction to capture the global market.
With the promise shown already, Fateh Technologies is sure of joining some big names in the market
in its pursuit of excellence in the near future.

I.2 Portfolio

Fateh Technologies is a customer focused organization. In order to achieve higher levels of


efficiency, they have removed conventional layers of management, and designed a non-hierarchal
system, which lays emphasis on empowered teams. Their project teams operate as a customer
controlled unit, giving top priority to customer needs. The communication channels are completely
transparent to the customer.
The project team is an empowered entity, designed to give quick response to the customer. A broad
business portfolio is:

3
I.2.1 Human Resource Development

Fateh Technologies follows a Human Resource Development program, which caters to:

• Tracking, monitoring and improvement of the skill levels of the employees.


• Planning and arrangement of training programs.
• Ensuring the safety and health concerns of all employees.

I.2.2 Learning Centre

This Centre is responsible for knowledge transfer across project teams. After completion of each
project, the experiences are presented through documents and interactive sessions. This Center also
collects and maintains project data for ready reference and use. The necessary technical literatures are
available with our Learning Centre.

I.3 Quality Systems

Quality Leadership
The executive management has developed the Vision, Mission, Quality Policy and Quality
Objectives as part of the leadership process.

I.3.1 Vision

Achieve Performance Excellence and create standards.

I.3.2 Mission

4
Provide dependable services in response to changing needs and to provide value addition in all our
endeavors as well as maintaining high standards of quality.

I.3.3 Quality Policy

Fateh Technologies understand and fulfill their customer’s needs, provide responsible solutions.
They support their customers in achieving their overall system goals. They strive for continual
improvement of their processes.

I.3.4 Quality Objectives

The following are first phase objectives for quality improvement in Fateh Technologies:
• Measure and improve project execution capabilities.
• Prevent defects by process control.
• Follow Plan-Do-Check-Act cycle to improve processes.

I.4 Services

I.4.1 Telecom

Radio Frequency Engineering Services


• RF Survey & Nominal Cell Planning
• RF Network Planning and Designing
• Drive Test & Network Optimization
• RF Network KPI analysis and Post-processing
• Comparative Drive Test for Network Benchmarking
• Microwave LOS Survey and Link Engineering
• Microwave Network Planning

I.4.2 Engineering Services

5
• Installation, Testing & Commissioning of all ranges of Telecom equipments related to GSM,
CDMA and Wi-Max
• Transportation Carrier-Terrestrial Microwave (SDH / PDH)
• Network Integration
• In-building solutions for wireless networks
• IT Enabled Services
• Electrical Installations
• Entrepreneur Solutions

I.4.3 Operation & Maintenance

• Telecom Cell Sites Maintenance (Preventive & Corrective)


• Professional Services

I.4.4 Training Programme

Professional training for 15 days/2 months/6 months

• Fundamentals of telecom networks


• 2G GSM, 2.5G GPRS, 2.75G EDGE
• 3G UMTS( Universal Mobile Telecom Service), Wideband CDMA
• 2G CDMA( IS-95), 2.5G CDMA( 2000) and 3G EVDO, EVDV
• Planning and installation of inbuilding solutions( IBS)
• Wi-Max

I.4.5 Live Projects Training

• RF( Radio frequency) performance and optimization


• RF site survey and planning
• Installation and commissioning of telecom network
• Transmission media planning(Microwave, fiber)

6
I.5 Embedded System

I.5.1 Implementation of Advanced Technologies like

• Intel's 8051 family


• Atmel's 89 series
• PIC
• AVR

I.5.2 Expertise on various software tools

• Keil compiler
• Assembly Language
• Embedded C
• Micro C

I.5.2 Embedded Products

• 89Sxx In-Circuit Serial Programmer


• Programmer for Atmel89C51/52/55/89S51/52
• Token display system

I.5.3 Various R & D Projects based on

• Microcontroller unit(MCU)
• PC
• Biomedical
• Wireless IR/RF
• OFC
• GSM
• Speech processing
• Image Processing
• Various Displays

7
I.6 Software Development

I.6.1 Services and Technical

• Application Development
• Application Migration
• Application Maintenance
• Software Testing
• On Site consulting

I.6.2 Technologies they use

• Java
• C/C++
• .Net
• SQL
• PHP

I.6.3 Projects

• Compression Performance Enhancers(Windows & Linux Platform)


• Web Based Applications
• IE Plug-ins.

I.7 Strengths

I.7.1 Human Resources

8
Skilled Manpower available for various projects.

I.7.2 Testing & Design

They are well equipped with highly experienced Engineers / Technicians and all necessary tools, test
equipment for execution of various projects and to name
some of them are:

• RF Network Planning Tools


• Site Masters
• RF Air-Interface test Tools
• RF Post Processing Tools
• GPSs

9
II INTRODUCTION

II.1EMBEDDED SYSTEM

What is an Embedded System?

An embedded system is a special-purpose computer system designed to perform one or a few


dedicated functions, often with real-time computing constraints. It is usually embedded as part of a
complete device including hardware and mechanical parts. In contrast, a general-purpose computer,
such as a personal computer, can do many different tasks depending on programming. Embedded
systems control many of the common devices in use today.

Since the embedded system is dedicated to specific tasks, design engineers can optimize it, reducing
the size and cost of the product, or increasing the reliability and performance. Some embedded
systems are mass-produced, benefiting from economies of scale.

Physically, embedded systems range from portable devices such as digital watches and MP4 players,
to large stationary installations like traffic lights, factory controllers, or the systems controlling
nuclear power plants. Complexity varies from low, with a single microcontroller chip, to very high
with multiple units, peripherals and networks mounted inside a large chassis or enclosure.

II.2MICROCONTROLLERS

Circumstances that we find ourselves in today in the field of microcontrollers had their beginnings in
the development of technology of integrated circuits. This development has made it possible to store
hundreds of thousands of transistors into one chip. That was a prerequisite for production of
microprocessors, and the first computers were made by adding external peripherals such as memory,
input-output lines, timers and other. Further increasing of the volume of the package resulted in
creation of integrated circuits. These integrated circuits contained both processor and peripherals.
That is how the first chip containing a microcomputer, or what would later be known as a
microcontroller came about.

II.2.1Definition

10
Microcontroller, as the name suggests, are small controllers. They are like single chip computers that
are often embedded into other systems to function as processing/controlling unit. For example, the
remote control you are using probably has microcontrollers inside that do decoding and other
controlling functions. They are also used in automobiles, washing machines, microwave ovens,
toys ... etc, where automation is needed.

The key features of microcontrollers include:

• High Integration of Functionality


• Microcontrollers sometimes are called single-chip computers because they have on-chip memory
and I/O circuitry and other circuitries that enable them to function as small standalone computers
without other supporting circuitry.
• Field Programmability, Flexibility
• Microcontrollers often use EEPROM or EPROM as their storage device to allow field
programmability so they are flexible to use. Once the program is tested to be correct then large
quantities of microcontrollers can be programmed to be used in embedded systems.
• Easy to Use

Assembly language is often used in microcontrollers and since they usually follow RISC architecture,
the instruction set is small. The development package of microcontrollers often includes an
assembler, a simulator, a programmer to "burn" the chip and a demonstration board. Some packages
include a high level language compiler such as a C compiler and more sophisticated libraries.

Most microcontrollers will also combine other devices such as:

• A Timer module to allow the microcontroller to perform tasks for certain time periods.
• A serial I/O port to allow data to flow between the microcontroller and other devices such as a PC
or another microcontroller.
• An ADC to allow the microcontroller to accept analogue input data for processing.

11
Figure II.1: Showing a typical microcontroller device and its different subunits

III MODULAR DESCRIPTION

III.1 NUMBERING AND CODING SYSTEM

III.1.1Various Number Systems are:


• Decimal number system (base 10)

12
• Binary system (base 2)
• Octal system (base 8)
• Hexadecimal system (base 16)

Human beings use decimal & computer use the binary system. The convenient representation of
binary numbers in base 16 is called hexadecimal number system. The base of the decimal number
system is 10 because it has 10 building blocks (i.e. 10 distinct symbols) which are 0, 1, 2, 3, ……..,
9. The base of the binary number system is 2 because there are only two building blocks, 0 and 1,
with which to generate numbers. These two binary digits, 0 and 1, are referred to as bits. The binary
system is used in computers because 1 and 0 represent the two voltage levels (Low level/ Ground
level & High level/ +VCC).The hexadecimal number system has 16 digits. In this system, the first 10
digits, 0 to 9, are the same as in decimal, and for the remaining six digits, the letters A, B, C, D, E, F
are used.

III.1.2 Converting from decimal to binary:


Knowing the weight associated with each binary bit position allows one to convert a decimal number
to binary. This is shown in example:
Convert 3910 to binary.
Weight 32 16 8 4 2 1
1 0 0 1 1 1
32+ 0+ 0+ 4+ 2+ 1 = 39
Therefore, 3910 = 1001112

Given Table shows the equivalent binary, decimal and hexadecimal representations for 0 to 15.

Decimal Binary Hex


0 0000 0
1 0001 1
2 0010 2
3 0011 3
4 0100 4
5 0101 5
6 0110 6
7 0111 7
8 1000 8
9 1001 9
10 1010 A
11 1011 B
12 1100 C
13 1101 D
14 1110 E
15 1111 F

13
Figure IV.1

III.1.3 Converting from binary to Hex:


To represent a binary number as its equivalent hexadecimal number, start from the right and group 4
bits at a time, replacing each 4-bit binary number with its hex equivalent shown in above table.
Example: convert 100111110101 in hex.
First the number is grouped into sets of 4 bits: 1001 1111 0101
Then each group of 4 bits is replaced with its hex equivalent:
8421 8421 8421
1001 1111 0101
8+1 8+4+2+1 4+1
9 F 5
Therefore, 100111110101B = 9F5H
IV DETAILED ANALYSIS

MICROPROCESSOR & MICROCONTROLLER

IV.1 MICROPROCESSOR (MPU)

A microprocessor is a general-purpose digital computer central processing unit (CPU). Although


popularly known as a “computer on a chip” is in no sense a complete digital computer. The block
diagram of a microprocessor CPU is shown, which contains an arithmetic and logical unit
(ALU), a program counter (PC), a stack pointer (SP),some working registers, a clock timing circuit,
and interrupt circuits.

ARITHMETIC
AND
LOGICAL UNIT

ACCUMULATOR
WORKING REGISTERS

PROGRAM STACK
COUNTER POINTER
COUNTER

14
CLOCK INTERRUPT
CIRCUIT CIRCUITS

Figure IV.2:- BLOCK DIAGRAM OF A MICROPROCESSOR

IV.2 MICROCONTROLLERS (MCU)

IV.2.1 Figure shows the block diagram of a typical microcontroller, which is a true computer on a
chip. The design incorporates all of the features found in micro-processor CPU: ALU, PC, SP, and
registers. It also added the other features needed to make a complete computer: ROM, RAM, parallel
I/O, serial I/O, counters, and clock circuit.

ALU TIMER / COUNTER


PORT
ACCUMULATOR
REGISTERS
PORT
INTERNAL
ROM
INTERNAL Interrupt
RAM Circuits

CLOCK
CIRCUIT
ALU

PROGRAM COUNTER

15
Figure IV.3:- BLOCK DIAGRAM OF A MICROCONTROLLER

IV.3 COMPARISON

MICROPROCESSORS AND MICROCONTROLLERS

MPU MCU

PIN CONFIGURATIONS

Total pins 40 40
Address pins 16(fixed) 16
Data pins 8(fixed) 8
Interrupt pins 2(fixed) 2
I/O pins 0 32
ARCHITECTURE

8-bit registers 20 34
16-bit registers 4 2
Stack size 64 128
Internal ROM 0 4K
Internal RAM 0 128
External memory 64K 128K
Timers 0 2
Flags 6 4

Figure IV.4
IV.4 VARIOUS MICROCONTROLLERS

IV.4.1 First microcontroller is ‘8031’


 FEATURES
• It is Intel’s product. Neither a microprocessor nor a microcontroller.
• It is a 8-bit controller.
• Internally no ROM is provided i.e. code is outside the chip.

IV.4.2 Second microcontroller is ‘8051’


 FEATURES
• It is a first complete 8-bit microcontroller.
• It is a name of a family. In which the instruction set, pin configuration, architecture are
same, only memory storage capacity is different.

16
• Internally PROM (programmable read only memory) is provided so it called one time
programmable (OTP).

IV.4.3 Third microcontroller is ‘AT89C51’


 FEATURES
• It is a similar to 8051 microcontroller i.e. having same instruction set, pin configuration,
architecture.
• It is a also 8-bit microcontroller. It’s cost is only Rs10 more than 8051.
• It uses EPROM (erasable programmable read only memory) or FLASH memory.
• It is Multiple time programmable (MTP) i.e. 1000 times. So it is better than 8051.

IV.5 THE 8051 ARCHITECTURE

XI.5.1 The 8051 Microcontroller’s Architecture consists of these specific features

• Eight-bit CPU with registers A (the accumulator) & B.


• Sixteen-bit program counter (PC) and data pointer (DPTR).
• Eight-bit program status word (PSW).
• Eight-bit stack pointer (SP).
• Internal ROM or EPROM (8751) of 0(8031) to 4K (8051).
• Internal RAM of 128 bytes.

1. Four register banks, each containing eight registers.


2. Sixteen bytes, which may be addressed at the bit level.
3. Eight bytes of general-purpose data memory.

• Thirty two I/O pins arranged as four-bit ports P0 – P3.


• Two 16-bit Timer/Counters T0 and T1.
• Full duplex serial data receiver/transmitter (SBUF).
• Control registers TCON, TMOD, SCON, PCON, IP and IE.
• Two external and three internal interrupt sources.
• Oscillator and clock circuits.

IV.6 THE 8051 MICROCONTROLLER

The 8051 provides the following standard features: 4Kbytes of ROM, 128 bytes of RAM, 32 I/O
lines, two 16-bit timer/counters, a five vector two-level interrupt architecture, a full duplex serial
port, on-chip oscillator and clock circuitry. In addition, the 8051 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.

17
IV.7 PIN CONFIGURATION

P1.0 1 40 Vcc
P1.1 2 39 P0.0(AD0)
P1.2 3 38 P0.1(AD1)
P1.3
P1.4
4
5
8051 37
36
P0.2(AD2)
P0.3(AD3)
P1.5 6 (8031) 35 P0.4(AD4)
P1.6 7 ARITHMETIC 34 P0.5(AD5)
P1.7 8 AND 33 P0.6(AD6)
RST 9 LOGICNIT 32 P0.7(AD7)
(RXD)P3.0 10 31 EA/VPP
(TXD)P3.1 11 30 ALE/PROG
(INT0)P3.2 12 29 PSEN
(INT1)P3.3 13 28 P2.7(A15)
(T0)P3.4 14 27 P2.6(A14)
(T1)P3.5 15 26 P2.5(A13)
(WR)P3.6 16 25 P2.4(A12)
(RD)P3.7 17 24 P2.3(A11)
XTAL2 18 23 P2.2(A10)
XTAL1 19 22 P2.1(A9)
GND 20 21 P2.0(A8)

Figure IV.4

IV.7.1 PIN DESCRIPTION

• VCC -- Supply voltage.


• GND -- Ground.
• Port 0 -- Port 0 is an 8-bit open drain bi-directional I/O port. As an output port each pin can sink
eight TTL inputs. When 1’s are written to port 0 pins, the pins can be used as high impedance
inputs. Port0 may 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 ROM 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 bi-directional I/O port with internal pull-ups. The Port1 output buffers
can sink/source four TTL inputs. When 1s are written to Port1 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

18
low will source current (IIL) because of the internal pull-ups. Port1 also receives the low-order
address bytes during ROM programming and verification.

• Port 2 -- Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The Port2 output buffers
can sink/source four TTL inputs. When 1s are written to Port2 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. Port2 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 it uses strong internal pull-ups
when emitting 1s. During accesses to external data memory that use 8-bit addresses (MOVX @
RI), Port 2 emits the contents of the P2 Special Function Register. 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 Port3 output buffers
can sink/source four TTL inputs. When 1s are written to Port3 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. Port 3 also receives
some control signals for ROM programming and verification. Port 3 also serves the functions of
various special features of the 8051.

• Port Pin Alternate Functions


1. P3.0 RXD (serial input port)
2. P3.1 TXD (serial output port)
3. P3.2 INT0 (external interrupt 0)
4. P3.3 INT1 (external interrupt 1)
5. P3.4 T0 (timer 0 external input)
6. P3.5 T1 (timer 1 external input)
7. P3.6 WR (external data memory write strobe)
8. P3.7 RD (external data memory read strobe)

• RST -- Reset input. A high on this pin for two machine cycles while the oscillator is
running resets the device.
+Vcc

19
Figure IV.5

• ALE/PROG -- Address Latch Enable 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 ROM
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. 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 is the read strobe to external program memory. When the 8051
is executing code from external program memory, PSEN is activated twice each machine
cycle, except that two PSEN activation’s 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

20
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, for parts that
require12-volt VPP.

• XTAL1—Input to the inverting oscillator amplifier and input to the internal clock operating
circuit.
XTAL2-- Output from the inverting oscillator amplifier.

IV.8 OSCILLATOR CHARACTERISTICS

IV.8.1 XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier which
can be configured for use as an on-chip oscillator. 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.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.
Figure IV.6

IV.9 ROM MEMORY

First models from 8051 family lacked the internal program memory, but it could be added externally
in a form of a separate chip. These MCU’s can be recognized by their mark which begins with 803
(e.g. 8031 or 8032). New models have built-in ROM, although there are substantial variations. With
some models internal memory cannot be programmed directly by the user. Instead, the user needs to
precede the program to the manufacturer, so that the MCU can be programmed (masked)
appropriately in the process of fabrication. Obviously, this option is cost-effective only for large
series. Fortunately, there are MCU models ideal for experimentation and small specialized series.

21
Many manufacturers deliver controllers that can be programmed directly by the user. These come in a
ceramic case with an opening (EPROM version) or in a plastic case without an opening (EEPROM
version). This book deals with one of the latter models that can be programmed via simple
programmer, even if the chip has already been mounted to the designated device.

IV.10 RAM MEMORY

As previously stated, RAM is used for storing temporary data and auxiliary results generated during
the runtime. Apart from that, RAM comprises a number of registers: hardware counters and timers,
I/O ports, buffer for serial connection, etc. With older versions, RAM spanned 256 locations, while
new models feature additional 128 registers. First 256 memory locations form the basis of RAM
(addresses 0 – FFh) of every 8051 MCU. Locations that are available to the user span addresses from
0 to 7Fh, i.e. first 128 registers, and this part of RAM is split into several blocks as can be seen in the
following image.

Figure IV.7
IV.10.1 First block comprises 4 "banks" of 8 registers each, marked as R0 - R7. To address these, the
parent bank has to be selected.

IV.10.2 Second memory block (range 20h – 2Fh) is bit-addressable, meaning that every belonging bit
has its own address (0 to 7Fh). Since the block comprises 16 of these registers, there is a total of 128
addressable bits. (Bit 0 of byte 20h has bit address 0, while bit 7 of byte 2Fh has bit address 7Fh).

IV.10.3 Third is the group of available registers at addresses 2Fh-7Fh (total of 80 locations)
without special features or a preset purpose.

22
IV.11 EXTRA MEMORY BLOCK

To satisfy the programmers' ever-increasing demands for RAM, latest 8051 models were added an
extra memory block of 128 locations. But it is not all that simple. The problem lies in the
fact that the electronics which addresses RAM employs 1 byte (8 bits), reaching only the
first 256 locations. Therefore, a little trick had to be applied in order to keep the existing
8-bit architecture for the sake of compatibility with older models. The idea is to make
the additional memory block share the addresses with the existent locations intended
for SFR registers (80h - FFh). For distinguishing these two physically separate
memory areas, different methods of addressing are used: if SFR registers are in
question, direct addressing is used; for extra RAM locations, indirect addressing is
used.

23
IV.12 THE PROGRAM STATUS WORD (PSW) SF REGISTER

Figure IV.9

24
IV.13 THE SPECIAL FUNCTION REGISTERS
The 8051 operations that do not use the internal 128-byte Ram addresses from 00h to 7Fh
are done by a group of specific internal register, each called a special function register
(SFR).

NAME FUNCTION INTERNALRAM ADD.


A ACCUMULATOR 0E0
B ARITHMETIC 0F0
DPH ADDRESSING EXTERNAL MEMORY 83
DPL ADDRESSING EXTERNAL MEMORY 82
IE INTERRUPT ENABLE CONTROL 0A8
IP INTERRUPT PRIORITY 0B8
P0 INPUT/OUTPUT PORT LATCH 80
P1 INPUT/OUTPUT PORT LATCH 90
P2 INPUT/OUTPUT PORT LATCH 0A0
P3 INPUT/OUTPUT PORT LATCH 0B0
PCON POWER CONTROL 87
PSW PROGRAM STATUS WORD 0D0
SCON SERIAL PORT CONTROL 98
SBUF SERIAL PORT DATA BUFFER 99
SP STACK POINTER 81
TMOD TIMER/COUNTER MODE CONTROL 89
TCON TIMER/COUNTER MODE CONTROL 88
TL0 TIMER 0 LOW BYTE 8A
TH0 TIMER 0 HIGH BYTE 8C
TL1 TIMER 1 LOW BYTE 8B
TH1 TIMER 0 HIGH BYTE 8D

IV.13.1 TIMER MODE CONTROL REGISTER (TMOD) SFR

[ TIMER1 ][ TIMER0 ]

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


7 6 5 4 3 2 1 0

25
BIT SYMBOL FUNCTION

7/3 GATE OR gate enable bit which controls RUN/STOP of


Timer I/O.

6/2 C/T Set to 1 by program to make timer I/O act as a


counter by counting pulses from external input
pin3.5 (T1) or 3.4(T0).
5/1 M1 Timer/Counter operating mode select bit1. Set
/Cleared by program to select mode.

4/0 M0 Timer/Counter operating mode select bit0


Set/Cleared by program to select mode.

Figure IV.10
TMOD is not bit addressable.
IV.15.1 POWER SUPPLY (+5V)
Power supplies are designed to convert high voltage AC mains electricity to a suitable low voltage
supply for electronics circuits and other devices. A power supply can by broken down into a
series of blocks, each of which performs a particular function.

For example a 5V regulated supply:

Figure IV.17

Each of the block has its own function as described below


1. Transformer – steps down high voltage AC mains to low voltage AC.
2. Rectifier – converts AC to DC, but the DC output is varying.
3. Smoothing – smooths the DC from varying greatly to a small ripple.
4. Regulator – eliminates ripple by setting DC output to a fixed voltage.

IV.15.2 TRANSFORMER
Transformers convert AC electricity from one voltage to another with little loss of power.
Transformers work only with AC and this is one of the reasons why mains electricity is AC.
The two types of transformers
• Step-up transformers increase voltage,
• Step-down transformers reduce voltage.

26
Transformer
Figure IV.18

Most power supplies use a step-down transformer to reduce the dangerously high mains
voltage (230V in UK) 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.

Transformers waste very little power so the power out is (almost) equal to the power in. Note that as
voltage is stepped down current is stepped up. The ratio of the number of turns on each coil, called
the turns ratio, determines the ratio of the voltages. A step-down transformer has a large number of
turns on its primary (input) coil which is connected to the high voltage mains supply, and a small
number of turns on its secondary (output) coil to give a low output voltage.

Turns ratio = Vp = Np
Vs Ns

And Power Out = Power In

Vs × Is = Vp × Ip

Where

Vp = primary (input) voltage


Np = number of turns on primary coil
Ip = primary (input) current
Ns = number of turns on secondary coil

27
Is = secondary (output) current
Vs = secondary (output) voltage
IV.15.3 BRIDGE RECTIFIER
A bridge rectifier can be made using four individual diodes, but it is also available in special
packages containing the four diodes required. It is called a full-wave rectifier because it uses all the
AC wave (both positive and negative sections). 1.4V is used up in the bridge rectifier because each
diode uses 0.7V when conducting and there are always two diodes conducting, as shown in the
diagram below. Bridge rectifiers are rated by the maximum current they can pass and the maximum
reverse voltage

they can withstand (this must be at least three times the supply RMS voltage so
the rectifier can withstand the peak voltages). In this alternate pairs of diodes conduct, changing over
the connections so the alternating directions of AC are converted to the one direction of DC.

OUTPUT – Full-wave Varying DC


Figure IV.19

IV.15.4 SMOOTHING
Smoothing is performed by a large value electrolytic capacitor connected across the DC supply to
act as a reservoir, supplying current to the output when the varying DC voltage from the rectifier
is falling. The diagram shows the unsmoothed varying DC (dotted line) and the smoothed DC (solid
line). The capacitor charges quickly near the peak of the varying DC, and then discharges as it
supplies current to the output.

28
Figure IV.20

Note that smoothing significantly increases the average DC voltage to almost the
peak value (1.4 × RMS value). For example 6V RMS AC is rectified to full wave
DC of about 4.6V RMS (1.4V is lost in the bridge rectifier), with smoothing this increases to
almost the peak value giving 1.4 × 4.6 = 6.4V smooth DC.
Smoothing is not perfect due to the capacitor voltage falling a little as it discharges, giving a small
ripple voltage. For many circuits a ripple which is 10% of the supply voltage is satisfactory and the
equation below gives the required value for the smoothing capacitor. A larger capacitor will give
fewer ripples. The capacitor value must be doubled when smoothing half-wave DC.
Smoothing capacitor for 10% ripple, C = 5 × Io
Vs × f

Where

C = smoothing capacitance in farads (F)


Io = output current from the supply in amps (A)
Vs = supply voltage in volts (V), this is the peak value of the unsmoothed DC
f = frequency of the AC supply in hertz (Hz), 50Hz in the UK

IV.15.5 REGULATOR

Figure IV.21
Voltage regulator ICs are available with fixed (typically 5, 12 and 15V) or variable output voltages.
They are also rated by the maximum current they can pass. Negative voltage regulators are available,

29
mainly for use in dual supplies. Most regulators include some automatic protection from excessive
current (‘overload protection')
and overheating (‘thermal protection'). Many of the fixed voltage regulator ICs has 3 leads and look
like power transistors, such as the 7805 +5V 1A regulator shown on the right. They include a hole for
attaching a heat sink if necessary.

IV.15.6 Working Of Power Supply


• Transformer

Figure IV.22

The low voltage AC output is suitable for lamps, heaters and special AC motors. It is not suitable for
electronic circuits unless they include a rectifier and a smoothing capacitor.

• Transformer + Rectifier

Figure IV.23

The varying DC output is suitable for lamps, heaters and standard motors. It is not suitable for
electronic circuits unless they include a smoothing capacitor.

• Transformer + Rectifier + Smoothing

30
Figure IV.24

The smooth DC output has a small ripple. It is suitable for most electronic circuits.

• Transformer + Rectifier + Smoothing + Regulator

D 1 L M 7 8 0 5
1 N 4 0 0 7 + 5 V
1 2
V I NV O U T

GND
J 1 D 2 1 0 0 0 u f
3
2 g n d C 1
3

1 V
D 3

D 4

Figure IV.25

The regulated DC output is very smooth with no ripple. It is suitable for all electronic circuits.

IV.16 VARIOUS INTERFACINGS


IV.16.1 INTERFACE
(Computer Science) a program that controls a display for the user (usually on a computer monitor)
and that allows the user to interact with the system part of a system exposed to a user. In general, the
system can be any kind of system with which a user may interact at will, such as a mechanical
system or a computer system. (Fluid, Electronic, Optic…) One of the important issues in micro-
fluidics is the interfacing of all the elements. How to align optical fibres? How to connect wires
to the micro-device? How to introduce a sample into the fluid channel? These are some of the
questions, which have to be solved.

31
An interface is a set of commands or menus through which a user Communicates with a
program. A command-driven interface is one in which you enter commands. A menu-driven
interface is one in which you select command choices from various menus displayed on the screen.

IV.16.2 INTERFACING
Interfacing is a common term for a variety of materials used on the unseen or "wrong" side of fabrics
in sewing. Interfacings can be used to stiffen or add body to fabric, such as the interfacing used
in shirt collars; to strengthen a certain area of the fabric, for instance where buttonholes will be
sewn; or to keep fabrics, particularly knit fabrics, from stretching out of shape. Interfacings come
in a variety of weights and stiffnesses to suit different purposes.

IV.16.3 USER INTERFACE


The user interface is the aggregate of means by which people (the users) Interact with a particular
machine, device, computer program or other complex tool (the system). The user interface
provides means of: * Input, allowing the users to controlthe system* & Output, allowing the
system to inform the users (also referred to as feedback). A good user interface makes it easy for
users to do what they want to do. An interface is a set of commands or menus through which a
user communicates with a program. A command-driven interface is one in which you enter
commands. A menu-driven interface is one in which you select command choices from various
menus displayed on the screen. The user interface is one of the most important parts of any program
because it determines how easily you can make the program do what we want to. It is widely
accepted that the user interface can make a critical difference in the perceived utility of a
system regardless of the system's performance.
In other words, the physical means of communication between a person and a software program or
operating system. At its most basic, this is the exchange of typed statements in English or a
program-like set of commands. It is the method by which the human operator communicates with
the various database, system, and applications modules.

• Efficacy of User Interface Design


Many technological innovations rely upon User Interface Design to elevate their technical
complexity to a usable product. Technology alone may not win user acceptance and subsequent
marketability. The User Experience, or how the user experiences the end product, is the key to
acceptance. And at is where User Interface Design enters the design the process. While product
engineers focus on the technology, usability specialists focus on the user interface. For greatest
efficiency and cost effectiveness, this working relationship should be maintained from the start of a
project to its rollout.
When applied to computer software, User Interface Design is also known as Human-Computer
Interaction or HCI. While people often think of Interface Design in terms of computers, it also
refers to many products where the user interacts with controls or displays. Military aircraft,
vehicles, airports, audio equipment, and computer peripherals, are a few products that
extensively apply

32
user interface design.
Optimized User Interface Design requires a systematic approach to the
design process. But, to ensure optimum performance, Usability testing is required. This
empirical testing permits naïve users to provide data about what does work as anticipated and
what does not work. Only after the resulting repairs are made can a product be deemed to
have a user optimized interface. The importance of good User Interface Design can be the
difference between product acceptance and rejection in the marketplace. If end-users feel it is
not easy to learn, not easy to use, or too cumbersome, an otherwise excellent product could fail.
Good User Interface Design can make a product easy to understand and use, which results in
greater user acceptance.

The two user interface units are


1. Display Unit
In display unit we have covered the two devices as under
(i) LED used to detect the presence of any signal.
(ii) Seven Segment Display used to display the numerical for any purpose in any
instruments such as the temperature or time in the microwave etc

2. Input Unit
In input unit, we have used the device SWITCH in two ways as follows
(i) switch in push position
(ii) switch in release position

So after studying about the interfacing and user interface units we were given the first minor
project on “USER INTERFACE”.
IV.16.4 LIGHT-EMITTING DIODE (LED)
The best known of all the photo electronic
devices is the so called LED (Light-emitting diode), which emits a fairly narrow bandwidth of visible
or invisible light when its internal diode junction is stimulated by a forward electric current / voltage
(power). A cross-sectional view of a typically diffused LED is shown.

EMITTED LIGHT

CHARGE CARRIER DIFFUSED


RECOMBINATION P-TYPE
. . . . . . . . . +
VS

EPITAXIAL -
N-TYPE

33
GOLD FILM CATHODE
CONNECTION

LED
Figure IV.26
The semiconductor material used is gallium arsenide (GaAs), gallium arsenide phosphide
(GaAsP), or gallium phosphide (GaP). An N-type epitaxial layer is grown upon a substrate, and
the P-region is produced by diffusion. Recombination of charge carriers occur in the P-region so
this region is required to be kept at the top. Thus, the p-region becomes the device surface. Figure
shows a circuit symbol for a LED. The arrow indicate radiation emitted by the diode.

ANODE CATHODE

SYMBOL
Figure IV.27

• OPERATION
The operation of light-emitting diode (LED) is based on the phenomenon of electro-luminance,
which is the emission of light from a semiconductor under the influence of an electrical field. The
recombination of charge carriers take place in a forward P-N junction as the electrons cross from
the N-region and recombine with holes exiting in the P-region. Typically, these electrons give up
energy in the form of heat and light.

• USE
A LED can be used as an indicator in ac circuit. The LEDs in a seven segment display may be
connected in common anode or in common-cathode configuration, as illustrated.

a
b C O M M O N A N O D E
c
d
e
f
g

COMMON ANODE CONFIGURATION

34
Figure IV.27

a
b
c
d
e
f
C O M M O N g
C A T H O D E

COMMON CATHODE CONFIGURATION


Figure IV.28

• DRAWBACK
The drawback of LEDs is that over-voltage may damage them.

IV.17 7-SEGMENT DISPLAY


A very common requirement in modern electronics is that of displaying alphanumeric
characters; digital watches, pocket calculators and digital instruments are examples of devices
that use such displays. The best known display of this type is the so-called the Seven-Segment
Display. It comprises seven independently-accessible photoelectrical segments arranged in the
form shown.

f b
g

e c
d

STANDARD FORM AND NOTATION


OF A SEVEN SEGMENT DISPLAY
Figure IV.29

35
The segments are conventionally notated from a to g in the as shown and It is possible to make
them display any numeral from 0 to 9 or any alphabetic characters from A to F by activating
these segments in different combinations as illustrated in Truth Table given.

TRUTH TABLE

SEGMENTS (√ =ON) DISPLAYS


a b c d e f g

√ √ √ √ √ √

√ √

√ √ √ √ √

√ √ √ √ √
√ √ √ √

√ √ √ √ √

√ √ √ √ √ √

√ √ √

√ √ √ √ √ √ √

√ √ √ √ √

√ √ √ √ √ √

√ √ √ √ √

√ √ √ √

√ √ √ √ √

√ √ √ √ √ 36
Figure IV.30

IV.18 LIQUID CRYSTAL DISPLAY (LCD)

Liquid crystal displays (LCD) are widely used in recent years as compares to LEDs. This is due to
the declining prices of LCD, the ability to display numbers, characters and graphics, incorporation of
a refreshing controller into the LCD, their by relieving the CPU of the task of refreshing the LCD and
also the ease of programming for characters and graphics. HD 44780 based LCDs are most
commonly used.

IV.18.1 LCD pin description:

The LCD discuss in this section has the most common connector used for the Hitachi 44780 based
LCD is 14 pins in a row and modes of operation and how to program and interface with
microcontroller is describes in this section.

Pin Symbol I/O Description


1 VSS - Ground
2 VCC - +5V power supply
3 VEE - Power supply to control contrast
4 RS I RS=0 to select command register, RS=1 to select data register.
5 R/W I R/W=0 for write, R/W=1 for read
6 E I/O Enable
7 DB0 I/O The 8 bit data bus
8 DB1 I/O The 8 bit data bus
9 DB2 I/O The 8 bit data bus
10 DB3 I/O The 8 bit data bus
11 DB4 I/O The 8 bit data bus
12 DB5 I/O The 8 bit data bus
13 DB6 I/O The 8 bit data bus
14 DB7 I/O The 8 bit data bus
Figure IV.31

37
1 6 G n d
1 6 1 5
1 5 V c c
1 4 D 7
1 4 1 3
1 3 D 6
1 2 D 5
1 2 1 1
1 1 D 4
1 0 D 3
1 0 9
9 D 2
8 D 1
8 7
7 D 0
6 E

3
6 5
5 R / W
4 R S
4 3
3 C o n t r a 2s t
2 V c c
2 1
1 G n d
1

LCD Pin Description Diagram

Figure IV.32

VCC, VSS, VEE


The voltage VCC and VSS provided by +5V and ground respectively while VEE is used for controlling
LCD contrast. Variable voltage between Ground and Vcc is used to specify the contrast (or
"darkness") of the characters on the LCD screen.

• RS (register select)
There are two important registers inside the LCD. The RS pin is used for their selection as follows. If
RS=0, the instruction command code register is selected, then allowing to user to send a command
such as clear display, cursor at home etc.. If RS=1, the data register is selected, allowing the user to
send data to be displayed on the LCD.

• R/W (read/write)
The R/W (read/write) input allowing the user to write information from it. R/W=1, when it read and
R/W=0, when it writing.

• EN (enable)
The enable pin is used by the LCD to latch information presented to its data pins. When data is
supplied to data pins, a high power, a high-to-low pulse must be applied to this pin in order to for the
LCD to latch in the data presented at the data pins.

• D0-D7 (data lines)

38
The 8-bit data pins, D0-D7, are used to send information to the LCD or read the contents of the
LCD’s internal registers. To displays the letters and numbers, we send ASCII codes for the letters A-
Z, a-z, and numbers 0-9 to these pins while making RS =1. There are also command codes that can
be sent to clear the display or force the cursor to the home position or blink the cursor.
We also use RS =0 to check the busy flag bit to see if the LCD is ready to receive the information.
The busy flag is D7 and can be read when R/W =1 and RS =0, as follows: if R/W =1 and RS =0,
when D7 =1(busy flag =1), the LCD is busy taking care of internal operations and will not accept any
information. When D7 =0, the LCD is ready to receive new information.

IV.18.2 INTERFACING OF MICRO CONTROLLER WITH LCD DISPLAY:

The LCD, which is used as a display in the system, is LMB162A. The main features of this LCD are:
16*2 display, intelligent LCD, used for alphanumeric characters & based on ASCII codes. This LCD
contains 16 pins, in which 8 pins are used as 8-bit data I/O, which are extended ASCII. Three pins
are used as control lines these are Read/Write pin, Enable pin and Register select pin. Two pins are
used for Backlight and LCD voltage, another two pins are for Backlight & LCD ground and one pin
is used for contrast change.
In most applications, the "R/W" line is grounded. This simplifies the application because when data
is read back, the microcontroller I/O pins have to be alternated between input and output modes.

In this case, "R/W" to ground and just wait the maximum amount of time for each instruction (4.1ms
for clearing the display or moving the cursor/display to the "home position", 160µs for all other
commands) and also the application software is simpler,
it also frees up a microcontroller pin for other uses. Different LCD execute instructions at different
rates and to avoid problems later on (such as if the LCD is changed to a slower unit). Before sending
commands or data to the LCD module, the Module must be initialized. Once the initialization is
complete, the LCD can be written to with data or instructions as required. Each character to display is
written like the control bytes, except that the "RS" line is set. During initialization, by setting
the "S/C" bit during the "Move Cursor/Shift Display" command, after each character is sent to the
LCD, the cursor built into the LCD will increment to the next position (either right or left). Normally,
the "S/C" bit is set (equal to "1")

39
VCC VCC

31
EA/VPP 33pF 22uF
30 9
ALE/PROG RST 18 33pF
29 XTAL2 19

8.2 K
PSEN XTAL1 16
16
AT89C51

17 8 15
VCC 15
16 P3.7/RD P1.7 7 14
P3.6/WR P1.6 13 14
15 6 13
14 P3.5/T1 P1.5 5 12
P3.4/TO P1.4 11 12
13 4 11
12 P3.3/INT1 P1.3 3 10
9
P3.2/INTO P1.2 10
9
11 2 8
10 P3.1/TXD P1.1 1 7 8
P3.0/RXD P1.0 6 7
28 32 5 6
27 P2.7/A15 P0.7/AD7 33 4 5
26 P2.6/A14 P0.6/AD6 34 3 4
25 P2.5/A13 P0.5/AD5 35 2 3
24 P2.4/A12 P0.4/AD4 36 1 2
23 P2.3/A11 P0.3/AD3 37 1
22 P2.2/A10 P0.2/AD2 38
21 P2.1/A9 P0.1/AD1 39
P2.0/A8 P0.0/AD0

3 1

VCC

VCC

Interfacing of Microcontroller with LCD


Figure IV.33

Code Command to LCD Instruction


IV.18.3 LCD Command
Code (HEX) Register
1 Clear the display screen
2 Return home
4 Decrement cursor(shift cursor to left)
6 Increment cursor(shift cursor to right)
7 Shift display right
8 Shift display left
9 Display off, cursor off
A Display off, cursor on
C Display on, cursor off
E Display on, cursor blinking
F Display on, cursor blinking
10 Shift cursor position to left
14 Shift cursor position to right
18 Shift the entire display to left
1C Shift the entire display to right
80 Force cursor to the beginning of 1st line
C0 Force cursor to the beginning of 2nd line 40
38 2 line and 5×7 matrix
Figure IV.34

IV.19 STEPPER MOTOR:

A stepper motor is a widely used devicethat translates electrical pulses into mechanical movement. In
applications such as disk drives, dot matrix printers, and robotics the stepper motor is used for
positioning control. Every stepper motor has a permanent magnet rotor(also called the shaft)
surrounded by a stator. The most common stepper motors have 4 stator windings that are paired with
a centre-tapped common. This type of stepper motor is commonly referred to as four phased stepper
motor. The centre tap allows a change of current directionin each of two coils when a winding is
grounded, thereby resulting in a polarity changeof the stator. Notice that a conventional motor shaft
runs freely, the stepper motor shaft moves in a fixed repeatable incrementwhich allows one to move
it to a precise position. This repeatable fixed movement is possible as a result of basic magnetic
theorywhere poles of the same polarity repel and opposite poles attract. The direction of rotation is
directed by the stator poles. The stator poles are determined by the current sent through the wire
coils. As the direction of the current is changed, the polarity is also changedcausing the reverse
motion of the rotor.The stepper motor discussed here has a total of 6 leads.As the sequense of power
is applied to each stator winding the rotor will rotate.

41
IV.19.1 VARIOUS TERMS OF STEPPER MOTOR STEP ANGLE

How much movement is associated with a single step, this depends on the internal construction of the
motor, in particular the number of teeth on the stator and the rotor. The step angle is the minimum
degree of rotation associated with a single step. Various motors has different step angles.

• STEPS PER REVOLUTION


These are the total number of steps needed to make one complete revolution or 360 degree.

• STEPS PER SECOND AND RPM RELATION


The relation between RPM(revolutions per minute), steps per revolution, and
steps per second is intuitive and is as follows:

Steps per second = RPM * Steps per revolution


-------------------------------------------------
60

Various Hardware Tools used are:


• Soldering Iron
• Soldering Wire
• Ribbon wire
• Flux
• Cutter
• Tin wire
• De-soldering pump
• Multimeter
• IC Programmer
• PC
Software Tools used are:
• Keil compiler
• Sunrom’s software to Program the Microcontroller (AT89s52)

42
• Embedded C Language

Basic Tutorials for Keil Software:


1. Open Keil from the Start menu
2. The Figure below shows the basic names of the windows referred in this document

Starting a new Assembler Project

1. Select New Project from the Project Menu.

43
2. Name the project ‘amrit.a51’
3. Click on the Save Button.

4. The device window will be displayed.


5. Select the part you will be using to test with. For now we will use the Atmel
Semiconductor part AT89C51.
6. Double Click on the ATMEL.

44
7. Scroll down and select the AT89C51 Part
8. Click OK

45
Creating Source File

o Click File Menu and select New.

o A new window will open up in the Keil IDE.

46
o write any code on this file.

o Click on File menu and select Save as…

47
5. Name the file with extension (.asm for assembly language code & .c for embedded
C language code).
6. Click the Save Button

Adding File to the Project


1. Expand Target 1 in the Tree Menu

48
2. Click on Project and select Targets, Groups, Files…

49
3. Click on Groups/Add Files tab
4. Under Available Groups select Source Group 1
5. Click Add Files to Group… button

50
6. Change file type to Asm Source file(*.a*; *.src)
7. Click on toggle.a51
8. Click Add button
9. Click Close Button
10. Click OK button when you return to Target, Groups, Files… dialog box.

51
11. Expand the Source Group 1 in the Tree menu to ensure that the file was added to
the project.

Creating HEX for the Part

1.Click on Target 1 in Tree menu


2. Click on Project Menu and select Options for Target 1

52
3. Select Target Tab
4. Change Xtal (Mhz) from 50.0 to 11.0592

53
5. Select Output Tab
6. Click on Create Hex File check box
7. Click OK Button

8. Click on Project Menu and select Rebuild all Target Files


9. In the Build Window it should report ‘0 Errors (s), 0 Warnings’
10. You are now ready to Program your Part

54
55

You might also like