Download In the project “Car Parking System”

Document related concepts

Electrification wikipedia , lookup

Spark-gap transmitter wikipedia , lookup

History of electric power transmission wikipedia , lookup

Flip-flop (electronics) wikipedia , lookup

Stray voltage wikipedia , lookup

Transistor wikipedia , lookup

Islanding wikipedia , lookup

Brushless DC electric motor wikipedia , lookup

Current source wikipedia , lookup

Three-phase electric power wikipedia , lookup

Electric machine wikipedia , lookup

Electric motor wikipedia , lookup

Power inverter wikipedia , lookup

Pulse-width modulation wikipedia , lookup

Brushed DC electric motor wikipedia , lookup

AC motor wikipedia , lookup

Voltage regulator wikipedia , lookup

Two-port network wikipedia , lookup

Resistive opto-isolator wikipedia , lookup

Voltage optimisation wikipedia , lookup

Alternating current wikipedia , lookup

Mains electricity wikipedia , lookup

Schmitt trigger wikipedia , lookup

Power electronics wikipedia , lookup

Induction motor wikipedia , lookup

Rectifier wikipedia , lookup

Buck converter wikipedia , lookup

Variable-frequency drive wikipedia , lookup

Switched-mode power supply wikipedia , lookup

Stepper motor wikipedia , lookup

Immunity-aware programming wikipedia , lookup

Opto-isolator wikipedia , lookup

Transcript
CAR PARKING SYSTEM
Introduction:
In the project “Car Parking System” we have shown the concept of an automatic car
parking system. As in the modern world everything is going automatic we have built a
system which will automatically sense the entry and exit of cars through the gate and
then display the number of cars in the parking lot. Even we can set a maximum
capacity of cars with the help of user interface given in the hardware in the form of
switches so that there is no congestion. We have deployed a microcontroller which is
used to sense the movement of cars and depending upon whether there is a capacity of
cars to enter, it either opens the gate or not. It is also possible to open a gate when any
car enters in the parking lot or close the door when a car exits from the parking lot.
There are two sets of sensors: one on the first gate (entry gate) and one on the second
gate (exit gate). When a car arrives at the door the microcontroller receives the signal
from the entry sensors and then checks whether there is a capacity of cars to be
accommodated. Simultaneously it will also display the number of cars present in the
parking lot on a LCD screen and also opens the gate. When a car moves out of the
parking area the microcontroller reduces the count displayed accordingly and also
closes the gate. The user will have an option to set the maximum count for the cars
with the help of switches connected to the microcontroller.
The sensing of entry and exit of cars is done with the help of Infrared transmitters and
receivers. Before the door the Infrared transmitter is mounted on one side and the
receiver is placed directly in front of the transmitter across the door. When a car
arrives the Infrared beam is blocked by the car and the receiver is devoid of Infrared
rays and its output changes. This change in output is sensed by the microcontroller
and accordingly it increments the count and opens the door if there is some capacity.
The procedure for the exit of the cars is similar as the entry.
Block Diagram of the Project:
MOTOR
INTRUDER2
(FOR EXIT
GATE)
AMPLIFIER
INTRUDER1
(FOR ENTRY
GATE)
LCD
ISOLATOR
CIRCUIT
MICROCONTROLLER
KEY PAD
BUZZER
POWER
SUPPLY1
(+5V)
Microcontroller unit:
Microcontroller used in the project is AT89s52. This part is the heart of the project. It
checks for the entry and exit of the car. It continuously polls the pins from where we
receive the signal from the intruder circuits.
When it detects the car from the entry gate then it checks whether there is any vacant
space in the parking lot. If there is vacant space then it opens the door and increases
the over all count in the parking lot by one. And after 3 seconds automatically closes
the door. And if it detects the car from the exit gate then it decreases the count by one.
Interfacing with switches (keypad):
Interfacing with keypad makes instrument menu driven user friendly. This will help to
the user to select the maximum capacity of the parking area.
Display unit (LCD)
LCD makes this instrument user friendly by displaying everything on the display. It is
an intelligent LCD module, as it has inbuilt controller which convert the alphabet and
digit into its ASCII code and then display it by its own i.e. we do not required to
specify which LCD combination must glow for a particular alphabet or digit.
Stepper Motor:
Stepper motor is used to open and close the door. It is interfaced with microcontroller
and takes command from the microcontroller to rotate some particular specified angle.
It can be interfaced with MCU as shown below:
OPTOISOLATOR
IC (MCT- 2E)
POWER AMPLIFIER
USING BC369
TRANSISTOR
Motor Winding
The switching circuit is comprises of an optocoupler which will isolate the controller
from the outer spikes or fluctuations or from the external hardware and at the same
time it drives a power transistor i.e. make it on when a signal from the controller pin
is applied to it. Optocoupler actually comprises of a diode and a phototransistor. It
comes in a DIP IC package. Thus signal from the MCU is given to the LED part or
the driving part. When LED begins to glow then the phototransistor acts as on switch
or short circuit. This output is given to power transistor, which will amplify the
current of the signal and then use it to drive winding of the Motor. Ground is directly
given to the common of the Motor. And +vcc is provided to the motor winding
through the amplifier.
If user wants to switch ON the Motor winding, then the microcontroller is sending a
signal to the optocoupler then ultimately that supply to that winding is ON. Reverse is
the case when MCU does not send any signal and thus, supply to that winding is OFF.
Intruder:
The 555 timer is used in the Infrared transmitters and receivers. At the transmitter it is
used to produce a pulse of 38 kHz. This pulse is then fed to the Infrared LED so that it
produces bursts of Infrared energy at the rate of 38 kHz. The reason of transmitting
frequency being this much particular value is that the Infrared receiver (i.e. TSOP
1738) works at maximum efficiency when the Infrared rays falling on it, are of 38
kHz. At the receiver the 555 timer is used to pass the output of the Infrared receiver to
the microcontroller. We are using the 555 timer in mono- stable operation where one
external resistor and capacitor control the pulse width. The 555 timer has a number of
features. When there is a person between receiver and transmitter then the trigger pin
gets low due to which at the output pin of timer we get a high pulse. This high pulse is
applied to the pin of microcontroller which in turn senses this pin and activates the
next task.
INTRUDER SENSOR
_
C1
12V DC
+
C
C2
CAP NP
D2
R4
7
R3
R
5
555 IC
8
IR LED
6
1
R
4
3
2
R2
R
R1
R
D1
2
1
TO MICROCONTROLLER GROUND
PHOTODIODE
COMMON
NC
1
0
K1
2
Q1
BC547
5
TO MICROCONTROLLER PORT 2.1
3
3
4
0
R1-100K, R2-1K, R3-470E, R4-47K
1
2
NO
RELAY SPDT
C1-22MF/25V, C2-104PF
Title
<Title>
Size
A
Date:
Document Number
<Doc>
Monday , January 01, 2001
Rev
<Rev Code>
Sheet
1
of
1
Entrance or Exit Detector:
The entrance or the exit of a person in the room is detected by using two infrared
modules. Each module will contain an IR transmitter and an IR receiver. Before the
door the Infrared transmitter is mounted on one side and the receiver is placed directly
in front of the transmitter on the other side of door. Infrared transmitter will
continuously transmit IR waves and the receiver will continuously receive IR waves.
The IR transmitter will use an IR LED. This LED can transmit IR whenever it is
supplied from a 5-volt voltage source. The receiver can either be photodiode if the
width of the door is less or a special IR receiver known as the IR eye. Now whether a
person enters or exits, the beam of each module will be interrupted that is the output
from the two receivers which actually is the pulse output from two different
monostable multivibrator using 555 timers. Thus the outputs from the two receivers
are in the form of pulse.
BLOCK DIAGRAM FOR IR RECEIVER
O/P TO MCU
OUTPUT
PHOTODIODE
IR INPUT
555 TIMER
MONOSTA
BLE
POWER
SUPPLY
VIBRATOR
At the receiver side the IR eye or the IR demodulator will demodulate the IR signal
and then give its output to the trigger of a 555 timer, which is mounted as a
monostable vibrator. Thus whenever there is an interrupt in the IR beam then
corresponding trigger will go from high to low thus the output from the 555 timer will
be a pulse which is then generated as in monostable mode by applying a –ve voltage
at the trigger a pulse is generated.
Features of the Project:

