Sei sulla pagina 1di 56

TRAINING REPORT

A report submitted in partial fulfillment of the requirement for the award of

Bachelor of technology

In

Electronics and communication engineering

Under the guidance of: Submitted By:


Er. Vikram Singh Choudhary Amit Mahajan (74544)

Page 1
ACKNOWLEDGEMENT

The completion of any report brings with it a sense of satisfaction, but it is never
complete without thanking those people who made it possible and whose constant support has
crowned our efforts with success. One cannot even imagine the power of the force that guides us
all and neither can we succeed without acknowledging it. My deepest gratitude to Almighty God
for holding my hands and guiding me throughout my life.

I am thankful to Er. Rahul Sharma for his expert guidance, encouragement and valuable
suggestions. I would like to express my gratitude to Er. Vikram Singh Choudhary, my guide, for
his lectures on embedded systems which constantly inspired me towards the attainment of
everlasting knowledge throughout the training. I am thankful to the Head of Advance
Technologies Major Pratap Singh, without his incredible support and steady involvement; the
report would not have been fruitful. I would also like to thank research scholar Ms Sherry Sethi
for explaining me various concepts of electronic components. I would like to thank all the staff
members of Advance Technologies for providing me with the required facilities and support. I
am extremely happy to acknowledge and express my sincere gratitude to my parents for their
constant support and encouragement and last but not the least, friends and well wishers for their
help and cooperation and solutions to problems during the course of the training.

Amit Mahajan

Page 2
COMPANY PROFILE

Advance Technologies is a well-established organization & is a leading


manufacturer of Electronics Educational Equipments for Engineering. It is a company
which deals in both education and agriculture business. In education it deals with all
kinds of Embedded, wireless, microcontroller, VLSI and DSP instruments. In agriculture
it deals in moisture meters, seed counters, Grain Examiners.

Incepted in the year 2006, Advance Technologies was established with an


objective to be recognized as one of India's Leading Manufacturers of Electronics
Educational Equipment. The combination of cutting edge technology and pro-active
client services has helped them to meet the exacting requirements of their clients and the
industry standards. Their Experience with a wide variety of Industry Groups allows them
to continually offer proven technologies creatively to meet unique challenges. The Goal
of the company is to design and manufacture quality equipments that consistently meet
their customer's requirements and needs. Advance Technologies delivers Best Quality at
Best Prices. They believe in Quality & Service. They exercise total control over the
Production and Quality of their range of products and ensure best service and value for
their customer’s investment at every stage. They have a team of experts, which maintains
supervision during the manufacturing process. The products are inspected with proper
documentation. All the scientific testing equipments have inspection reports and test
certificates to avoid any defects. They are into the business of Manufacturing, Supply &
Maintenance of the Electronic Educational Products of the following fields:

1. Embedded System.
2. VLSI Technology.
3. Wireless Technology.

MANUFACTURED PRODUCTS

Page 3
1. 8051 microcontroller development board
2. AVR microcontroller development board
3. PIC microcontroller development board
4. Embedded Universal microcontroller development board
5. ARM microcontroller development board
6. Cygnal microcontroller development board
7. FPGA/CPLD Universal microcontroller development board
8. FPGA microcontroller development board
9. CPLD microcontroller development board
10. RFID microcontroller development board
11. Embedded Bluetooth microcontroller development board
12. Embedded GSM microcontroller development board
13. GPS microcontroller development board
14. Radio Frequency application board.
15. WiFi microcontroller development board.
16. ZigBee microcontroller development board.
17. Finger Print authentication microcontroller development board.
18. Moisture meters.
19. Seed Counter.
20. Grain Examiner.

Currently they have many clients in North India (Punjab, Haryana, Himachal Pradesh,
J&K and Uttrakhand).

CONTENTS

Page 4
Section-1 Introduction to Embedded systems

1.1. Definition.

1.2. Features of Embedded systems

1.3. Characteristics of Embedded systems.

1.4. Developing Embedded System.

1.5. Advantages and Disadvantages.

1.6. Applications.

Section-2 The 8051 Microcontroller

2.1. Introduction.

2.2. Overview of 89c51 Microcontroller.

2.3. Timers and Counters.

2.4. Criteria for choosing 89c51 Microcontroller.

Section-3 Trainer Kit

3.1. Introduction.

3.2 Features of Trainer kit

3.3 Block Diagram of Trainer kit.

3.3.1. Circuit Diagram.

3.4 Applications

3.4.1 Trainer kit

3.4.2 Digital Clock

3.4.3 Temperature Monitoring System

3.4.4 Wave Generation

3.4.5 Serial Communication

3.4.6 Prospective

Page 5
Section-4 Light emitting diode

4.1. Introduction.

4.2. Advantages of LEDs.

4.2.1 Shapes and Sizes.

4.2.2 Colors.

4.2.3 Current Consumption.

4.2.4 Long Life.

4.3. Hardware Connections.

4.4. Program to Blink LED’s Clockwise.

Section-5 Keyboard Interfacing

5.1. Introduction.

5.2. Keyboard Configurations.

5.3. Scanning and Identifying Key press.

5.4. Hardware Criteria.

5.4.1 To detect matrix keyboard using 4 LED’s

Section-6 Interfacing of Seven-segment Display

6.1. Introduction.

6.2 Schematic Diagram

6.3 Seven segment Display Layout

6.4 Hardware Criteria.

6.5 Program to display from 0-9 on one seven segment.

Section-7 Interfacing Of EEPROM

Page 6
7.1. Introduction.

7.1.1 Features

7.2. Pin description

7.3. Operating modes

7.4. Device operation based on I2C protocol.

7.5 Hardware Criteria.

Section-8 Liquid crystal Display Interfacing

8.1 LCD Features.

8.2 LCD Pin Descriptions.

8.3 Connection OF LCD with 8255.

Section-9 Real time clock

9.1. Introduction.

9.2. Features of DS1307 RTC chip.

9.3. Pin Descriptions.

9.4. Operation based on I2c protocol.

9.5. Data transfer on two –wire serial bus

9.6. Hardware Criteria.

Section-10 Timer operation using 555 IC

10.1. Introduction.

10.2. Pin description.

Section 11- Troubleshooting and testing

Page 7
11.1 Testing Trainer kit

11.2 Trouble shooting trainer kit

Section 12- Conclusion

Section 13- References

Page 8
CHAPTER 1
INTRODUCTION TO EMBEDDED SYSTEMS

1.1 DEFINITION
Embedded system is in almost every electronic device that are designed today. There is software
hidden away inside our watches, microwaves, VCRs, cellular Telephones, and pagers; the
military uses embedded software to guide smart Missiles and detect enemy aircraft;
communications satellites, space probes, and Modern medicine would be nearly impossible
without it. Of course, someone has to write all that software, and there are thousands of computer
scientists, embedded Engineers and other professionals who actually do. Microprocessors and
Microcontrollers are widely used in such embedded system products. Embedded systems are
extremely important branch of modern digital Technology. Each embedded system is unique and
highly customized to the application at hand. In General, Embedded system can be defined as a
system that has software embedded into hardware. As a result, embedded systems programming
is a widely varying field that can take years to master. The main basics that includes in
embedded programming are either Assembly programming or it may be high-level Languages
such as C, C++ or JAVA. Basically embedded systems are the part of a large system but it need
not be a computer.
An embedded system is a special-purpose computer controlled electro-mechanical system
in which the computer is completely encapsulated by the device it controls. An embedded system
has specific requirements and performs pre-defined tasks, unlike a general-purpose personal
computer. An embedded system is a computer controlled system. The core of any embedded
system is a microprocessor/microcontroller, programmed to perform a few tasks (often just one
Task) . This is to be compared to other computer systems with general purpose hardware and
externally loaded software. Embedded systems are often designed for mass production.

1.2 Features of Embedded Systems

There are certain key features of embedded systems that differentiate them from other systems in
the world. They have been discussed below:

1. Software: The software used by embedded systems is called firmware and is stored in
Read Only Memory or ROM or a Flash memory chip. Such software is efficient enough
to work with the limited amount of hardware resources available. Typically, such
software does not use a keyboard or if it does, it is small. There is very little RAM
provided to such software.

2. User interfaces: There are various types of user interfaces used in embedded systems.
Some systems do not have any user interface at all. Devices such as PDAs provide
interactive and complete user interfaces. Other devices, such as budget mobile phones
have small screens that display only two colors and provide very limited (but enough)
functionality. Some other systems have character-only screens such as that in digital
railway timetables at stations.

Page 9
3. CPU Platform: Embedded systems use various CPU platforms or architectures that
include ARM, X86, PowerPC, and PIC etc. embedded systems tend to use specifically
purchased CPUs that are added to the embedded system which itself is put on a chip, that
is, an integrated circuit (IC) specially designed for it.

4. Tools: Embedded system designers use software ranging from compilers and assemblers
to debuggers and emulators to develop software for embedded systems. These are usually
scaled-down versions of their full software versions.

5. Start-up: Embedded systems the world over begin with what is called the start-up
process. At this point, a self-test is conducted by the system where the hardware,
peripherals, power supply etc. are tested for being in good condition. These tests are
usually very short (usually, no more than 10 seconds) and determine the health of the
system overall.

1.3 Characteristics of Embedded system

Application specific- System designed for a given application is known a prior before the system
Design begins and system flexibility is important for upgrades, design reuse which are usually
achieved through reprogramming. Digital signal processing in ES Signals are represented as
digitally as sequence samples. DSP processing occurs in system like averaging, filtering, device
controls, encoding, decoding etc. Reactivity in Embedded System- Having increasingly higher
performance with constraints which are important part of system functionality in building
embedded computing system. Real-time application of embedded system- A real time system
consists of tasks under deadline constraints. It consist of two types- Hard real-time and Soft real-
time. Hard Real time systems- In these systems the task must complete by specified Deadlines
e.g. - flight control. Soft Real time systems- in these system task executions may go beyond
specific deadlines e.g. – connection establishment, updates etc. Power, cost & reliability are
often important attributes that influence design of embedded systems.

