Digital Code Locking System
Digital Code Locking System
1. ABSTRACT
2. BLOCK DIAGRAM
3. MICROCONTROLLER
3.1 A Brief History of 8051
3.2 Description of 89C52 Microcontroller
3.3 Block Diagram of Microcontroller
3.4 Pin Configurations
3.5 Timers
3.6 Interrupts
3.7 Special function registers:
3.8 Memory Organization
4. POWER SUPPLY
4.1 Description
4.2 Block Diagram
4.3 Circuit Diagram
4.4 IC Voltage Regulators
5. ULN 2003
6. STEPPER MOTOR
7. KEYPAD
8. LCD
9. KEIL SOFTWARE
13. CONCLUSION
15. BIBLIOGRAPHY
DIGITAL CODE LOCKING SYSTEM
ABSTRACT
The aim of this project is to provide the security. Now a days security system
is must for every organization. Access control system is one system that is used for security
purpose in many organizations. The main aim of this project is to provide access only if the
password of particular user is matched. So, every user is given a unique password. So, that
access is denied to unauthorized persons.
This system can be used in military areas, bank security and security for important
documents.
Our system has intelligent of allowing only valid passwords. This is 89C52
microcontroller based project which is interfaced to keypad, LCD- display and Stepper motor.
We used a 4x3 matrix keypad to have an access to system. An LCD (16x2) and a stepper motor
to open or close the door. We have used KEIL for microcontroller programming. The software
prompts user to enter a password and checks its validity .If it’s valid the door is opened using
Stepper motor.
• HARDWARE COMPONENTS:
1. 89C52 MICROCONTROLLER
3. STEPPER MOTOR.
LCD DISPLAY.
4.
KEY PAD.
5.
• SIMULATION:
PLATFORM: WINDOWS
LANGUAGE: EMBEDDED ‘C’
Block diagram
ULN STEPPER
LCD DRIVER MOTOR
DISPLAY
AT 89C52
MICROCONTROLLER
4x3 MATRIX
KEYPAD
MICROCONTROLLER
The 8051 is an 8-bit processor meaning that the CPU can work only on 8 bits data
at a time. Data larger than 8 bits has to be broken into 8 bits pieces to be processed by the
CPU. The 8051 has a total of four I\O ports each 8 bit wide.
There are many versions of 8051 with different speeds and amount of on-chip
ROM and they are all compatible with the original 8051. This means that if you write a
program for one it will run on any of them.
The 8052 is an original member of the 8051 family. There are two other members
in the 8051 family of microcontrollers. They are 8052 and 8031. All the three
microcontrollers will have the same internal architecture, but they differ in the following
aspects.
8031 has 128 bytes of RAM, two timers and 6 interrupts.
89S51 has 4KB ROM, 128 bytes of RAM, two timers and 6
interrupts.
89S52 has 8KB ROM, 128 bytes of RAM, three timers and 8
interrupts.
Of the three microcontrollers, 89S51 is the most preferable. Microcontroller
supports both serial and parallel communication.
In the concerned project 89S52 microcontroller is used. Here microcontroller used
is AT89S52, which is manufactured by ATMEL laboratories.
3.2 Description of 89C52 Microcontroller
The AT89S52 provides the following standard features: 8Kbytes of Flash, 256
bytes of RAM, 32 I/O lines, three 16-bit timer/counters, six-vector two-level interrupt
architecture, a full duplex serial port, on-chip oscillator, and clock circuitry. In addition,
the AT89S52 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 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.
• VCC
Pin 40 provides Supply voltage to the chip. The voltage source is +5v
• GND.
• Port 0
Port 0 is an 8-bit open drain bidirectional I/O port from pin 32 to 39. As an output
port each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can
be used as high-impedance inputs. Port 0 may also be configured to be the multiplexed
low-order address/data bus during accesses to external program and data memory. In this
mode P0 has internal pull-ups.
Port 0 also receives the code bytes during Flash programming, and outputs the
code bytes during program verification. External pull-ups are required during program
verification.
• Port 1
Port 1 is an 8-bit bidirectional I/O port with internal pull-ups from pin 1 to 8. The
Port 1 output buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins
they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 1
pins that are externally being pulled low will source current (IIL) because of the internal
pull-ups.
In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external
count input (P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively, as
shown in following table.
Port 1 also receives the low-order address bytes during Flash programming and
program verification.
• Port 2
Port 2 is an 8-bit bidirectional I/O port with internal pull-ups from pin 21 to 28.
The Port 2 output buffers can sink / source four TTL inputs. When 1s are written to Port
2 pins they are pulled high by the internal pull-ups and can be used as inputs. As inputs,
Port 2 pins that are externally being pulled low will source current (IIL) because of the
internal pull-ups.
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 uses 8-bit addresses (MOVX @ RI), Port 2 emits
the contents of the P2 Special Function Register. Port 2 also receives the high-order
address bits and some control signals during Flash programming and verification.
• Port 3
Port 3 is an 8-bit bidirectional I/O port with internal pull-ups from pin 10 to 17.
The Port 3 output buffers can sink / source four TTL inputs. When 1s are written to
Port 3 pins they are pulled high by the internal pull-ups and can be used as inputs. As
inputs, Port 3 pins that are externally being pulled low will source current (IIL)
because of the pull-ups.
Port 3 also serves the functions of various special features of the AT89C52 as
listed below:
Table 3.1 Special Features of port3
Port 3 also receives some control signals for Flash programming and
programming verification.
• RST
Pin 9 is the Reset input. It is active high. Upon applying a high pulse to this pin,
the microcontroller will reset and terminate all activities. A high on this pin for two
machine cycles while the oscillator is running resets the device.
• ALE/PROG
Address Latch is an output pin and is active high. Address Latch Enable output
pulse for latching the low byte of the address during accesses to external memory.
This pin is also the program pulse input (PROG) during Flash programming. In
normal operation ALE is emitted at a constant rate of 1/6 the oscillator frequency, and
may be used for external timing or clocking purposes.
Note, however, that one ALE pulse is skipped during each access to external Data
Memory. If desired, ALE operation can be disabled by setting bit 0 of SFR location
8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction.
Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if
the microcontroller is in external execution mode.
PSEN
Program Store Enable is the read strobe to external program memory. When the
AT89S52 is executing code from external program memory, PSEN is activated twice
each machine cycle, except that two PSEN activations are skipped during each access to
external data memory.
• EA/VPP
• XTAL1
Input to the inverting oscillator amplifier and input to the internal clock operating
circuit.
• XTAL2
• 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
5.3. 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 5.4.
There are no requirements on the duty cycle of the external clock signal, since the
input to the internal clocking circuitry is through a divide-by two flip-flop, but minimum
and maximum voltage high and low time specifications must be observed.
• Idle Mode
In idle mode, the CPU puts itself to sleep while all the on-chip peripherals remain
active. The mode is invoked by software. The content of the on-chip RAM and all the
special functions registers remain unchanged during this mode. The idle mode can be
terminated by any enabled interrupt or by a hardware reset. It should be noted that when
idle is terminated by a hardware reset, the device normally resumes program execution,
from where it left off, up to two machine cycles before the internal reset algorithm takes
control.
On-chip hardware inhibits access to internal RAM in this event, but access to the
port pins is not inhibited. To eliminate the possibility of an unexpected write to a port pin
when Idle is terminated by reset, the instruction following the one that invokes Idle
should not be one that writes to a port pin or to external memory.
In the power down mode the oscillator is stopped, and the instruction that invokes
power down is the last instruction executed. The on-chip RAM and Special Function
Registers retain their values until the power down mode is terminated. The only exit from
power down is a hardware reset. Reset redefines the SFRs but does not change the on-
chip RAM. The reset should not be activated before VCC is restored to its normal
operating level and must be held active long enough to allow the oscillator to restart and
stabilize.
Table 3.2 Status Of External Pins During Idle and Power Down Mode
TIMERS
• Timer 0 and 1
Timer 0 and Timer 1 in the AT89S52 operate the same way as Timer 0 and Timer
1 in the AT89S52.
Register pairs (TH0, TL1), (TH1, TL1) are the 16-bit counter registers for timer/c;
ounters 0 and 1.
• Timer 2
• Capture Mode
In the capture mode, two options are selected by bit EXEN2 in T2CON. If
EXEN2 = 0, Timer 2 is a 16-bit timer or counter which upon overflow sets bit TF2 in
T2CON.This bit can then be used to generate an interrupt. IfEXEN2 = 1, Timer 2
performs the same operation, but a 1-to-0 transition at external input T2EX also causes
the current value in TH2 and TL2 to be captured into RCAP2H andRCAP2L,
respectively. In addition, the transition at T2EXcauses bit EXF2 in T2CON to be set. The
EXF2 bit, likeTF2, can generate an interrupt.
The AT89C52 has a total of six interrupt vectors: two external interrupts (INT0
and INT1), three timer interrupts (Timers 0, 1, and 2), and the serial port interrupt. These
interrupts are all shown in Figure 2.5
Note that Table 5.3 shows that bit position IE.6 is unimplemented. In the
AT89C51, bit position IE.5 is also unimplemented. User software should not write 1s to
these bit positions, since they may be used in future AT89 products.
Table 3.7 Interrupts Enable Register
Timer 2 interrupt is generated by the logical OR of bits TF2 and EXF2 in register
T2CON. Neither of these flags is cleared by hardware when the service routine is
vectored to. In fact, the service routine may have to determine whether it was TF2 or
EXF2 that generated the interrupt, and that bit will have to be cleared in software.
The Timer 0 and Timer 1 flags, TF0 and TF1, are set at S5P2 of the cycle in
which the timers overflow. The values are then polled by the circuitry in the next cycle.
However, the Timer 2 flag, TF2, is set at S2P2 and is polled in the same cycle in which
the timer overflows.
a) Accumulator (0E0h)
b) B register (oFoh)
The B register is very similar to accumulator. It may hold 8-bit value. The B
register is only used by MUL AB and DIV AB instructions. In MUL AB the higher byte
of the products gets stored in B register. In DIV AB the quotient gets stored in B with the
remainder in A.
The stack pointer holds 8-bit value. This is used to indicate where the next value
to be removed from the stack should be taken from. When a value is to be pushed on to
the stack, the 8052 first store the value of SP and then store the value at the resulting
memory location. When a value is to be popped from the stack, the 8052 returns the value
from the memory location indicated by SP and then decrements the value of SP.
The SFRs DPL and DPH work together to represent a 16-bit value called the data
pointer. The data pointer is used in operations regarding external RAM and some
instructions code memory. It is a 16-bit SFR and also an addressable SFR.
e) Program counter
The program counter is a 16 bit register, which contains the 2 byte address, which
tells the next instruction to execute to be found in memory. When the 8052 is initialized
PC starts at 0000h and is incremented each time an instruction is executes. It is not
addressable SFR.
The power control SFR is used to control the 8052’s power control modes.
Certain operation modes of the 8052 allow the 8052 to go into a type of “sleep mode”
which consumes low power.
The timer mode control SFR is used to configure and modify the way in which
the 8052’s two timers operate. This SFR controls whether each of the two timers is
running or stopped and contains a flag to indicate that each timer has overflowed.
Additionally, some non-timer related bits are located in TCON SER. These bits are used
to configure the way in which the external interrupt flags are activated, which are set
when an external interrupt occur.
h)TMOD(Timer Mode,89h)
The timer mode SFR is used to configure the mode of operation of each of the
two timers. Using this SR your program may configure each timer to be a 16-bit timer, or
13 bit timer, 8-bit auto reload timer, or two separate timers. Additionally you may
configure the timers to only count when an external pin is activated or to count “events”
that are indicated on an external pin.
Gate C/ T M1 M0 Gate C/ T M1 M0
TIMER1 TIMER0
These two SFRs together represent timer 0. Their exact behavior depends on how
the timer is configured in the TMOD SFR; however, these timers always count up. What
is configurable is how and when they increment value.
These two SFRs together represent timer 1. Their exact behavior depends on how
the timer is configured in the TMOD SFR; however, these timers always count up. What
is configurable is how and when they increment in value.
This is port 0 latch. Each bit of this SFR corresponds to one of the pins on a micro
controller. Any data to be outputted to port 0 is first written on P0 register. For e.g., bit 0
of port 0 is pin P0.0, bit 7 is pin P0.7. Writing a value of 1 to a bit of this SFR will send a
high level on the corresponding I/O pin whereas a value of 0 will bring it to low level.
This is port 1 latch. Each bit of this SFR corresponds to one of the pins on a micro
controller. Any data to be outputted to port 1 is first written on P1 register. For e.g., bit 0
of port 1 is pin P1.0, bit 7 is pin P1.7. Writing a value of 1 to a bit of this SFR will send a
high level on the corresponding I/O pin whereas a value of 0 will bring it to low level.
This is port 2 latch. Each bit of this SFR corresponds to one of the pins on a micro
controller. Any data to be outputted to port 2 is first written on P2 register. For e.g., bit 0
of port 2 is pin P2.0, bit 7 is pin P2.7. Writing a value of 1 to a bit of this SFR will send a
high level on the corresponding I/O pin whereas a value of 0 will bring it to low level.
This is port 3 latch. Each bit of this SFR corresponds to one of the pins on a micro
controller. Any data to be outputted to port 3 is first written on P3 register. For e.g., bit 0
of port 3 is pin P3.0, bit 7 is pin P3.7. Writing a value of 1 to a bit of this SFR will send a
high level on the corresponding I/O pin whereas a value of 0 will bring it to low level.
The interrupt enable SFR is used to enable and disable specific interrupts. The
low 7 bits of the SFR are used to enable/disable the specific interrupts, where the MSB
bit is used to enable or disable all the interrupts. Thus, if the high bit of IE 0 all interrupts
are disabled regardless of whether an individual interrupt is enabled by setting a lower
bit.
___
EA ET2 ES ET1 EX1 ET0 EX0
The interrupt priority SFR is used to specify the relative priority of each interrupt.
On 8052, an interrupt may be either low or high priority. An interrupt may interrupt
interrupts. For e.g., if we configure all interrupts as low priority other than serial
interrupt. The serial interrupt always interrupts the system; even if another interrupt is
currently executing no other interrupt will be able to interrupt the serial interrupt routine
since the serial interrupt routine has the highest priority.
___ ___
PT2 PS PT1 PX1 PT0 PX0
The Program Status Word is used to store a number of important bits that are set
and cleared by 8052 instructions. The PSW SFR contains the carry flag, the auxiliary
carry flag, the parity flag and the overflow flag. Additionally, it also contains the register
bank select flags, which are used to select, which of the “R” register banks currently in
use.
4.1 Description:
Circuit Features:
Brief description of operation: Gives out well regulated +5V output, output
current capability of 100 mA
A power supply can be built using a transformer connected to the ac supply line to
step the ac voltage to desired amplitude, then rectifying that ac voltage, filtering with a
capacitor and RC filter, if desired, and finally regulating the dc voltage using an IC
regulator. The regulators can be selected for operation with load currents from hundreds
of mill amperes to tens of amperes, corresponding to power ratings from mill watts to
tens of watts.
Three-Terminal Voltage Regulators:
Fixed Positive Voltage Regulators:
IN OUT
Vin 78XX
Vout
GND
C1 C2
Fig shows the basic connection of a three-terminal voltage regulator IC to a load.
The fixed voltage regulator has an unregulated dc input voltage, Vi, applied to one input
terminal, a regulated output dc voltage, Vo, from a second terminal, with the third
terminal connected to ground. While the input voltage may vary over some permissible
voltage range, and the output load may vary over some acceptable range, the output
voltage remains constant within specified voltage variation limits. A table of positive
voltage regulated ICs is provided in table. For a selected regulator, IC device
specifications list a voltage range over which the input voltage can vary to maintain a
regulated output voltage over a range of load current. The specifications also list the
amount of output voltage change resulting from a change in load current (load regulation)
or in input voltage (line regulation).
7805 +5
7806 +6 35V
7808 +8
7810 +10
7812 +12
7815 +15
7818 +18
7824 +24 40V
ULN2003
5.ULN DRIVER
Features:
• High-Voltage Outputs . . . 50 V
Applications:
The applications include relay drivers, hammer drivers, lamp drivers,
display drivers (LED and gas discharge), line drivers, and logic buffers. The
ULN2803A has a 2.7-kΩ series base resistor for each Darlington pair for
Description:
The name stepper is used because this motor rotates through a fixed angular step in
response to each input curent pulse received by it’s controller. In recent years, there has
been wide-spread demand of stepping motors because of th eexplosive growth of
computer industry. Their popularity is due to th efact that they can be controlled directly
by computers, microprocessors and programmable controllers. Stepper motors are
ideally suited for situations where precise positon and precise speed control are required
without the use of closed-loop feedback. When a definite number of pulses are supplied ,
th eshaft turns through a definite known angle. This fact mekes th emotor well suited for
open-loop position control because no feedback need be taken from the output shaft.
Every stepper motor has a permanent magnet rotor also kown as shaft surrounded by a
stator poles. The most common stepper motor s have four stator windings that are paired
with a center-tapped. This type of stepper motor is commonly referred to as a four-phase
stepper motor. The center tap allows a change of current direction in each of two coils
when a winding is grounded,there by resulting in a polarity change of the stator.
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 direction of the rotation is
determined by the stator poles.the stator poles are determined by the current sent through
the wire coils. As the pol;arity of the current is changed, the polarity is also changed
causing th reverse motion of the motor 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. While a conventional motor shaft moves
freely,stepper motor shaft moves ina fixed repeatable increment which allows one to
move it to a precise position.this repeatable fixed movement is possible as a result of
basic magnetic theory where poles of he same polarity repel and opposite poles attract.
The stepper motor converts digital signals into fixed mechanical increment of motion. It
thereby provides a natural interface with the digital computer. It is a synchronous motor
such that the rotor rotates a specific incremental number of degrees for each pulse input
given to the motor system. These motors can provide accurate positioning without the
need of position feedback sensors when compared to other motors. The position is known
simply by keeping track of the input step pulses. Usually, position information can be
obtained simply by keeping count of the pulses sent to the motor thereby eliminating the
need of expensive position sensors and feedback controls
Stepper motors are rated by the torque they produce,step angle,steps per second and the
number of teeth on rotor.
The minimum degree of rotation with which the stepper motor turns for a single pulse if
supply to one wire or a pair is called step angle. The minimum step angle is always a
function of the number of teeth on rotor .i.e.,the smaller the step angle the more teeth the
rotor possess.
Stepping motors has the extraordinary ability to operate at very high speeds(upto 20,000
steps per second ) and yet to remain fully in synchronism with the command pulses, when
the pulse rate is high ,the shaft rotation seems continuous. If the stepping rate is
increased too quickly, the motor loses synchronism and stops. Stepper motors are
designed to operate for long periods with the rotor held in a fixed position and with rated
current flowing in the stator windings whereas for most of the other motors, this results in
collapse of back emf and a very high current which can lead to a quick burn out.
A stepper motor is a special kind of motor that moves in individual steps which are
usually .9 degrees each. Each step is controlled by energizing coils inside the motor
causing the shaft to move to the next position. Turning these coils on and off in sequence
will cause the motor to rotate forward or reverse. The time delay between each step
determines the motor's speed. Steppers can be moved to any desired position reliably
by sending them the proper number of step pulses.
@@@@@@@@@@@
Stepper motors:
A stepper motor's shaft has permanet magnets attached to it. Around the body of the
motor is a series of coils that create a magnetic field that interacts with the permanet
magnets. When these coils are turned on and off the magnetic field causes the rotor to
move. As the coils are turned on and off in sequence the motor will rotate forward or
reverse.
BACK EMF:
A motor is a machine which converts electric energy into mechanical energy. Its action is
based on the principle that when a current carrying conductor is placed in a mgnetic field,
it expieriences a mechanicalm force whose direction is given by Fleming’s left hand rule.
Fleming's left hand rule (for electric motors) shows the direction of the resultant motion
of the motor on a conductor carrying a current in a magnetic field.
The left hand is held with the thumb, index finger and middle finger mutually at right
angles.
The Second finger represents the direction of the Current (in the classical direction, from
positive to negative). The Thumb represents the direction of the Thrust or resultant
Motion.
Energy conversion is not possible unless there is some opposition whose overcoming
provides the necceessary means for such conversion. In case of generator it was the
magnetic drag which provided the necessary opposition. The equivalent in the case of a
motor is called as the back emf.
As soon as the armature or the rotor starts rotating , dynamically(or motionally ) induced
emf is produced in the armature conductors. The direction of this induced emf as found
by the fleming’s right hand rule , is in direct oppposition to the applied voltage. That is
why this is known as BACK EMF or counter emf. The electrical work done in
overcoming this opposition is converted into mechanical energy developed in the
armature. Therefore, it is obvious that but for the production of this opposing emf energy
eould not have been possible.
When the armature rotates the conductors also rotate and hence cut the flux. In
accordance with the laws of electromagnetic induction, emf is induced in them whose
direction, is in oppoaition to the applied voltage. This induced emf is called back emf.
Obviously supply voltage has to drive armature current against the opposition of back
emf.
These motors also suffer from EMF, which means that once the coil is turned off it starts
to generate current because the motor is still rotating. There needs to be an explicit way
to handle this extra current in a circuit otherwise it can cause damage and affect
performance of the motor.
The ULN2003 / MC1413 is a 7-bit 50V 500mA TTL-input NPN darlington driver. This
is more than adequate to control a four phase unipolar stepper motor such as the KP4M4-
001.
It is recommended to connect a 12v zener diode between the power supply and VDD (Pin
9) on the chip, to absorb reverse (or "back") EMF from the magnetic field collapsing
when motor coils are switched off. (See Douglas W. Jones' rather more sophisticated
example)
1. The four leads of the stator winding are controlled by the four bits of the 8051
port (p1.0-p1.3). However, since the 8051 lacks sufficient current to drive the
stepper motor windings, we must use a driver such as uln2003a to energize the
stator. Instead of the uln2003a, we could have used transistors as drivers.
2. However, notice that if transistors are used as drivers, we must also use diodes to
take care of inductive current generated when the coil is turned off. One reason
that the uln2003a is preferable to the use of transistors as drivers is that the
uln2003 has as internal diode to take care of back emf.
Most stepper motor circuits that are available onlne have a bunch of transistors,
Sometimes power trnsistors too quite a complicted circuit that drives you away far frm
using it. Well i felt for most robotic use the stepper motor can be driven by a simple
ULN2003 IC that costs just 12 bucks in my backyard.
While controlling the stepper motor with a embededd or distributed microoller for a
specific application, the controlling signals from the controller to the stepper motor must
be boosted up using a driven circuitry inorder to have the compatibility between them. In
the following figure, we show that the stepper motor is driven with ULN 2003 driven
circuitry.
@@@@@@@@@@@@@@@@@@@@@
A pulse is an electrical signal that repeats ON and OFF voltages as shown in the
illustration below. Each cycle of ON and OFF (1 cycle) is called a “pulse.”
Normally, a 5 volts is used. ON is high and OFF is low.
Figure 2.1 Pulse Train
To make a stepper motor rotate, you must constantly turn on and off the coils. If you
simply energize one coil the motor will just jump to that position and stay there resisting
change. This energized coil pulls full current even though the motor is not turning. The
stepper motor will generate a lot of heat at standstill. The ability to stay put at one
position rigidly is often an advantage of stepper motors. The torque at standstill is called
the holding torque.
Because steppers can be controlled by turning coils on and off, they are easy to control
using digital circuitry and microcontroller chips. The controller simply energizes the coils
in a certain pattern and the motor will move accordingly. At any given time the computer
will know the position of the motor since the number of steps given can be tracked. This
is true only if some outside force of greater strength than the motor has not interfered
with the motion.
When a phase winding of a stepper motor is energised with current ,a magnetic flux is
developed in the sator.the direction of this flux is determined by the “right hand rule”
which states:”if the coil is grasped in the right hand with fingers pointing in the direction
of th ecurrent in the winding (the thumb is extended at right angle to the fingers ),then the
thumb will point in the direction of the magnetic field .”
The number of times the stepper motor turns on and off depends on the number of teeth
present on the rotor and this is shown with an example in which four-step sequence is
considerd. Four-step sequence means, after completing every four steps,the rotor moves
only one tooth pitch. In this example,the rotor has only 25 teeth and so it makes 100 steps
for one complete rotation.
Figure 1 illustrates one complete rotation of a stepper motor. At position 1, we can see
that the rotor is beginning at the upper electromagnet, which is currently active (has
voltage applied to it). To move the rotor clockwise (CW), the upper electromagnet is
deactivated and the right electromagnet is activated, causing the rotor to move 90 degrees
CW, aligning itself with the active magnet. This process is repeated in the same manner
at the south and west electromagnets until we once again reach the starting position.
You may double the resolution of some motors by a process known as "half-stepping".
Instead of switching the next electromagnet in the rotation on one at a time, with half
stepping you turn on both electromagnets, causing an equal attraction between, thereby
doubling the resolution.
There are basically two types of stepper motors depending on the arrangements of the
electromagnetic coils. They are unipolar and bipolar
Unipolar:
In a unipolar stepper motor, there are four separate electromagnets. To turn the motor,
first coil "1" is given current, then it's turned off and coil 2 is given current, then coil 3,
then 4, and then 1 again in a repeating pattern. Current is only sent through the coils in
one direction; thus the name unipolar.
A unipolar stepper motor will have 5 (or 6) wires coming out of it. Four of those wires
are each connected to one end of one coil. The extra wire (or 2) is called "common" and
is connected to the other ends of all four coils. To operate the motor, the "common" wire
is connected to the supply voltage, and the other four wires are connected to ground
through transistors, so the transistors control whether current flows or not. A
microcontroller or stepper motor controller is used to activate the transistors in the right
order. these are the cheapest way to get precise angular movements.
Bipolar motor:
In a bipolar motor, there are only two coils, and current must be sent through a coil first
in one direction and then in the other direction; thus the name bipolar. Bipolar motors
need more than 4 transistors to operate them, but they are also more powerful than a
unipolar motor of the same weight. To be able to send current in both directions,
engineers can use an H-bridge to control each coil or a step motor driver chip.this type of
motor is not regularly used for robotics.
Bipolar controllers can switch between supply voltage, ground, and unconnected.
Unipolar controllers can only connect or disconnect a cable, because the voltage is
already hard wired. Unipolar controllers need center-tapped windings.
It is possible to drive unipolar stepper motors with bipolar drivers. The idea is to connect
the output pins of the driver to 4 transistors. The transistor must be grounded at the
emitter and the driver pin must be connected to the base. Collector is connected to the
coil wire of the motor.
Advantages:
Disadvantages:
3. This motor can also be heated at standing because of the torque required to hold it in
position.
Computer-controlled stepper motors are one of the most versatile forms of positioning
systems, particularly when digitally controlled as part of a servo system. Stepper motors
can be used to advantage where you need to control rotation angle,position and
synchronism. Stepper motors are used in floppy disk drives, flatbed scanners, and
typewriters, printers-y plotters, milling machines, valve actuators, medical equipment, fax
machines, automotives and many more devices.
5.4 APPLICATIONS:
Stepper motors are used for operation control in computer peripherals, textile industry, IC
fabrication and robotics etc. applications requiring incremental motion are typewriters,
line printers, tape drives, numerically-controlled machine tools, process control systems
and X-Y plotters.. Stepper motors also perform countless tasks outside the computer
industry. It includes commercial, military and medical applications where these motors
perform such functions as mixing, cutting, striking, metering, blending and purging. They
also take part in the manufacture of packed food stuffs, commercial end-products and
even the production of science fiction movies
KEYPAD :-
At the lowest level, keyboards are organized in a matrix of row and columns. The
CPU access both rows and columns through ports therefore
,with two bit ports, an 4x4 matrix of keys can be connected to the microprocessor. When
a key is pressed, a row and column make contact; otherwise there is no connection
between rows and columns.
Figure shows 4x4 matrixes connected to two ports. The rows are connected
to out port and columns are connected to an input port. If no key has been
pressed, reading the port will yield 1s for all column since all they are connected to high
(vcc).if all the rows are grounded and key is pressed provides the path to the ground. It is
the function of the microcontroller to scan the keyboard continuously to detect and
identify the key is pressed.
LCD
8.LCD:-
To send any of the commands from given table to the lcd, make pin RS =0.For
data, make RS=1.then send a high to low pulse to the E pin to enable the internal latch of
the LCD. As shown in figure for LCD connections.
Pin
Symbol Level I/O Function
number
1 Vss - - Power supply (GND)
2 Vcc - - Power supply (+5V)
3 Vee - - Contrast adjust
0 = Instruction input
RS 0/1 I
1 = Data input
0 = Write to LCD module
5 R/W 0/1 I
1 = Read from LCD module
6 E 1, 1->0 I Enable signal
7 DB0 0/1 I/O Data bus line 0 (LSB)
8 DB1 0/1 I/O Data bus line 1
9 DB2 0/1 I/O Data bus line 2
10 DB3 0/1 I/O Data bus line 3
11 DB4 0/1 I/O Data bus line 4
Pin
Symbol Level I/O Function
number
12 DB5 0/1 I/O Data bus line 5
13 DB6 0/1 I/O Data bus line 6
14 DB7 0/1 I/O Data bus line 7 (MSB)
KEIL SOFTWARE
9.KEIL SOFTWARE
1. SOFTWARE DESCRIPTION:
15. Click on the file option from menu bar and select “new”
16. The next screen will be as shown in next page, and just maximize it by double
clicking on its blue boarder.
20. Now you will get another window, on which by default “C” files will appear.
21. Now select as per your file extension given while saving the file
22. Click only one time on option “ADD”
23. Now Press function key F7 to compile. Any error will appear if so happen.
28. Drag the port a side and click in the program file.
29. Now keep Pressing function key “F11” slowly and observe.
You are running your program successfully
10.CIRCUIT DIAGRAM
11.WORKING PRINCIPLE
12. SOURCE CODE:
#include<reg51.h>
#include<string.h>
#define COL P2 //LOWER PINS OF PORT 2 :0,1,2
#define ROW P3 //LOWER PINS OF PORT 3 :0,1,2,3
sfr LCDDATA=0X90;//PORT 1;
sbit RS=P2^5;
sbit RW=P2^6;
sbit EN=P2^7;
sbit BUZZER=P2^3;
KEYPAD1();
lcdcmd(unsigned char);
lcddata();
serail();
lcddata1();
lcddata2();
lcddata3();
lcddata4();
lcddata5();
lcddata6(unsigned char);
lcdready();
strngcmp();
stepmotor();
delay(unsigned int);
int i,j,r ;
char passwd[4]="1234";
unsigned char keypad[4][3]=
{'1', '2', '3',
'4', '5', '6',
'7', '8', '9',
'*', '0', '#'};
char a[5];
main()
{
BUZZER=0;
lcdcmd(0x38);
lcdcmd(0x0E);
lcdcmd(0x01);
lcdcmd(0x06);
lcdcmd(0x81);
lcddata();
while(1)
{
serail();
strngcmp();
}//while(1)
///////////////////////////////////////////////////////////////////
strngcmp()
{
if((strcmp(passwd,a) ==0))
{
lcddata2();
lcdcmd(0xc3);
lcddata4();
stepmotor();
else
{
lcddata3();
lcdcmd(0xc3);
lcddata5();
BUZZER=1;
}
}// closing strcmp
serail()
{
for(i=0;i<4;i++)
{
a[i]=KEYPAD1();
lcddata6('*');
}
}
////////////////////////////////////////////////
lcddata()
{
unsigned char s;
unsigned char temp[14]="ENTER PASSWORD";
lcdready();
for(s=0;s<14;s++)
{
LCDDATA=temp[s];
RS=1;
RW=0;
EN=1;
delay(1);
11EN=0;
}
}
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
lcddata2()
{
unsigned char s;
unsigned char temp[12]=" VALID ";
lcdready();
for(s=0;s<12;s++) //DATA2
{
LCDDATA=temp[s];
RS=1;
RW=0;
EN=1;
delay(1);
EN=0;
}
}
///////////////////////////////////////////////////////////////////
lcddata3()
{
unsigned char s;
unsigned char temp[12]=" IN VALID ";
lcdready();
//DATA3
for(s=0;s<12;s++)
{
LCDDATA=temp[s];
RS=1;
RW=0;
EN=1;
delay(1);
EN=0;
}
}
/////////////////////////////////////////////////////////////////
lcddata4()
{
unsigned char s;
unsigned char temp[12]=" WELCOME ";
lcdready();
//DATA4
for(s=0;s<12;s++)
{
LCDDATA=temp[s];
RS=1;
RW=0;
EN=1;
delay(1);
EN=0;
}}
////////////////////////////////////////////////////////////////////////////
lcddata5()
{
unsigned char s;
unsigned char temp[12]=" SORRY ";
lcdready();
for(s=0;s<12;s++)
{ //DATA5
LCDDATA=temp[s];
RS=1;
RW=0;
EN=1;
delay(1);
EN=0;
}}
//////////////////////////////////////////////////////////////
lcdcmd(unsigned char value)
{
lcdready();
LCDDATA=value;
RS=0;
RW=0;
EN=1;
delay(1);
EN=0;
return;
}
//////////////////////////////////////////////////
lcdready()
{
BUSY=1;
RS=0;
RW=1;
while(BUSY==1)
{
EN=0;
delay(1);
EN=1;
}
return;
}
/////////////////////////////////////////////////////////////
KEYPAD1()
{
while(1)
{
ROW=0xFE;
colloc=COL;
colloc&=0x07;
if (colloc != 0x07)
{
rowloc=0;
break;
}
ROW=0xFD;
colloc=COL;
colloc&=0x07;
if (colloc != 0x07)
{
rowloc=1;
break;
}
ROW=0xFB;
colloc=COL;
colloc&=0x07;
if (colloc != 0x07)
{
rowloc=2;
break;
}
ROW=0xF7;
colloc=COL;
colloc&=0x07;
if (colloc != 0x07)
{
rowloc=3;
break;
}
}
if (colloc== 0x06)
return(keypad[rowloc][0]);
else if(colloc==0x05)
return(keypad [rowloc][1]);
else
return(keypad [rowloc][2]);
}
stepmotor()
{
P0=0X11;
delay(20);
P0=0X22;
delay(20);
P0=0X44;
delay(20);
P0=0X88;
delay(20);
P0=0X11;
delay(20);
P0=0X22;
delay(20);
P0=0X44;
delay(20);
P0=0X88;
delay(20);
P0=0X11;
delay(20);
P0=0X22;
delay(20);
P0=0X44;
delay(20);
P0=0X88;
delay(20);
P0=0X44;
delay(20);
P0=0X22;
delay(20);
P0=0X11;
delay(20);
P0=0X88;
delay(20);
P0=0X44;
delay(20);
P0=0X22;
delay(20);
P0=0X11;
delay(20);
P0=0X88;
delay(20);
P0=0X44;
delay(20);
P0=0X22;
delay(20);
P0=0X11;
delay(20);
}
13. CONCLUSION
Embedded systems are emerging as a technology with high potential. In the past
decades micro processor based embedded system ruled the market. The last decade
witnessed the revolution of Microcontroller based embedded systems. This project
basically deals with how many number of persons are in the room very accurately with
the help of Microcontroller. With regards to the requirements gathered the manual work
and the complexity in counting can be achieved with the help of electronic devices.
14.FUTURE SCOPE
This system is a rapidly growing field and there are new and improved
strategies popping up all the time. For the most part these systems are all built around the
same basic structure, a central box that monitors several detectors and perimeter guards
This system is best for guiding the perimeter of a house or a business center
the points where an intruder would enter the building. In this system IR sensor is used to
detect the intrusion. Similarly the vibration and temperature sensors recognize vibration
Incorporating the features discussed below can further enhance the system
This system can detect intrusion only at discrete points. This system
intrusion into the building can be detected with much more efficiently.
The redialing feature can also be incorporated such that if the call is not put
forward the first time, the auto dialer will dial the same number until the call
is successfully completed.
A pre-recorded voice message can delivered to the owner notifying him about
The addition of the above discussed advancements certainly builds this project
3..www.howsstuffworks.com
4. www.alldatasheets.com
5. www.electronicsforu.com
6. www.knowledgebase.com
7.www.8051 projectsinfo.com