Powered by +5V & +12V supply

Current consumption 0.45mA for Microcontroller circuit, 0.75mA for
switching circuit, 200mA for amplification circuit

Automatic detection of any incoming/outgoing car

Automatic opening and closing of entry gate

User interface using LCD and switches

Always display the number of cars present in the Parking Lot
Various Components used in various Modules of the Project along
with specifications and quantity:
Power Supply Unit1 (+5V):
S. No.
1.
2.
3.
4.
5.
Component
PCB
Transformer
Diode
Cap.
Regulator
Specification
Designed
9-0-9, 500mA
1N4007
1000 µF
7805
Qty.
1
1
4
1
1
Power Supply Unit2 (+12V):
S. No.
1.
2.
3.
4.
5.
Component
PCB
Transformer
Diode
Cap.
Regulator
Specification
Designed
9-0-9, 500mA
1N4007
1000 µF
7812
Qty.
1
1
4
1
1
Specification
Designed
40 Pin
11.0592MHZ
33 PF
10µF
AT89s52
Qty.
1
1
1
2
1
1
1
1
Microcontroller Unit:
S. No.
1.
2.
3.
4.
Component
PCB
Base
Crystal
Cap.
5.
6.
7.
MCU
Micro switch
Resistance
10K Ω
LCD Module:
S. No. Component
Specification Qty.
1.
LCD Connector 16 Pin
1
2.
LCD
16 x 2
1
Keypad Module (For input to MCU):
S. No. Component
Specification Qty.
1.
PCB
G.P.PCB
1
2.
Micro Switches 2 Pin
3
Intruder Module1 (For Entry gate):
S. No.
1.
2.
3.
4.
Component
PCB
Base
IC Timer
Resistance
5.
6.
IR Pair
Capacitor
Specification
Designed
8 Pin
555
10K Ω
470 Ω
100K
Qty.
1
1
1
1
1
1
1
10µF
1
103 (0.01 µF) 1
Intruder Module2 (For Exit gate):
S. No.
1.
2.
3.
4.
Component
PCB
Base
IC Timer
Resistance
5.
6.
IR Pair
Capacitor
Specification
Designed
8 Pin
555
10K Ω
470 Ω
100K
Qty.
1
1
1
1
1
1
1
10µF
1
103 (0.01 µF) 1
Motor Driver Card:
S. No. Component
1.
PCB
2.
3.
4.
5.
6.
Specification
Designed
General
Base
6 Pin
Opto coupler 817
Resistance
470Ω
Transistor
369
Stepper Motor 12V
Qty.
1
1
4
4
4
4
1
Detailed Hardware Description:
POWER SUPPLY
Power supplies are designed to convert high voltage AC mains to a suitable low
voltage supply for electronics circuits and other devices. A power supply can be
broken down into a series of blocks, each of which performs a particular function.
For example a 5V regulated supply:
Each of the block has its own function as described below
1. Transformer – steps down high voltage AC mains to low voltage AC.
2. Rectifier – converts AC to DC, but the DC output is varying.
3. Smoothing – smoothes the DC from varying greatly to a small ripple.
4. Regulator – eliminates ripple by setting DC output to a fixed voltage.
TRANSFORMER
Transformers convert AC electricity from one voltage to another with little loss of
power. Transformers work only with AC and this is one of the reasons why mains
electricity is AC. The two types of transformers

Step-up transformers increase voltage,