1.4 Developing Embedded System


Developing software and hardware for microcontroller based embedded systems involves the use
of a range of tools that can include editors, assemblers, compilers, debuggers, simulators,
emulators and Flash/OTP programmers. To the newcomer to microcontroller development it is
often not clear how all of these different components play together in the development cycle and
what differences there are for example between Trainer kits, emulators and simulator. Figure
shows a typical microcontroller software development cycle with some of the software and
hardware components involved. The basic operations that are involved in above microcontroller
development cycle are:
1. Writing Microcontroller Code.
2. Translating the Code.
3. Debugging the code.

Page 10
1. Writing microcontroller code: Software Code for a microcontroller is written in a
programming language of choice (often Assembler or C). This source code is written with a
standard ASCII text editor and saved as an ASCII text file. Programming in assembler involves
learning a microcontroller's specific instruction set (assembler mnemonics), but results in the
most compact and fastest code. A higher level language like C is for the most part independent of
a microcontroller's specific architecture, but still requires some controller specific extensions of
the standard language to be able to control all of a chip's peripherals and functionality. The
penalty for more portable code and faster program development is a larger code size (20%...40%
compared to assembler).

2. Translating the code: Next the source code needs to be translated into instructions the
microcontroller can actually execute. A microcontroller’s instruction set is represented by "op
codes". Op codes are a unique sequence of bits ("0" and "1") that are decoded by the controller's
instruction decode logic and then executed. Instead of writing opcodes in bits, they are
commonly represented as hexadecimal numbers, whereby one hex number represents 4 bits
within a byte, so it takes two hex numbers to represent 8 bits or 1 byte. For that reason a

Page 11
microcontroller's firmware in machine readable form is also called Hex-Code and the file that
stores that code Hex-File. Assemblers, Compilers, Linkers and Librarians Assemblers or (C-)
Compilers translate the human readable source code into "hex code" that represents the machine
instructions (op codes). To support modular code and reusable libraries of code, most assemblers
and compilers today come with Linkers and Librarians. Linkers, link code modules saved in
different files together into a single final program. At the same time they take care of a chip's
memory allocation by assigning each instruction to a microcontroller memory addresses in such
a way that different modules do not overlap. Librarians help you to manage, organize and
revision control a library of reusable code modules. Once the ASCII source code text file has
been assembled (with an Assembler) or compiled (with a Compiler) and the files have been
linked (with the Linker), the output results in a number of files that can be used for debugging
the software and programming the actual microcontroller's memory.

3. Debugging the Code: A debugger is a piece of software running on the PC, which has to be
tightly integrated with the emulator that you use to validate your code. For that reason all
emulator manufacturers ship their own debugger software with their tools, but also compiler
manufacturers frequently include debuggers, which work with certain emulators, into their
development suites. A Debugger allows you to download your code to the emulator's memory
and then control all of the functions of the emulator from a PC. Common debugging features
Include the capability to examine and modify the microcontroller's on-chip registers, data- and
program-memory; pausing or stopping program executing at defined program locations by
setting breakpoints; single-stepping (execute one instruction at a time) through the code; and
looking at a history of executed code (trace). So far we've talked about several different pieces of
software: Text Editor, Assembler or Compiler, Linkers, Librarians and Debugger. You can easily
imagine that it can become quite a time-consuming challenge to alternate back and forth between
all of these programs during the debugging process (discover a bug, edit the source code,
compile it again, link it again, download the modified code to the emulator, etc.). This is where
an integrated development environment (IDE) comes in. An Integrated Development
Environment puts all of the previously discussed software components under one common
unified user interface, so that it becomes possible to make a code change and get the modified
code loaded into the emulator with a few mouse clicks, instead of dozens. A good IDE allows
you for example to click on a syntax error message produced by the compiler and have the
source code with the highlighted offending instruction pop up for editing in the text editor. One
click of a button and the modified code gets retranslated, linked and downloaded to the emulator.
An IDE allows you to store the configuration settings for a project - like compiler switches, or
what flavor of chip to emulate - so you can easily recreate a project later on. Some IDEs are
flexible enough to allow you to incorporate different choices of third party tools (like compilers
and debuggers), others only work with a manufacturer's own tool chain.

Debugging Tools: When it comes to debugging your code and testing your application there are
several different tools you can utilize that differ greatly in terms of development time spend and
debugging features available. In this section we take a look at simulators. Simulators try to
model the behavior of the complete microcontroller in software. Some simulators go even a step
further and include the whole system (simulation of peripherals outside of the microcontroller).
No matter how fast you’re PC, there is no simulator on the market that can actually simulate a
microcontroller's behavior in real-time. Simulating external events can become a time-
consuming exercise, as you have to manually create "stimulus" files that tell the simulator what
external waveforms to expect on which microcontroller pin. A simulator can also not talk to your

Page 12
target system, so functions that rely on external components are difficult to verify. For that
reason simulators are best suited to test algorithms that run completely within the microcontroller
(like a math routine for example). They are the perfect tool to complement expensive emulators
for large development teams, where buying an emulator for each developer is financially not
feasible. For our case we have used a simulator called “TOPVIEW”. Figure shows you the
procedure that is involved in loading a program into the Targeted hardware system that is
designed on basis of embedded technology.

1.5 ADVANTAGES & DISADVANTAGES

Advantages:

1. One of the advantages of an embedded system is to decrease power consumption and space.
2. All embedded systems that are based on microcontroller have low power consumption in
addition to some form of I/O, COM port and ROM all on a single chip.

Disadvantages:

1. Higher Hardware/Software development overhead.


2. Design, compilers, debuggers may result in delayed time to market.

1.6 APPLICATIONS

1. Consumer electronics- e.g., cameras, camcorders etc.


2. Consumer products, e.g., washers, microwave ovens.
3. Automobiles (anti-lock braking, engine control).
4. Industrial process controllers & avionics/defense applications
5. Computer/Communication products, e.g., printers, FAX machines.
6. Emerging multimedia applications & consumer electronics e.g., cellular phones, personal
digital assistants, videoconferencing servers, interactive game boxes, TV set-top boxes.

1.7 Training report layout:

The report is divided into following five chapters:

Chapter 1: It presents an introduction to embedded systems.

Chapter 2: It gives a detail of the 8051 microcontroller.

Page 13
Chapter 3: It presents Microcontroller development board.

Chapter4-10: These chapters deals with LED, switches, keyboard, relay, LCD,
EEPROM, RTC, Buzzer, 555 timer interfacing to 8051.

Chapter 11: This chapter deals with troubleshooting of the trainer kit.

CHAPTER 2
THE 8051 MICROCONTROLLER
2.1 INTRODUCTION

This section begins with a discussion of the role and importance of Microcontroller in
everyday life. Microcontrollers are not well known to the general public, or too many in the
technical community, as are the glamorous microprocessor. However we are very well aware
that “something” is responsible for all of the smart VCRs, clock radios, video games,

Page 14
Telephones, TVs, automobiles, Mobile phones, camcorder, security systems, instrumentation,
printers and a myriad of other articles that are intelligent and “programmable”. These all things
are due to a smart “Microcontroller”. Microcontrollers are widely used devices in embedded
system. An embedded system product using Microcontroller has one and only one task. In such
systems there is only one application software that is typically burned into ROM. One Such
system is our 89c51 Microcontroller based Trainer kit in which controller is its heart. For our
trainer Kit, we have chosen 89c51 microcontroller which is an 8-bit microcontroller from the
family of 8051 controllers.

2.2 OVERVIEW OF 89c51 MICROCONTROLLER

89c51 is introduced by Intel corporation is an 8-bit microcontroller. This microcontroller


has 128 bytes of RAM, 4K of on-chip ROM, two timers, one serial port, and four ports of 8-bits
each all on a single chip. 89c51 is basically Flash ROM version of 8051 family. 89c51 is
basically a 40 pin Dual-in-package. Block Diagram of 89c51 is as shown in figure, which shows
the microcontroller Hardware. The main features of 89c51 Hardware can be labeled as below:

1. It has 8-bit CPU with registers A (the accumulator) and B.


2. Sixteen-bit program counter (PC) and data pointer (DPTR).
3. Eight-bit program status word (PSW).
4. Eight-bit stack pointer (SP).
5. Internal ROM of 0 to 4K.
6. Internal RAM of 128 bytes.
7. 32 I/0 pins arranged as four 8-bit ports: P0-P3
8. Two 16-bit Timer/Counters: T0 and T1
9. Full duplex serial data receiver/transmitter: SBUF
10. Control registers: TCON, TMOD, SCON, PCON, IP, and IE.
11. Two external and three internal interrupt sources.
12. Oscillator and Clock circuits.

A pin out of the 89c51 packaged in a 40 pin DIP is as shown in figure:

Pin descriptions:
1. VSS (pin-20)
Ground= 0 V reference.

2. VCC (pin-40)
This is the power supply voltage for normal, idle and power-down modes.

3. P.0-P0.7 (pin-39 to pin 32 i.e., port 0)


Port 0 is an open-drain, bidirectional I/O port. Pins of Port 0 on which there is a high
logic will float and can be used as a high impedance inputs. Port 0 is also the multiplexed low-

Page 15
order address and data bus during accesses to external program and data memory; In this
application it uses strong internal pull-ups for emitting 1’s.

4. P1.0-P1.7 (pin-1 to pin 8 i.e., port 1)


Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. Port 1 pins that have 1s
written to them are pulled high by the internal pull-ups and can be used as inputs. As inputs, port
1 pins that are externally pulled low will source current because of the internal pull-ups.

5. P2.0-p2.7 (pin-21 to pin-28 i.e., port 2)


Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. Port 2 pins that have 1s
written to them 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 because of the internal pull-ups.
Port 2 emits the high-order address byte during fetches from external program memory and
during accesses to external data memory that uses 16-bit addresses (MOVX @DPTR). In this
application, it uses strong internal pull-ups when emitting 1s. During accesses to external
Data memory that use 8-bit addresses (MOV @Ri), port 2 emits the contents of the P2 special
function register.

