Upload
arun-golwara
View
218
Download
0
Embed Size (px)
Citation preview
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
1/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
ABSTRACT
Each and every part of our life is somehow linked with the embedded products.
Embedded systems are the product of hardware and software co-design. Embedded system is
becoming an integral part of Engineering design process for efficient analysis and effective
operation. From data analysis to hardware work, everywhere embedded products are the main
interest because of its reliability and time bound perfection. Due to time complexity in electronic
aspects embedded systems have become a major part of our daily life. This project describes the
design of an embedded system for the MCROCONTROLLER BASED DAM CONTROL
SYSTEM.
Personal Computer based electrical appliances control is an interesting Personal
Computer based project, mainly useful for industrial applications, home automation, and
supervisory control applications. This project gives exact concept of interfacing a high voltage
electrical device or DC / AC motor to high sensitive personal computer system.
We are using RS232 as the communication medium between personal computer and
controller. We are controlling the dc motor by sending signals from the personal computer to
controller.
This project uses regulated 5V, 500mA power supply, LM7805 three terminal voltage
regulators for voltage regulation. Full wave rectifier is used to rectify the ac output of secondary
of 230/12V step down transformer.
Water level in a dam needs to be maintained effectively to avoid complications. This is
generally performed manually which requires full time supervision by the operators & have
fairly large staff complements. Moreover, the quantity of water released is hardly ever correct
resulting in wastage of water & it is impossible for a man to precisely control the gates without
the knowledge of exact water level and water inflow rate. The main objective of this project is to
develop a mechatronics based system, which will detect the level of water and thereby themovement of gates can be controlled in a real-time basis which offers more flexibility. This
system consists of a set of sensors connected to a stepper motor through an 8-bit microcontroller
(AT89S52). The water level is detected based on the feedback from the mechanism used. Based
on this data, the level of dam gate can be controlled using a stepper motor via personal computer.
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
2/108
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
3/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
1.2 History:
In January 1975 issue, Popular Electronics magazine featured an article describing the
Altair 8800 computer that was the first microcomputer build and programs themselves. The basic
Altair included no keyboard, video display, disk drives, or other elements essential for personal
computer. Flipping toggle switches on front panel programmed its 8080 microprocessor. Altairs
usability occurred when small company called Microsoft offered a version of different
programming languages for it.
Of course, Microsoft has become an enormous software publisher, and a typical personal
computer now includes a keyboard, video display, disk drives, and Megabytes of RAM. Theres
no longer any need to build a personal computer from scratch. A personal computer like Apples
Macintosh or IBMs PC is a general-purpose machine, since you can use it for many
applications- Word processing, spreadsheets, computer-aided design and more. But along with
cheap, powerful, and versatile personal computers has developed a new interest in small,
customized computers for specific uses. Each of these small computers is dedicated to one task
or a set of closely related tasks.
At core of many of these specialized computers is a micro controller. The computers
program is typically stored permanently in semiconductor memory such as ROM or EPROM.
The interfaces between the microcontrollers and the outside world vary with the application, andmay include a small display, a keypad or switches, sensors, relays, motors, and so on. These
small, special purpose computers are sometimes called single-board computers or SBCs.
Now, micro controllers have become the part and parcel of todays world. More and more
advanced featured microcontrollers.
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
4/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
1.3 A block diagram of the Microcontroller:
Figure 1.1: A basic block diagram of a typical Microcontroller
1.4 Micro-Processor CPU:
The design incorporates all of the features found in a micro-processor CPU: ALU, PC, SP,
and registers. It also has added the other features needed to make a complete computer: ROM,
RAM, parallel I/O, serial I/O, counters, and a clock circuit.
Like a microprocessor, a microcontroller is a general purpose device, but one that is meant
to read data, performs limited calculations on that data, and control its environment based on
those calculations. The prime use of a microcontroller is to control the operation of a machine
using a fixed program that is stored in ROM and that does not change over the lifetime of the
system.
The design approach of the microcontroller mirrors that of the microprocessor: make a
single design that can be used in as many applications as possible in order to sell, hopefully, as
many as possible. The microprocessor design accomplishes this goal by having a very flexible
and extensive repertoire of multi-byte instructions. These instructions work in a hardware
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
5/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
configuration that enables large amounts of memory and I/O to be connected to the address and
data bus pins on the integrated circuit package. Much of the activity in the microprocessor has to
do with moving code and data to and from external memory to the CPU. The architecture features
working registers that can be programmed to take part in the memory access process, and the
instruction set is aimed at expediting this activity in order to improve throughout. The pins that
connect the microprocessor to the external memory are unique, each having a single function.
Data is handled in byte, or larger, sizes.
The microcontroller design uses a much more limited set of single and double-byte
instructions that are used to move code and data from internal memory to the ALU. Many
instructions are coupled with pins on the integrated circuit package, the pins are programmable -
that is, capable of having several different functions depending on the wishes of the programmer.
The microcontroller is concerned with getting data from and its own pins; the architecture
and instruction set are optimized to handle data in bit and byte size.
The pin diagram of the 8051 shows all of the input/output pins unique to microcontrollers:
Figure 1.2: pin diagram of 8051 microcontroller
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
6/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
The following are some of the capabilities of 8051 microcontroller:
Internal ROM and RAM
I/O ports with programmable pins
Timers and counters
Serial data communication
The 8051 architecture consists of these specific features:
16 bit PC &data pointer (DPTR)
8 bit program status word (PSW)
8 bit stack pointer (SP)
Internal ROM 4k
Internal RAM of 128 bytes
4 register banks, each containing 8 registers
80 bits of general purpose data memory
32 input/output pins arranged as four 8 bit ports: P0-P3
Two 16 bit timer/counters: T0-T1
Two external and three internal interrupt sources Oscillator and Clock circuits.
1.5 Comparing Microprocessors and Microcontrollers:
The contrast between a microcontroller and a microprocessor is best exemplified by the
fact that most microprocessors have many operational codes (op-codes) for moving data from
external memory to the CPU; microcontrollers may have one or two. Microprocessors may have
one or two types of bit handling instructions; microcontrollers will have many.
To summarize the microprocessor is concerned with rapid movement of code and data
from external address to the chip. The microcontroller is concerned with rapid movement of bits
with in the chip. The microcontroller can function as a computer with the addition of no external
digital parts; the microprocessor must have many additional parts to be operational.
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
7/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
1.6 Project steps:
Putting together a microcontrollers project involves several steps:
1. Define the task.2. Design and build the circuits.3. Write the controls program.4. Test and debug.
Sometimes the steps wont follow exactly in this order. You may begin writing your
program before you build the circuits or you may build and test some of the circuits before you
start programming. But however you go about it; each of the above steps is part of the process. To
see whats involved in each step, lets look at each in more detail.
1.Define the task:Every project begins with an idea or a problem that needs a solution i.e., how can I
monitor light intensity at different locations and times of find the best location for a solar
collector? Or how can I automate the process of drilling printed- circuit boards? Or how can I
create a computer-controlled, animated display for a store window?
Once you know what to accomplish, you need to determine whether that idea is been
required to computer. In general, a computer is the way to go when the circuits must make
complex decisions or deal with complex data. For example, a simple AND gate can easily decide
whether or not two inputs are both valid logic highs, and will changes its output accordingly. But
it require many small-scale chips to build a circuit that stores a series of values representing
sensor outputs and times they occurred and display easily.
In this type of applications microcontrollers in comes handy. Inside, microcontrollers are
little more than a carefully designed array logic gates and memory cells, but modern fabrication
processes allow thousands of these to fit on a single chip. Since basic function microcontrollers
are performing arithmetic, logic, data-moving, and program branching functions-commonly
useful in many applications.
On the other end, how does u know that this idea is suitable for a microcontroller, or
whether you should use a full desktop computer? Then a system with keyboard, full-screen
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
8/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
display, and disk drives makes sense. For simpler designs, a microcontroller with perhaps a
keypad, small display, and solid-sate memory (no disk drives) can often do the job, with less
expense and smaller size.
In fact, recently the two extremes have been meeting. Some 32-bit microcontrollers are as
capable as desktop systems, and notebook-size computers are available with solid-state, diskless
storage. And also expansion cards, other hardware, and software are now available for those who
want to use desktop computer for monitoring and control tasks. So theres something for
everyone.
2.Design and building:When youre ready to design and build the circuits for a project, there are several ways to
proceed. You can design your circuits from scratch. You can buy an assembled single-board
computer, adding only the interfaces and programming your application requires and you can also
build yourself, but you can also use a kit or assembled broad as a base.
Choosing a chip:
Does it matter which microcontrollers chip you use? All microcontrollers contain CPU,
chance are that you can use any of several devices for a specific project.
Within each device, youll usually find ma selection of family members, each with
different combination of options. For example, the 8052- BASIC is a member of the 8051 family
of microcontrollers which includes chips with program memory in ROM or PRTOM, and with
varying amounts of RAM and other features. You can select the version that best suits your
systems requirements.
Microcontrollers are also characterized by how many bits of data they process at once,
with a higher number of bits generally including a faster or more powerful chip. Eight-bit chips
are popular for simpler design, but 4-bits, 16-bits, and 32-bits architectures are also available.
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
9/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
Power consumption is another consideration, especially for battery-powered systems.
Chips manufactured with CMOS process usually have lower power consumption than those
manufactured with NMOS process.
All microcontrollers have a defined instruction set, which consists of the binary words that
cause the CPU to carry out specific operations. For example, the instruction 0010 0110 tells to
add the values in two locations. The binary instructions are also known as operation codes or
opcodes for short. The opcodes perform basic functions like adding, subtraction, logic operations,
moving and copying data, and controlling program branching.
Control circuits often require reading or changing single bits of input or output, rather
than reading and writing a byte at a time. For example, a microcontroller might use the eight bitsof an output port to switch power to eight sockets. If each socket must operate independently of
others, a way is needed to change each bit without affecting the others. Many microcontrollers
include bit- manipulation (also called Boolean) opcodes that easily allows to set, clear, compare,
copy, or perform other logic operations on single bits of data, rather than a byte at a time.
Options for storing programs:
Another consideration in circuit design is how to store programs. Instead of using disk
storage, moist microcontroller circuits store their programs on-chip. For one-of-kind projects for
small-volume production, PROM has long been the most popular method of program storage.
Other options include EEPROM, ROM, nonvolatile (NV), or battery-backed, RAM, and flash
EPROM. The program memory may be in the microcontrollers chip, or a separate component.
Some microcontrollers contain a one time-programmable (OTP), or field-programmable,
EPROM. This type has no windows, so you cant erase its contents, but because its cheaper than
a windowed IC, its a good choice when you finished the program and device is ready.
Several techniques available for programming EPROMs and other memory chips. With a
manual programmer, you flip switches to toggle each bit and program the EPROM byte by byte.
It is acceptable for short programs, but quickly becomes tedious. In EPROM programmer can
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
10/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
write program, save it to disk and store the program in a few steps. Some of other storing
programs are
EEPROMs are much like EPROM except that they are electrically any ultraviolet sources are
required. Limitations of EEPROM include slow speed, high cost, and a limited no. of times that
can be reprogrammed (typically 10, 000 to 100,000).
ROMs are cost-effective when you need thousands of copies of a single program. ROMs must
be factory-programmed and once programmed, cant change.
NVRAM typically includes a lithium cell, control circuits, and RAM encapsulated in a single IC
package. When power is removed from the circuit, lithium cells takes over and preserves the
information in RAM for 10 years or more. You can program NVRAM infinite no of times with
the only limitation being battery life.
Flash EPROM is electrically erasable, like EEPROM, but most flash devices erase all at once or
byte-byte like EEPROM. Some Flash EPROMs requires special programming voltages.
Other memory: Most systems also require a store way for temporary use like RAM, whose
contents can change. Unlike EPROM, ROM, EEPROM and NVRAM. The contents of the RAM
disappear when you remove power the chip. Most microcontrollers include some RAM, typicallya few 100bytes.
I/O options:
Finally, I/O requires design. Most system require interface to things like sensors, keypads,
switches, relays and displays. Most microcontrollers have ports for interfacing to the world
outside the chip. You can easilyincrease the available I/O by adding support chips.
3. Writing the controls programs:When its time to write program that controls your project, the options include using
machine code, assembly language, or a higher-level language. Which programming languages
you use depend on things like desired execution speed, program length, and convenience as well
as price range.
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
11/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
Machine code:
The most fundamental program form is machine code, the binary instruction that causes
the CPU to perform the operations.
Assembly language:
One step removed from machine code is assembly language, where abbreviation called
mnemonics (memory aids) substitute for the machine codes. The mnemonics are easier to
remember than the machine codes. For example, in the 8052s assembly language, the mnemonic
CLR C means clear the carry bit, and is easier to remember than its binary code (11000011).
Since machine code is ultimately the only language that a CPU understands, you needsome ways of translating assembly-language programs into machine code. For short programs,
you can hand assemble or translate the mnemonics into machine codes. Another option is
assemble, which is software that runs on a desktop computer and translates the mnemonics into
machine code. Most assemblers provide after features, such as formatting the program code and
creating a listing both the machine- code assembly-language versions of a program side-by-side.
Higher-level language:
A disadvantage to assembly language is that each device family has its own set of
mnemonics, so you have to learn a new vocabulary for each family. To get around this program,
higher-level languages like C, Pascal, FORTRAN, Forth, and BASIC follows a standard syntax.
Higher-level languages also simplify programming by allowing you to do in one or a few
lines what would require many lines of assembly code to accomplish.
Interpreters and compilers:
Interpreters and compilers are two forms of higher-level languages. An interpreter
translates a program into machine code each time the program runs, while a compiler translates
only once, creating a new, executable that the computer runs directly, without re-translating.
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
12/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
As interpreters are very convenient for shorter programs where execution speed is not
critical. An interpreter language, you can run your program code immediately after you write it,
without a separate compiler or assembly. A compiler is a good choice when a program is long or
has to execute quickly.
Each device family requires its own interpreter or compiler to translate the higher-level
code into the machine level code. In other words, you can use PCs to program a microcontroller.
4. Testing and debugging:After you have written a program, its time to test it and find correct mistakes to get it
work properly. The process of ferreting out correcting mistakes is called debugging. Easy
debugging and troubleshooting can make a big difference in how long it takes to get a system upand running. You have several options.
Testing in EPROM:
One way is to burn your program into EPROM, install the EPROM in your system, run
the program, and observes the results. If problems occur you modify he program, erase and reburn
the EPROM and try again, repeating as many times as necessary until the system is operating
properly.
Development systems:
Another option is to use development system. A typical development system consists of a monitor
program,which is a program stored in EPROM or other memory in the microcontroller system,
and a serial link to a personal computer. Using the abilities of the monitor program, you can load
your program from personal computer into RAM on the microcontroller system, then run the
program, modify it, and retry as often as necessary until the program is working properly.
Most development systems also allow single stepping, setting breakpoints, and viewing
and changing the data in memory. In single stepping, you run the program one step at a time,
pausing after each step, so you can more easily monitor what the circuits and program are doing
at each step. A breakpoint is a program location where the program stops executing and waits for
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
13/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
a command to continue. You can set breakpoints at critical spots. At any breakpoint, you can view
or change the contents of memory or perform.
Simulators:
Another development tool is a simulator, which is software that runs on a desktop
computer and uses the video display to demonstrate what would happen if a specific
microprocessor or microcontroller were to run a particular program. You can look inside the
simulated chip, observe the contents of internal memory, and single step or set breakpoint to stop
program execution at a desired program location or condition. In this way, you can get a program
working properly. One of the drawbacks is that they cant mimic all features of the chip of interest,
especially interrupt- response and timing characteristics.
Emulators:
An in-circuit emulator (ICE) is hardware that replaces the microprocessor in question by
plugging into the microprocessors socket on the device you want to test. Like simulator, an
emulator lets you control program execution and monitor what happens at each program step.
Microprocessor emulators typically are expensive. A ROM emulator is a lower-cost option that
simulates an EPROM for program storage, and usually provides the abilities of a development
system as well.
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
14/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
CHAPTER 2: STEPPER MOTOR
2.1 INTRODUCTION TO STEPPER MOTORS:
Motion control, in electronic terms, means to accurately control the movement of an
object based on speed, distance, load, inertia or a combination of all these factors. There are
numerous types of motion control systems, including; Stepper Motor, Linear Step Motor, DC
Brush, Brushless Servo and more. This document will concentrate on Step Motor technology.
Like many conventional electric motors, a stepper motor consists of a magnet and coils
of wire. Whereas conventional motors spin continuously, a stepper motor moves around one
small step at a time (hence the name). A stepper motor is a marvel in simplicity. It has no
brushes, or contacts. Basically its a synchronous motor with the magnetic field electronically
switched to rotate the armature magnet around.
The stepper motor is an electromagnetic device that converts digital pulses into
mechanical shaft or spindle 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
motors rotation has several direct relationships to these applied input pulses. 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 rotations
applied. The simplest way to think of a stepper motor is a bar magnet and four coils.
A B C D
Figure2.1: linear stepper motor basic principle.
When the current flows through coil A the magnet is attracted and moves one step to the right.
Coil B is then turned off and coil C turned on. The magnet moves another step to the right
and soon. A similar process occurs inside the stepper motor, but the magnet is cylindrical and
rotates inside the coils. In order to make a stepper motor rotate you must turn on each coil in the
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
15/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
correct sequence. The motor will continue to rotate as long as you continue the sequence. Pulsing
the coils, or phases, sequentially will cause the motor to rotate clockwise or counterclockwise
depending on the sequence chosen. The speed of rotation is determined by the frequency of the
pulses to the coils i.e., speed of pulsating the coils in a sequence.
Figure 2.2: General arrangement of windings inside a stepper motor
A stepping motor system consists of three basic elements, often with same type of user
interface (Host Computer, PLC or Dumb Terminal):
Figure2.3: General stepper motor system.
The indexer (or Controller)) is a microprocessor capable of generating step pulses and
direction signals for the driver. In addition, the indexer is typically required to perform many
other sophisticated command functions.
The Driver (or Amplifier) converts the indexer command signals into the power
necessary to energize the motor windings. There are numerous types of drivers, with different
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
16/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
current/amperage ratings and construction technology. Not all drivers are suitable to run all
motors, so when designing a Motion Control System the driver selection process is critical.
2.2 CONSTRUCTION AND TYPES OF STEPPER MOTORS:
Stepping motors are electromagnetic, rotary, incremental devices which convert digital
pulses intomechanical rotation. The amount of rotation is directly proportional to the number of
pulses and the speed of rotation is relative to the frequency of those pulses. Stepping motors are
simple to drive in an open loop configuration and their size provides excellent torque at low
speed.
Although various types of stepping motor have been developed, they all fall into three
basic categories. Classification is based on the use of permanent magnets and/or iron rotors with
laminated steel stators in their construction. The three types of stepping motors are:
1. Variable reluctance (V.R) stepping motor,
2. Permanent magnet stepper (tin can) motor and
3.
Hybrid stepper motor.
Stepper motor can also be classified based on their size and power.
Size: Generally stepper motors are classified according to their frame size (body diameter). For
example, a size 23 stepper motor has a body size of approximately 2.3 inches. The most common
frame sizes are 11, 17, 23, 34, and 42.
Power: power levels for the stepper motors range typically from few hundred mill watts (for
small motors) up to several watts (for larger motors). The max power dissipation of a steppermotor is determined by the thermal limits of the windings in the motor. To determine this we
must apply the relationship P=V*I.
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
17/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
2.2.1 VARIABLE RELUCTANCE STEPPER MOTOR:
The variable reluctance motor does not use a permanent magnet. As a result, the motor
can move without constraint or detent torque. This type of construction is good in non
industrial applications that do not require a high degree of motor torque, such as the positioning
of the micro slide.
The stator of variable reluctance stepper motor is similar to that of permanent magnet
stepper motor. The torque is developed due to large difference in magnetic reluctances that exist
between direct and quadrature axis. The stationary field developed by the direct current in some
stator coil tends to develop a torque which causes the rotor to move position where the reluctance
of the flux path is minimum.
Figure 2.4: Cross section of the variable reluctance stepper motor.
The variable reluctance or V.R motor consists of a rotor and stator each with a different
number of teeth. Since the rotor does not have a permanent magnet it spins freely i.e., it has no
detent torque. Although the torque to inertia ratio is good, the rated torque for a given frame size
is restricted. Therefore small frame sizes are generally used and then very seldom for industrial
applications.
The variable reluctance motor in the above illustration has four stator pole sets (A, B,
C), set 15deg apart. Current applied to pole A through the motor winding causes a magnetic
attraction that aligns the rotor ( tooth) to pole A. energizing stator pole B causes the motor to
rotate 15 deg in alignment with pole B. this process will continue with pole C and back to A in
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
18/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
clockwise direction. Reversing the procedure (C to A) would result in counter clockwise
rotation.
Figure2. 5: Variable reluctance stepper motor.
2.2.2 PERMANENT MAGNET STEPPER MOTOR:
The permanent magnet motor also referred to as can-stack motor has, as the name
implies b a permanent magnet rotor. It is a relatively low speed, low torque device with large
step angles of either 45 or 90 deg. Its simple construction and low cost make it an ideal choice
for non industrial applications, such as a line printer print wheel positioned.
Figure 2.6: Crosssection Through A Permanent Magnet
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
19/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
In its simplest form the motor consists of a radially magnetized permanent magnet rotor
and a stator similar to the V.R. motor. Due to the manufacturing techniques used in constructing
the stator they are also sometimes known as claw pole motors.
Figure 2.7: Permanent magnet stepper motor.
The rotor of such a motor has even number of poles made of high retentively steel alloy
(Alnico). Both rotor and stator may employ salient or non salient pole construction usually the
stepper motors have in small stepping angles are of non salient pole constructionUnlike the other
stepping motors, the PM motor rotor has no teeth and is designed to be magnetized at a right
angle to it's axis. The above illustration shows a simple, 90 degree PM motor with four phases
(A-D). Applying current to each phase in sequence will cause the rotor to rotate by adjusting to
the changing magnetic fields. Although it operates at fairly low speed the PM motor has a
relatively high torque characteristic.
2.2.3 HYBRID STEPPER MOTOR:
The hybrid is probably the most widely used of all stepping motors. Originally developed
as a slow speed synchronous PM motor its construction is a combination of the V.R. and tin-can
designs. The hybrid consists of a multi-toothed stator and a three part (single stack). The single
stack rotor contains two toothed pole pieces separated by an axially magnetized permanent
magnet, with the opposing teeth off-set by half of one tooth pitch (fi8) to enable a high resolution
of steps.
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
20/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
Hybrid motors combine the best characteristics of the variable reluctance and permanent
magnet motors. They are constructed with multi-toothed stator poles and a permanent magnet
rotor. Standard hybrid motors have 200 rotor teeth and rotate at 1.80 step angles. Other hybrid
motors are available in 0.9and 3.6 step angle configurations.
Figure 2.8: Exploded Drawing Illustrating The Tooth Pitch Off-set
Because they exhibit high static and dynamic torque and run at very high step rates,
hybrid motors are used in a wide variety of industrial applications.
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
21/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
Figure 2.9: Hybrid Stepper Motor
2.3 WINDINGS OVERVIEW OF STEPPER MOTOR:
2.3.1 BIPOLAR WINDING:
The two phase stepping sequence described utilizes a bipolar coil winding. Each phase consists
of a single winding. By reversing the current in the windings, electromagnetic polarity is
reversed. The output stage of a typical two phase bipolar drive is further illustrated in the
electrical schematic diagram and stepping sequence in figure 5. As illustrated, switching simply
reverses the current flow through the winding thereby changing the polarity of that phase.
BIPOLAR
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
22/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
CW
BIPOLAR STEP Q2-Q3 Q1-Q4 Q6-Q7 Q5-Q8
CCW
1 ON OFF ON OFF
2 OFF ON ON OFF
3 OFF ON OFF ON
4 ON OFF OFF ON
1 ON OFF ON OFF
Figure 2.10: Bipolar winding arrangement
2.3.2 UNIPOLAR WINDING:
Another common winding is the unipolar winding. This consists of two windings on a pole
connected in such a way that when one winding is energized a magnetic north pole is created;
when the other winding is energized a south pole is created. This is referred to as a unipolarwinding because the electrical polarity, i.e., current flow, from the drive to the coils is never
reversed. The stepping sequence is illustrated in figure 6. The design allows for a simpler
electronic drive.
UNIPOLAR
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
23/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
Figure 2.11: Unipolar winding arrangement
However, there is approximately 30% less torque available compared to a bipolar winding.
Torque is lower because the energized coil only utilizes half as much copper as compared to a
bipolar coil.
CW
UNIPOLAR STEP Q1 Q2 Q3 Q4
CCW
1 ON OFF ON OFF
2 OFF ON ON OFF
3 OFF ON OFF ON
4 ON OFF OFF ON
1 ON OFF ON OFF
2.4 STEPPER MOTOR SWITCHING SEQUENCE:
Switching sequences for stepper motor are:
1. Full step
2. Half step, and
3. Micro-step.
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
24/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
2.4.1 FULL STEP MODE:
The stepper motor uses a four switching sequence, which is called a full-step switching
sequence. Figure below shows a switching diagram and a table that indicates the sequence for the
four switches used to control the stepper motor. The diagram shows four switches with four
separate amplifiers. The diagram for the motor shows the same four windings that were
discussed in the theory of operation the previous section. Each of the windings is tapped at one
end and they are connected through a resistor to the negative terminal of the power supply.
The table shows the sequence for energizing the coils. During the first step of the
sequence, switches SW1 and SW3 are on and the other two are off. During the second step of the
sequence, switches SW1 and SW4 are on and the other two are off. During the third step of thesequence, SW2and SW4 are on and the other two are off. . During the fourth step of the
sequence, SW2 and SW3 are on and the other two are off. This sequence continues through four
steps, then the same four steps are repeated again. These steps cause the motor to rotate one step
or tooth on the rotor when a pulse is applied by closing two of the switches.
Figure 2.12: (a) Diagram of switching circuits for stepper motor (b) The switching sequence for afour step (full step) switching mode
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
25/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
Figure 2.13: The diagram that shows the position of each pole while the motor is infull step mode.
The diagrams a, b, c and d show the movement of rotor in sequence
Figure 11 shows the position of the poles during each step when the motor is in full-step mode.
2.4.2 HALF STEP MODE:
Another switching sequence for the stepper motor is called an eight-step or half- step
sequence. Theswitching diagram for the half-step sequence is shown in fig12. The main feature
of this switching sequence is that you can double the resolution of the stepper motor by causing
the rotor to move half the distance it does when the full-step switching sequence is used. This
means that a 200-step motor, which has a resolution of 1.8 deg, will have a resolution of 400
steps and 0.9 deg. The half-step switching sequence requires a special motor controller, but it can
be used with a standard hybrid motor. The way the controller gets the motor to reach the half-
step is to energize both phases at the sane time with equal current.
In this sequence the first step has SW1 and SW3 on, and SW2 and SW4 are off. The sequence
for the first step is the same as the full-step sequence. The second step has SW1 on and all of the
remaining switches are off. This configuration of switches causes the rotor to move an additional
half-step.
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
26/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
The third step has SW1 and SW4 on, and sw2 and SW3 are off, which is the same as step 2 of
the full-step sequence. The sequence continues for eight steps and then repeats.
Figure 2.14: The stepper motor with its switches, (b) the switching sequence for the eight step
input (half step mode)
The main difference between this sequence and the full step sequence is that steps 2, 4, 6,
and 8 are added to the full-step sequence to create the half-step moves.
2.4.3 MICRO STEP MODE:
The full-step and half-step motors tend to be slightly jerky in their operation as the motor
moves from step to step. The amount of resolution is also limited by the number of physical
poles that the rotor can have. The amount of resolution (number of steps) can be increased by
manipulating the current that the controller sends to the motor during each step. The current can
be adjusted so that it looks similar to a sine wave.
Figure 15 shows the waveform for the current to each phase. From this diagram you can
see that the current sent to each of the two windings is timed so that it is always out of phase
with each other. The fact that the current to each individual phase increase and decreases like a
sine wave and that is always out of time with the other phase will allow the rotor to reach
hundreds of intermediate steps. In fact it is possible for the controller to reach as many as 500
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
27/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
micro steps for a sequence full-step sequence, which will provide 100, 00 steps for each
resolution. The voltage sent to the motor is now a sine wave. The motor for this type of
application is generally a permanent magnet brushless DC motor. When the sine wave is sent to
the motor at 60hz, it will cause the motor shaft to rotate at 72rpm. The motor windings will
require capacitor to be wired in series for this type of application.
Figure
2.15: Phase-current diagram for a stepper motor controller in micro step mode
2.5 PERFORMANCE CHARACTERISTICS OF STEPPER MOTOR:
1. Rotation angle is proportion to the number of input pulses.
2. Rotational speed is proportional to the frequency of input pulses.
3. Open loop system with no position feedback required.
4. Excellent response to acceleration, deceleration and step commands.
5. No cumulative position error (+ or5% of step angle).
6. Excellent low speed and high torque characteristics without need for gear reduction.
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
28/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
7. Inherent detent torque.
8. Bi-directional operation.
9. Can be stalled without motor damage.
10. No brushes for longer trouble free life.
11. Precision ball bearings.
12. Repetition of accurate motion or velocity profiles.
13. A holding torque at 0 speed and
14. Capability for digital control
15. Holding torque when energized.
2.6 DRIVER TECHNOLOGY OVERVIEW:
The stepper motor driver receives low-level signals from the indexer or control
system and converts them into electrical (step) pulses to run the motor. One step pulse is required
for every step of the motor shaft. In full step mode, with a standard 200 step motor, 200 step
pulses are required to complete one revolution. Likewise, in microstepping mode the driver may
be required to generate 50,000 or more step pulses per revolution. Speed and torque performance
of the step motor is based on the flow of current from the driver to the motor winding. The factor
that inhibits the flow, or limits the time it takes for the current to energize the winding, is known
as inductance. The lower the inductance, the faster the current gets to the winding and the better
the performance of the motor. To reduce inductance, most types of driver circuits are designed to
supply a greater amount of voltage than the motors rated voltage.
2.6.1 TYPES OF STEP MOTOR DRIVERS:
For industrial applications there are basically three types of driver technologies. They all
utilize a "translator" to convert the step and direction signals from the indexer into electrical
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
29/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
pulses to the motor. The essential difference is in the way they energize the motor winding. The
circuit that performs this task is known as the "switch set."
Figure 2.16: Block diagram of switch set
2.6.2 UNIPOLAR:
The name unipolar is derived from the fact that current flow is limited to one direction.
As such, the switch set of a unipolar drive is fairly simple and inexpensive. The drawback to
using a unipolar drive however, is its limited capability to energize all the windings at any one
time. As a result, the number of amp turns (torque) is reduced by nearly 40% compared to other
driver technologies. Unipolar drivers are good for applications that operate at relatively low step
rates.
2.6.3 R/L:
R/L (resistance/limited) drivers are, by today's standards, old technology but still exist in
some (low power) applications because they are simple and inexpensive. The drawback to using
R/L drivers is that they rely on a "dropping resistor" to get almost 10 times the amount of motor
current rating necessary to maintain a useful increase in speed. This process also produces an
excessive amount of heat and must rely on a DC power supply for its current source.
2.6.4 BIPOLAR CHOPPER:
Bipolar chopper drivers are by far the most widely used drivers for industrial
applications. Although they are typically more expensive to design, they offer high performance
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
30/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
and high efficiency. Bipolar chopper drivers use an extra set of switching transistors to eliminate
the need for two power sources. Additionally, these drivers use a four transistor bridge with re-
circulating diodes and a sense resistor that maintains a feedback voltage proportional to the
motor current. Motor windings, using a bipolar chopper driver, are energized to the full supply
level by turning on one set (top and bottom) of the switching transistors. The sense resistor
monitors the linear rise in current until the required level is reached. At this point the top switch
opens and the current in the motor coil is maintained via the bottom switch and the diode.
Current "decay" (lose over time) occurs until a preset position is reached and the process starts
over. This "chopping" effect of the supply is what maintains the correct current voltage to the
motor at all times.
Figure 2.17: Bipolar chopper drive switch circuit
2.7 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 35% 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/31/2019 Microcontroller Based Dam Gate Control System Project (2)
31/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
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.
9. Known limit to the dynamic position error.
10. A wide range of rotational speeds can be realized as the speed is proportional to the
frequency of the input pulses.
11. Low cost, high reliability, high torque at low speeds and a simple, rugged construction that
operates in almost any environment.
12. It can be readily interfaced with microprocessor or computer based controller.
Disadvantages:
1. Resonances can occur if not properly controlled.
2. Not easy to operate at extremely high speeds.
3. If over torque, all knowledge of position is lost and system must be re-initialized.
4. Produces much less torque, for a given size than the equivalent DC/AC motor.
The main disadvantage in using a step motor is the resonance effect often exhibited at low speed
and decreasing torque with increasing speed.
2.8 APPLICATIONS OF STEPPER MOTOR:
Stepper motors are used in a wide variety of applications in industry, including computer
peripherals, business machines, motion control, and robotics, which are included and machine
tool applications.
Use of stepper motor in different areas:
Computer peripherals
Business machines
Process Control
Machine Tool
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
32/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
Figure 2.18: simple example of stepper motor with paper drive mechanism.
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
33/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
CHAPTER 3: ABOUT KEIL
3.1 About Keil
Keil Software to provide you with software development tools for 8051 based
microcontrollers. With the Keil tools, you can generate embedded applications for virtually every
8051 derivative. Throughout this project we refer to these tools as the 8051 development tools.
However, they support all derivatives and variants of the 8051 microcontroller family.
The Keil Software 8051 development tools listed below are programs you use to compile
your C code, assemble your assembly source files, link and locate object modules and libraries,
create HEX files, and debug your target program.
Vision is an Integrated Development Environment that combines project management,
source code editing, and program debugging in one single, powerful environment.
The Cx51 ANSI Optimizing C Cross Compiler creates re-locatable object modules from
your C source code.
The Ax51 Macro Assembler creates re-locatable object modules from your 8051
assembly source code.
The BL51 Linker/Locator combines re-locatable object modules created by the C51
Compiler and the A51 Assembler into absolute object modules.
The LX51 Extended Linker/Locator supports extended device variants and provides
additional features. LX51 supports all variants of the Cx51 Compiler and the Ax51
Assembler.
TheLIBx51Library Manager combines object modules into libraries that may be used
by the linker.
The OHx51 Object-HEX Converter creates Intel HEX files from absolute object
modules.
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
34/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
The RTX51 Tiny Real-time Operating System that simplifies the design of complex,
time-critical software projects.
They are designed for professional software developer, but any level of programmer canuse them to get the most out of the 8051 hardware
The Keil Software 8051 development tools are designed for the professional software
developer, but any level of programmer can use them to get the most out of the 8051
microcontroller architecture.
3.2 Getting started and creating applications:
Evaluation kits and production kits:
Keil software provides two types of kits in which our tools are delivered. The EK51 Evaluation
Kit includes evaluation version of our 8051 tolls along with this users guide. The tools in the evaluation
kit let you generate these applications up to 2kbytes in size. You may use this kit to evaluate for the
effectiveness of our 8051 tools and to generate small target applications
The 8052 production kits discussed in Product overview topic section include the unlimited
versions of our 8052 tools along with this users guide and the full manual set. The production kits also
include one year of free technical support in product updates.
DEVELOPMENT TOOLS:
This chapter discusses the advantages and features of the 8052 tools available from keil software.
These tools have been designed to help quick and successful completion of job. They are easy to use and
guaranteed help to achieve your design goals.
These development tools are meant for easy user understanding and easy endurance of user.
These are integrated part of this IDE (INTEGRATED DEVELOPMENT ENVIRONMENT).
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
35/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
3.3 U-VISION3 INTEGRATED WINDOWS DEVELOPMENT ENVIRONMENT
The Vision3 IDE is a Windows-based software development platform that combines a
robust editor, project manager, and make facility. Vision3 integrates all tools including the Ccompiler, macro assembler, linker/locator, and HEX file generator. Vision3 helps expedite the
development process of your embedded applications by providing the following:
Full-featured source code editor,
Device database for configuring the development tool setting,
Project manager for creating and maintaining your projects,
Integrated make facility for assembling, compiling, and linking your embeddedapplications,
Dialogs for all development tool settings,
True integrated source-level Debugger with high-speed CPU and peripheral simulator,
Advanced GDI interface for software debugging in the target hardware and for
connection to Keil ULINK,
Flash programming utility for downloading the application program into Flash ROM,
Links to development tools manuals, device datasheets & users guides.
3.4 ABOUT THE ENVIRONMENT
The vision3 screen provides you with a menu bar for command entry, tool bar where
you can rapidly select command button, and windows for source files, dialog box and
information displays. vision3 lets you simultaneously open and view multiple source files.
MENU COMMANDS, TOOL BARS AND SHORTCUTS:
The menu bar provides you with menus for editor operations, project maintenance,
development tool option settings, program debugging, windows selection and manipulation, and
online help. With the tool bar buttons you can rapidly execute operations. The commands can be
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
36/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
reached also with configurable keyboard shortcuts. The following tables give you an overview of
the vision3 commands and the default shortcuts.
C51 OPTIMIZING C CROSS COMPILER:
For 8051 controller operations the Keil C51 Cross Compiler offers a way to program in
C which truly matches assembly programming in terms of code efficiency and speed. The keil
C51 is not a universal C compiler that generates extremely fast and compact code. Use of high
level language such as C has many advantages over assembly language programming.
3.5 ADVANTAGES:
Knowledge of the processor instruction set is not required, rudimentary knowledge of
thememory structure o the 8052 CPU is desirable.(but not necessary).
Details like register allocation and addressing of the various memory types and data
types are managed by the compiler.
Programs get a formal structure and can be divided into separate functions. This leads
to better program structure.
The ability to combine variable selection with specific operations improves program
readability
Keywords and operational functions can be used that more nearly resemble the
human thought process.
Programming and program test time is drastically reduced which increases your
efficiency.
The C run-time library contains many standard routines such as: formatted output,numeric conversions and floating point arithmetic.
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
37/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
CHAPTER 4: HARDWARE MODEL
4.1 Block Diagram:
Figure 4.1 Block diagram
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
38/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
4.2 Circuit diagram:
Figure 4.2 Circuit diagram
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
39/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
4.3 Circuit diagram of water level indicator:
Figure 4.3 Water level indicator circuit
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
40/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
4.4 CIRCUIT DESCRIPTION:
This circuit design for supervisory control over serial communication makes use of the
following main components
1. AT89S52 Microcontroller
2. 7805 Regulator
3. ULN2003 driver
4. Stepper motor-1Kg Torque
5. Serial port communication- MAX 232 & RS 232
6. Transformer- 12-0-12
7. IC 7404
8. IC 7408
9. DB9 connector
10. Piezo-Buzzer
In this circuit design microcontroller is the main component. The 9th
pin of the
microcontroller is given to the reset pin. The other end of the reset pin is given to the power
supply of 5V. A capacitor of 10/25V is connected between the supply and the reset button. A
resistor of value 8.2K is connected between the 9th pin and ground. A crystal oscillator is
connected between the 18th and 19th pin. To this crystal oscillator of 11.592MHz two capacitors
of 22pf are connected and the other ends of capacitors are grounded. The 31st and 40th pin of the
microcontroller are given to the supply of 5V. The 20th pin is grounded.
+5v
GND
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
41/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
Figure 4.4: various connections from a ULN 2003 driver
The pins 21-24- are connected via resistors to the ULN2003 driver which drives the stepper
motor. The 10th and 11th pin i.e. receive and transmit pins of the microcontroller are connected
the 9th and 10th pins of the serial communication MAX 232 respectively. Since the RS232 is not
in the standard form to make it compatible with the TTL CMOS we make use of MAX232. The
MAX232 is used for receiving the value from serial port and the output of which is given as
input to the microcontroller. Capacitors of value 4.7/25Vor 0.1 are connected between 6-16,
2-15, 1-3 and 4-5 pins respectively. The 16 th pin is given to the supply and the 15 th is grounded.
The 8th
and 7th
pin i.e., RIN & T2OUT are connected to the 2nd
and 3rd
pins of DB9 connector.
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
42/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
Figure 4.5: Connections from max232 standard
In telecommunications,RS-232 (Recommended Standard 232) is the traditional name for a
series of standards for serial binary single-ended data and control signals connecting between a
DTE (Data Terminal Equipment) and a DCE (Data Circuit-terminating Equipment). It is
commonly used in computer serial ports. The standard defines the electrical characteristics and
timing of signals, the meaning of signals, and the physical size and pin-out of connectors. The 5 th
pin o the RS232 is grounded. The microcontroller acts as an interface between the user
instructions and the stepper motor. The 9th
pin of ULN2003, high voltage, high current
Darlington transistor arrays is given a supply of 5V. The 8th pin of the ULN2003 is grounded and
the 13th
, 14th, 15th & 16th
are connected to the 1kg torque, 5pin stepper motor.
In the supply circuit, a 12-0-12 step down transformer is made use. The primary of the
transformer is given to the 230V supply. In the secondary side the two terminals are given to the
anodes of the IN 4007 diodes. The cathodes of these two diodes are junctioned and given to the
7805 regulator. A capacitor of value 1000f/25v is connected between the 1st and 2nd of the
regulator and a capacitor of value 100f/25V is connected between 2 nd and 3rd pin. The 3rd pin of
11
10
A
t
8
9
s
5
2
http://en.wikipedia.org/wiki/Telecommunicationshttp://en.wikipedia.org/wiki/Serial_communicationshttp://en.wikipedia.org/wiki/Single-ended_signallinghttp://en.wikipedia.org/wiki/Data_signalhttp://en.wikipedia.org/wiki/Control_signalhttp://en.wikipedia.org/wiki/Data_Terminal_Equipmenthttp://en.wikipedia.org/wiki/Data_circuit-terminating_equipmenthttp://en.wikipedia.org/wiki/Computerhttp://en.wikipedia.org/wiki/Serial_porthttp://en.wikipedia.org/wiki/Serial_porthttp://en.wikipedia.org/wiki/Computerhttp://en.wikipedia.org/wiki/Data_circuit-terminating_equipmenthttp://en.wikipedia.org/wiki/Data_Terminal_Equipmenthttp://en.wikipedia.org/wiki/Control_signalhttp://en.wikipedia.org/wiki/Data_signalhttp://en.wikipedia.org/wiki/Single-ended_signallinghttp://en.wikipedia.org/wiki/Serial_communicationshttp://en.wikipedia.org/wiki/Telecommunications7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
43/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
the regulator is given to the 5V supply. Thus the transformer step down the supply voltage of
230V to 12V is given to the input pin of voltage regulator.
Figure 4.6: circuit diagram of LM7805 voltage regulator
WATER LEVEL INDICATOR CIRCUIT DESCRIPTION AND CONNECTIONS:
The circuit uses five sensors to sense the different water levels in the Dam. Sensor G is
connected to the negative terminal (GND) of the power supply. The other four sensors (L
through O) are connected to the inputs of NOT gate IC 7404.When there is a high voltage at the
input pin of the NOT gate, it outputs a low voltage. Similarly, for a low voltage at the input pin
of the NOT gate, it outputs a high voltage. When the dam is empty, the input pins of IC 7404 are
pulled high via a 1-mega-ohm resistor. So it outputs a low voltage.
As water starts filling the dam, a low voltage is available at the input pins of the gate and
it outputs a high voltage. When the water in the dam rises to touch the low level, there is a low
voltage at input pin 1 of 7404 and high output at pin 2. Pin 2 of the gate is connected to pin 10 of
gate (3B) 7408, so pin10 also goes high. Now as both pins 9 and 10 of gate (3) 7408 are high, itsoutput pin 8 also goes high, which indicates water level at low-level. Similarly, when water in
the tank touches the half level, pins 13 and 12 of AND gate becomes high. As a result, its output
also goes high, which indicates water level is medium. At this time, pin 9 of gate 7408 also goes
low via gate pins 3 and 4 of IC 7404; output of pin 8 of 7408 goes low. When the water tank
12-0-12v
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
44/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
becomes full, the voltage at pin 11 of gate (7404) and pin 11 of gate 7404 goes low. Output pin 6
of gate (7408) goes high which indicates the water tank is full. When water starts overflowing
the tank, pin 11 of another gate of 7404 goes low to make output pin 10 to high. The buzzer
sounds to indicate that water is overflowing the tank and you need to raise the gates immediately
to control overflow of water. Use a non-corrosive material such as steel strip for the five sensors
and hang them in the water tank as shown in the circuit diagram. Use regulated 5V to power the
circuit.
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
45/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
CHAPTER 5: SOFTWARE MODEL
5.1 SERIAL COMMUNICATION
All IBM PC and compatible computers are typically equipped with two serial ports and one
parallel port. Although these two types of ports are used for communicating with external
devices, they work in different ways.
A parallel port sends and receives data eight bits at a time over 8 separate wires. This
allows data to be transferred very quickly; however, the cable required is more bulky because of
the number of individual wires it must contain. Parallel ports are typically used to connect a PC
to a printer and are rarely used for much else. A serial port sends and receives data one bit at atime over one wire. While it takes eight times as long to transfer each byte of data this way, only
a few wires are required. In fact, two-way (full duplex) communications is possible with only
three separate wires - one to send, one to receive, and a common signal ground wire.
5.2 Bi-Directional Communications
The serial port on your PC is a full-duplex device meaning that it can send and receive
data at the same time. In order to be able to do this, it uses separate lines for transmitting andreceiving data. Some types of serial devices support only one-way communications and therefore
use only two wires in the cable - the transmit line and the signal ground.
5.3 Communicating by Bits
Once the start bit has been sent, the transmitter sends the actual data bits. There may
either be 5, 6, 7, or 8 data bits, depending on the number you have selected. Both receiver and
the transmitter must agree on the number of data bits, as well as the baud rate. Almost all devicestransmit data using either 7 or 8 data bits. Notice that when only 7 data bits are employed, you
cannot send ASCII values greater than 127. Likewise, using 5 bits limits the highest possible
value to 31. After the data has been transmitted, a stop bit is sent. A stop bit has a value of 1 - or
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
46/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
a mark state - and it can be detected correctly even if the previous data bit also had a value of 1.
This is accomplished by the stop bit's duration. Stop bits can be 1, 1.5, or 2 bit periods in length.
5.4The Parity Bit
Besides the synchronization provided by the use of start and stop bits, an additional bit
called a parity bit may optionally be transmitted along with the data. A parity bit affords a small
amount of error checking, to help detect data corruption that might occur during transmission.
You can choose either even parity, odd parity, mark parity, space parity or none at all. When
even or odd parity is being used, the number of marks (logical 1 bits) in each data byte are
counted, and a single bit is transmitted following the data bits to indicate whether the number of
1 bits just sent is even or odd.
For example, when even parity is chosen, the parity bit is transmitted with a value of 0 if the
number of preceding marks is an even number. For the binary value of 0110 0011 the parity bit
would be 0. If even parity were in effect and the binary number 1101 0110 were sent, then the
parity bit would be 1. Odd parity is just the opposite, and the parity bit is 0 when the number of
mark bits in the preceding word is an odd number. Parity error checking is very rudimentary.
While it will tell you if there is a single bit error in the character, it doesn't show which bit was
received in error. Also, if even numbers of bits are in error then the parity bitwould not reflect any error at all.
Mark parity means that the parity bit is always set to the mark signal condition and likewise
space parity always sends the parity bit in the space signal condition. Since these two parity
options serve no useful purpose whatsoever, they are almost never used.
5.5RS-232C
RS-232 stands for Recommend Standard number 232 and C is the latest revision of thestandard. The serial ports on most computers use a subset of the RS-232C standard. The full RS-
232C standard specifies a 25-pin "D" connector of which 22 pins are used. Most of these pins are
not needed for normal PC communications, and indeed, most new PCs are equipped with male D
type connectors having only 9 pins.
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
47/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
5.6 DCE and DTE Devices
Two terms you should be familiar with are DTE and DCE. DTE stands for Data Terminal
Equipment, and DCE stands for Data Communications Equipment. These terms are used to
indicate the pin-out for the connectors on a device and the direction of the signals on the pins.Your computer is a DTE device, while most other devices are usually DCE devices. If you have
trouble keeping the two straight then replace the term "DTE device" with "your PC" and the term
"DCE device" with "remote device" in the following discussion.
The RS-232 standard states that DTE devices use a 25-pin male connector, and DCE
devices use a 25-pin female connector. You can therefore connect a DTE device to a DCE using
a straight pin-for-pin connection. However, to connect two like devices, you must instead use a
null modem cable. Null modem cables across the transmit and receive lines in the cable, and are
discussed later in this chapter. The list below shows the connections and signal directions for
both 25 and 9-pin connectors.
Table 5.1: pin connectors on a DTE device
25 Pin Connector on a DTE device (PC connection)
Male RS232
DB25
Pin Number Direction of signal:
1 Protective Ground
2 Transmitted Data (TD) Outgoing Data (from a DTE to a DCE)
3 Received Data (RD) Incoming Data (from a DCE to a DTE)
4 Request To Send (RTS) Outgoing flow control signal controlled by DTE
5 Clear To Send (CTS) Incoming flow control signal controlled by DCE
6 Data Set Ready (DSR) Incoming handshaking signal controlled by DCE
7 Signal Ground Common reference voltage
8 Carrier Detect (CD) Incoming signal from a modem
20 Data Terminal Ready (DTR) Outgoing handshaking signal controlled by DTE
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
48/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
22 Ring Indicator (RI) Incoming signal from a modem
Table 5.2: 9 pin connector on a DTE device
9 Pin Connector on a DTE device (PC connection)
Male RS232
DB9
Pin Number Direction of signal:
1 Carrier Detect (CD) (from DCE) Incoming signal from a modem
2 Received Data (RD) Incoming Data from a DCE
3 Transmitted Data (TD) Outgoing Data to a DCE
4 Data Terminal Ready (DTR) Outgoing handshaking signal
5 Signal Ground Common reference voltage
6 Data Set Ready (DSR) Incoming handshaking signal
7 Request To Send (RTS) Outgoing flow control signal
8 Clear To Send (CTS) Incoming flow control signal
9 Ring Indicator (RI) (from DCE) Incoming signal from a modem
The TD (transmit data) wire is the one through which data from a DTE device is
transmitted to a DCE device. This name can be deceiving, because this wire is used by a DCE
device to receive its data. The TD line is kept in a mark condition by the DTE device when it is
idle. The RD (receive data) wire is the one on which data is received by a DTE device, and theDCE device keeps this line in a mark condition when idle.
RTS stands for Request To Send. This line and the CTS line are used when "hardware flow
control" is enabled in both the DTE and DCE devices. The DTE device puts this line in a mark
condition to tell the remote device that it is ready and able to receive data. If the DTE device is
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
49/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
not able to receive data (typically because its receive buffer is almost full), it will put this line in
the space condition as a signal to the DCE to stop sending data. When the DTE device is ready to
receive more data (i.e. after data has been removed from its receive buffer), it will place this line
back in the mark condition. The complement of the RTS wire is CTS, which stands for Clear To
Send. The DCE device puts this line in a mark condition to tell the DTE device that it is ready to
receive the data. Likewise, if the DCE device is unable to receive data, it will place this line in
the space condition. Together, these two lines make up what is called RTS/CTS or "hardware"
flow control. The Software Wedge supports this type of flow control, as well as Xon/XOff or
"software" flow control. Software flow control uses special control characters transmitted from
one device to another to tell the other device to stop or start sending data. With software flow
control the RTS and CTS lines are not used.DTR stands for Data Terminal Ready. Its intended function is very similar to the RTS line. DSR
(Data Set Ready) is the companion to DTR in the same way that CTS is to RTS. Some serial
devices use DTR and DSR as signals to simply confirm that a device is connected and is turned
on. The Software Wedge sets DTR to the mark state when the serial port is opened and leaves it
in that state until the port is closed. The DTR and DSR lines were originally designed to provide
an alternate method of hardware handshaking. It would be pointless to use both RTS/CTS and
DTR/DSR for flow control signals at the same time. Because of this, DTR and DSR are rarely
used for flow control.
CD stands for Carrier Detect. Carrier Detect is used by a modem to signal that it has a
made a connection with another modem, or has detected a carrier tone.
The last remaining line is RI or Ring Indicator. A modem toggles the state of this line when an
incoming call rings your phone. The Carrier Detect (CD) and the Ring Indicator (RI) lines are
only available in connections to a modem. Because most modems transmit status information to
a PC when either a carrier signal is detected (i.e. when a connection is made to another modem)
or when the line is ringing, these two lines are rarely used.
5.7 9 to 25 Pin Adapters
The following table shows the connections inside a standard 9 pin to 25 pin adapter.
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
50/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
Table 5.3: connections inside a standard 9 to 15 pin connector
9-Pin Connector 25 Pin Connector
Pin 1 DCD Pin 8 DCD
Pin 2 RD Pin 3 RD
Pin 3 TD Pin 2 TD
Pin 4 DTR Pin 20 DTR
Pin 5 GND Pin 7 GND
Pin 6 DSR Pin 6 DSR
Pin 7 RTS Pin 4 RTS
Pin 8 CTS Pin 5 CTS
Pin 9 RI Pin 22 RI
5.8 Baud vs. Bits per Second
The baud unit is named after Jean Maurice Emile Baudot, who was an officer in the
French Telegraph Service. He is credited with devising the first uniform-length 5-bit code forcharacters of the alphabet in the late 19th century. What baud really refers to is modulation rate
or the number of times per second that a line changes state. This is not always the same as bits
per second (BPS). If you connect two serial devices together using direct cables then baud and
BPS are in fact the same. Thus, if you are running at 19200 BPS, then the line is also changing
states 19200 times per second. But when considering modems, this isn't the case. Because
modems transfer signals over a telephone line, the baud rate is actually limited to a maximum of
2400 baud. This is a physical restriction of the lines provided by the phone company. The
increased data throughput achieved with 9600 or higher baud modems is accomplished by using
sophisticated phase modulation, and data compression techniques.
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
51/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
5.9 Cables, Null Modems, and Gender Changers
In a perfect world, all serial ports on every computer would be DTE devices with 25-pin
male "D" connectors. All other devices would be DCE devices with 25-pin female connectors.This would allow you to use a cable in which each pin on one end of the cable is connected to
the same pin on the other end. Unfortunately, we don't live in a perfect world. Serial ports use
both 9 and 25 pins; many devices can be configured as either DTE or DCE, and - as in the case
of many data collection devices - may use completely non-standard or proprietary pin-outs.
Because of this lack of standardization, special cables called null modem cables, gender changers
and custom made cables are often required.
5.10 Cables Lengths
The RS-232C standard imposes a cable length limit of 50 feet. You can usually ignore
this "standard", since a cable can be as long as 10000 feet at baud rates up to 19200 if you use a
high quality, well shielded cable. The external environment has a large effect on lengths for
unshielded cables. In electrically noisy environments, even very short cables can pick up stray
signals. The following chart offers some reasonable guidelines for 24 gauge wire under typical
conditions. You can greatly extend the cable length by using additional devices like optical
isolators and signal boosters. Optical isolators use LEDs and Photo Diodes to isolate each line in
a serial cable including the signal ground. Any electrical noise affects all lines in the optically
isolated cable equally - including the signal ground line. This causes the voltages on the signal
lines relative to the signal ground line to reflect the true voltage of the signal and thus canceling
out the effect of any noise signals.
Table 5.4: comparison for various baud rates, cable lengths and unshielded cable lengths
Baud Rate Shielded Cable Length Unshielded Cable Length
110 5000 1000
300 4000 1000
1200 3000 500
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
52/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
2400 2000 500
4800 500 250
9600 250 100
5.11 Gender Changers
A problem you may encounter is having two connectors of the same gender that must be
connected. You can purchase gender changers at any computer or office supply store for under
$5.
5.12 Null Modem Cables and Null Modem Adapters: If you connect two DTE devices (or
two DCE devices) using a straight RS232 cable, then the transmit line on each device will be
connected to the transmit line on the other device and the receive lines will likewise be
connected to each other. A Null Modem cable or Null Modem adapter simply crosses the receive
and transmit lines so that transmit on one end is connected to receive on the other end and vice
versa. In addition to transmit and receive, DTR & DSR, as well as RTS & CTS are also crossed
in a Null Modem connection.
5.13 Synchronous and Asynchronous Communications
There are two basic types of serial communications, synchronous and asynchronous.
With synchronous communications, the two devices initially synchronize themselves to each
other, and then continually send characters to stay in sync. Even when data is not really being
sent, a constant flow of bits allows each device to know where the other is at any given time.
That is, each character that is sent is either actual data or an idle character. Synchronous
communications allows faster data transfer rates than asynchronous methods, because additional
bits to mark the beginning and end of each data byte are not required. The serial ports on IBM-
style PCs are asynchronous devices and therefore only support asynchronous serialcommunications.
Asynchronous means "no synchronization", and thus does not require sending and
receiving idle characters. However, the beginning and end of each byte of data must be identified
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
53/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
by start and stop bits. The start bit indicates when the data byte is about to begin and the stop bit
signals when it ends. The requirement to send these additional two bits causes asynchronous
communication to be slightly slower than synchronous however it has the advantage that the
processor does not have to deal with the additional idle characters. An asynchronous line that is
idle is identified with a value of 1 (also called a mark state). By using this value to indicate that
no data is currently being sent, the devices are able to distinguish between an idle state and a
disconnected line. When a character is about to be transmitted, a start bit is sent. A start bit has a
value of 0 (also called a space state). Thus, when the line switches from a value of 1 to a value of
0, the receiver is alerted that a data character is about to be sent.
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
54/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
Snapshots of hardware
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
55/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
CHAPTER 6: CONCLUSION AND FUTURE WORK
6.1 Conclusion:
In order to complete the project, the hardware is initially tested on bread board.
Subsequently, the hardware is wired on general purpose PCB. This software is written in C
language and simulation is tested on pc. Afterwards the code is dumped into an 89s52 micro
controller. The integrated hardware and software is tested successfully. The principle proved
thorough this project can be utilized in many real time applications.
This project, MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
facilitates us to control the gates of a dam depending on the water level.
Here as a part of our project to exhibit the control, we control the operations of a stepper
motor with the help of serial port communication.
This project if implemented will help the people in a very major way by saving their time
in this busy daily routine. Efficient control over the device can be achieved in real time
applications.
Keil IDE has provided an easy user interface for the project. The program code is
compiled using the keil c compiler.
With all the above discussion a conclusion can be made that the system Supervisory
Control over serial communication has wide range of real time applications in industrial
sector and domestic sectors as well.
There is a lot of scope for further development of the system with this idea using all
technical advancements.
6.2 Future Work:
RF modem can be used for applications that need two way wireless data transmission. It features
high data rate (adjustable baud rate) and longer transmission distance. The communication
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
56/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
protocol is self controlled and completely transparent to user interface. The module can be
embedded to your current design so that wireless communication can be set up easily.
This module works in half-duplex mode. Means it can either transmit or receive but not both at
same time. After each transmission, module will be switched to receiver mode automatically.
The LED for TX and RX indicates whether IC is currently receiving or transmitting data. The
data sent is checked for CRC error if any. If chip is transmitting and any data is input to transmit,
it will be kept in buffer for next transmission cycle. It has internal 64 bytes of buffer for
incoming data.
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
57/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
APPENDIX
7/31/2019 Microcontroller Based Dam Gate Control System Project (2)
58/108
MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM
M.SUNILKUMAR (9666822581)
7.1 THE RS-232 STANDARD
Information being transferred between data processing equipment and peripherals is in
the form of digital data which is transmitted in either a serial or parallel mode.Parallelcommunications are used mainly for connections between test instruments or computers and
printers, while serial is often used between computers and other peripherals. Serial transmission
involves the sending of data one bit at a time, over a single communications line. In contrast,
parallel communications require at least as many lines as there are bits in a word being
transmitted (for an 8-bit word, a minimum of 8 lines are needed). Serial transmission is
beneficial for long distance communications, whereas parallel is designed for short distances or
when very high transmission rates are required.
Standards
One of the advantages of a serial System is that it lends itself to transmission over
telephone lines. The serial digital data can be converted by modem, placed onto a standard voice-
grade telephone line, and converted back to serial digital data at the