Step-down transformers reduce voltage.
Transformer
Most power supplies use a step-down transformer to reduce the dangerously
high mains voltage (230V in UK) to a safer low voltage. The input coil is called
the primary and the output coil is called the secondary. There is no electrical
connection between the two coils, instead they are linked by an alternating
magnetic field created in the soft-iron core of the transformer. The two lines in the
middle of the circuit symbol represent the core.
Transformers waste very little power so the power out is (almost) equal to the power
in. Note that as voltage is stepped down current is stepped up. The ratio of the number
of turns on each coil, called the turn ratio, determines the ratio of the voltages. A stepdown transformer has a large number of turns on its primary (input) coil which is
connected to the high voltage mains supply, and a small number of turns on its
secondary (output) coil to give a low output voltage.
Turns ratio = Vp = Np
Vs
And
Ns
Power Out = Power In
Vs  Is = Vp  Ip
Where
Vp = primary (input) voltage
Np = number of turns on primary coil
Ip = primary (input) current
Ns = number of turns on secondary coil
Is = secondary (output) current
Vs = secondary (output) voltage
BRIDGE RECTIFIER
A bridge rectifier can be made using four individual diodes, but it is also available in
special packages containing the four diodes required. It is called a full-wave rectifier
because it uses all AC wave (both positive and negative sections). 1.4V is used up in
the bridge rectifier because each diode uses 0.7V when conducting and there are
always two diodes conducting, as shown in the diagram below. Bridge rectifiers are
rated by the maximum current they can pass and the maximum reverse voltage they
can withstand (this must be at least three times the supply RMS voltage so the
rectifier can withstand the peak voltages). In this alternate pairs of diodes conduct,
changing over the connections so the alternating directions of AC are converted to the
one direction of DC.
OUTPUT – Full-wave Varying DC
SMOOTHING
Smoothing is performed by a large value electrolytic capacitor connected across the
DC supply to act as a reservoir, supplying current to the output when the varying
DC voltage from the rectifier is falling. The diagram shows the unsmoothed
varying DC (dotted line) and the smoothed DC (solid line). The capacitor charges
quickly near the peak of the varying DC, and then discharges as it supplies current to
the output.
Note that smoothing significantly increases the average DC voltage to almost the peak
value (1.4 × RMS value). For example 6V RMS AC is rectified to full wave DC of
about 4.6V RMS (1.4V is lost in the bridge rectifier), with smoothing this
increases to almost the peak value giving 1.4 × 4.6 = 6.4V smooth DC.
Smoothing is not perfect due to the capacitor voltage falling a little as it discharges,
giving a small ripple voltage. For many circuits a ripple which is 10% of the supply
voltage is satisfactory and the
equation below gives the required value for the
smoothing capacitor. A larger capacitor will give fewer ripples. The capacitor value
must be doubled when smoothing half-wave DC.
Smoothing capacitor for 10% ripple, C = 5 × Io
Vs × f
Where
C = smoothing capacitance in farads (F)
Io = output current from the supply in amps (A)
Vs = supply voltage in volts (V), this is the peak value of the unsmoothed
DC
f
= frequency of the AC supply in hertz (Hz), 50Hz in the UK
REGULATOR
Voltage regulator ICs are available with fixed (typically 5, 12 and 15V) or variable
output voltages. They are also rated by the maximum current they can pass. Negative
voltage regulators are available, mainly for use in dual supplies. Most regulators
include some automatic protection from excessive current (‘overload protection') and
overheating (‘thermal protection'). Many of the fixed voltage regulator ICs has 3 leads
and look like power transistors, such as the 7805 +5V 1A regulator shown on the
right. They include a hole for attaching a heat sink if necessary.
Working of Power Supply
 Transformer
The low voltage AC output is suitable for lamps, heaters and special AC motors. It is
not suitable for electronic circuits unless they include a rectifier and a smoothing
capacitor.
 Transformer + Rectifier
The varying DC output is suitable for lamps, heaters and standard motors. It is not
suitable for electronic circuits unless they include a smoothing capacitor.
 Transformer + Rectifier + Smoothing
The smooth DC output has a small ripple. It is suitable for most electronic circuits.
 Transformer + Rectifier + Smoothing + Regulator
J1
1000uf
D2
3
2
1
gnd
1
C1
D3
VIN
GND
LM7805
1N4007
VOUT
2
+5V
3
D1
V
D4
The regulated DC output is very smooth with no ripple. It is suitable for all electronic
circuits.
The Microcontroller:
In our day to day life the role of micro-controllers has been immense. They are used
in a variety of applications ranging from home appliances, FAX machines, Video
games, Camera, Exercise equipment, Cellular phones musical Instruments to
Computers, engine control, aeronautics, security systems and the list goes on.
Microcontroller versus Microprocessors:
What is the difference between a microprocessor and microcontroller? The
microprocessors (such as 8086, 80286, 68000 etc.) contain no RAM, no ROM and no
I/O ports on the chip itself. For this reason they are referred as general- purpose
microprocessors. A system designer using general- purpose microprocessor must add
external RAM, ROM, I/O ports and timers to make them functional. Although the
addition of external RAM, ROM, and I/O ports make the system bulkier and much
more expensive, they have the advantage of versatility such that the designer can
decide on the amount of RAM, ROM and I/o ports needed to fit the task at hand. This
is the not the case with microcontrollers. A microcontroller has a CPU (a
microprocessor) in addition to the fixed amount of RAM, ROM, I/O ports, and
timers are all embedded together on the chip: therefore, the designer cannot add any
external memory, I/O, or timer to it. The fixed amount of on chip RAM, ROM, and
number of I/O ports in microcontrollers make them ideal for many applications in
which cost and space are critical. In many applications, for example a TV remote
control, there is no need for the computing power of a 486 or even a 8086
microprocessor. In many applications, the space it takes, the power it consumes, and
the price per unit are much more critical considerations than the computing power.
These applications most often require some I/O operations to read signals and turn on
and off certain bits. It is interesting to know that some microcontroller’s manufactures
have gone as far as integrating an ADC and other peripherals into the
microcontrollers.
Microcontrollers for Embedded Systems:
In the literature discussing microprocessors, we often see a term embedded system.
Microprocessors and microcontrollers are widely used in embedded system products.
An embedded product uses a microprocessor (or microcontroller) to do one task and
one task only. A printer is an example of embedded system since the processor inside
it performs one task only: namely, get data and print it. Contrasting this with a IBM
PC which can be used for a number of applications such as word processor, print
server, network server, video game player, or internet terminal. Software for a variety
of applications can be loaded and run. Of course the reason a PC can perform myriad
tasks is that it has RAM memory and an operating system that loads the application
software into RAM and lets the CPU run it. In an embedded system, there is only one
application software that is burned into ROM. A PC contains or is connected to
various embedded products such as the keyboard, printer, modem, disk controller,
sound card, CD-ROM driver, mouse and so on. Each one of these peripherals has a
microcontroller inside it that performs only one task. For example, inside every mouse
there is a microcontroller to perform the task of finding the mouse position and
sending it to the PC.
Although microcontrollers are the preferred choice for many embedded systems,
there are times that a microcontroller is inadequate for the task. For this reason, in
many years the manufacturers for general-purpose microprocessors have targeted
their microprocessor for the high end of the embedded market.
Introduction to 8051:
In 1981, Intel Corporation introduced an 8-bit microcontroller called the 8051. This
microcontroller had 128 bytes of RAM, 4K bytes of on-chip ROM, two timers, one
serial port, and four ports (8-bit) all on a single chip. The 8051 is an 8-bit processor,
meaning the CPU can work on only 8- bit pieces to be processed by the CPU. The
8051 has a total of four I/O ports, each 8- bit wide. Although 8051 can have a
maximum of 64K bytes of on-chip ROM, many manufacturers put only 4K bytes on
the chip.
The 8051 became widely popular after Intel allowed other
manufacturers to make any flavor of the 8051 they please with the condition that they
remain code compatible with the 8051. This has led to many versions of the 8051 with
different speeds and amount of on-chip ROM marketed by more than half a dozen
manufacturers. It is important to know that although there are different flavors of the
8051, they are all compatible with the original 8051 as far as the instructions are
concerned. This means that if you write your program for one, it will run on any one
of them regardless of the manufacturer. The major 8051 manufacturers are Intel,
Atmel, Dallas Semiconductors, Philips Corporation, Infineon.
AT89C51 From ATMEL Corporation:
This popular 8051 chip has on-chip ROM in the form of flash memory. This is ideal
for fast development since flash memory can be erased in seconds compared to
twenty minutes or more needed for the earlier versions of the 8051. To use the
AT89C51 to develop a microcontroller-based system requires a ROM burner that
supports flash memory: However, a ROM eraser is not needed. Notice that in flash
memory you must erase the entire contents of ROM in order to program it again. The
PROM burner does this erasing of flash itself and this is why a separate burner is not
needed. To eliminate the need for a PROM burner Atmel is working on a version of
the AT89C51 that can be programmed by the serial COM port of the PC.
Atmel Microcontroller AT89C51
Hardware features

40 pin Ic.

4 Kbytes of Flash.

128 Bytes of RAM.

32 I/O lines.

Two16-Bit Timer/Counters.

Five Vector.

Two-Level Interrupt Architecture.

Full Duplex Serial Port.

On Chip Oscillator and Clock Circuitry.
Software features

Bit Manipulations

Single Instruction Manipulation

Separate Program And Data Memory

4 Bank Of Temporary Registers

Direct, Indirect, Register and Relative Addressing.
In addition, the AT89C51 is designed with static logic for operation down to zero
frequency and supports two software selectable power saving modes. The Idle Mode
stops the CPU while allowing the RAM, timer/counters, serial port and interrupt
system to continue functioning. The Power Down Mode saves the RAM contents but
freezes the oscillator disabling all other chip functions until the next hardware reset.
The Atmel Flash devices are ideal for developing, since they can be reprogrammed
easy and fast. If we need more code space for our application, particularly for
developing 89Cxx projects with C language. Atmel offers a broad range of
microcontrollers based on the 8051 architecture, with on-chip Flash program memory.
Interal Architecture of AT89C51
Pin description:
The 89C51 have a total of 40 pins that are dedicated for various functions such as I/O,
RD, WR, address and interrupts. Out of 40 pins, a total of 32 pins are set aside for the
four ports P0, P1, P2, and P3, where each port takes 8 pins. The rest of the pins are
designated as Vcc, GND, XTAL1, XTAL, RST, EA, and PSEN. All these pins except
PSEN and ALE are used by all members of the 8051 and 8031 families. In other
words, they must be connected in order for the system to work, regardless of whether
the microcontroller is of the 8051 or the 8031 family. The other two pins, PSEN and
ALE are used mainly in 8031 based systems.
Vcc
Pin 40 provides supply voltage to the chip. The voltage source is +5V.
GND
Pin 20 is the ground.
Oscillator Characteristics:
XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier
which can be configured for use as an on-chip oscillator, as shown in Figure. Either a
quartz crystal or ceramic resonator may be used. To drive the device from an external
clock source, XTAL2 should be left unconnected while XTAL1 is driven as shown in
Figure.
Oscillator Connections
It must be noted that there are various speeds of the 8051 family. Speed refers to the
maximum oscillator frequency connected to the XTAL. For example, a 12 MHz chip
must be connected to a crystal with 12 MHz frequency or less. Likewise, a 20 MHz
microcontroller requires a crystal frequency of no more than 20 MHz. When the 8051
is connected to a crystal oscillator and is powered up, we can observe the frequency
on the XTAL2 pin using oscilloscope.
RST
Pin 9 is the reset pin. It is an input and is active high (normally low). Upon
applying a high pulse to this pin, the microcontroller will reset and terminate all
activities. This is often referred to as a power –on reset. Activating a power-on reset
will cause all values in the registers to be lost. Notice that the value of Program
Counter is 0000 upon reset, forcing the CPU to fetch the first code from ROM
memory location 0000. This means that we must place the first line of source code in
ROM location 0000 that is where the CPU wakes up and expects to find the first
instruction. In order to RESET input to be effective, it must have a minimum duration
of 2 machine cycles. In other words, the high pulse must be high for a minimum of 2
machine cycles before it is allowed to go low.
EA
All the 8051 family members come with on-chip ROM to store programs. In such
cases, the EA pin is connected to the Vcc. For family members such as 8031 and 8032
in which there is no on-chip ROM, code is stored on an external ROM and is fetched
by the 8031/32. Therefore for the 8031 the EA pin must be connected to ground to
indicate that the code is stored externally. EA, which stands for “external access,” is
pin number 31 in the DIP packages. It is input pin and must be connected to either Vcc
or GND. In other words, it cannot be left unconnected.
PSEN
This is an output pin. PSEN stands for “program store enable.” It is the read
strobe to external program memory. When the microcontroller is executing from
external memory, PSEN is activated twice each machine cycle.
ALE
ALE (Address latch enable) is an output pin and is active high. When
connecting a microcontroller to external memory, port 0 provides both address and
data. In other words the microcontroller multiplexes address and data through port 0
to save pins. The ALE pin is used for de-multiplexing the address and data by
connecting to the G pin of the 74LS373 chip.
I/O port pins and their functions
The four ports P0, P1, P2, and P3 each use 8 pins, making them 8-bit ports.
All the ports upon RESET are configured as output, ready to be used as output ports.
To use any of these as input port, it must be programmed.
Port 0
Port 0 occupies a total of 8 pins (pins 32 to 39). It can be used for input
or output. To use the pins of port 0 as both input and output ports, each pin
must be connected externally to a 10K-ohm pull-up resistor. This is due to fact
that port 0 is an open drain, unlike P1, P2 and P3. With external pull-up
resistors connected upon reset, port 0 is configured as output port. In order to
make port 0 an input port, the port must be programmed by writing 1 to all the
bits of it. Port 0 is also designated as AD0-AD7, allowing it to be used for
both data and address. When connecting a microcontroller to an external
memory, port 0 provides both address and data. The microcontroller
multiplexes address and data through port 0 to save pins. ALE indicates if P0
has address or data. When ALE=0, it provides data D0-D7, but when ALE=1
it has address A0-A7. Therefore, ALE is used for de-multiplexing address and
data with the help of latch 74LS373.
Port 1
Port 1 occupies a total of 8 pins (pins 1 to 8). It can be used as input or
output. In contrast to port 0, this port does not require pull-up resistors since it
has already pull-up resistors internally. Upon reset, port 1 is configures as an
output port. Similar to port 0, port 1 can be used as an input port by writing 1
to all its bits.
Port 2
Port 2 occupies a total of 8 pins (pins 21 to 28). It can be used as input
or output. Just like P1, port 2 does not need any pull-up resistors since it has
pull-up resistors internally. Upon reset port 2 is configured as output port. To
make port 2 as input port, it must be programmed as such by writing 1s to it.
Port 3
Port 3 occupies a total of 8 pins (pins 10 to 17). It can be used as input
or output. P3 does not need any pull-up resistors, the same as P1 and P2 did
not. Although port 3 is configured as output port upon reset, this is not the way
it is most commonly used. Port 3 has an additional function of providing some
extremely important signals such as interrupts. Some of the alternate functions
of P3 are listed below:
P3.0
RXD (Serial input)
P3.1
TXD (Serial output)
P3.2
INT0 (External interrupt 0)
P3.3
INT1 (External interrupt 1)
P3.4
T0 (Timer 0 external input)
P3.5
T1 (Timer 1 external input)
P3.6
WR (External memory write strobe)
P3.7
RD (External memory read strobe)
Memory Space Allocation
1. Internal ROM
The 89C51 has 4K bytes of on-chip ROM. This 4K bytes ROM
memory has memory addresses of 0000 to 0FFFh. Program addresses higher
than 0FFFh, which exceed the internal ROM capacity, will cause the
microcontroller to automatically fetch code bytes from external memory.
Code bytes can also be fetched exclusively from an external memory,
addresses 0000h to FFFFh, by connecting the external access pin to ground.
The program counter doesn’t care where the code is: the circuit designer
decides whether the code is found totally in internal ROM, totally in external
ROM or in a combination of internal and external ROM.
2. Internal RAM
The 1289 bytes of RAM inside the 8051 are assigned addresses 00 to
7Fh. These 128 bytes can be divided into three different groups as follows:
1. A total of 32 bytes from locations 00 to 1Fh are set aside for register
banks and the stack.
2. A total of 16 bytes from locations 20h to 2Fh are set aside for bit
addressable read/write memory and instructions.
A total of 80 bytes from locations 30h to 7Fh are used for read and write storage, or
what is normally called a scratch pad. These 80 locations of RAM are widely used for
the purpose of storing data and parameters by 8051 programmers.
Interfacing of Microcontroller with LCD
The LCD, which is used as a display in the system, is LMB162A. The main features
of this LCD are: 16*2 display, intelligent LCD, used for alphanumeric characters &
based on ASCII codes. This LCD contains 16 pins, in which 8 pins are used as 8-bit
data I/O, which are extended ASCII. Three pins are used as control lines these are
Read/Write pin, Enable pin and Register select pin. Two pins are used for Backlight
and LCD voltage, another two pins are for Backlight & LCD ground and one pin is
used for contrast change.
LCD pin description
Pin
Symbol
I/O
Description
1
VSS
-
Ground
2
VCC
-
+5V power supply
3
VEE
-
Power supply to control contrast
4
RS
I
RS=0 to select command register, RS=1 to select data
register.
5
R/W
I
R/W=0 for write, R/W=1 for read
6
E
I/O
Enable
7
DB0
I/O
The 8 bit data bus
8
DB1
I/O
The 8 bit data bus
9
DB2
I/O
The 8 bit data bus
10
DB3
I/O
The 8 bit data bus
11
DB4
I/O
The 8 bit data bus
12
DB5
I/O
The 8 bit data bus
13
DB6
I/O
The 8 bit data bus
14
DB7
I/O
The 8 bit data bus
Liquid Crystal Display:
Liquid crystal displays (LCD) are widely used in recent years as compares to LEDs.
This is due to the declining prices of LCD, the ability to display numbers, characters
and graphics, incorporation of a refreshing controller into the LCD, their by relieving
the CPU of the task of refreshing the LCD and also the ease of programming for
characters and graphics. HD 44780 based LCDs are most commonly used.
LCD pin description:
The LCD discuss in this section has the most common connector used for the Hitachi
44780 based LCD is 14 pins in a row and modes of operation and how to program and
interface with microcontroller is describes in this section.
Gnd
Vcc
D7
D6
D5
D4
D3
D2
D1
D0
E
R/W
RS
Contrast
Vcc
Gnd
3
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
2
1
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
LCD Pin Description Diagram
VCC, VSS, VEE
The voltage VCC and VSS provided by +5V and ground respectively while VEE is used
for controlling LCD contrast. Variable voltage between Ground and Vcc is used to
specify the contrast (or "darkness") of the characters on the LCD screen.
RS (register select)
There are two important registers inside the LCD. The RS pin is used for their
selection as follows. If RS=0, the instruction command code register is selected, then
allowing to user to send a command such as clear display, cursor at home etc.. If
RS=1, the data register is selected, allowing the user to send data to be displayed on
the LCD.
R/W (read/write)
The R/W (read/write) input allowing the user to write information from it. R/W=1,
when it read and R/W=0, when it writing.
EN (enable)
The enable pin is used by the LCD to latch information presented to its data pins.
When data is supplied to data pins, a high power, a high-to-low pulse must be applied
to this pin in order to for the LCD to latch in the data presented at the data pins.
D0-D7 (data lines)
The 8-bit data pins, D0-D7, are used to send information to the LCD or read the
contents of the LCD’s internal registers. To displays the letters and numbers, we send
ASCII codes for the letters A-Z, a-z, and numbers 0-9 to these pins while making RS
=1. There are also command codes that can be sent to clear the display or force the
cursor to the home position or blink the cursor.
We also use RS =0 to check the busy flag bit to see if the LCD is ready to receive the
information. The busy flag is D7 and can be read when R/W =1 and RS =0, as
follows: if R/W =1 and RS =0, when D7 =1(busy flag =1), the LCD is busy taking
care of internal operations and will not accept any information. When D7 =0, the LCD
is ready to receive new information.
Interfacing of micro controller with LCD display:
In most applications, the "R/W" line is grounded. This simplifies the application
because when data is read back, the microcontroller I/O pins have to be alternated
between input and output modes.
In this case, "R/W" to ground and just wait the maximum amount of time for each
instruction (4.1ms for clearing the display or moving the cursor/display to the "home
position", 160µs for all other commands) and also the application software is simpler,
it also frees up a microcontroller pin for other uses. Different LCD execute
instructions at different rates and to avoid problems later on (such as if the LCD is
changed to a slower unit). Before sending commands or data to the LCD module, the
Module must be initialized. Once the initialization is complete, the LCD can be
written to with data or instructions as required. Each character to display is written
like the control bytes, except that the "RS" line is set. During initialization, by setting
the "S/C" bit during the "Move Cursor/Shift Display" command, after each character
is sent to the LCD, the cursor built into the LCD will increment to the next position
(either right or left). Normally, the "S/C" bit is set (equal to "1")
VCC
EA/VPP
30
29
17
16
15
14
13
12
11
10
28
27
26
25
24
23
22
21
ALE/PROG
RST
XTAL2
XTAL1
PSEN
P3.7/RD AT89C5
P3.6/WR 1
P3.5/T1
P3.4/TO
P3.3/INT1
P3.2/INTO
P3.1/TXD
P3.0/RXD
P2.7/A15
P2.6/A14
P2.5/A13
P2.4/A12
P2.3/A11
P2.2/A10
P2.1/A9
P2.0/A8
P1.7
P1.6
P1.5
P1.4
P1.3
P1.2
P1.1
P1.0
P0.7/AD7
P0.6/AD6
P0.5/AD5
P0.4/AD4
P0.3/AD3
P0.2/AD2
P0.1/AD1
P0.0/AD0
VCC
31
33pF
9
18
19
22uF
33pF
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
VCC
8
7
6
5
4
3
2
1
32
33
34
35
36
37
38
39
3
VCC
VCC
Interfacing of Microcontroller with LCD
LCD Command Code
Code
Command to LCD Instruction
(HEX)
Register
1
Clear the display screen
2
Return home
4
Decrement cursor(shift cursor to left)
6
Increment cursor(shift cursor to right)
7
Shift display right
8
Shift display left
9
Display off, cursor off
A
Display off, cursor on
C
Display on, cursor off
E
Display on, cursor blinking
F
Display on, cursor blinking
10
Shift cursor position to left
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
8.2 K
1
14
Shift cursor position to right
18
Shift the entire display to left
1C
Shift the entire display to right
80
Force cursor to the beginning of 1st line
C0
Force cursor to the beginning of 2nd line
38
2 line and 5×7 matrix
555Timer:
The 8-pin 555 timer must be one of the most useful ICs ever made and it is used in
many projects. With just a few external components it can be used to build many
circuits, not all of them involve timing!
A popular version is the NE555 and this is suitable in most cases where a '555 timer'
is specified. The 556 is a dual version of the 555 housed in a 14-pin package, the two
timers (A and B) share the same power supply pins. The circuit diagrams on this page
show a 555, but they could all be adapted to use one half of a 556.
Low power versions of the 555 are made, such as the ICM7555, but these should only
be used when specified (to increase battery life) because their maximum output
current of about 20mA (with a 9V supply) is too low for many standard 555 circuits.
The ICM7555 has the same pin arrangement as a standard 555.
The circuit symbol for a 555 (and 556) is a box with the pins arranged to suit the
circuit diagram: for example 555 pin 8 at the top for the +Vs supply, 555 pin 3 output
on the right. Usually just the pin numbers are used and they are not labeled with their
function.
The 555 and 556 can be used with a supply voltage (Vs) in the range 4.5 to 15V (18V
absolute maximum).
Standard 555 and 556 ICs create a significant 'glitch' on the supply when their output
changes state. This is rarely a problem in simple circuits with no other ICs, but in
more complex circuits a smoothing capacitor (eg 100µF) should be connected across
the +Vs and 0V supply near the 555 or 556.
The input and output pin functions are described briefly below and there are fuller
explanations covering the various circuits:

Astable - producing a square wave

Monostable - producing a single pulse when triggered

Bistable - a simple memory which can be set and reset

Buffer - an inverting buffer (Schmitt trigger)
Inputs of 555/556
Trigger input: when < 1/3 Vs ('active low') this makes the output high (+Vs). It
monitors the discharging of the timing capacitor in an astable circuit. It has a high
input impedance > 2M .
Threshold input: when > 2/3 Vs ('active high') this makes the output low (0V)*. It
monitors the charging of the timing capacitor in astable and monostable circuits. It has
a
high
input
impedance
> 10M .
* providing the trigger input is > 1/3 Vs, otherwise the trigger input will override the
threshold input and hold the output high (+Vs).
Reset input: when less than about 0.7V ('active low') this makes the output low (0V),
overriding other inputs. When not required it should be connected to +Vs. It has an
input impedance of about 10k .
Control input: this can be used to adjust the threshold voltage which is set internally
to be 2/3 Vs. Usually this function is not required and the control input is connected to
0V with a 0.01µF capacitor to eliminate electrical noise. It can be left unconnected if
noise is not a problem.
The discharge pin is not an input, but it is listed here for convenience. It is connected
to 0V when the timer output is low and is used to discharge the timing capacitor in
astable and monostable circuits.
Output of 555/556
The output of a standard 555 or 556 can sink and source up to 200mA. This is more
than most ICs and it is sufficient to supply many output transducers directly, including
LEDs (with a resistor in series), low current lamps, piezo transducers, loudspeakers
(with a capacitor in series), relay coils (with diode protection) and some motors (with
diode protection). The output voltage does not quite reach 0V and +Vs, especially if a
large current is flowing.
To switch larger currents you can connect a transistor.
The ability to both sink and source current means that two devices can be connected
to the output so that one is on when the output is low and the other is on when the
output is high. The diagram shows two LEDs connected in this way. This
arrangement is used in the Disco Lights project to make the LEDs flash alternately.
555/556 Astable
An astable circuit produces a 'square
wave', this is a digital waveform with
sharp transitions between low (0V) and
high (+Vs). Note that the durations of
555 astable output, a square wave
(Tm and Ts may be different)
the low and high states may be different.
The circuit is called an astable because it
is not stable in any state: the output is
continually changing between 'low' and
'high'.
The time period (T) of the square wave
is the time for one complete cycle, but it
is usually better to consider frequency
555 astable circuit
(f) which is the number of cycles per
second.
T = 0.7 × (R1 + 2R2) × C1 and f =
T = time period in seconds (s)
f = frequency in hertz (Hz)
R1 = resistance in ohms ( )
R2 = resistance in ohms ( )
C1 = capacitance in farads (F)
1.4
(R1 + 2R2) × C1
The time period can be split into two parts: T = Tm + Ts
Mark time (output high): Tm = 0.7 × (R1 + R2) × C1
Space time (output low): Ts = 0.7 × R2 × C1
Many circuits require Tm and Ts to be almost equal; this is achieved if R2 is much
larger than R1.
For a standard astable circuit Tm cannot be less than Ts, but this is not too restricting
because the output can both sink and source current. For example an LED can be
made to flash briefly with long gaps by connecting it (with its resistor) between +Vs
and the output. This way the LED is on during Ts, so brief flashes are achieved with
R1 larger than R2, making Ts short and Tm long. If Tm must be less than Ts a diode
can be added to the circuit as explained under duty cycle below.
Choosing R1, R2 and C1
R1 and R2 should be in the range
1k
to 1M . It is best to choose C1
first
because
capacitors
Choose C1 to suit the
frequency range you require
(use the table as a guide).

C1
are
available in just a few values.

555 astable frequencies
R2 = 10k
R1 = 1k
R2 = 100k
R1 = 10k
R2 = 1M
R1 = 100k
0.001µF
68kHz
6.8kHz
680Hz
0.01µF
6.8kHz
680Hz
68Hz
0.1µF
680Hz
68Hz
6.8Hz
1µF
68Hz
6.8Hz
0.68Hz
10µF
6.8Hz
0.68Hz
0.068Hz
(41 per min.) (4 per min.)
Choose R2 to give the frequency (f) you require. Assume that R1 is much
smaller than R2 (so that Tm and Ts are almost equal), then you can use:
R2 =

0.7
f × C1
Choose R1 to be about a tenth of R2 (1k
min.) unless you want the mark
time Tm to be significantly longer than the space time Ts.

If you wish to use a variable resistor it is best to make it R2.

If R1 is variable it must have a fixed resistor of at least 1k
in series
(this is not required for R2 if it is variable).
Astable operation
With the output high (+Vs) the capacitor C1 is charged by current flowing through R1
and R2. The threshold and trigger inputs monitor the capacitor voltage and when it
reaches 2/3Vs (threshold voltage) the output becomes low and the discharge pin is
connected to 0V.
The capacitor now discharges with current flowing through R2 into the discharge pin.
When the voltage falls to 1/3Vs (trigger voltage) the output becomes high again and
the discharge pin is disconnected, allowing the capacitor to start charging again.
This cycle repeats continuously unless the reset input is connected to 0V which forces
the output low while reset is 0V.
An astable can be used to provide the clock signal for circuits such as counters.
A low frequency astable (< 10Hz) can be used to flash an LED on and off, higher
frequency flashes are too fast to be seen clearly. Driving a loudspeaker or piezo
transducer with a low frequency of less than 20Hz will produce a series of 'clicks'
(one for each low/high transition) and this can be used to make a simple metronome.
An audio frequency astable (20Hz to 20kHz) can be used to produce a sound from a
loudspeaker or piezo transducer. The sound is suitable for buzzes and beeps. The
natural (resonant) frequency of most piezo transducers is about 3kHz and this will
make them produce a particularly loud sound.
Duty cycle
The duty cycle of an astable circuit is the proportion of the complete cycle for which
the output is high (the mark time). It is usually given as a percentage.
For a standard 555/556 astable circuit the mark time (Tm) must be greater than the
space time (Ts), so the duty cycle must be at least 50%:
Duty cycle =
Tm
Tm + Ts
=
R1 + R2
R1 + 2R2
555/556 Monostable
A monostable circuit produces a single output pulse when triggered. It is called a
monostable because it is stable in just one state: 'output low'. The 'output high' state is
temporary.
555 monostable out, a single pulse
555 monostable circuit with manual trigger
The duration of the pulse is called the time period (T) and this is determined by
resistor R1 and capacitor C1:
time period, T = 1.1 × R1 × C1
T = time period in seconds (s)
R1 = resistance in ohms ( )
C1 = capacitance in farads (F)
The maximum reliable time period is about 10 minutes.
Why 1.1? The capacitor charges to 2/3 = 67% so it is a bit longer than the
time constant (R1 × C1) which is the time taken to charge to 63%.

Choose C1 first (there are relatively few values available).

Choose R1 to give the time period you need. R1 should be in the range 1k
1M , so use a fixed resistor of at least 1k

to
in series if R1 is variable.
Beware that electrolytic capacitor values are not accurate, errors of at least
20% are common.

Beware that electrolytic capacitors leak charge which substantially increases
the time period if you are using a high value resistor - use the formula as only
a very rough guide!
Monostable operation
The timing period is triggered (started) when the trigger input (555 pin 2) is less than
1
/3 Vs, this makes the output high (+Vs) and the capacitor C1 starts to charge through
resistor R1. Once the time period has started further trigger pulses are ignored.
The threshold input (555 pin 6) monitors the voltage across C1 and when this reaches
2
/3 Vs the time period is over and the output becomes low. At the same time
discharge (555 pin 7) is connected to 0V, discharging the capacitor ready for the next
trigger.
The reset input (555 pin 4) overrides all other inputs and the timing may be cancelled
at any time by connecting reset to 0V, this instantly makes the output low and
discharges the capacitor. If the reset function is not required the reset pin should be
connected to +Vs.
IR Light Emitter
Principle of Operation
Because they emit at wavelengths which provide a close match to the peak spectral
response of silicon photo detectors, both GaAs and GaAlAs. There are many off-theshelf, commercially available, IR LED emitters that can be used for a discrete infrared
transceiver circuit design. It should be mentioned here that there are also a number of
integrated transceivers that the designer can choose as well. In general, there are four
characteristics of IR emitters that designers have to be wary of:

Rise and Fall Time

Emitter Wavelength

Emitter Power

Emitter Half-angle
Wavelength vs. Radiant Power
Description
In this system IR LED used is The QED233 / QED234 which is a 940 nm GaAs /
AlGaAs LED encapsulated in a clear untinted, plastic T-1 3/4 package.
QED234 Features

Wavelength=940nm

Chip material =GaAs with AlGaAs window

Package type: T-1 3/4 (5mm lens diameter)

Matched Photo sensor: QSD122/123/124, QSE 973.

Medium Emission Angle, 40°

High Output Power

Package material and color: Clear, untinted, plastic

Ideal for remote control applications
Semiconductor Light Detectors
Energy entering a semiconductor crystal excites electrons to higher levels, leaving
behind "holes". These electrons and "holes" can recombine and emit photons, or they
can move away from one another and form a current. This is the basics of
semiconductor light detectors. The basic optical receiver converts the modulated light
coming from the space back in to a replica of the original signal applied to the
transmitter.
Types of optical detector

P-N photodiode

P-I-N photodiode

Avalanche photodiode
In P-N photodiode, electron hole pairs are created in the depletion region of a p-n
junction in proportion to the optical power. Electrons and holes are swept out by the
electric field, leading to a current. In P-I-N photodiode, electric field is concentrated
in a thin intrinsic layer. In avalanche photodiode, like P-I-N photodiodes, but have an
additional layer in which an average of M secondary electron –hole pairs are
generated through impact ionization for each primary pair. Photodiodes usually have a
large sensitive detecting area that can be several hundreds microns in diameter.
IR Light Detector
The most common device used for detecting light energy in the standard data stream
is a photodiode, Photo transistors are not typically used in IrDA standard-compatible
systems because of their slow speed. Photo transistors typically have ton/toff of 2 µs or
more. A photo transistor may be used, however, if the data rate is limited to 9.6 kb
with a pulse width of 19.5 µs. A photodiode is packaged in such a way as to allow
light to strike the PN junction.
Characteristic Curve of a Reverse Biased Photodiode
In infrared applications, it is common practice to apply a reverse bias to the device.
Refer to Figure 3.17 for a characteristic curve of a reverse biased photodiode. There
will be a reverse current that will vary with the light level. Like all diodes, there is an
intrinsic capacitance that varies with the reverse bias voltage. This capacitance is an
important factor in speed.
Description
The QSE973 is a silicon PIN photodiode encapsulated in an infrared transparent,
black, plastic T092 package.
1
_
QSE 973 Features

Daylight filter

T092 package

PIN photodiode
2
+

Receipting angle 90°

Chip size = .1072 sq. inches (2.712 sq. mm)
Link Distance
To select an appropriate IR photo-detect diode, the designer must keep in mind the
distance of communication, the amount of light that may be expected at that distance
and the current that will be generated by the photodiode given a certain amount of
light energy. The amount of light energy, or irradiance that is present at the activeinput interface is typically given in µW/cm2. This is a convenient scale of light flux.
Stepper Motor:
Introduction to Stepper Motor
The stepper motor is an electromagnetic device that converts digital pulses into
mechanical shaft rotation. The shaft or spindle of a stepper motor rotates in discrete
step increments when electrical command pulses are applied to it in the proper
sequence. The sequence of the applied pulses is directly related to the direction of
motor shafts rotation. The speed of the motor shafts rotation is directly related to the
frequency of the input pulses and the length of rotation is directly related to the
number of input pulses applied. Many advantages are achieved using this kind of
motors, such as higher simplicity, since no brushes or contacts are present, low cost,
high reliability, high torque at low speeds, and high accuracy of motion. Many
systems with stepper motors need to control the acceleration/ deceleration when
changing the speed.
Stepper Motor
Bipolar v/s. Unipolar Stepper Motors
The two common types of stepper motors are the bipolar motor and the unipolar
motor. The bipolar and unipolar motors are similar, except that the unipolar has a
center tap on each winding. The bipolar motor needs current to be driven in both
directions through the windings, and a full bridge driver is needed .The center tap on
the unipolar motor allows a simpler driving circuit, limiting the current flow to one
direction. The main drawback with the unipolar motor is the limited capability to
energize all windings at any time, resulting in a lower torque compared to the bipolar
motor. The unipolar stepper motor can be used as a bipolar motor by disconnecting
the center tap.
In unipolar there are 5 wires. One common wire and four wires to which power
supply has to be given in a serial order to make it drive. Bipolar can have 6 wires and
a pair of wires is given supply at a time to drive it in steps.
A 2- phase (winding) unipolar Stepper Schematic
A two phase (winding) bipolar stepper motor
Driving a Stepper Motor:
Identify the wire: Common and windings
Connection to identify the common winding
It has been seen that out of the five wires two are grouped as common. The other four
are the windings that have to give supply to. Major crux here is to identify the
common line. Just take the multimeter and check the resistance between the wires.
Hold one wire a common and it must bear a resistance of 75 ohms with all the other
wires then that is the common wire.
Connection of the Circuit:
Stepper Motor Advantages and Disadvantages
Advantages:
1. The rotation angle of the motor is proportional to the input pulse.
2. The motor has full torque at standstill (if the windings are energized)
3. Precise positioning and repeatability of movement since good stepper motors
have an accuracy of 3 – 5% of a step and this error is non cumulative from one
step to the next.
4. Excellent response to starting/ stopping/reversing.
5. Very reliable since there are no contact brushes in the motor. Therefore, the
life of the motor is simply dependant on the life of the bearing.
6. The motors response to digital input pulses provides open-loop control,
making the motor simpler and less costly to control.
7. It is possible to achieve very low speed synchronous rotation with a load that
is directly coupled to the shaft.
8. A wide range of rotational speeds can be realized as the speed is proportional
to the frequency of the input pulses.
Disadvantages:
1. Resonances can occur if not properly controlled.
2. Not easy to operate at extremely high speeds.
Stepper Motor Type
There are three basic stepper motor types. They are:

Variable-reluctance

Permanent-magnet

Hybrid
Variable-reluctance (VR)
This type of stepper motor has been around for a long time. It is probably the easiest
to understand from a structural point of view. This type of motor consists of a soft
iron multi-toothed rotor and a wound stator. When the stator windings are energized
with DC current the poles become magnetized. Rotation occurs when the rotor teeth
are attracted to the energized stator poles.
Cross section of a variable reluctance motor
Permanent Magnet (PM)
Often referred to as a “tin can” or “canstock” motor the permanent magnet step motor
is a low cost and low resolution type motor with typical step angles of 7.5° to 15°. (48
– 24 steps/revolution) PM motors as the motor name implies have permanent magnets
added to the motor structure. The rotor no longer has teeth as with the VR motor.
Instead the rotor is magnetized with alternating north and south poles situated in a
straight line parallel to the rotor shaft. These magnetized rotor poles provide an
increased magnetic flux intensity and because of this the PM motor exhibits improved
torque characteristics when compared with the VR type.
Principle of a PM type stepper motor
Hybrid (HB)
The hybrid stepper motor is more expensive than the PM stepper motor but provides
better performance with respect to step resolution, torque and speed. Typical step
angles for the hybrid stepper motor, range from 3.6° to 0.9° (100 – 400 steps per
revolution). The hybrid stepper motor combines the best features of both the PM and
VR type stepper motors. The rotor is multi toothed like the VR motor and contains an
axially magnetized concentric magnet around its shaft. The teeth on the rotor provide
an even better path which helps guide the magnetic flux to preferred locations in the
air gap. This further increases the detent, holding and dynamic torque characteristics
of the motor when compared with both the VR and PM types.
Cross section of hybrid stepper motor
Applications of Stepper Motor
A stepper motor can be a good choice whenever controlled movement is required.
They can be used to advantage in applications where you need to control rotation
angle, speed, position and synchronism. Because of the inherent advantages listed
previously, stepper motors have found their place in many different applications.
Some of these include printers, plotters, high end office equipment, hard disk drives,
medical equipment, fax machines, automotive and many more.
Torque Generation
The torque produced by a stepper motor depends on several factors:
• The step rate
• The drive current in the windings
• The drive design or type
In a stepper motor a torque is developed when the magnetic fluxes of the rotor and
stator are displaced from each other. The stator is made up of a high permeability
magnetic material. The presence of this high permeability material causes the
magnetic flux to be confined for the most part to the paths defined by the stator
structure in the same fashion that currents are confined to the conductors of an
electronic circuit. This serves to concentrate the flux at the stator poles. The torque
output produced by the motor is proportional to the intensity of the magnetic flux
generated when the winding is energized. The basic relationship which defines the
intensity of the magnetic flux is defined by:
H = (N * i) / l
Where:
N = Number of winding turns
i = Current
H = Magnetic field intensity
l =Magnetic flux path length
This relationship shows that the magnetic flux intensity and consequently the torque is
proportional to the number of winding turns and the current and inversely
proportional to the length of the magnetic flux path. It has been seen that the same
frame size stepper motor could have very different torque output capabilities simply
by changing the winding parameters.
Phases, Poles and Stepping Angles
Usually stepper motors have two phases, but three- and five-phase motors also exist.
A bipolar motor with two phases has one winding/phase and a unipolar motor has one
winding, with a center tap per phase. Sometimes the unipolar stepper motor is referred
to as a “four phase motor”, even though it has only two phases. Motors that have two
separate windings per phase also exist—these can be driven in either bipolar or
unipolar mode. A pole can be defined as one of the regions in a magnetized body
where the magnetic flux density is concentrated. Both the rotor and the stator of a step
motor have poles.
In reality several more poles are added to both the rotor and stator structure in order to
increase the number of steps per revolution of the motor, or in other words to provide
a smaller basic (full step) stepping angle. The permanent magnet stepper motor
contains an equal number of rotor and stator pole pairs. Typically the PM motor has
12 pole pairs. The stator has 12 pole pairs per phase. The hybrid type stepper motor
has a rotor with teeth. The rotor is split into two parts, separated by a permanent
magnet making half of the teeth south poles and half north poles. The number of pole
pairs is equal to the number of teeth on one of the rotor halves. The stator of a hybrid
motor also has teeth to build up a higher number of equivalent poles (smaller pole
pitch, number of equivalent poles = 360/teeth pitch) compared to the main poles, on
which the winding coils are wound. It is the relationship between the number of rotor
poles and the equivalent stator poles, and the number the number of phases that
determines the full-step angle of a stepper motor.
Step Angle: The angle with which the stepper motor turns for a single pulse if supply
to one wire or a pair is called step angle.
NPh = Number of equivalent poles per
Phase = number of rotor poles
Ph = Number of phases
N = Total number of poles for all phases together
If the rotor and stator tooth pitch is unequal, a more-complicated relationship exist
Optocoupler:
It has one IR LED and a photo- transistor. One pin of the LED is connected to the
MCU to get a signal (0 or 1) and the pin is given ground. When the signal from the
MCU is 0, then LED emits light. This light will turn on the NPN transistor. Emitter of
the transistor is grounded. Collector is connected to the PNP transistor whose emitter
is connected to Vcc and collector to the relay.
The purpose of using the optocouplers is to pass the supply from the PC/MCU to the
appliances & is for isolation of the port of the PC/MCU from an external hardware.
The voltage signal from the PC/MCU is being converted into light by the LED and
then further converted into voltage by the phototransistor. This ensures that there is no
physical connection between the PC and the appliances. The signal from
the
PC/MCU is coupled only through light so that if in any case the external hardware
( in this case :appliances) produces an error voltage it will not be passed over to the
port of the PC/MCU and will not damage the internal circuitry of the PC/MCU.
MCT-2E Pin Diagram
Pin no.
Function
1
Anode
2
Cathode
3
NC
4
Emitter
5
Collector
6
Base
The MCT2XXX series opto isolators consist of a gallium arsenide infrared emitting
diode driving a silicon phototransistor in a 6-pin dual in-line package. There is no
electrical connection between the two, just a beam of light. The light emitter is nearly
always an LED. The light sensitive device may be a photodiode, phototransistor, or
more esoteric devices such as thyristors, triacs etc. To carry a signal across the
isolation barrier, optocouplers are operated in linear mode.
Pin Description of MCT2E
The IC package may also be called an IC or a chip. It is important to note that each
type of optocoupler may use different pin assignments. For carrying a linear signal
across isolation barrier there are two types of optocouplers. Both types use an infrared
light emitting diode (LED) to generate and send a light signal across an isolation
barrier. The difference is in the detection method. Some optocouplers use a
phototransistor detector while others use a photodiode detector which drives the base
of a transistor.
The phototransistor detector uses the transistors collector base junction to
detect the light signal. This necessitates that the base area be relatively large
compared to a standard transistor. The result is a large collector to base capacitance
which slows the collector rise time and limits the effective frequency response of the
device. In addition the amplified photocurrent flows in the collector base junction and
modulates the response of the transistor to the photons. This cause the transistor to
behave in a non-linear manner. Typical phototransistor gains range from 100 to 1000.
The photodiode/transistor detector combination on the other hand uses a diode
to detect the photons and convert them to a current to drive the transistor base. The
transistor no longer has a large base area. The response of this pair is not affected by
amplified photocurrent and the photodiode capacitance does not impair speed.
Optocoupler Operation:
Optocouplers are good devices for conveying analog information across a power
supply isolation barrier, they operate over a wide temperature range and are often
safety agency approved they do, however, have many unique operating
considerations.
Optocouplers are current input and current output devices. The input LED is
excited by changes in drive current and maintains a relatively constant forward
voltage. The output is a current which is proportional to the input current. The output
current can easily be converted to a voltage through a pull-up or load resistor.
Applications:

AC mains detection

Reed relay driving

Switch mode power supply feedback

Telephone ring detection

Logic ground isolation

Logic coupling with high frequency noise rejection.
Features:

Interfaces with common logic families

Input-output coupling capacitance < 0.5 pF

Industry Standard Dual-in line 6-pin package

5300 VRMS isolation test voltage

Lead-free component
Optocoupler (817)
Description
The HCPL-817 contains a light emitting diode optically coupled to a phototransistor.
It is packaged in a 4-pin DIP package and available in wide-lead spacing option.
Input-output isolation voltage is 5000 Vrms. Response time (tr), is typically 4 ms and
minimum CTR (Current transfer ratio) is 50% at input current of 5 mA.
Power Transistor (BC 369):

High current gain

High collector current

Low collector-emitter saturation voltage

Complementary type: BC 368 (NPN)
Various Hardware Tools used are:

Soldering Iron

Soldering Wire

Ribbon wire

Flux

Cutter

Tin wire

De-soldering pump

Multimeter

IC Programmer

PC
Software Tools used are:

Keil compiler

Sunrom’s software to Program the Microcontroller (AT89s52)

Embedded C Language
Basic Tutorials for Keil Software:
1. Open Keil from the Start menu
2. The Figure below shows the basic names of the windows referred in this document
Starting a new Assembler Project
1. Select New Project from the Project Menu.
2. Name the project ‘Toggle.a51’
3. Click on the Save Button.
4. The device window will be displayed.
5. Select the part you will be using to test with. For now we will use the Dallas
Semiconductor part DS89C420.
6. Double Click on the Dallas Semiconductor.
7. Scroll down and select the DS89C420 Part
8. Click OK
Creating Source File
1. Click File Menu and select New.
2. A new window will open up in the Keil IDE.
3. Write any code on this file.
4. Click on File menu and select Save as…
5. Name the file with extension (.asm for assembly language code & .c for embedded
C language code).
6. Click the Save Button
Adding File to the Project
1. Expand Target 1 in the Tree Menu
2. Click on Project and select Targets, Groups, Files…
3. Click on Groups/Add Files tab
4. Under Available Groups select Source Group 1
5. Click Add Files to Group… button
6. Change file type to Asm Source file(*.a*; *.src)
7. Click on toggle.a51
8. Click Add button
9. Click Close Button
10. Click OK button when you return to Target, Groups, Files… dialog box.
11. Expand the Source Group 1 in the Tree menu to ensure that the file was added to
the project.
Creating HEX for the Part
1. Click on Target 1 in Tree menu
2. Click on Project Menu and select Options for Target 1
3. Select Target Tab
4. Change Xtal (Mhz) from 50.0 to 11.0592
5. Select Output Tab
6. Click on Create Hex File check box
7. Click OK Button
8. Click on Project Menu and select Rebuild all Target Files
9. In the Build Window it should report ‘0 Errors (s), 0 Warnings’
10. You are now ready to Program your Part
CONCLUSION
I would like to conclude this project as a very great and enriching experience.
During the project labs I familiarized myself with P.C.B designing, application of I.C.
(its pin diagram), mounting of components using soldering process and interfacing of
the hardware circuit with the computer.
The circuit can be used at all places starting from domestic to the industrial sectors.
The simplicity in the usage of this circuit helps it to be used by a large number of
people as people with less knowledge of hardware can also use it without facing any
problem. The
I also learned about the engg. Responsibility and about their hard work. This project
was not only good for personality development but also great in terms of imparting
practical knowledge.
Thus I conclude our project with a very nice and wonderful experience