6. P3.0-p3.7 (pin-10 to pin-17 i.e., port 3)


Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. Port 3 pins that have 1s
written to them 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 also
serves the special features of the 89C51, as listed below:
RxD (P3.0): Serial input port.
TxD (P3.1): Serial output port.
INT0 (P3.2): External interrupt.
INT1 (P3.3): External interrupt.
T0 (P3.4): Timer 0 external input.
T1 (P3.5): Timer 1 external input.
WR (P3.6): External data memory write strobe.
RD (P3.7): External data memory read strobe.

7. RESET (pin-9)
A high on this pin for two machine cycles while the oscillator is running resets the
device. An internal diffused resistor to VSS permits a power-on reset using only an external
capacitor to VCC

8. ALE (pin-30)
Output pulse for latching the low byte of the address during an Access to external
memory. In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator frequency,
and can be used for external timing or clocking. Note that one ALE pulse is skipped during each
access to external data memory. ALE can be disabled by setting SFR auxiliary.0. With this bit
set, ALE will be active only during a MOVX instruction.

Page 16
9. PSEN (pin-29)
The read strobe to external program memory. When executing code from the external
program memory, PSEN is activated twice each machine cycle, except that two PSEN
activations are skipped during each access to external data memory. PSEN is not activated
during fetches from internal program memory.

10. EA/VPP (pin-31)


EA must be externally held low to enable the device to fetch code from external program
memory locations 0000H to the maximum internal memory boundary. If EA is held high, the
device executes from internal program memory unless the program counter contains an address
greater than 0FFFH for 4 k devices, 1FFFH for 8 k devices, 3FFFH for 16 k devices, and 7FFFH
for 32 k devices. The value on the EA pin is latched when RST is released and any subsequent
changes have no effect. This pin also receives the 5V/12V programming supply voltage (VPP)
during FLASH programming.

11. XTAL1 and XTAL2 (pin-18 and pin-19)


Crystal 1: Input to the inverting oscillator amplifier and input to the internal clock
generator circuits.
Crystal 2: Output from the inverting oscillator amplifier.

OSCILLATOR CHARACTERISTICS:
XTAL1 and XTAL2 are the input and output, respectively, of an Inverting amplifier. The pins
can be configured for use a an On-chip oscillator. To drive the device from an external clock
source, XTAL1 should be driven while XTAL2 is left unconnected. There are no requirements
on the duty cycle of the external clock signal, because the input to the internal clock circuitry is
through a divide-by two flip-flop. However, minimum and maximum high and low times
specified in the data sheet must be observed.

RESET:
A reset is accomplished by holding the RST pin high for at least two machine cycles (24
oscillator periods), while the oscillator is running. To insure a good power-on reset, the RST pin
must be high long enough to allow the oscillator time to start up (normally a few milliseconds)
plus two machine cycles. At power-on, the voltage on VCC and RST must come up at the same
time for a proper start-up. Ports 1, 2, and 3 will asynchronously be driven to their reset condition
when a voltage above VIH1 (min.) is applied to RST. The value on the EA pin is latched when
RST is disserted and has no further effect.

Accumulator:
The A (Accumulator) is the versatile of the two CPU registers and is used for many operations,
including addition, subtraction, division, integer multiplication and Boolean bit manipulations.
The A register is also used for data transfers between the 8051 and any external memory.

B Register:
The B register is used during multiply and divide operations. For other instructions it can be
treated as another scratch pad register.

Page 17
Program Status Word:
The PSW register contains program status information as detailed in Table below: The PSW
consists of math flags, user program flag F0, and the register bank select bits that identify which
of the four general register banks is currently in use by the program.

Stack Pointer:
The Stack Pointer register is 8 bits wide. It is incremented before data is stored during PUSH and
CALL executions. While the stack may reside anywhere in on-chip RAM, the Stack Pointer is
initialized to 07H after a reset. This causes the stack to begin at locations 08H.

Data Pointer:
The Data Pointer (DPTR) consists of a high byte (DPH) and a low byte (DPL). Its intended
function is to hold a 16-bit address. It may be manipulated as a 16-bit register or as two
independent 8-bit registers.

Serial Data Buffer:


The Serial Buffer is actually two separate registers, a transmit buffer and a receive buffer. When
data is moved to SBUF, it goes to the transmit buffer and is held for serial transmission. (Moving
A byte to SBUF is what initiates the transmission.) When data is moved from SBUF, it comes
from the receive buffer.

Timer Registers:
Register pairs (TH0, TL0), and (TH1, TL1) are the 16-bit Counting registers for Timer/Counters
0 and 1, respectively.

Control Register:
Special Function Registers IP, IE, TMOD, TCON, SCON, and PCON contain control and status
bits for the interrupt system, the Timer/Counters, and the serial port. They are described in later
sections.

2.3 TIMERS AND COUNTERS:

Timer 0 and Timer 1:


The “Timer” or “Counter” function is selected by control bits C/T in the Special Function
Register TMOD. These two Timer/Counters have four operating modes, which are selected by
bit-pairs (M1, M0). In TMOD. Modes 0, 1, and 2 are the same for both Timers/Counters. Mode
3 is different. The four operating modes are described in the following text:

Mode 0:
Timer, which is an 8-bit Counter with a divide-by-32 pre scalar. Figure shows the Mode 0
operation as it applies to Timer 1. In this mode, the Timer register is configured as a 13-bit
register. As the count rolls over from all 1s to all 0s, it sets the Timer interrupt flag TF1. The
counted input is enabled to the Timer when TR1 = 1 and either GATE = 0 or INT1 = 1. (Setting
GATE = 1 allows the Timer to be controlled by Putting either Timer into Mode 0 makes it look
like an 8048 external input INT1, to facilitate pulse width measurements). TR1 is a control bit in

Page 18
the Special Function Register TCON (Figure 3). GATE is in TMOD. The 13-bit register consists
of all 8 bits of TH1 and the lower 5 bits of TL1. The upper 3 bits of TL1 are indeterminate and
should be ignored. Setting the run flag (TR1) does not clear the registers. Mode 0 operation is the
same for the Timer 0 as for Timer 1. Substitute TR0, TF0, and INT0 for the corresponding Timer
1 signals in Figure 2. There are two different GATE bits, one for Timer 1 (TMOD.7)
And one for Timer 0 (TMOD.3).

Mode 1: Mode 1 is the same as Mode 0, except that the Timer register is being run with all 16
bits.

Mode 2: Mode 2 configures the Timer register as an 8-bit Counter (TL1) with automatic reload,
as shown in Figure 4. Overflow from TL1 not only sets TF1, but also reloads TL1 with the
contents of TH1, which is preset by software. The reload leaves TH1 unchanged. Mode 2
operation is the same for Timer/Counter 0.

Mode 3: Timer 1 in Mode 3 simply holds its count. The effect is the same as setting TR1 = 0.
Timer 0 in Mode 3 establishes TL0 and TH0 as two separate counters. The logic for Mode 3 on
Timer 0 is shown in Figure 5. TL0 uses the Timer 0 control bits: C/T, GATE, TR0, and TF0, as
well as the INT0 pin. TH0 is locked into a timer function (counting machine cycles) and takes
over the use of TR1 and TF1 from Timer 1. Thus, TH0 now controls the “Timer 1” interrupt.
Mode 3 is provided for applications requiring an extra 8-bit timer on the counter. With Timer 0
in Mode 3, an 80C51 can look like it has three Timer/Counters. When Timer 0 is in Mode 3,
Timer 1 can be turned on and off by switching it out of and into its own Mode 3, or can still be
used by the serial port as a baud rate generator, or in fact, in any application not requiring an
interrupt. TCON and TMOD are the two registers used for setting the above modes. The format
of these registers are as shown in figure: TMOD is dedicated solely to the timers and can be
considered to be two duplicate 4-bit registers, each of which controls the action of one of the
timers. TCON has
Control bits and flags for the timers in the upper nibble, and control bits and flags for the
external interrupts in the lower nibble. Figure shows the bit assignments for TMOD and TCON.

2.4 CRITERIA FOR CHOOSING 89c51 MICROCONTROLLER

1. The first and foremost criterion in choosing a microcontroller is that it must meet the task
at hand efficiently and cost effectively. In our project we have chosen an 8-bit
microcontroller which can handle the computing needs of the task most effectively.

2. The highest speed this microcontroller can support is 12MHZ.

3. To fulfill our requirements in terms of space, assembling, we have chosen the 40-pin
DIP.

4. To support the memory requirement we have chosen it as it includes 4K ROM and


128byte RAM.

5. As there are 32 I/O pins and 2 timers, it supports our input-output requirement Greatly.

Page 19
6. We have used the battery power product like an RTC the power consumption is Critical
for it.

7. In choosing this controller we have considered the availability of an assembler,


debugger, simulator etc.

8. The ready availability in needed quantities both now and in the future. Currently, of the
leading 8-bit microcontrollers, the 8051 family has the largest number of diversified
suppliers.

Page 20
CHAPTER 3
TRAINER KIT OVERVIEW
3.1. INTRODUCTION

The trainer kit is a microcontroller based embedded system through which students can
understand different types of interfacings such as LEDs, 7-segment,switches,relays,buzzers,
keyboard, ADC, DAC, Sensors, EEPROM, RTC, LCD, 8255 etc. using these kit one can easily
understands the hardware and software details of above mentioned devices. We have use all
fundamental devices, knowledge of them enable the user to easily switch on to other complex
and advance technology. Our project also includes some industrial applications like ‘Digital
Clock’, ‘Temperature Monitoring System’, ‘Communication System’ etc. The simple design of
our project can be easily extended into other application such as Access Control system, Digital
Function Generator, Temperature monitoring and controlling kit, General purpose sensor kit,
Graphical LCD Display etc.

