Вы находитесь на странице: 1из 40

BEE202_Microprocessor

Systems

Post_1:
PIN connections of the
8051
in order to enable microcontroller to operate properly it is
necessary to provide :
Power supply
Reset signal
Clock signal
Obviously, all this is about very simple circuits, but it does not
have to be always like that. If device is used for handling
expensive machines or for maintaining vital functions,
everything becomes more and more complicated! This kind of
solution is quite enough for the time being...
Power supply
Although this circuit can operate with
different power supply voltage, why to
test Murphys low?! Voltage of 5V is
so common that it imposes itself. The
circuit, shown on the figure, uses
cheap voltage stabilisator LM7805 and
provides high-quality voltage level and
guite enough current to enable
microcontroller and peripheral
electronics to operate ( sufficient
current in this case amounts to 1A)
Reset signal
In order to operate properly, the microcontroller
must see logic 0 (0V) on reset pin RS (It explains
connection pin-resistor 10K-ground). Pushbutton
which connects reset pin RS to power supply VCC is
not necessary but it is almost always built in
because it enables microcontroller safe return to
normal operating conditions when the things go
wrong. By activating this pin, 5V is brought to it, the
microcontroller is reset and program starts
execution from the beginning.
Clock signal
Although the microcontroller has built
in oscillator, it cannot operate without
two external condensators and quartz
crystal which stabilize its frequency
(microcontrollers operating speed).
Naturally, there are some
exceptions too:
if this solution cannot be applied
for some reason, there are
always alternative ones. One of
them is to bring clock signal
from special source through
invertor. See the first figure on
the left; on the next slide.
In addition to these hardware
solutions, a simple software solution
is commonly applied too: when a
program tests the state of some input
pin and finds changes, the check
should be done one more time after
certain time delay. If the change is
confirmed it means that switch (or
pushbutton) has changed its position.
The advantages of such solution are
obvious: it is free of charge, effects of
disturbances are eliminated too and it
can be adjusted to the worst-quality
contacts. Disadvantage is the same
as in case of using RC filter-pulses
shorter than program delay cannot be
registered.
The simplest solution is to connect simple RC circuit
which will suppress each quick voltage change.
Since the bouncing time is not defined, the values of
elements are not strictly determined. In the most
cases, the values shown on figure are sufficient.
If complete safety is needed, radical measures
should be taken! The circuit, shown on the figure
(RS flip-flop), changes logic state on its output with
the first pulse triggered by contact bounce. Even
though this is more expensive solution (SPDT
switch), the problem is definitely resolved! Besides,
since the condensator is not used, very short pulses
can be also registered in this way.
Optocoupler is a device commonly used to galvanically
separate microcontrollers electronics from potentionally
dangerous currents and voltages in environment.
Optocouplers usually have one, two or four light sources (LE
diodes) on their input while on their output, opposite to
diodes, there are the same number of elements sensitive to
light (phototransistors, photo-thyristors or photo-triacs). The
point is that there is no electrical contact between input and
output, but the signal is transferred by light. For this isolation
to make sense, electrical power supply of diodes and photo-
sensitive elements must be independent. Being connected in
this way, the microcontroller and expensive additional
electronics are completely protected from high voltage and
disturbances which in practice are the most common cause
of destroying, damaging or unstable operating of electronic
devices. Most frequently used optocouplers are those with
phototransistors on their output. In case the model of
optocouplers with internal base-to-pin 6 connection is on
disposal (there are optocouplers without it), the base can be
left unconnected. Optional connection, decreasing effects of
disturbances by eliminating very short pulses, is on the
Relays are elements connected to ouput pins of the
microcontroller and used to turn on/off all that being out of
board which has sensitive components: motors,
transformators, heaters, bulbs, high-voltage components,
antenna systems etc. There are various types of relays but
all have the same operating principle: when a current flows
through the coil, it makes or brakes machanical connection
between one or more pairs of contacts. As it is case with
optocouplers, there is no galvanically connection (electrical
contact) between input and output circuits. Relays usually
demand both higher voltage and current to start operating
but there are also miniature versions which can be activated
with a low current directly obtained from the
microcontrollers pin.
Below figure presents one solution specific to the 8051
microcontrollers. In this very case, darlington transistor is
used to activate relays because of its high current gain. This
is not in accordance with rules, but it is necessary in case
of logic one activation since the current is then very low (pin
acts as input)!
Light-emitting diodes are elements
for light signalization in electronics.
They are manufactured in different
shapes, colors and sizes. For their low
price, low consumption and simple
use, they have almost completely
pushed aside other light sources-
bulbs at first place. They perform
similar to common diodes with the
difference that they emit light when
current flows through them.
Since the 8051 microcontrollers can
provide only low input current and
since their pins are configured as
outputs when voltage level on them
is equal to 0, direct connectining to
LEDs is carried out as it is shown on
figure (Low current LED, cathode is
connected to output pin).
Basically, LED displays are nothing
else but several LEDs moulded in the
same plastic case. Diodes are
arranged so that different marks-
commonly digits: 0, 1, 2,...9 are
displayed by activating them. There
are many types of displays composed
of several dozens of built in diodes
which can display different symbols.
The most commonly used are so called 7-segment displays.
They are composed of 8 LEDs, 7 segments are arranged as a
rectangle for symbol displaying and there is additional
segment for decimal point displaying. In order to simplify
connecting, anodes and catodes of all diodes are connected to
the common pin so that there are common cathode displays
and common anode displays. Segments are marked with the
latters Ato G as shown on the figure on the left. When
connecting, each diode is treated independently, which means
that each must have its own conductor for current limitation.
When connecting displays to the microcontroller, the greatest
problem is a great deal of valuable I/O pins which they
occupy, especially if it is needed to display several-digit
numbers. Problem is more than obvious if for example it is
needed to display two 6-digit numbers (a simple calculation
shows that 96 output pins are needed)!The solution on this
problem is called MULTIPLEXING. This is how optical illusion
based on the same operating principle as filmcamera occurs.
The principle is that only one digit is active but by quick
changing one gets impression that all digits of a number are
The most commonly used are so called 7-segment displays.
They are composed of 8 LEDs, 7 segments are arranged as
a rectangle for symbol displaying and there is additional
segment for decimal point displaying. In order to simplify
connecting, anodes and catodes of all diodes are connected
to the common pin so that there are common cathode
displays and common anode displays. Segments are marked
with the latters Ato G as shown on the figure on the left.
When connecting, each diode is treated independently,
which means that each must have its own conductor for
current limitation.
When connecting displays to the microcontroller, the
greatest problem is a great deal of valuable I/O pins which
they occupy, especially if it is needed to display several-
digit numbers. Problem is more than obvious if for example
it is needed to display two 6-digit numbers (a simple
calculation shows that 96 output pins are needed)!The
solution on this problem is called MULTIPLEXING. This is how
optical illusion based on the same operating principle as
filmcamera occurs. The principle is that only one digit is
active but by quick changing one gets impression that all
In special subroutine, a several digit number must be first separated in
units, tens etc. Afterwards, each of these digits must be stored in
specific byte. In order to make these digits familiar to us, masking is
carried out. Basically, it is a simple subroutine by which binary format
of each number is replaced by different combination of bits. For
example, the digit 8 (0000 1000) is replaced by binary digit 0111 111 in
order to activate all LEDs which represent digit 8 on display. The only
diode, inactive in this case is reserved for decimal point. If a
microcontrollers port is connected to display in a way that bit 0
activates segment a, bit 1 activates segment b, bit 2 segment c
etc., the table below shows mask for each digit.
Beside digits 0 to 9, some letters of alphabet : A, C, E, J, F, U, H, L, b, c,
d, o, r, t can be displayed by appropriate masking.
If common cathode displays are used all units in the table should be
replaced by zeros and vice versa. In that case NPN transistors should
be also used as drivers

Digits to
Display Segments
display

dp a b c d e f g
0 1 0 0 0 0 0 0 1
1 1 0 0 1 1 1 1 1
2 1 0 0 1 0 0 1 0
3 1 0 0 0 0 1 1 0
4 1 1 0 0 1 1 0 0
5 1 0 1 0 0 1 0 0
6 1 0 1 0 0 0 0 0
7 1 0 0 0 1 1 1 1
8 1 0 0 0 0 0 0 0
9 1 0 0 0 0 1 0 0

Вам также может понравиться