Professional Documents
Culture Documents
Developed at
MCBS Pvt. Ltd.
B-138/139, GIDC Electronics Estate,
Sector-25, Gandhinagar.
Submitted By
Shah Vrushank M.
Rajan Rushvi T.
May-June 2007
B.E. Sem VIII (Electronics and Communication)
Submitted To,
Department of Electronics and Communication,
Govt. Engineering College.
Modasa-383 315.
Project Report on
May-June 2007
B.E. Sem VIII (Electronics and Communication)
Submitted To,
Department of Electronics and Communication,
Govt. Engineering College.
Modasa-383 315.
Date: /05/07
C E R T I F I C A T E
T O W H O M S O E V E R I T M A Y C O N C E R N
This is to certify that Mr. Vrushank M. Shah and Ms. Rushvi Rajan students of
B.E. Semester VIII (Electronics and communication ) has completed their one full
semester project training on Microcontroller Based Trainer Kit satisfactorily in
partial fulfillment of requirement of Bachelor Of Engineering in stream
Electronics and Communication from Hemchandracharya North Gujarat University,
Patan in the year 2007.
An engineer is a person who applies the knowledge of science for the welfare of
society. Teaching technical studies can’t be perfect without project work. Hence,
the project work is great valuable for the engineering students. This report
contains the design and development of Microcontroller based Trainer Kit.
***********
ACKNOWLEDGEMENT
I am also obliged to Mr. Chandresh Parekh for their guidance in my project in the
organization who was right there from the first lap to the finishing line.
With regards
Contents at a Glance
Company details
Institute details
Project details
1 . MCBS Profile.
Modern Communication & Broadcast Systems Pvt. Ltd, popularly known as “MCBS” is
headquartered at Ahmedabad, Gujarat, India. Instituted in 1985 by professionals
and technocrats having engineering experience of more than 20 years from India’s
pioneering space technology institutions, MCBS is in the service of Communication
& Broadcast industry since past 20 years.
MCBS STRENGTHS
MCBS has highly skilled manpower to take care of its operations including
system design, consultancy and turnkey projects.
MCBS has more than 150 field staff for technical support services and has
more than 15 project offices throughout India.
DEPARTMENTS IN MCBS
There are different departments in MCBS. They are mentioned below as per their
alphabetical order:
CCTV
Modulation
R & D
Receiver
CATV
Mechanical Workshop
Marketing Department
There are other companies associated with MCBS which also work in the same field
of communication. Their entire products are either for MCBS or for same
applications. These companies are as following:
2. Introducing NICIT
NICIT has a technical tie-up with Modern Communication and Broadcast Systems Ltd.
(MCBS), a pioneering and leading Indian company in the field of Communication,
Broadcasting and Information Technology.
NICIT has a wide range of programmes and activities. This has been designed to
provide adequate Knowledge and Skills to those who attend the course and undergo
the training to face the challenges in the global world.
Practical project work and inplant training are of vital importance in the
advanced technology areas as most colleges and institutes do not have facilities
to meet practical training needs.
More than 2000 students have already benefited by our “Training Programmes &
Projects” and are employed with various organizations of repute.
Projects are based on advanced technology areas of ICT industry namely IT,
Infocomm, Infotainment, Info media and Info education.
Projects and training are based on latest subjects of technology and these
are need-based for Indian industry, thereby providing immediate job and career
opportunities.
Training modules have been designed for various levels starting from lower
level (H.S.S. & I.T.I) to higher level (B.E. & M.E.) Covering basic understanding
& awareness of technology, operation & maintenance, in-depth academic & practical
knowledge. These modules are based on various curricula of diploma / degree & post
graduate courses.
***********
Institute details
1. Introduction:
Government Engineering College, Modasa was established in 1984 under the
Directorate of Technical Education, Gujarat State, and Gandhinagar in North
Gujarat region with a view of strengthening the industrial development in the
region. The region consists of industrially potential areas of Panchmahal,
Sabarkantha, Banaskantha, Mehsana and Patan district of Gujarat.
The college is affiliated to Hemchandracharya North Gujarat University, Patan. It
is also recognized by an apex body in technical education, All India Council for
Technical Education (AICTE), New Delhi.
The college is now entering in its 18th year and 15 batches have passed out up
till now. Our students are well accepted in different fields i.e. Industries,
Academic and for Higher studies within and outside the country. Each Department
has well established laboratories, computer center and has well qualified staff.
The institution is one of the centers for conducting a TECH-SAT programme run by
Gujarat Council on Science & Technology (GUJCOST), Gandhinagar, with a concept of
providing technical education through satellite. Students as well as faculty
members taking full advantage of expertise available within and outside the state
in different discipline.
3. POSTAL ADDRESS:
Principal,
Government Engineering College,
Shamlaji Road, Modasa-383315,
Dist.-Sabarkantha
***********
Project Details
Section-13 Sensors
13.1. Introduction.
13.2. General description of LM35 sensor.
13.3. LM35 pin descriptions.
13.4. Hardware connections.
Section-14 8255
14.1. 8255 features.
14.2. Mode selection of 8255.
14.3. Interfacing 8255 with 89c51.
SECTION-1
EMBEDDED SYSTEMS
1.1 DEFINATION
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.
• 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.
Having increasingly higher performance with constraints which are important part
of system functionality in building embedded computing 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.
The basic operation that are involved in above microcontroller development cycle
are:
ADVANTAGES:
DISADVANTAGES:
1.6 APPLICATIONS
********
SECTION-2
THE 8051 MICROCONTROLLER
2.1 Introduction
For our trainer Kit, we have chosen 89c51 microcontroller which is an 8-bit
microcontroller from the family of 8051 controllers.
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.
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.
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.
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:
6. 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
7. 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.
8. 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.
9. 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.
Crystal 1: Input to the inverting oscillator amplifier and input to the internal
clock generator circuits.
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 deasserted 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.
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.
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.
Mode 0:
Timer, which is an 8-bit Counter with a divide-by-32 prescaler. 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 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.
5. As there are 32 I/O pins and 2 timers, it supports our input-output requirement
greatly.
6. We have used the battery power product like an RTC the power consumption is
critical for it.
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.
*******
SECTION-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, 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.
Following are some feature which make 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:
Our simple trainer kit design make 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.
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.
In this trainer kit also students can get knowled about different modules and has
useful applications. Using 4*4 matrix keyboard it can be used as calculater. 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:
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:
3. One 8255 PPI, In order to expand Microcontroller port pins and to make
system design simpler.
3.5. 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, home automation System etc.
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 segment so
through them can check the out put of the other interfacings like key board, DAC,
ADC, E2PROM, RTC ,sensors etc.
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.
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.
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.
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.
1.3.6 PROSPECTIVES:
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.
SOFTWARE DETAILS
The software used for making the programs in the assembly language is Topview
simulator. The software provides the utility to convert the assembly program to be
converted into the hex file that can be then loaded to the controller. Further
detail about it is as follows
TOPVIEW SIMULATOR
INTRODUCTION:
Topview Simulator gives an excellent simulation environment for the Industry's
most popular 8 bit microcontroller family, MCS 51. It gives all the required
facilities to enable the system designers to start projects right from the scratch
and finish them with ease and confidence. Topview Simulator is the total solution
giving many state of art features meeting the needs of the designers possessing
different levels of expertise. If you are a beginner, then you can easily learn
about 8031 based embedded solutions without any hardware. If you are an
experienced designer, you may find most of the required facilities built in the
simulator that enable you to complete your next project without waiting for the
target hardware. The simulator is designed by the active feedback from the
demanding designers and when you use this in your next 8031 project, you are
assured of definite savings in time and increase in productivity.
Features
In the field of electronics, there are many applications with the need to generate
signals to assist with circuit experiment, alignment, and troubleshooting. This
simple signal generator mini-kit MK105 from Velleman could be the economical
solution you need for generating those simple AC electronic signals. This kit
outputs a fixed 1 KHz sine wave, triangle wave, square wave, and integrator
signals that are selectable through jumper configuration. Output level is
adjustable from 0 to 100 mV RMS with the onboard Level potentiometer.
Features
Signal output : sine wave, triangle wave, square wave and integrator
(selectable through jumper)
Signal generator frequency : about 1kHz (fixed)
Output level : adjustable from 0 to 100mVrms (LEVEL potentiometer)
Signal generator mini-kit assembly is required
***********
SECTION-4
LED INTERFACING
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 programme instruction. The
individual light display are easy to use. A port present a bit or a character and
then strobe the device.
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
Colours
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-colour'. Bi-colour 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-colour 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 colour, typically
orange. The central lead of such a package is the common for both LEDs.
Some manufacturers produce true 'tri-colour' LEDs incorporating red, green, and
blue LEDs, so in theory it is possible to create light of any colour.
The physical colour of an LED package does not necessarily indicate the colour 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 2. Bi-colour LEDs 3. Tri-colour LEDs
Current Consumption
LEDs consume much less current than lamps - usually only 20mA - so they are ideal
for battery powered models.
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.
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.
***********
SECTION-5
KEYBOARD INTERFACING
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.
The software must be such that the keyboard application must guard against
following Human Factors:
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 a 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.
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.
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.
TO DETECT MATRIX KEYBOARD USING 4 LEDs.
***********
SECTION-6
INTERFACING OF 7-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 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.
Schematic Diagram
As shown in the two schematic diagrams above, 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 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.
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.
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 portpins. Transistor must be used to handle the currents
required by the leds, typically 10 milliamperes 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.
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.
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)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.
While collector is connected to segment. For common anode and npn transistor
connecton is reversed
This is example of single sevan segment. For non multiplex another segment is
connected to remaining eight port pins.
SECTION-7
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 requires 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.
FEATURES:-
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.
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.
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.
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.
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 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 3.
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.
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.
***********
SECTION-8
LCD INTERFACING
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 :
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.
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.
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.
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.
This section shows you the details about how to control enable, register select,
read/write and data lines of LCD for its proper operation. Figure shows you read
timing waveform and figure shows write timing waveform.
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 connection required to interfaced an LCD to 89c51.
Here data lines of LCD are connected to 8 port of 89c51 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.
Circuit diagram:
**********
SECTION-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 interfaced 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 a 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.
2. 56-byte, battery-backed, nonvolatile (NV) RAM for data storage.
3. Two-wire serial interface..
4. Programmable squarewave output signal.
5. Automatic power-fail detect 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.
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 25ºC. UL recognized to ensure against reverse charging current when used
in conjunction with a lithium battery.
X1, X2 –
Connections for a standard 32.768kHz 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.768kHz
oscillator.
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:
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 associated with this acknowledge bit.
A device that acknowledges must pull down the SDA line during the acknowledge
clock pulse in such away 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.
Depending upon the state of the R/W bit, two types of data transfer are possible:
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.
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 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.
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 bettry is
connected to pin3 of DS-1307. VCC and GROUND is applied to rtc.
Fig:
*********
SECTION-10
DAC INTERFACING
10.1 Introduction
In electronics, a digital-to-analog converter (DAC or D-to-A) is a device for
converting a digital (usually binary) code to an analog signal (current, voltage
or electric charge). Digital-to-analog converters are interfaces between the
abstract digital world and analog real life. This section will show you how to
interface a DAC to 89c51 microcontroller. Then we will demonstrate how to generate
various waves such as sine, triangular and square on a scope using DAC. The
DAC0808 is an 8-bit monolithic digital-to-analog converter (DAC) featuring a full
scale output current settling time of 150 ns while dissipating only 33 mW with ±5V
supplies. No reference current (IREF) trimming is required for most applications
since the full scale output current is typically ±1 LSB of 255 IREF/256. Relative
accuracies of better than ±0.19% assure 8-bit monotonicity and linearity while
zero level output current of less than 4 μA provides 8-bit zero accuracy for
IREF³2 mA. The power supply currents of the DAC0808 is independent of bit codes,
and exhibits essentially constant device characteristics over the entire supply
voltage range.
Features:
1.relative accuracy: +0.19% error maximum.
2. full scale current match: + 1 lsb typical
3.fast setting time: 150 ns typical
4.noninverting digital inputs are ttl and cmos compatible
5.high speed multiplying input slew rate:8 ma/microsecond
6.powersuply voltage range:+ 4.5v to + 18v
7.low power consumption: 33 mw@ + 5v
DAC 0808 is 16 pin dual in package ic. To know how it works, detail description
of pins is given below.
A1-A8 :
These eight pins are digital inputs. For which digital input we want analog
output, it’s eight bits are given to A0-A8 pins.
VDC:
It is power supply voltage range between 4.5v to 5.5v. Typically 5v supply is
given.
Compensation :
Capacitor’s value increases with increasing resistor value r14 to make
proper phase margin. It is connected to compensation pin and other end is
connected to ground or vee.
VEE:
Using vee with capacitor increase negative supply rejection in case of vref (-) is
connected. Negative reference voltage should be 4v lower than vee.
DAC 0808 work on r/2r network.We are going to build a 8-bit digital to analog
conveter with parallel input, a circuit that will take as input a digital number
from 0 (00000000) to 255 (11111111), and output the relative value on a scale from
0 to 5v. An 8 bit converter will divide the 5 volts into 255 steps, each step
having a value of:
5/255 = 0.019v
Output voltage converter should be equal to the binary input multiplied by the
step value, e.g. for an input of 129 (1000 0001 in binary) the output voltage
should be:
The R-2R Ladder DAC, which is a binary weighted DAC that uses a repeating cascaded
structure of resistor values R and 2R. This improves the precision due to the
relative ease of producing equal valued matched resistors (or current sources).
However, wide converter performs slowly due to increasingly large RC-constants for
each added R-2R link.
FOUR-BIT D/A CONVERTER
One way to achieve D/A conversion is to use a summing amplifier.
This approach is not satisfactory for a large number of bits because it requires
too much precision in the summing resistors. This problem is overcome in the R-2R
network DAC.
The digital data entering thought the 8 lines (D0 to D7) are going to be converted
to an equivalent analog voltage (V out) by the mean of the R/2R resistor network.
Actually most of the commercial Digital to Analog converter ICs are based on this
same principle. The R/2R network is build by a set of resistors of 2 values, with
one of them double the other (example 10K and 20K). for example , one can use 1M
ohm and 470K ohm resistors, which is quite near to the R/2R ratio, and this small
difference didn't cause any detectable errors in most applications. However, if
you want to build a very precise DAC, be precise when choosing the values of the
resistors that will exactly match the R/2R ratio.
One last note here, you can build a DAC with any number of bits you
want, simple by enlarging the resistor network, by adding more R/2R branches (like
the one shaded in green), but you must keep the 2R resistance connected to ground.
Where the D's take the value 0 or 1. The digital inputs could be TTL voltages
which close the switches on a logical 1 and leave it grounded for a logical 0.
This is illustrated for 4 bits, but can be extended to any number with just the
resistance values R and 2R.
We are going to build an 8-bit digital to analog converter with parallel input. If
you don't know what this means, well its simply a circuit that will take as input
a digital number from 0 (00000000) to 255 (11111111), and output the relative
value on a scale from 0 to 5v.
By using the DAC we have generated square wave, triangular wave and sine wave.
SQUARE WAVE:
For generating the square wave we have made the samples low and high
alternatively and through DAC we have got the following waveforms, which can be
easily observed through CRO.
TRIANGLE WAVE:
For generating triangle waves we have incremented the samples from low to
high. Once it becomes high we have decremented the samples from high to low. Thus,
we have generated the triangle wave forms, which can be easily observed through
CRO.
SINE WAVE:
1. The total no. of samples are 256.then 128 of them is used for +ve part and the
rest of the 128 samples are used for –vet part.
2. Out of those 128 samples the 64th (40h) sample indicates the peak point. There
will be two peak points. One for negative and one for positive. So it makes 128
(80h).which is taken as a base value in calculation.
3. We have taken the memory addresses from 00 h to ff h. Then we have found the
angle. Further we have taken the sine value of that angle and then converted it to
a binary value and finally we have added that binary value in to the binary value
of 80h.the reason for adding it to 80h is that it is the base value(refer the
point 2).
EXAMPLE:
angle is symboled as a Q
Q = (360/256)*memory address
Q = (360/256) *10
= 1.411*10
= 14.11
Equation:
*******
SECTION-11
HOW TO GENERATE CLOCK USING
555 Timer ?
11.1. Introduction
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
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.
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.
Pin5 Control Voltage: An external voltage applied to this terminal changes the
threshold as well as the trigger voltage.
Pin6 Threshold: This is the noninverting terminal of comparator 1, which moniters
the voltage across external capacitor.
Pin7 Discharge: This pinis 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.
11.4. CALCULATION
CHARGING TIME tc: the time during which the capacitor charges from1/3 Vcc to
2/3Vcc is equal to the time the output is high and is given by
tc = 0.69(RA+RB) C
DISCHARGING TIME td: The time during which capacitor discharges from 2/3 to 1/3
Vcc is equal to the time the output is low and is given by
td =0.69(RB) C
T = tc + td
= 0.69(RA+2RB) C
F0 = 1/T
= 1.45/{(RA+2RB)
DUTY CYCLE: the duty cycle is the ratio of the time tc during which the output is
high to the total time period T. it is generally expressed as a percentage.
SECTION-12
ADC INTERFACING
Analog-to-digital converters are among the most widely used devices or data
acquisition type of application. Digital computers use binary (discrete) values,
but in the physical world everything is analog (continuous). Temperature,
Pressure, Light, humidity and velocity are the few examples of physical quantities
that we have to deal in our day-to-day life. Therefore we need Analog-to-digital
converter to convert real world applications into digital form that digital
computers can understand.
The ADC0808, ADC0809 data acquisition component is a onolithic CMOS device with an
8-bit analog-to-digital converter, 8-channel multiplexer and microprocessor
compatible control logic, the 8-bit A/D converter uses successive approximation as
the conversion technique.. The ADC0808 offers high-Speed, high accuracy, minimal
temperature dependence, excellent long-term accuracy and repeatability, and
consumes minimal power. These features make this device Ideally suited to
applications from process and machine control to consumer and automotive
applications.
The ADC 0808 is an 8-bit A-to-D converter, having data lines D0-D7. It
works on the principle of successive approximation. It has a total of eight
analogue input channels, out of which any one can be selected using address lines
A, B and C. Here, in this case, input channel IN0 is selected by grounding A, B
and C address lines. Usually the control signals EOC (end of conversion), SC
(start conversion), ALE (address latch enable) and OE (output enable) are
interfaced by means of a. microcontroller.. The ADC 0808 IC requires clock signal
of typically 550 kHz, which can be easily derived from 555 timer circuit. Which is
explained as above.
Features :
1.Easy interface to all microprocessors
2 Operates ratiometrically or with 5 VDC or analog span adjusted voltage ref.
3.No zero full-scale adjust required
4.8-channel multiplexer with address logic
5.0V to VCC input range
6.Outputs meet TTL voltage level specifications
Key specification
Resolution 8 Bits
Total Unadjusted Error ±½ LSB and ±1 LSB
Single Supply 5 VDC
Low Power 15 mW
Conversion Time 100 μs
The 256R ladder network approach was chosen over the conventional R/2R ladder
because of its inherent monotonicity, which guarantees no missing digital
codes.Monotonicity is particularly important in closed loop feedback control
systems. A non-monotonic relationship can cause oscillations that will be
catastrophic for the system. Additionally, the 256R network does not cause load
variations on reference voltage. The bottom resistor and the top resistor of the
ladder network are not the same value as the remainder of the network. The first
output transition occurs when the analog signal has reached +1⁄2 LSB and
succeeding output transitions occur every 1 LSB later up to full-scale.
The most important section of the A/D converter is the comparator. It is this
section which is responsible for the ultimate accuracy of the entire converter. It
is also the comparator drift which has the greatest influence on the repeatability
the device. The chopper-stabilized comparator converts the DC input signal into an
AC signal. This signal is then fed through a high gain AC amplifier and has the DC
level restored. This technique limits the drift component of the amplifier since
the drift is a DC component which is not passed by the AC amplifier. This makes
the entire A/D converter extremely insensitive to temperature, long term drift and
input offset errors.
********
SECTION-13
SENSOR INTERFACING
13.1 Introduction
Transducers convert physical data such as Temperature, light intensity, flow and
speed to electrical signal. Depending on the transducers the output produced is in
the form of voltage, current, resistance or capacitance. In other term transducers
are also called as sensors. We need to convert the output of sensors to voltage in
order to send input to an A/D converter. This conversion is commonly called Signal
conditioning. Signal conditioning can be current to voltage conversion or may be
simply signal amplification. Sensors can be of many kinds such as Temperature
sensor, motion sensor, light sensor etc. next section gives you a brief
introduction on LM35 Temperature sensor.
The LM35 series are precision integrated-circuit temperature sensors, whose output
voltage is linearly proportional to the Celsius (Centigrade) temperature. The LM35
thus has an advantage over linear temperature sensors calibrated in ° Kelvin, as
the user is not required to subtract a large constant voltage from its output to
obtain convenient Centigrade scaling. The LM35 does not require any external
calibration or trimming to provide typical accuracies of ±1.4°C at room
temperature and ±3.4°C over a full -55 to +150°C temperature range. Low cost is
assured by trimming and calibration at the wafer level. The LM35’s low output
impedance, linear output, and precise inherent calibration make interfacing to
readout or control circuitry especially easy. It can be used with single power
supplies, or with plus and minus supplies. As it draws only 60 µA from its supply,
it has very low self-heating, less than 0.1°C in still air.
Features:-
Here +Vs pin of LM35 is provided +5V Vcc, and the output pin is connected to one
of the eight inputs of ADC0808. ADC0808
Has a 8-bit resolution with maximum of 256 steps, and Lm35 produce 10mV for every
degree of temperature change. We can condition Vin of the ADC0808 to produce a
Vout of 2560mV, for Full-scale output. Therefore, to produce a full-scale Vout of
2.56 V for ADC0808, we need to set Vref(+) = 2.56 V. this makes Vout of ADC0808
corresponds directly to the temperature as monitored by LM35.
**********
SECTION-14
8255 INTERFACING
14.1 8255 features:
In this section we study the 8255 chip, one of the most widely used I/O
chips. The 8255 is a 40-pin DIP chip(see figure 14.1). It has three separately
accessible ports. The ports are each 8-bit, and are named as A, B, and C. The
individual ports of 8255 can be programmed to be input of output, and can be
changed dynamically. In addition, 8255 ports have handshaking capability, therby
allowing interface with the devices that also have handshaking signals, such as
printers. The handshaking capability of 8255 is not discussed since it is no long
used.
PA0-PA7
The 8-bit port A can be programmed as all input, of as all output, or all
bit as bidirectional input/output.
PB0-PB7
The 8-bit port B can be programmed as all input or as all output . Port B
cannot be used as a bidirectional port.
PC0-PC7
This 8-bit port C can be all input or all output. It can also be split into
two parts, CU(upper bits PC4-PC7) and CL(lower bits PC0-PC3). Each can be used for
input and output.
RD and WR
These two active low control signals are the input to 8255 chip. The RD and
WR signals from 89c51 are connected to these inputs.
RESET
This is an active-high signal input into the 8255 used to clear the control
register. When RESET is activated, all ports are initialized as input ports. In
many designs this pin is connected to the RESET output of the system bus of
grounded to make it inactive. Like all IC input pins, it should not be left
unconnected
While port A, B and C are used to input or output data it is the control register
that must be programmed to select the operation mode of 3 ports. The ports of 8255
can be programmed in any of the following modes
2. MODE-1
In this mode port A and port B can be used as 8-bit input port or 8-bit output
port with handshaking capability. Handshaking signals are provided by bits of port
C.
3. MODE-2
In this mode port A can be used as a Bi-directional I/O port with handshaking
capabilities whose signals are provided by port C. Port B can be used either in
simple I/O mode or handshaking Mode-1
Here we used 8255 for the purpose of expanding I/O pins of 89c51 microcontroller.
We connect various modules to 8255 port pins due to lack of I/O pins of 89c51, so
we just want to convey data between controller and devices. That is why, we have
used 8255 in Mode-0 i.e, Simple I/O Mode without Handshaking. Figure shows
connection of 8255 with 89c51.
Hardware connection:
1. The port of 89c51 which requires expansion is connected to the data pins of
8255 i.e, D0-D7. As shown in figure, here we have connected port p2 of 89c51 to
the data lines D0-D7 of 8255.
4. A1-A0 are also connected to 89c51 port pins. This pins are used to select
any of the port and control register. Here A1 and A0 are connected to P3.4 and
P3.5 respectively.
********
SECTION-15
SERIAL COMMUNICATION
PARALLAL TRANSFER
Asynchronous
Synchronous
The synchronous method transfers a block of data (characters) at a time, while the
asynchronous transfers a single byte at a time. It is possible to write software
to use either of this method but the program can be tedious and long. For this
reason there are special ic chips are made by manufacturer.
DUPLEX TRANSMISSION:
In this transmission mode the data can be transferred and received. if data is
transmitted one way at a time it is referred to as half duplex. if the data can
go both ways at same time it is full duplex. Full Duplex required two wire
conductors for the data lines in addition to signal and ground, one for
transmission and one for reception, in order to transmit and receive data
simultaneously.
FULL DUPLEX
HALF DUPLEX
SIMPLEX TRANSMISSION:
In our project we have used the simplex transfer. In which only transmitter can
send and receiver can receive. The data transfer is always one way. At the
transmitter side we have connected input device and at the receiver side we have
connected the display, from which output can be observed easily.
SERIAL COMMUNICATION:
The data coming in at the receiving end of the data line in a serial data
transfer is all 0s and 1s; it is difficult to make sense of the data unless the
sender and receiver agree on a set of rules,”protocol”, on how the data is packed,
how many bits constitute a character and when data begins and ends.
SERIAL COMMUNICATION:
The AT89C51 has two pins that are used specifically for transferring and receiving
data serially. These two pins are called TxD and RxD ,they are the part of the
port3 group(p3.0 and p3.1). pin 11 of the AT89C51 is assigned to TxD and pin 10
(p3.0) is designated as RxD. This pin is TTL compatible; so if one wants to make
it RS232 compatible then they require a line driver. e.g MAX232 chip.
********
SECTION-15
TROUBLESHOOTING & TESTING
TRAINER KIT
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.
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.
By making the selection switch position to 0011, Single seven segment and 4×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.
By making the selection switch position to 0100, multiplexed seven segments and
4×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 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. 8255:
By making the selection switch position to 1000, 8255 Program will be selected and
the practical name will be displayed on LCD. In this case, a switch is given when
the switch is pressed LCD will shows you the data and port p2 which is read off,
via 8255
10. ADC0808:
By making the selection switch position to 1010, ADC and Temperature sensor
program will be selected and the practical name will be displayed on LCD. In
these, case the output of temperature sensor is converted into Digital via ADC0808
and is display on LCD. E.g. 38 °C .
12. DAC0808:
By making the selection switch position to 1011, DAC0808 program will be selected
and the practical name will be displayed on LCD. Here there are 4 switches from
switch0- switch3. As the switch 0 is pressed it gives the analog voltage of given
digital data. This data is observed with the help of multimeter. When, Switch 1 is
pressed then it shows square wave on CRO.
When, Switch 2 is pressed then it shows triangular wave on CRO.
And finally when, Switch 3 is pressed then it shows sine wave on CRO.
By making the selection switch position to 1100, Serial communication program will
be selected and the practical name will be displayed on LCD. In serial
communication whatever has been transferred from the transmitter microcontroller
is observed on seven segment at the receiver microcontroller..
14. Lcd:
Here lcd is connected with all the devices. By using the selection switch the
topic which has been selected, is displayed on LCD. If selection switch position
is 1011 then it will displays as follows:
“TOPIC”
“DAC INTERFACING”
LED:
Once you make led ON and if it doesn’t glow then follow the steps given
below for trouble shooting of the circuit.
2. Check the anode and cathode connection ,ideally anode is connected with Vcc and
cathode with the ground.
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.
5. Check the other devices which are connected with the key board.
seven segment:
if you will not get the desired display on seven segment then follow
the steps ,given below for trouble shooting of this circuit.
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.
5.check the other devices which are connected with the eeprom
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.
RTC:
From an RTC if you are not getting the exact output then folloe the steps
given below for trouble shooting of this circuit.
DAC:
If you are not getting the exact analog waveform through the DAC then follow
,the steps given below for the trouble shooting of the circuit.
ADC:
If you are not getting the exact digital data through ADC0808 then follow the
the steps given below for trouble shooting of this circuit.
Sensor:
If you are not able to sense the exact temperature through the LM35 then
follow the steps given below for the trouble shooting of this circuit.
8255:
if yor not getting the exact output of the devices which are connected with
8255 then follow the steps given below for the trouble shooting of this circuit.
Serial communication:
If you are not able to transmit or receive the through transmitter and
receiver then follow the steps given below for the trouble shooting of this
circuit.
********
Books:
1. 8051 Microcontroller and
Embedded systems- Mazidi.
Websites:
1. www.wikipedia.com
2. www.chip&cheap.com
3. www.digchip.com
4. www.sunrom.com
WEEK
6
7
10
11
12
13
14
15
16
Activity January February March April
Project
Understanding
Analysis
Learning
Process
Final
Documentation
*******