3.2. FEATURES OF TRAINER KIT


Following are some feature which makes our Trainer Kit unique.

1. Simple Design:

We have designed our Trainer Kit in such a manner that all its modules works independently as
well as in combination with other modules. We have provided various pin connectors so that the
connections can be made as per User’s requirement. We have designed PCBs of various modules
and then combined them to give the Hardware an aesthetic appearance. As various modules are
independent, the troubleshooting become easier.

2. User Friendly:

We have provided a User’s Manual for operating Trainer kit. This manual will help user to
understand each section thoroughly. The manual enables the user to understand hardware
connections and Troubleshooting. As we have provided various pin connectors the user can
easily connect as per manual description. As we have include some very simple interfacings such
as 1 LEDs, 4 LEDs etc., the user who are new to the system can easily access and move further
to keyboard, seven segment, RTC and so on. To reduce the connections complexity, we have
used 8255 PPI. So we could keep some of the connections as permanent one. For observing
waveforms user can easily connect to the CRO.

3. Flexibility:

Page 21
Our simple trainer kit design makes the system portable. We have interfaced some display
devices such as LCDs and 7-segments, so that the output of various devices can be easily viewed
on such displays. The output of DAC can be easily viewed by connecting CRO. Similarly, key
detection can be displayed on either LEDs or 7- segments. As our Trainer Kit is enclosed inside a
wooden box, it is completely unaffected by external parameters.

4. Versatility:

As in the Trainer kit, we have included RTC, it can works as a Digital Clock. Temperature can
be measured with the help of temperature sensor of Trainer Kit, which makes it a Temperature-
monitoring system. It can be used as a multi controller communication system. By interfacing
RS-232 with Trainer Kit, we can easily make communication between PC and Trainer kit. We
have included all fundamental devices interfacing such as LEDs, LCD,7-segment, keyboard,
ADC, DAC, Sensors etc. which make the students to understand the control system thoroughly.

5. Cost Effective:

In our Trainer Kit we have used 2 Microcontroller IC’s and one 8255 Ic. With the help of 3 Ic’s
we are able to interfaced a number of different modules. We have used various components that
are easily available in the local market. This makes our Trainer Kit Cost-Effective.

6. Multiple function in one device:

In this trainer kit also students can get knowledge about different modules and has useful
applications. Using 4*4 matrix keyboards it can be used as calculator. Using RTC it can work as
digital clock. Using DAC various waves like square wave, triangle wave, sine wave are
generated. Using LM35 temperature sensor it can monitor temperature and on this basis we can
design temperature security system. Using RS-232 communication between computer and
controller is done.

7. Simple modules:

This trainer kit is designed very simply. As students can understand different modules we avoid
using complicate modules. Instead using other more advantageous controller we use 89c51. Also
programming is done in assembly. We start from basic level so students understand easily.

3.3. BLOCK DIAGRAM OF TRAINER KIT


Figure 3.1 shows the block diagram of Microcontroller based Trainer Kit. The main parts
included inside the Trainer Kit can be listed as below:

1. 89c51 Microcontrollers from 8051 family.

2. Selection switches which defines which particular modules which be executed at a given time.
There are specific codes given to each and every practical. On the basis of switch status,
particular practical is selected.

Page 22
3. Matrix keyboard with 16 keys arranged as 4 rows and 4 columns.

4. Four LEDs, for understanding basics of display.

5. ADC (Analog-to-Digital Converter) o deal with real-world physical quantities.

6. Temperature sensor, for temperature monitoring system.

7. EEPROM, to access the ROM for reading and Writing data.(not shown )

8. RTC (Real Time Clock), to make digital Clock.

9. LCD, for displaying various practical names.

10. DAC (Digital-to-Analog Convertor) for generating various waves such as Square, sine and
triangular.

11. Seven-segments for displaying the key detection.

3.3.1 C IRCUIT DIAGRAM OF TRAINER KIT

Page 23
3.4. APPLICATIONS

Apart from the trainer kit, this project can be used as a digital clock temperature monitoring
system. It can also be used for various types of wave generation and serial communication. By
extending some of its features it can be used as a digital Function generator, control access
system, general purpose sensor kit, and home automation System etc.

3.4.1 TRAINER KIT:


The trainer kit is used for giving the explanation of various types of Interfacings to the students.
By using this trainer kit the student can learn the interaction between the hardware and software
of the particular device. In our trainer kit we have included the display devices like LCD, seven

Page 24
segment so through them can check the output of the other interfacings like key board, DAC,
ADC, E2PROM, RTC ,sensors etc.

3.4.2 DIGITAL CLOCK:

In our trainer kit the combination of RTC and LCD works as a digital clock. We have used an RTC DS-
1307, which works on battery mode also so it fulfills the requirement of real time applications. To display
the time we have used the LCD, so user can view the time on it. Only limitation is that the user can not set
the time according to his/her requirement. To set the time, changes must be made in software.

3.4.3 TEMPRATURE MONITORING SYSTEM:

In our trainer kit the combination of ADC, temperature sensor and LCD interfacing can be used
as a temperature monitoring system. It will sense the temperature of its surrounding and display
it on an LCD .the temperature will be measured in Celsius. Here an ADC is used for converting
the analog output of the sensor in the digital one.

3.4.4 WAVE GENERATION:

In our trainer kit if the DAC interfacing module is connected with the CRO then Sine wave,
square wave and triangle wave can be generated. Some other types of wave forms like saw tooth,
staircase can also be generated by modifying the software.

3.4.5 SERIAL COMMUNICATION:

The communication link for the multi processor and multi Controller can be established. Same
way the RS-232 interfacing is used for establishing the communication link with the
PERSONAL COMPUTER.

3.4.6 PROSPECTIVE: By modifying the trainer kit it can be used as a control access system,
digital function generator, general purpose sensor kit, temperature controlling system, home
automation system etc.

Chapter 4

LED INTERFACING

Page 25
4.1 Introduction

When you need to add light to a model, an ordinary filament lamp is the first thing that springs to
mind. But if you don’t need a high light output, or you need light as an indicator, an LED has
many advantages over a lamp. LEDS are basically the single light display that include
incandescent and are treated as single binary points to be switched on and off by programmer
instructions. The individual light display is easy to use. A port presents a bit or a character and
then strobe the device.

4.2 ADVANTAGES OF LEDs

4.2.1 Shapes and Sizes:

LEDs are available in many shapes and sizes, some of which are shown in the selection below.
The 'standard' LED shape is the 5mm diameter domed type, and the smaller 3mm domed type is
also popular.

1. Tri-LED array

2. 10 segment bar displays

3. Domed LED sizes 3, 5, 8, 10mm

4. Panel mounting LED

5. PCB mounting LED

6. 26mm red & green LED cluster

4.2.2 Colors:
LEDs have traditionally been red, orange, yellow, or green, but advances in LED technology
mean that blue and white LEDs are now available, though at a much higher price. These LEDs
are considerably brighter than standard LEDs so they could be used for lighting, but you will
find the ones described as 'white' still have a blue tinge. Also available are LEDs described as 'bi-
color' and 'tri-color'. Bi-color LEDs typically incorporate one red and one green LED in the same
package. Since they have only two leads, only one LED can be on at any time. Tri-color LEDs
also have two LEDs in one package, but because they have three leads, both LEDs can be
switched on together, their light combining to make a third color, typically orange. The central
lead of such a package is the common for both LEDs. Some manufacturers produce true 'tri-
color' LEDs incorporating red, green, and blue LEDs, so in theory it is possible to create light of
any color. The physical color of an LED package does not necessarily indicate the color it will be
when switched on. Some LEDs have a clear plastic package, while others may have a diffused
plastic package.

1. Standard red, green and yellow LEDs

Page 26
2. Bi-color LEDs

3. Tri-color LEDs

4.2.3 Current Consumption:

LEDs consume much less current than lamps - usually only 20mA - so they are ideal for battery
powered models.

4.2.4 Long Life:

LEDs rarely fail (unless you supply them with the wrong voltage!) so are handy in parts of a
model that are hard to reach.

Which Way Around?

How can you tell which lead on an LED is which? Figure 2 shows a standard domed LED. If
brought new, you will find that the longest lead is the positive lead, or 'anode', and the shortest
lead is the negative lead, or 'cathode'. If the leads have been cut there are a few other ways to
find out the polarity:

• The plastic package nearest the cathode will be flattened slightly.

• When holding the LED up to a light, the largest triangular section inside will be nearest the
cathode. You can also connect up the LED (as in Figure 1) both ways around to see which is
correct - reverse biasing the LED won't do it any harm.

4.3 HARDWARE CONNECTIONS:

For interfacing a single Led to 89c51 microcontroller, we connect the anode (+) end of LED to
the designated port pin via a pull-up resistor. While the cathode end of LED is connected to
GND. Connection of 1 LED to 89c51 port pins is as shown in figure. For glowing a LED, a high
logic is required at the anode (+), so port pin is set to high for glowing LED. One end of single
LED is connected to port pin of 89c51 via a pull up resistor and other one is grounded. In
Switch, One end is connected to port pin of 89c51, while other one is grounded.

Page 27
LED Interfacing

4.4 Program to blink LED’s clockwise:

#include<reg51.h> /* include the file reg51.h

void delay(); /*declaration of a function delay()

void main()

P0=0x80; /*assigning a value to port 0

delay();

Page 28
P0=0x40; /*assigning a next value to port 0

delay();

P0=0x20;

delay();

P0=0x10;

delay();

P0=0x08;

delay();

P0=0x04;

delay();

P0=0x02;

delay();

P0=0x01;

delay();

void delay()

int i;

for(i=0;i<=30000;i++)

Chapter 5

KEYBOARD INTERFACING

Page 29
5.1 Introduction

The predominant interface between humans and computers is the keyboard. Keyboard range in
complexity from the “up-down” buttons used for elevators to the personal computer multimedia
keyboard layout, with the addition of function keys and numeric keypads. One of first
requirement was to interface keyboard with microcontroller and with the main processor in
personal computers. Industrial and commercial applications fall somewhere in between these
extremes, using layouts that might feature from six to twenty keys. One of the most basic
requirements in configuring a keypad is to accommodate need of human user. Human beings are
irritable. They have little tolerance for machine failure. You have seen the behavior of people at
the elevator. Even if the “up” light is lit when we arrive, we will push it again to let the machine
know that “I’m here too.” Thus the hardware designer has to select keys that will survive in the
intended environment. The programmer must write the code that will anticipate and defeat
deliberate attempts by human to confuse program. The software must be such that the keyboard
application must guard against following Human Factors:

1. More than one key pressed.

2. Key pressed and held.

3. Rapid key press and release.

5.2 Keyboard Configurations

Keypads are often used as a primary input device for embedded microcontrollers. At the lowest
level keypads are arranged as a matrix of rows and columns which are for by using number of
switches as shown in Fig 5.1 and Fig 5.2 shows how it looks on real hardware. The CPU
accesses both rows and columns through ports; therefore, with one bit ports a 4×4 matrix keys
can be connected to a microcontroller. When a key is pressed the row makes a contact with
column. Otherwise there is no connection between rows and columns. Microcontroller itself
makes a continuous check of all rows and columns with the help of program stored in its ROM to
see whether a key is pressed or not, It takes care of both hardware and software. In order for the
microcontroller to scan the keypad, it outputs a nibble to force one (only one) of the rows and
then reads the columns. If any keys in that column have been pressed. The rows are pulled up by
the internal weak pull-ups in the 8051 ports. Consequently, as long as no buttons are pressed, the
microcontroller sees logic high on each of the pins attached to the keypad rows. The nibble
driven onto the columns always contains only a single 0. The only way the microcontroller can
find a 0 on any row pin is for the keypad button to be pressed that connects the column set to 0 to
a row. The controller knows which column is at a 0-level and which row reads 0, allowing it to
determine which key is pressed. For the keypad, the pins from left to right are: R1, R2, R3, R4,
C1, C2, C3, and C4. Next section shows you how to detect a key press using 89C51.

5.3 SCANNING AND IDENTIFYING KEY PRESS

Page 30
Here we have used 4×4 matrix keyboard. Its interfacing to 89C51 is as shown in

Figure. Rows are connected to the output port and columns are connected to input port. If no key
is pressed then the status of all columns will be high at Vcc. If all rows are grounded and a key is
press, then the status of one of the column will goes low since the key provides path to ground.
Using the above procedure Microcontroller scans continuously and detects a key press. To detect
key press, the microcontroller grounds all rows by providing 0 to the output latch, then it reads
the columns, If date read is p0.4-p0.7=1111, no key is pressed and process continues until a key
press is detected. When a key press occurs, one of the columns will go zero. For example, if
p0.4-p0.7=1101 this means that key of column-3 that is connected to p0.6 is pressed. After the
key press is detected than microcontroller goes for identifying a key. Starting with the top rows
microcontroller continuously ground each of the row and check corresponding column. If the
column status is all high then no key is press and process is moved to next row.

5.4 HARDWARE CRITERIA

Figure shows interfacing of 89c51 with 4 x 4 matrix keyboard. Here rows are connected from
p0.0-p0.3. While columns are connected from p0.4-p0.7.

5.4.1 TO DETECT MATRIX KEYBOARD USING 4 LEDs.

Display Keypad Data to LED:

Page 31
In this lesson we are like to design, how to scan keypad 4 x 4, and then display it to LED. In this
hardware 4*4 keyboard is connected to eight port pins. And 4 LEDS are connected to four other
port pins. All cathodes of LEDS are shorted and grounded while anode of each LED is connected
to port pin via pull up resistor. Which key is pressed on key board (0 to f keys) hex value of this
key digit is displayed on four LEDS. If 0 key is pressed all four LEDS are off. If 1 key digit
pressed 0001 pattern will be displayed on LEDS.

CHAPTER 6
INTERFACING OF SEVEN-SEGMENT DISPLAY

6.1 Introduction

One common requirement for many different digital devices is a visual numeric display.
Individual LEDs can of course display the binary states of a set of latches or flip-flops. However,
we're far more used to thinking and dealing with decimal numbers. To this end, we want a

Page 32
display of some kind that can clearly represent decimal numbers without any requirement of
translating binary to decimal or any other format. One possibility is a matrix of 28 LEDs in a 7×4
array. We can then light up selected LEDs in the pattern required for whatever character we
want. Indeed, an expanded version of this is used in many ways, for fancy displays. However, if
all we want to display is numbers, this becomes a bit expensive. A much better way is to arrange
the minimum possible number of LEDs in such a way as to represent only numbers in a simple

fashion. This requires just seven LEDs (plus an eighth one for the decimal point, if that is
needed). A common technique is to use a shaped piece of translucent plastic to operate as a
specialized optical fiber, to distribute the light from the LED evenly over a fixed bar shape. The
seven bars are laid out as a squared-off figure "8". The result is known as a seven-segment LED.
We've all seen seven-segment displays in a wide range of applications. Clocks, watches, digital
instruments, and many household appliances already have such displays. In this experiment,
we'll look at what they are and how they can display any of the ten decimal digits 0-9 on demand
Seven segments display a single character. Seven segments Display commonly contains LED
segments arranged as an 8 with one common Lead that is either anode or cathode and seven
individual leads for its segment. Figure shows the pattern and equivalent circuit representation of
common cathode display. If more than one display is to be used then they can be time-
multiplexed. The human eye cannot detect the blinking if each display is relit every 10ms or so.
The 10ms is divided by number of displays used to find intervals between updating each display.

6.2 Schematic Diagram


As shown in the schematic diagram , the LEDs in a seven-segment display are not isolated from
each other. Rather, either all of the cathodes, or all of the anodes, are connected together into a
common lead, while the other end of each LED is individually available. This means fewer
electrical connections to the package, and also allows us to easily enable or disable a particular
digit by controlling the common lead. (In some cases, the common connections are

Page 33
made to groups of LEDs, and the external wiring must make the final connections between them.
In other cases, the common connection is made available at more than one location for
convenience in laying out printed circuit boards. When laying out circuits using such devices,
you simply need to take the specific connection details into account.) There is no automatic
advantage of the common-cathode seven-segment unit over the common-anode version, or vice-
versa. Each type lends itself to certain applications, configurations, and logic families. We'll
learn more about this in later experiments. For the present, we will use a common-cathode
display as our experimental example.
6.3 Seven-Segment Display Layout
The illustration to the right shows the basic layout of the segments in a seven segment display.
The segments themselves are identified with lower-case letters "a" through "g," with segment "a"
at the top and then counting clockwise. Segment "g" is the center bar. Most seven-segment digits
also include a decimal point ("dp”) and some also include an extra triangle to turn the decimal
point into a comma. This improves readability of large numbers on a calculator, for example.
The decimal point is shown here on the right, but some display units put it on the left, or have a
decimal point on each side. In addition, most displays are actually slanted a bit, making them
look as if they were in italics. This arrangement allows us to turn one digit upside down and
place it next to another, so that the two decimal points look like a colon between the two digits.
The technique is commonly used in LED clock displays. Seven-segment displays can be
packaged in a number of ways. Three typical packages are shown above. On the left we see three

Page 34
small digits in a single 12-pin DIP package. The individual digits are very small, so a clear
plastic bubble is molded over each digit to act as a magnifying lens. The sides of the end bubbles
are flattened so that additional packages of this type can be placed end-to-end to create a display
of as many digits as may be needed. The second package is essentially a 14-pin DIP designed to
be installed vertically. Note that for this particular device, the decimal point is on the left. This is
not true of all seven-segment displays in this type of package. One limitation of the DIP package
is that it cannot support larger digits. To get larger displays for easy reading at a distance, it is
necessary to change the package size and shape. The package on the right above is larger than
the other two, and thus can display a digit that is significantly larger than will fit on a standard
DIP footprint. Even larger displays are also available; some digital clocks sport digits that are
two to five inches tall. Seven-segment displays can be constructed using any of a number of
different technologies. The three most common methods are fluorescent displays (used in many
line-powered devices such as microwave ovens and some clocks and clock radios), liquid crystal
displays (used in many battery-powered devices such as watches and many digital instruments),
and LEDs (used in either line-powered or battery powered devices). However, fluorescent
displays require a fairly high driving voltage to operate, and liquid crystal displays require
special treatment that we are not yet ready to discuss. Therefore, we will work with a seven
segment LED display in this experiment.

6.4 HARDWARE CRITERIA:


Multiplex seven segment display when there is need of more than one seven segment they can be
time multiplexed. In the connection segment information is output on any port of 89c51 and the
cathode selection is done by port pins. Transistor must be used to handle the currents required by
the led’s, typically 10 mill amperes for each segment and 70 milliamperes for each cathode.
These are average current values, the peak currents will be four times as high for the 2.5
milliseconds each display is illuminated. In multiplexed segment transistors are required as
number of segments. Enable lines also required as much as segments, high logic on any of the
one port pins select the segment. All data lines or segment lines of different segments are shorted
first. As an segment line “a” of the for first segment is shorted with all segments’ line a. Finally
for any number of segments there are eight segment lines. Each of the segment is selected by the
enable lines connected to port pins by transistor. At ones only one segment can be lit.
Advantage of this kind of connection or multiplexing is the minimum use of port pins. For two
segments no need of 16 port pins but only 8 pins required. The difference is only time
multiplexing. All segments not lit at ones but time between two is hardly observed by human
eyes. That’s why it is more in use.

Inter facing of four multiplexed seven segment to 89c51

Figure:
As key is pressed using look up table scan code is given to segment and character or number is
displayed. Only difference is that segment lit one by one. Non multiplexed seven segment
Here more than one segment can be used but they are not multiplexed. At once multiple
segments lit and no time sharing between two segments. In short, segment lines a,b,c…..dp of
different segments are not shorted. For connection of two segments 16 segment lines (8 per one)

Page 35
are required. Controller has not so much port pins to effort. Due to lack of port pins or saving the
pins multiplexing is the better choice over non multiplexing. Only advantage is many segments
can be lit at a time. Here we show connection of single seven segments to controller. Keyboard is
input device and display is output device. If switch is pressed on keyboard after detecting which
key is pressed, we get scan code (a pattern of zero’s and one’s to which can lit a segment and
form a character or digit) using look up table. This pattern is given to segment lines appropriate
digit according to key is displayed on segment. To enable segment one port pin is used to which
(we use pnp transistor and common cathode) transistor base is connected and emitter is grounded
While collector is connected to segment. For common anode and npn transistor connection is
reversed This is example of single seven segment. For non multiplex another segment is
connected to remaining eight port pins.

6.5 Program to Display from 0-9 on one seven segment

#include<reg51.h>
unsigned char array[10]={0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd,0x87,0xff,0xef};
void delay();
void main()
{
int a;
while(1)

Page 36
{
P2=0x08;
for(a=0;a<=9;a++)
{
P0=array[a];
delay();
}
}
}
void delay()
{
int i;
for(i=0;i<=30000;i++);
{
}
}

CHAPTER 7

Page 37
INTERFACING OF EEPROM

7.1 Introduction
As we know, ROM is a memory that does not lost its contents when the power is turned off. For
this reason ROM is also called Non-Volatile Memory. There are different types of ROM such as
PROM, EPROM, EEPROM, Flash EPROM and Mask ROM. In which PROM refers to the Kind
of ROM that the user can burn information into. PROM is a user programmable memory. PROM
is referred to as OTP (One time programmable). EPROM was invented to allow making changes
in the contents of PROM after it is burned. In short, one can program the memory chip and erase
it thousands of time. This is especially necessary during development of microcontroller based
project. EEPROM is electrically erasable programmable ROM. EEPROM has several advantages
over EPROM. EEPROM does not require external eraser and programming device. Flash
EPROM has become a popular user programmable memory chip. The reason behind that is the
eraser of entire content takes less than a second that why it is named Flash memory. When flash
memory contents are erased the entire device is erased whether in EEPROM one can erased a
desired section or byte. In masked ROM, the contents are programmed by the IC Manufacturer.
It is not a user programmable ROM. Masked ROM is used when the needed volume is high and
the contents will not change. It is cheaper than other kind of ROM.

7.1.1 FEATURES:-
1. 1000000 erase/write cycle’s minimum with over 10 year’s data retention.
2. Single 3V to 5.5V supply voltage.
3. Two wire serial interface, fully I2C BUS compatible.
4. Byte and multi byte write (up to 4 bytes) Page write (up to 8 bytes).
5. Byte, random and sequential read modes.
6. Self timed programming cycle.
7. Automatic address incrementing

7.2 Pin Description

AT24c02 provides bits of serially erasable and programmable Read Only memory
(EEPROM) organized as 256 words of 8-bits each. The device is optimized to be used in many
industrial and commercial applications where low power and low voltage operation are essential.

Page 38
24c02 EEPROM IC is available in 8-pin DIP and is accessed via two-wire serial Interface.
Figure shows pin Description of 24c02 EEPROM IC.

SERIAL CLOCK (SCL):


The SCL input is used to positive edge clock data into each EEPROM device and negative edge
clock data out of each device.

SERIAL DATA (SDA):


The SDA pin is bidirectional for serial data transfer. This pin is open-drain driven and may be
wire-ORed with any number of other open-drain or open-collector devices.

DEVICE/PAGE ADDRESSES (A2, A1, A0):


The A2, A1 and A0 pins are device address inputs that are hard wired for the AT24C02. As
many as eight 1K/2K devices may be addressed on a single bus system (device addressing is
discussed in detail under the Device Addressing section).

WRITE PROTECT (WP):


The AT24C02 has a Write Protect pin that provides hardware data protection. The Write Protect
pin allows normal Read/Write operations when connected to ground (GND). When the Write
Protect pin is connected to VCC, the write protection feature is enabled and operates as shown in
Table 2. WP pin status Part of Array Protected 24c02 .At VCC Full (2K) Array. At GND Normal
Read/Write Operations
The ST24C02A is a 2k bit electrically erasable programmable memory, organized as 256x8 bits.
The memory is compatible with the I2C bus standard, two data bus and serial clock. The
STA240C2A carries a built in a bit unique device information code corresponding to the I2C bus
definition. This is used together with a 3-bit chip enable input to form a 7-bit memory select
signal. In this way up to 8 ST24C02A’S may be connected to the I2C bus and selected
individually. The ST24C02A behaves as a slave device in the I2C protocol with all memory
operations synchronized by the serial clock. Read and write operations are initiated by start
condition generated by the bus master. The start condition is followed by a stream of 7 device
select bit plus one read/write bit and terminated by an acknowledge bit. When writing data to the
memory it respond to the 8 bits received by asserting an acknowledge bit during the ninth bit
time. Data transfers are terminated with a stop condition.

7.3OPERATING MODES:-
There are both read and write modes. Each is entered by the correct sequence of serial bits sent
to the device on the SDA line. For some write modes the status of the mode input is also used to
set the operating mode. The 8 bits sent after a start condition are made up of a bits that identify
the device type, 3 chip enable bits and one direction indicator bit. Whether the controller wants
to read from the device or write to the device is decided by the very first byte sent to it on the
SDA line. The last bit of very first sent to E2PROM is directional indicator. If this bit is ‘Zero’
the direction of data flow is from controller to the E2PROM and if ‘One’ it is from E2PROM to
the controller. Following are the different modes for reading or writing from the E2PROM.

Page 39
1). Byte Write: - In this mode a device select is sent with the R/W bit at ‘0’ followed by the
address of the byte. This is followed by the 8 bit data to be written during the programming
cycle.
2). Multi byte Write And Page Write: - In these modes up to 4 or 8 bytes respectively may be
written in one programming cycle. Multi-byte write mode is activated when the mode pin is at
V/H level and page write when mode is at V/L. A device select is sent with the R/W bit at ‘0’
followed by the data bytes to write. The bytes are written in the programming cycle 8 bytes
written in the page write mode must have the same five upper address bits
3). Current Address: In this mode device select is sent with the R/W bit at ‘1’. The address of
various byte accessed is automatically incremented and the new byte read.
4). Random Address Read: - This mode allows random access to the memory. A device select is
sent with R/W bit at ‘0’ (write) followed by the address. Then a new start condition is forced
with the same device select is sent with the R/W bit at ‘1’ (read) and the byte is read.

5). Sequential Read: - This mode starts with either a current address or random address read
sequence it reads consecutive bytes as long as the bus master acknowledges each one without
generating a stop condition.

7.4 Device operation based on I2c protocol:


The 24C02 family uses two I/O lines for interfacing: SCL (Serial Clock) and SDA (Serial Data).
SCL edges have different functions, depending on whether a device is being read from or written
to. When clocking data into the device, the positive edges of the clock latch the data. The
negative clock edges clock data out of the device. The SDA signal is bi-directional, and is
physically an open-drain so that multiple EEPROMs or other devices can share the pin. Both
SCL and SDA must be pulled high externally. The protocol used by the EEPROM is based in
part on an ACK (acknowledge) bit sent by the EEPROM, if the data sent to it has been received.
All addresses and data are sent in 8-bit words. The EEPROM sends the ACK as a low bit period
during the ninth clock cycle. The EEPROM looks for specific transitions on the SCL and SDA
pins to qualify READ and WRITE. Data on the SDA pin may change only during the time SCL
is low. Data changes during SCL high periods indicate a START or STOP condition. A START
condition is a high-to-low transition of SDA with SCL high. All data transfers must begin with a
START condition. A STOP condition is a low-to-high transition of SDA with SCL high. All data
transfers must end with a STOP condition. After a READ, the STOP places the EEPROM in a
standby power mode. Refer to Figure 1 for START and STOP conditions. Figure 1. START and
STOP conditions.

Device Addressing
The 24C02 has 3 physical pins, designated A2, A1, and A0, which are tied to logic 1 or 0 levels.
This allows eight unique hardware addresses, so that up to eight 24C02s can share the SCL and
SDA lines without conflict. There is an internal address comparator that looks for a match
between the address sent by the master controller and the 24C02's unique 7-bit address,
determined in part by A2, A1, and A0. Refer to Table 1below. Table 1. 24C02 Device Address
MSB LSB
1 0 1 0 A2 A1 A0 R/~W
The device address is sent immediately after a START condition. The first four bits are the
sequence "1010", which is a simple "noise filter" which prevents a random noise burst on the
lines from accessing the device. The last bit sent is a 1 for READ and a 0 for WRITE. The code
example below is for random READ/WRITE operations. The part can also perform Page

Page 40
Write/Sequential Read with slight code modifications. See the 24C02 data sheet for more
information.

Byte Write to Memory: The Byte Write sequence is shown in Figure 2. After receiving a START
condition and a device address, the EEPROM sends an ACK if the device address matches its
own unique address. The MAX7651 waits for the ACK and aborts communication if it is not
present. Next, an 8-bit byte address is sent, followed by another ACK. The MAX7651 then sends
the 8-bit data byte, waits for the third ACK, and sends a STOP condition.

WRITE operation.
It is important to note that after the STOP condition is received, the EEPROM internally waits
for the data to be stored into its internal memory array. This can take as long as 10ms. The
24C02 will ignore attempted accesses while the internal EEPROM is being programmed. The
part can be polled for completion of the internal write cycle. This involves sending another
START condition (also called a REPEATED START), followed by the device address byte.
Note, in this case, there is no STOP condition sent. The EEPROM will send an ACK if the
internal programming cycle is completed. The MAX7651 can also be programmed to wait 10ms
before proceeding.

Byte Read from Memory


Reading a byte from the 24C02 EEPROM at a random address requires that a dummy WRITE
operation be performed before the READ. See Figure
The sequence is:
• START condition
• Send device address with R/~W = 0 'dummy WRITE' command
• Wait for ACK
• Send byte memory address
• Wait for ACK
• Send REPEATED START condition
• Send device address with R/~W = 1 (READ command)
• Wait for ACK
• Read the 8 data bits into the MAX7651, MSB first
• No ACK
• STOP condition
This sequence is quite involved! The total number of SCL transitions required for a READ is 38.
Waveform for data
7.5 Hardware connection
EEPROM is based on i2c protocol ,two wired serial protocol. For that we need two pins. We use
p3.6 for SCL and p3.7 for SDA . a0,a1,a2 are address lines to select EEPROM chip. That is hard
wired and fix for each EEPROM. To send address, data, start-stop condition data we use SCL
and SDA.

CHAPTER 8

LCD INTERFACING

Page 41
8.1 LCD Features

LCD stands for Liquid Crystal Display are the most widely used output devices for 89c51 type
microcontroller. Nowadays LCDs is finding widespread use compared to LEDs and 7-segment.
This is due to following specific features:

1. The declining prices of LCDs make its use cost-effective.

2. The ability to display numbers, characters and graphics. This is contrast to LEDs, which has
limited to numbers and few characters. Incorporation of a refreshing controller into LCD,
thereby relieving the CPU of the task of refreshing the LCD. In contrast, the LED must be
refreshed by the CPU to keep displaying data.

3. Ease of programming for characters and graphics.

8.2 LCD Pin Descriptions

The LCD which we have used in our TRAINER KIT is discussed in this section. It has 14 pins.
Figure shows the position of various pins.

1. VCC, VSS, and VEE


While VCC and VSS provide +5V and ground, respectively, VEE is used for controlling LCD
contrast.

2. RS (Register Select)
There are two very 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, allowing the 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 LCD.

3. R/W (Read/Write)
R/W input allows the user to write information to LCD or read information from it. R/W=1 when
reading; R/W=0 when writing.

Page 42
4. E (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-to-low pulse must be applied to this pin in order for the LCD to
latch in the data present the data pins. This pulse must be a minimum of 450 ns wide.

5. D0-D7 (8-bit Data bus)


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 display 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 instruction command
codes that can be sent to LCD to clear the cursor to the home position or blink the cursor. Table
lists some of the instruction command codes.

8.3 Connection of LCD with 8255


The main purpose of LCD in our Trainer kit is to display the name of the practical which is
going to perform by the user and so LCD is programmed according. Figure shows various
connections required to interface an LCD to 89c51. Here data lines of LCD are connected to 8
port of 89c51 microcontroller.

Interfacing of LCD to Microcontroller


On this data lines, various command codes for LCD settings and data codes which are required
to display are sent. There are three controlling lines for LCD viz, RS, R/W and E. RS that is
register select is connected to designated port pin of 89c51 and set or reset as required. Similarly
remaining two lines R/W that is Read/Write and E that is Enable are connected to designated
89c51 port pins and set or reset as required.

Page 43
CHAPTER 9

RTC INTERFACING
9.1 INTRODUCTION

The real time clock is most widely device that provides accurate time and date for many
applications. RTC chip has the capability of providing time components of hour, minute and
second, in addition to date/calendar components of year, month, and day. The RTC chip uses an
internal battery, which keeps the time and date even when power is off. Although some 8051
microcontrollers come with RTC embedded into the chip, we have to interface vast majority of
them external to the 8051 chip. One of most widely used RTC chip is DS1307 from Dallas
Semiconductor/Maxim Corp. This RTC chip has specific features of Two-wire Serial Interface.
The DS1307 Serial Real-Time Clock is a low-power; full binary-coded decimal (BCD)
clock/calendar plus 56 bytes of NV SRAM. Address and data are transferred serially via a 2-
wire, bi-directional bus. The clock/calendar provides seconds, minutes, hours, day, date, month,
and year information. The end of the month date is automatically adjusted for months with fewer
than 31 days, including corrections for leap year. The clock operates in either the 24-hour or 12
hour format with AM/PM indicator. The DS1307 has a built in power sense circuit that detects
power failures and automatically switches to the battery supply. Next section describes you some
of the features of DS1307 RTC chip.

9.2 FEATURES

1. Real-time clock (RTC) counts seconds, minutes, hours, date of the month, month, day of the
week, and year with leap-year compensation valid up to 2100 years.

Page 44
2. 56-byte, battery-backed, nonvolatile (NV) RAM for data storage.

3. Two-wire serial interface..

4. Programmable square wave output signal.

5. Automatic power-fail detects and switch circuitry.

6. Consumes less than 500nA in battery backup mode with oscillator running.

7. Optional industrial temperature range: -40‹C to +85‹C.

8. Available in 8-pin DIP or SOIC.

9.3 Pin Descriptions

This Section describes you DS1307 pins. See Figure 9.1

VCC, GND:

DC power is provided to the device on these pins. VCC is the +5V input. When 5V is applied
within normal limits, the device is fully accessible and data can be written and read. When a 3V
battery is connected to the device and VCC is below 1.25 x VBAT, reads and writes are
inhibited. However, the timekeeping function continues unaffected by the lower input voltage.
As VCC falls below VBAT the RAM and timekeeper are switched over to the external power
supply (nominal 3.0V DC) at VBAT.

VBAT:

Battery input for any standard 3V lithium cell or other energy source. Battery voltage must be
held between 2.0V and 3.5V for proper operation. The nominal write protect trip point voltage at
which access to the RTC and user RAM is denied is set by the internal circuitry as 1.25 x VBAT
nominal. A lithium battery with 48mAhr or greater will back up the DS1307 for more than 10
years in the absence of power at 25oC. UL recognized to ensure against reverse charging current
when used in conjunction with a lithium battery.

SCL (Serial Clock Input): SCL is used to synchronize data movement on serial interface.

SDA (Serial Data Input /Output): SDA is the input/output pin for the 2-wire serial interface. The
SDA pin is open drain which requires an external pull-up resistor.

Page 45
SQW/OUT (Square Wave/Output Driver) :When enabled, the SQWE bit set to 1, the SQW/OUT
pin outputs one of four square wave frequencies (1Hz, 4kHz, 8kHz, 32kHz). The SQW/OUT pin
is open drain and requires an external pull-up resistor. SQW/OUT will operate with either Vcc or
Vbat applied.

X1, X2: Connections for a standard 32.768 kHz quartz crystal. The internal oscillator circuitry is
designed for operation with a crystal having a specified load capacitance (CL) of 12.5pF. The
DS1307 can also be driven by an external 32.768 kHz Oscillator. In this configuration, the X1
pin is connected to the external oscillator signal and the X2 pin is floated.

9.4 Operation Based on I2C protocol

The DS1307 supports a bi-directional, 2-wire bus and data transmission protocol that is called
I2C protocol. A device that sends data onto the bus is defined as a transmitter and a device
receiving data as a receiver. The device that controls the message is called a master. The devices
that are controlled by the master are referred to as slaves. The bus must be controlled by a master
device that generates the serial clock (SCL), controls the bus access, and generates the START
and STOP conditions. The DS1307 operates as a slave on the 2-wire bus. A typical bus
configuration using this 2-wire protocol is show in Figure 4. Figures 5, 6, and 7 detail how data
is transferred on the 2-wire bus. Data transfer may be initiated only when the bus is not busy.
During data transfer, the data line must remain stable whenever the clock line is HIGH. Changes
in the data line while the clock line is high will be interpreted as control signals. Accordingly, the
following bus conditions have been defined:

Bus not busy: Both data and clock lines remain HIGH.

Start data transfer: A change in the state of the data line, from HIGH to LOW, while the clock is
HIGH, defines a START condition.

Stop data transfer: A change in the state of the data line, from LOW to HIGH, while the clock
line is HIGH, defines the STOP condition.

Data valid: The state of the data line represents valid data when, after a START condition, the
data line is stable for the duration of the HIGH period of the clock signal. The data on the line
must be changed during the LOW period of the clock signal. There is one clock pulse per bit of
data. Each data transfer is initiated with a START condition and terminated with a STOP
condition. The number of data bytes transferred between START and STOP conditions is not
limited, and is determined by the master device. The information is transferred byte-wise and
each receiver acknowledges with a ninth bit. Within the 2-wire bus specifications a regular mode

(100 kHz clock rate) and a fast mode (400 kHz clock rate) are defined. The DS1307 operates in
the regular mode (100 kHz) only.

Acknowledge: Each receiving device, when addressed, is obliged to generate an acknowledge


after the reception of each byte. The master device must generate an extra clock pulse which is

Page 46
associated with this acknowledge bit. A device that acknowledges must pull down the SDA line
during the acknowledge clock pulse in such a way that the SDA line is stable LOW during the
HIGH period of the acknowledge related clock pulse. Of course, setup and hold times must be
taken into account. A master must signal an end of data to the slave by not generating an
acknowledge bit on the last byte that has been clocked out of the slave. In this case, the slave
must leave the data line HIGH to enable the master to generate the STOP condition.

9.5 DATA TRANSFER ON 2-WIRE SERIAL BUS

Depending upon the state of the R/W bit, two types of data transfer are possible:

1. Data transfer from a master transmitter to a slave receiver. The first byte transmitted by the
master is the slave address. Next follows a number of data bytes. The slave returns an
acknowledge bit after each received byte. Data is transferred with the most significant bit (MSB)
first.

2. Data transfer from a slave transmitter to a master receiver. The first byte (the slave address) is
transmitted by the master. The slave then returns an acknowledge bit. This is followed by the
slave transmitting a number of data bytes. The master returns an acknowledge bit after all
received bytes other than the last byte. At the end of the last received byte, a not acknowledge is
returned. The master device generates all of the serial clock pulses and the START and STOP
conditions. A transfer is ended with a STOP condition or with a repeated START condition.
Since a repeated START condition is also the beginning of the next serial transfer, the bus will
not be released. Data is transferred with the most significant bit (MSB) first.

The DS1307 may operate in the following two modes:

1. Slave receiver mode (DS1307 write mode): Serial data and clock are received through SDA
and SCL. After each byte is received an acknowledge bit is transmitted. START and STOP
conditions are recognized as the beginning and end of a serial transfer. Address recognition is
performed by hardware after reception of the slave address and *direction bit (See Figure 6). The
address byte is the first byte received after the start condition is generated by the master. The
address byte contains the 7 bit DS1307 address, which is 1101000, followed by the *direction bit
(R/ W) which, for a write, is a 0. After receiving and decoding the address byte the device
outputs an acknowledge on the SDA Line. After the DS1307 acknowledges the slave address +
write bit, the master transmits a register address to the DS1307 this will set the register pointer
on the DS1307. The master will then begin transmitting each byte of data with the DS1307
acknowledging each byte received. The master will generate a stop condition to terminate the
data write.

2. Slave transmitter mode (DS1307 read mode): The first byte is received and handled as in the
slave receiver mode. However, in this mode, the *direction bit will indicate that the transfer
direction is reversed. Serial data is transmitted on SDA by the DS1307 while the serial clock is
input on SCL. START and STOP conditions are recognized as the beginning and end of a serial

Page 47
transfer (See Figure 7). The address byte is the first byte received after the start condition is
generated by the master. The address byte contains the 7-bit DS1307 address, which is 1101000,
followed by the*direction bit (R/ W) which, for a read, is a 1. After receiving and decoding the
address byte the device inputs an acknowledge on the SDA line. The DS1307 then begins to
transmit data starting with the register address pointed to by the register pointer. If the register
pointer is not written to before the initiation of a read mode the first address that is read is the last
one stored in the register pointer. The DS1307 must receive a not acknowledge to end a read.

9.6 Hardware Criteria

RTC is based on i2c protocol which is two wired protocol. So we required only two pins to send
address, to set RTC. This two pins serial data line and serial clock line are connected to any of
two port pins. In our hardware connection we use p3.6 for SCL and p3.7 for SDA. To keep
always on, RTC even in off supply 3v battery is connected to pin3 of DS-1307. VCC and
GROUND is applied to RTC.

CHAPTER 10

Timer operation using 555 IC


10.1. Introduction

Page 48
One of the most versatile linear integrated circuits is the 555 timer. The 555 is a monolithic
timing circuit that can produce accurate and highly stable time delays or oscillation. The timer
basically operates in one of the two modes: either as a mono-stable multivibrator or an astable
multivibrator. The device is available as an 8-pin metal can, an 8-pin mini DIP or a 14-pin DIP.

FEATURES:

1. It operates on +5V to +18V supply voltage in both free running and monostable modes

2. It has an adjustable duty cycle; timing is from microsecond through hours.

3. It has a high current output; it can source or sink 200mA

4. The output can drive TTL and has a temperature stability of 50 parts per million per degree
Celsius change in temperature.

5. Like general-purpose op-amps, the 555 timer is reliable ,easy to use and low cost.

10.2. Pin Descriptions

The 555 timer IC can be used as a monostable multivibrator, an astable multivibrator. It is an 8-


pin IC, its pin description is given below.

Pin 1 Ground: All voltages are measured with respect to this terminal.

Pin 2 Triggered: The output of the timer depends on the amplitude of the external trigger pulse
applied to this pin.

Pin3 Output: There are two ways a load can be connected to the output terminal: either between
pin3 and ground or between pin3 and Vcc.

Pin4 Reset: The 555timer can be reset (disabled) by applying a negative pulse to this Pin.

Page 49
Pin5 Control Voltage: An external voltage applied to this terminal changes the threshold as well
as the trigger voltage.

Pin6 Threshold: This is the non inverting terminal of comparator 1, which monitors the voltage
across external capacitor.

Pin7 Discharge: This pin is connected internally to the collector of the transistor Q1.

Pin8 +Vcc: The supply voltage of +5v to +18v is applied to this pin with respect to ground.

CHAPTER 11

11.1 TROUBLESHOOTING & TESTING

Page 50
TRAINER KIT

11.1.1 Testing Trainer Kit.

11.1.2. Trouble shooting Trainer Kit.

11.1.1 Testing Trainer Kit

1. One LED and One SWITCH: By making the selection switch position to 0000, One led & One
switch Program will be selected and the practical name will be displayed on LCD. Here a single
led is connected along with the switch to microcontroller. As the switch has been pressed a led
glows. After keeping it on, again the switch has been pressed then the led becomes off.

2. Four LEDS and Four Switches: By making the selection switch position to 0001, four leds &
four switches program will be selected and the practical name will be displayed on LCD. Here 4
led are connected along with 4 switches to microcontroller. As switch 1 is pressed the first led
becomes on. Then as the switch 2 is pressed the second led becomes on. Same with the third and
fourth led. Note that, when switch is pressed the only the corresponding LED remains on, While
remaining gets off.

3. Eight LEDS and 4~4 Matrix Keyboard: By making the selection switch position to 0010,
Eight leds & Matrix Keyboard program will be selected and the practical name will be displayed
on LCD. Here 8 led are connected to microcontroller along with matrix keyboard. As key-0 is
pressed all LEDs remains off to show that Key-0 is pressed. Similarly, for key-15, LED1, LED3
and LED5 glows to show that data is 00010101 i.e., key-15. In this manner all keys are detected.

4. Single Seven-segment and 4 by 4 Matrix Keyboard: By making the selection switch position
to 0011, Single seven segment and 4 by 4 matrix keyboard program will be selected and the
practical name will be displayed on LCD. Here single segment is connected with the keyboard so
the number has been displayed according to key pressed. If key 1 is pressed then 1 will be
displayed on seven segment.

5. Multiplexed Seven-segment and 4 by 4 Matrix Keyboard: By making the selection switch


position to 0100, multiplexed seven segments and 4 by 4 matrix keyboard program will be
selected and the practical name will be displayed on LCD. Here two segments have been
connected with the key board to microcontroller. Key 1 and key 0 pressed then it shows 10 on
the multiplexed seven segments.

6. EEPROM Write: By making the selection switch position to 0101, EEPROM Write Program
has been selected and the practical name will be displayed on LCD. In this case a switch is
connected to microcontroller. When the switch is pressed, LCD will display the data written at a
particular location e.g. 00H.

7. EEPROM Read: By making the selection switch position to 0110, EEPROM Read Program
has been selected and the practical name will be displayed on LCD. In this case also, a switch is

Page 51
connected to microcontroller. When switch is pressed, LCD will display the data which is read
out from EEPROM.

8. RTC: By making the selection switch position to 0111, Real Time Clock Program has been
selected and the practical name will be displayed on LCD. In real time clock as we pressed the
switch it will shows us the time in terms of second, minute and hour. e.g. 11:30:02 on LCD.

9. LCD:

Here lcd is connected with all the devices. By using the selection switch the topic which has been
selected, is displayed on LCD.

11.1.2 Troubleshooting Trainer kit

LED:

Once you make led ON and if it doesn’t glow then follow the steps given below for trouble
shooting of the circuit.

1. Check the supply and ground are given properly or not

2. Check the anode and cathode connection , ideally anode is connected with Vcc and cathode
with the ground.

3. Check the IC AT89C51 on ic tester.

4. Check the led. and pull up resistor

5. Check the software.

Keyboard:

Through the key board if you are not able to detect the key then follow the steps given below for
trouble shooting of the circuit.

1. Check the supply and ground are given properly or not.

2. Check the connections of rows and columns

3. Check the switches.

4. Check the IC AT89C51

5. Check the other devices which are connected with the key board.

6. Check the software

Seven segment display: If you will not get the desired display on seven segment then follow the
steps, given below for trouble shooting of this circuit.

Page 52
1. Check the supply and ground are given properly or not

2. check the anode and cathode of the segment

3. check its connections with the transistor and pull-up resistor.

4. Check the segment and its connections

5. Check the IC AT89C51.

6. Check the other devices which are connected with it.

7. Check the software.

EEPROM: If you are not able to write and read through the EEPROM then follow the steps
given below for trouble shooting of the circuit.

1. Check the supply and ground are given properly or not.

2. Check the connection of all master and slave devices.

3. Check all the pin connection of IC24C02 and the IC itself

4. Check the IC AT89C51.

5. Check the other devices which are connected with the EEPROM

6. Check the software.

LCD:

If you won’t get desired display on LCD then follow the steps given below for troubleshooting of
the circuit.

1. Check the supply and ground are given properly or not.

2. Check the lcd and its pin connection.

3. Check the IC

4. Check the other devices which are connected with it

5. Check the IC AT89C51.

6. Check the software.

RTC: From an RTC if you are not getting the exact output then folloe the steps given below for
trouble shooting of this circuit.

1. Check the supply and ground are given properly or not.

Page 53
2. Check the RTC DS1307 and its pin connection.

3. Check the other devices which are connected with it.

4. Check the IC AT89C51

5. Check the software.

CONCLUSION

Based on the interfacing of various devices to the microcontroller a huge number of projects can
be undertaken a few are as follow:

 Voter Identification and electoral enrollment

 Industries

Page 54
 Banks and ATM

 Personal Computer

 Finger- print authentication

 Line following robot.

 IR transmitter and receiver etc.

REFERENCES
Books:
1. 8051 Microcontroller and Embedded systems- Mazidi.
2. The 8051 Microcontroller- Ayala
3. Embedded systems- Raj Kamal

Websites:
1. www.wikipedia.com

Page 55
2. www.sunrom.com

3. www.google.com

4. www.shreeelectronics.com.

5. www.scribd.com

6. www.8051projects.net

Page 56

Potrebbero piacerti anche