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

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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 the movement 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.
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

CHAPTER 1: INTRODUCTION TO MICROCONTROLLERS

1.1 What is a Microcontroller?


A Microcontroller is a computer-on-a-chip or a single-chip computer that contains the processor (the CPU), non-volatile memory for the program (ROM or flash), volatile memory for input and output (RAM), a clock and an I/O control unit. Micro suggests that the device is small and controller tells that the device might be used to control objects, processes or events. Another term is Embedded Microcontroller tells that it support circuits are often built into or embedded in the devices for control. You find microcontroller in all kinds of things never days. It is used for measures, controls, stores or displays information by placing microcontroller inside any device. The largest single use for microcontroller in automobiles-car manufactured today includes at least one microcontroller for engine control and more to control additional systems. In desktop computer, you may find microcontrollers inside keyboards, modems, printers, and other peripherals. In test equipment, microcontrollers make things easier to store measurement, to create and store user routines, and to display messages and waveforms. Consumer products like cameras, video recorders, compact-disk players, and ovens. And they are so many applications where we use microcontrollers. A micro controller is similar to the microprocessor inside a personal computer. Examples are Intels 8086, Zilogs Z80. Both microprocessors and microcontrollers contain CPU. The CPU executes instructions that perform the basic logic, math, and data moving functions of a computer. To make a complete computer, a microprocessor require memory for storing data and programs, and I/O interfaces for connecting external devices like keyboard and displays. In contrast, microcontrollers are a single chip computer because it contains memory and I/O interfaces in addition to the CPU. It tends to limit the amount of memory and interfaces that can fit on single chip, microcontrollers tend to be used in smaller system. Examples of popular microcontrollers are Intels 8052, 89C052, Motorolas 68HC11 and Zilogs Z8.
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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, and may 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.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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 programmablethat 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


M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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 bits of 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
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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, typically a 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 easily increase 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.
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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 need some 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.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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 up and 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
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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.

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
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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 into mechanical 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 stepper motor is determined by the thermal limits of the windings in the motor. To determine this we must apply the relationship P=V*I.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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


M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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 construction Unlike 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.
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

BIPOLAR STEP 1 2 3 CW 4 1

Q2-Q3 ON OFF OFF ON ON

Q1-Q4 OFF ON ON OFF OFF

Q6-Q7 ON ON OFF OFF ON

Q5-Q8 OFF OFF ON ON OFF CCW

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 unipolar winding 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

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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. UNIPOLAR STEP 1 2 3 CW 4 1 ON ON OFF OFF OFF ON ON OFF CCW Q1 ON OFF OFF Q2 OFF ON ON Q3 ON ON OFF Q4 OFF OFF ON

2.4 STEPPER MOTOR SWITCHING SEQUENCE: Switching sequences for stepper motor are: 1. Full step 2. Half step, and 3. Micro-step.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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 the sequence, 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 a
four step (full step) switching mode

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

Figure 2.13: The diagram that shows the position of each pole while the motor is in full 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. The switching 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 halfstep 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.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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 (+ or 5% of step angle). 6. Excellent low speed and high torque characteristics without need for gear reduction.
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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 recirculating 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 3 5% of a step and this error is non cumulative from one step to the next. 4. Excellent response to starting/stopping/reversing. 5. Very reliable since there are no contact brushes in the motor. Therefore the life of the motor is simply dependant on the life of the bearing. 6. The motors response to digital input pulses provides open-loop control, making the motor simpler and less costly to control.
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

Figure 2.18: simple example of stepper motor with paper drive mechanism.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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.

The LIBx51 Library 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.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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 can

use 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).

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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 C compiler, 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 embedded applications,

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
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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 the memory 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.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

CHAPTER 4: HARDWARE MODEL


4.1 Block Diagram:

Figure 4.1 Block diagram

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

4.2 Circuit diagram:

Figure 4.2 Circuit diagram

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

4.3 Circuit diagram of water level indicator:

Figure 4.3 Water level indicator circuit


M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

4.4 CIRCUIT DESCRIPTION: This circuit design for supervisory control over serial communication makes use of the following main components 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. AT89S52 Microcontroller 7805 Regulator ULN2003 driver Stepper motor-1Kg Torque Serial port communication- MAX 232 & RS 232 Transformer- 12-0-12 IC 7404 IC 7408 DB9 connector 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

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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 16th pin is given to the supply and the 15th is grounded. The 8th and 7th pin i.e., RIN & T2OUT are connected to the 2nd and 3rd pins of DB9 connector.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

11 10

A t 8 9 s 5 2

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 5th 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 2nd and 3rd pin. The 3rd pin of
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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.

12-0-12v

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, its output 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
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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 a time 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 and receiving 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 devices transmit 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

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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 bit would 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.5 RS-232C RS-232 stands for Recommend Standard number 232 and C is the latest revision of the standard. The serial ports on most computers use a subset of the RS-232C standard. The full RS232C 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.
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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 1 2 3 4 5 6 7 8 20 Direction of signal: Protective Ground Transmitted Data (TD) Outgoing Data (from a DTE to a DCE) Received Data (RD) Incoming Data (from a DCE to a DTE) Request To Send (RTS) Outgoing flow control signal controlled by DTE Clear To Send (CTS) Incoming flow control signal controlled by DCE Data Set Ready (DSR) Incoming handshaking signal controlled by DCE Signal Ground Common reference voltage Carrier Detect (CD) Incoming signal from a modem Data Terminal Ready (DTR) Outgoing handshaking signal controlled by DTE

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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 1 2 3 4 5 6 7 8 9 Direction of signal: Carrier Detect (CD) (from DCE) Incoming signal from a modem Received Data (RD) Incoming Data from a DCE Transmitted Data (TD) Outgoing Data to a DCE Data Terminal Ready (DTR) Outgoing handshaking signal Signal Ground Common reference voltage Data Set Ready (DSR) Incoming handshaking signal Request To Send (RTS) Outgoing flow control signal Clear To Send (CTS) Incoming flow control signal 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 the DCE 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
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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.
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

Table 5.3: connections inside a standard 9 to 15 pin connector 9-Pin Connector Pin 1 DCD Pin 2 RD Pin 3 TD Pin 4 DTR Pin 5 GND Pin 6 DSR Pin 7 RTS Pin 8 CTS Pin 9 RI 25 Pin Connector Pin 8 DCD Pin 3 RD Pin 2 TD Pin 20 DTR Pin 7 GND Pin 6 DSR Pin 4 RTS Pin 5 CTS 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 for characters 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.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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 110 300 1200 Shielded Cable Length 5000 4000 3000 Unshielded Cable Length 1000 1000 500

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

2400 4800 9600 5.11 Gender Changers

2000 500 250

500 250 100

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 IBMstyle PCs are asynchronous devices and therefore only support asynchronous serial communications. 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
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

Snapshots of hardware

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

APPENDIX

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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.Parallel communications 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 voicegrade telephone line, and converted back to serial digital data at the receiving end of the line by another modem. Officially, RS-232 is defined as the Interface between data terminal equipment and data communications equipment using serial binary data exchange. This definition defines data terminal equipment (DTE) as the computer, while data communications equipment (DCE) is the modem. A modem cable has pin-to-pin connections, and is designed to connect a DTE device to a Dc device. Interfaces In addition to communications between computer equipment over telephone lines, RS232 is now widely used for direct connections between data acquisition devices and computer systems. As in the definition of RS-232, the computer is data transmission equipment (DTE). However, many interface products are not data communications equipment (DCE).Null modem cables are designed forthis situation; rather than having the pin- to-pin connections of modem cables, null modem cables have different internal wiring to allow DTE devices to communicate with one another.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

Cabling Options RS-232 cables are commonly available with either 4, 9 or 25-pin wiring. The 25-pin cable connects every pin; the 9-pin cables do not include many of the uncommonly used connections; 4-pin cables provide the bare minimum connections, and have jumpers to provide handshaking for those devices that require it. These jumpers connect pins 4, 5 and 8, and also pins 6 and 20.The advent of the IBM PC AT has created a new wrinkle in RS-232 communications. Rather than having the standard 25-pin connector, this computer and many new expansion boards for PCs feature a 9-pin serial port. To connect this port to a standard 25- pin port, a 9-to-25-pin adaptor cable can be utilized, or the user can create his own cable specifically for that purpose. Selecting a Cable The major consideration in choosing an RS-232 cable is, what devices are to be connected? First, are you connecting two DTE devices (null modem cable) or a DTE device to a DCE device (modem cable)? Second, what connectors are required on each end, male or female, 25-pin or 9-pin (AT style)? Usually, it is recommended that the user obtain the two devices to be connected, and then determine which cable is required.

RS-232 Specifications TRANSMITTED SIGNAL VOLTAGE LEVELS: Binary 0: +5 to +15 Vdc (called a space or on) Binary 1: -5 to -15 Vdc (called a mark or off) RECEIVED SIGNAL VOLTAGE LEVELS: Binary 0: +3 to +13 Vdc Binary 1: -3 to -13 Vdc DATA FORMAT: Start bit: Binary 0
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

Data: 5, 6, 7 or 8 bits Parity: Odd, even, mark or space (not used with 8-bit data) Stop bit: Binary 1,one or two bits

MAX232, MAX232I DUAL EIA-232 DRIVERS/RECEIVERS Description: The MAX232 is a dual driver/receiver that includes a capacitive voltage generator to supply EIA-232 voltage levels from a single 5-V supply. Each receiver converts EIA-232 inputs to 5-V TTL/CMOS levels. These receivers have a typical threshold of 1.3 V and a typical hysteresis of 0.5 V, and can accept 30 inputs. Each driver converts -V TTL/CMOS input levels into EIA-232 levels. The driver, receiver, and voltage-generator functions are available as cells in the Texas Instruments Lin ASIC library.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

C3 can be connected to VCC or GND.

Figure 4. Typical Operating Circuit 7.2 8-bit Microcontroller with 8K Bytes In-System Programmable Flash AT89S52

1. Description
The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 8K bytes of in-system programmable Flash memory. The device is manufactured using Atmels highdensity nonvolatile memory technology and is compatible with the indus-try-standard 80C51 instruction set and pinout. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory pro-grammer. By combining a versatile 8-bit CPU with in-system programmable Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcontroller which provides a highly-flexible and cost-effective solution to many embedded control applications. The AT89S52 provides the following standard features: 8K bytes of Flash, 256 bytes of RAM, 32 I/O lines, Watchdog timer, two data pointers, three 16-bit timer/counters, a 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
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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 con-tents but freezes the oscillator, disabling all other chip functions until the next interrupt or hardware reset.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

4. Pin Description 4.1 VCC: Supply voltage. 4.2 GND: Ground. 4.3 Port 0: Port 0 is an 8-bit open drain bidirectional I/O port. 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 highimpedance inputs. Port 0 can 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.
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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. 4.4 Port 1 Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. 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 inter-nal 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 the follow-ing table. Port 1 also receives the low-order address bytes during Flash programming and verification

4.5

Port 2 Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. 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 inter-nal 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 dur-ing accesses to external data memory that use 16-bit addresses (MOVX @ DPTR). In this application, Port 2 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.
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

4.6 Port 3: Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. 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 inter-nal 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 receives some control signals for Flash programming and verification. Port 3 also serves the functions of various special features of the AT89S52, as shown in the fol-lowing table.

4.7 RST: Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device. This pin drives high for 98 oscillator periods after the Watchdog times out. The DISRTO bit in SFR AUXR (address 8EH) can be used to disable this feature. In the default state of bit DISRTO, the RESET HIGH out feature is enabled. 4.8 ALE/PROG Address Latch Enable (ALE) is an 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 dur-ing each access to external data memory. If desired, ALE operation
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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 ALEdisable bit has no effect if the microcontroller is in external execution mode. 4.9 PSEN Program Store Enable (PSEN) 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. 4.10 EA/VPP External Access Enable. EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal program executions. This pin also receives the 12-volt programming enable voltage (VPP) during Flash programming. 4.11 XTAL1 Input to the inverting oscillator amplifier and input to the internal clock operating circuit. 4.12 XTAL2 Output from the inverting oscillator amplifier. 5. Special Function Registers A map of the on-chip memory area called the Special Function Register (SFR) space is shown in Table 5-1. Note that not all of the addresses are occupied, and unoccupied addresses may not be imple-mented on the chip. Read accesses to these addresses will in general return random data, and write accesses will have an indeterminate effect. User software should not write 1s to these unlisted locations, since they may be used in future products to invoke new features. In that case, the reset or inactive values of the new bits will always be 0. Timer 2 Registers: Control and status bits are contained in registers T2CON (shown in Table 5- 2) and T2MOD (shown in Table 10-2) for Timer 2. The register pair (RCAP2H, RCAP2L) are the Capture/Reload registers for Timer 2 in 16-bit capture mode or 16-bit auto-reload mode.
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

Interrupt Registers: The individual interrupt enable bits are in the IE register. Two priorities can be set for each of the six interrupt sources in the IP register.

Dual Data Pointer Registers: To facilitate accessing both internal and external data memory, two banks of 16-bit Data Pointer Registers are provided: DP0 at SFR address locations 82H-83H and DP1 at 84H-85H. Bit DPS = 0 in SFR AUXR1 selects DP0 and DPS = 1 selects DP1. The user should ALWAYS initialize the DPS bit to the appropriate value before accessing the respective Data Pointer Register.

Power Off Flag:


M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

The Power Off Flag (POF) is located at bit 4 (PCON.4) in the PCON SFR. POF is set to 1 during power up. It can be set and rest under software control and is not affected by reset.

6. Memory Organization
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

MCS-51 devices have a separate address space for Program and Data Memory. Up to 64K bytes each of external Program and Data Memory can be addressed.

6.1 Program Memory If the EA pin is connected to GND, all program fetches are directed to external memory. On the AT89S52, if EA is connected to VCC, program fetches to addresses 0000H through 1FFFH are directed to internal memory and fetches to addresses 2000H through FFFFH are to external memory. 6.2 Data Memory The AT89S52 implements 256 bytes of on-chip RAM. The upper 128 bytes occupy a parallel address space to the Special Function Registers. This means that the upper 128 bytes have the same addresses as the SFR space but are physically separate from SFR space. When an instruction accesses an internal location above address 7FH, the address mode used in the instruction specifies whether the CPU accesses the upper 128 bytes of RAM or the SFR space. Instructions which use direct addressing access the SFR space. For example, the following direct addressing instruction accesses the SFR at location 0A0H (which is P2). MOV 0A0H, #data Instructions that use indirect addressing access the upper 128 bytes of RAM. For example, the following indirect addressing instruction, where R0 contains 0A0H, accesses the data byte at address 0A0H, rather than P2 (whose address is 0A0H). MOV @R0, #data Note that stack operations are examples of indirect addressing, so the upper 128 bytes of data RAM are available as stack space. 7. Watchdog Timer (One-time Enabled with Reset-out) The WDT is intended as a recovery method in situations where the CPU may be subjected to software upsets. The WDT consists of a 14-bit counter and the Watchdog Timer Reset (WDTRST) SFR. The WDT is defaulted to disable from exiting reset. To enable the WDT, a user must write 01EH and 0E1H in sequence to the WDTRST register (SFR location 0A6H).
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

When the WDT is enabled, it will increment every machine cycle while the oscillator is running. The WDT timeout period is dependent on the external clock frequency. There is no way to disable the WDT except through reset (either hardware reset or WDT overflow reset). When WDT over-flows, it will drive an output RESET HIGH pulse at the RST pin. 7.1 Using the WDT To enable the WDT, a user must write 01EH and 0E1H in sequence to the WDTRST register (SFR location0A6H). When the WDT is enabled, the user needs to service it by writing 01EH and 0E1H to WDTRST to avoid a WDT overflow. The 14-bit counter overflows when it reaches 16383 (3FFFH), and this will reset the device. When the WDT is enabled, it will increment every machine cycle while the oscillator is running. This means the user must reset the WDT at least every 16383 machine cycles. To reset the WDT the user must write 01EH and 0E1H to WDTRST. WDTRST is a write-only register. The WDT counter cannot be read or written. WhenWDT overflows, it will generate an output RESET pulse at the RST pin. The RESET pulse dura-tion is 98xTOSC, where TOSC = 1/FOSC. To make the best use of the WDT, it should be serviced in those sections of code that will periodically be executed within the time required to prevent a WDT reset. 7.2 WDT During Power-down and Idle In Power-down mode the oscillator stops, which means the WDT also stops. While in Power-down mode, the user does not need to service the WDT. There are two methods of exiting Power-down mode: by a hardware reset or via a level-activated external interrupt which is enabled prior to entering Power-down mode. When Power-down is exited with hardware reset, servicing the WDT should occur as it normally does whenever the AT89S52 is reset. Exiting Power-down with an interrupt is significantly different. The interrupt is held low long enough for the oscillator to stabilize. When the interrupt is brought high, the interrupt is serviced. To prevent the WDT from resetting the device while the interrupt pin is held low, the WDT is not started until the interrupt is pulled high. It is suggested that the WDT be reset during the interrupt service for the interrupt used to exit Power-down mode. To ensure that the WDT does not overflow within a few states of exiting Power-down, it is best to reset the WDT just before
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

entering Power-down mode. Before going into the IDLE mode, the WDIDLE bit in SFR AUXR is used to determine whether the WDT continues to count if enabled. The WDT keeps counting during IDLE (WDIDLE bit = 0) as the default state. To prevent the WDT from resetting the AT89S52 while in IDLE mode, the user should always set up a timer that will periodically exit IDLE, service the WDT, and reenter IDLE mode. With WDIDLE bit enabled, the WDT will stop to count in IDLE mode and resumes the count upon exit from IDLE.

8. UART
The UART in the AT89S52 operates the same way as the UART in the AT89C51 and AT89C52. For further information on the UART operation, please click on the document link below: http://www.atmel.com/dyn/resources/prod_documents/DOC4316.PDF

9. Timer 0 and 1Timer 0 and Timer 1 in the AT89S52 operate the same way as Timer 0 and
Timer 1 in the AT89C51 and AT89C52. For further information on the timers operation, please click on the document link below:

http://www.atmel.com/dyn/resources/prod_documents/DOC4316.PDF

10. Timer 2 Timer 2 is a 16-bit Timer/Counter that can operate as either a timer or an event
counter. The type of operation is selected by bit C/T2 in the SFR T2CON (shown in Table 5-2). Timer 2 has three operating modes: capture, auto-reload (up or down counting), and baud rate generator. The modes are selected by bits in T2CON, as shown in Table 10-1. Timer 2 consists of two 8-bit registers, TH2 and TL2. In the Timer function, the TL2 register is incremented every machine cycle. Since a machine cycle consists of 12 oscillator periods, the count rate is 1/12 of the oscil-lator frequency.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

In the

Counter function, the register is incremented in response to a 1-to-0 transition at its

corre-sponding external input pin, T2. In this function, the external input is sampled during S5P2 of every machine cycle. When the samples show a high in one cycle and a low in the next cycle, the count is incremented. The new count value appears in the register during S3P1 of the cycle following the one in which the transition was detected. Since two machine cycles (24 oscillator periods) are required to recognize a 1-to-0 transition, the maximum count rate is 1/24 of the oscillator frequency. To ensure that a given level is sampled at least once before it changes, the level should be held for at least one full machine cycle. 10.1 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. If EXEN2 = 1, Timer 2 performs the same operation, but a 1-to-0 transi-tion at external input T2EX also causes the current value in TH2 and TL2 to be captured into RCAP2H and RCAP2L, respectively. In addition, the transition at T2EX causes bit EXF2 in T2CON to be set. The EXF2 bit, like TF2, can generate an interrupt. The capture mode is illus-trated in Figure 10-1. 10.2 Auto-reload (Up or Down Counter) Timer 2 can be programmed to count up or down when configured in its 16-bit autoreload mode. This feature is invoked by the DCEN (Down Counter Enable) bit located in the SFR T2MOD (see Table 10-2). Upon reset, the DCEN bit is set to 0 so that timer 2 will default to count up. When DCEN is set, Timer 2 can count up or down, depending on the value of the T2EX pin.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

Figure 10-2 shows Timer 2 automatically counting up when DCEN = 0. In this mode, two options are selected by bit EXEN2 in T2CON. If EXEN2 = 0, Timer 2 counts up to 0FFFFH and then sets the TF2 bit upon overflow. The overflow also causes the timer registers to be reloaded with the 16-bit value in RCAP2H and RCAP2L. The values in Timer in Capture ModeRCAP2H and RCAP2L are preset by software. If EXEN2 = 1, a 16-bit reload can be triggered either by an overflow or by a 1-to-0 transition at external input T2EX. This transition also sets the EXF2 bit. Both the TF2 and EXF2 bits can generate an interrupt if enabled. Setting the DCEN bit enables Timer 2 to count up or down, as shown in Figure 10-2. In this mode, the T2EX pin controls the direction of the count. A logic 1 at T2EX makes Timer 2 count up. The timer will overflow at 0FFFFH and set the TF2 bit. This overflow also causes the 16-bit value in RCAP2H and RCAP2L to be reloaded into the timer registers, TH2 and TL2, respectively. A logic 0 at T2EX makes Timer 2 count down. The timer underflows when TH2 and TL2 equal the values stored in RCAP2H and RCAP2L. The underflow sets the TF2 bit and causes 0FFFFH to
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

be reloaded into the timer registers. The EXF2 bit toggles whenever Timer 2 overflows or underflows and can be used as a 17th bit of resolution. In this operating mode, EXF2 does not flag an interrupt.

11. Baud Rate Generator Timer 2 is selected as the baud rate generator by setting TCLK and/or RCLK in T2CON (Table 5-2). Note that the baud rates for transmit and receive can be different if Timer 2 is used for the receiver or transmitter and Timer 1 is used for the other function. Setting RCLK and/or TCLK puts Timer 2 into its baud rate generator mode, as shown in Figure 11-1. The baud rate generator mode is similar to the auto-reload mode, in that a rollover in TH2 causes the Timer 2 registers to be reloaded with the 16-bit value in registers RCAP2H and
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

RCAP2L, which are preset by software. The baud rates in Modes 1 and 3 are determined by Timer 2s overflow rate according to the fol-lowing equation.

The Timer can be configured for either timer or counter operation. In most applications, it is con-figured for timer operation (CP/T2 = 0). The timer operation is different for Timer 2 when it is used as a baud rate generator. Normally, as a timer, it increments every machine cycle (at 1/12 the oscillator frequency). As a baud rate generator, however, it increments every state time (at 1/2 the oscillator frequency). The baud rate formula is given below.

where (RCAP2H, RCAP2L) is the content of RCAP2H and RCAP2L taken as a 16-bit unsigned integer. Timer 2 as a baud rate generator is shown in Figure 11-1. This figure is valid only if RCLK or TCLK = 1 in T2CON. Note that a rollover in TH2 does not set TF2 and will not generate an inter-rupt. Note too, that if EXEN2 is set, a 1-to-0 transition in T2EX will set EXF2 but will not cause a reload from (RCAP2H, RCAP2L) to (TH2, TL2). Thus, when Timer 2 is in use as a baud rate generator, T2EX can be used as an extra external interrupt. Note that when Timer 2 is running (TR2 = 1) as a timer in the baud rate generator mode, TH2 or TL2 should not be read from or written to. Under these conditions, the Timer is incremented every state time, and the results of a read or write may not be accurate. The RCAP2 registers may be read but should not be written to, because a write might overlap a reload and cause write and/or reload errors. The timer should be turned off (clear TR2) before accessing the Timer 2 or RCAP2 registers.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

12. Programmable Clock Out A 50% duty cycle clock can be programmed to come out on P1.0, as shown in Figure 121. This pin, besides being a regular I/O pin, has two alternate functions. It can be programmed to input the external clock for Timer/Counter 2 or to output a 50% duty cycle clock ranging from 61 Hz to 4 MHz (for a 16-MHz operating frequency). To configure the Timer/Counter 2 as a clock generator, bit C/T2 (T2CON.1) must be cleared and bit T2OE (T2MOD.1) must be set. Bit TR2 (T2CON.2) starts and stops the timer. The clock-out frequency depends on the oscillator frequency and the reload value of Timer 2 capture registers (RCAP2H, RCAP2L), as shown in the following equation.

In the clock-out mode, Timer 2 roll-overs will not generate an interrupt. This behavior is similar to when Timer 2 is used as a baud-rate generator. It is possible to use Timer 2 as a baudrate gen-erator and a clock generator simultaneously. Note, however, that the baud-rate and
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

clock-out frequencies cannot be determined independently from one another since they both use RCAP2H and RCAP2L.

13. Interrupts The AT89S52 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 13-1. Each of these interrupt sources can be individually enabled or disabled by setting or clearing a bit in Special Function Register IE. IE also contains a global disable bit, EA, which disables all interrupts at once. Note that Table 13-1 shows that bit position IE.6 is unimplemented. User software should not write a 1 to this bit position, since it may be used in future AT89 products. Timer 2 interrupt is generated by the logical OR of bits TF2 and EXF2 in register T2CON. Nei-ther 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.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

14. Oscillator Characteristics XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier that can be configured for use as an on-chip oscillator, as shown in Figure 16-1. Either a quartz
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

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 16-2. There are no requirements on the duty cycle of the external clock signal, since the input to the internal clock-ing circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage high and low time specifications must be observed. 15. 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. Note that when idle mode is terminated by a hardware reset, the device normally resumes pro-gram 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 mode is terminated by a reset, the instruction following the one that invokes idle mode should not write to a port pin or to external memory. 16. Power-down Mode 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. Exit from Power-down mode can be initiated either by a hardware reset or by an enabled external interrupt. 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.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

Note: 1. C1, C2 = 30 pF 10 pF for Crystals = 40 pF 10 pF for Ceramic Resonators

17. Program Memory Lock Bits The AT89S52 has three lock bits that can be left unprogrammed (U) or can be programmed (P) to obtain the additional features listed in Table 17-1.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

When lock bit 1 is programmed, the logic level at the EA pin is sampled and latched during reset. If the device is powered up without a reset, the latch initializes to a random value and holds that value until reset is activated. The latched value of EA must agree with the current logic level at that pin in order for the device to function properly.

18. Programming the Flash Parallel Mode The AT89S52 is shipped with the on-chip Flash memory array ready to be programmed. The programming interface needs a high-voltage (12-volt) program enable signal and is compatible with conventional third-party Flash or EPROM programmers. The AT89S52 code memory array is programmed byte-by-byte. Programming Algorithm: Before programming the AT89S52, the address, data, and control signals should be set up according to the Flash Programming Modes (Table 22-1) and Figure 22-1 and Figure 22-2. To program the AT89S52, take the following steps: 1. Input the desired memory location on the address lines. 2. Input the appropriate data byte on the data lines. 3. Activate the correct combination of control signals. 4. Raise EA/VPP to 12V. 5. Pulse ALE/PROG once to program a byte in the Flash array or the lock bits. The byte-write cycle is self-timed and typically takes no more than 50 s. Repeat steps 1 through 5, changing the address and data for the entire array or until the end of the object file is reached.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

Data Polling: The AT89S52 features Data Polling to indicate the end of a byte write cycle. Dur-ing a write cycle, an attempted read of the last byte written will result in the complement of the written data on P0.7. Once the write cycle has been completed, true data is valid on all outputs, and the next cycle may begin. Data Polling may begin any time after a write cycle has been initiated. Ready/Busy: The progress of byte programming can also be monitored by the RDY/BSY output signal. P3.0 is pulled low after ALE goes high during programming to indicate BUSY. P3.0 is pulled high again when programming is done to indicate READY. Program Verify: If lock bits LB1 and LB2 have not been programmed, the programmed code data can be read back via the address and data lines for verification. The status of the individual lock bits can be verified directly by reading them back. Reading the Signature Bytes: The signature bytes are read by the same procedure as a nor-mal verification of locations 000H, 100H, and 200H, except that P3.6 and P3.7 must be pulled to a logic low. The values returned are as follows. (000H) = 1EH indicates manufactured by Atmel (100H) = 52H indicates AT89S52 (200H) = 06H Chip Erase: In the parallel programming mode, a chip erase operation is initiated by using the proper combination of control signals and by pulsing ALE/PROG low for a duration of 200 ns - 500 ns. In the serial programming mode, a chip erase operation is initiated by issuing the Chip Erase instruction. In this mode, chip erase is self-timed and takes about 500 ms. During chip erase, a serial read from any address location will return 00H at the data output.
M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

19. Programming the Flash Serial Mode The Code memory array can be programmed using the serial ISP interface while RST is pulled to VCC. The serial interface consists of pins SCK, MOSI (input) and MISO (output). After RST is set high, the Programming Enable instruction needs to be executed first before other operations can be executed. Before a reprogramming sequence can occur, a Chip Erase operation is required. The Chip Erase operation turns the content of every memory location in the Code array into FFH. Either an external system clock can be supplied at pin XTAL1 or a crystal needs to be connected across pins XTAL1 and XTAL2. The maximum serial clock (SCK) frequency should be less than 1/16 of the crystal frequency. With a 33 MHz oscillator clock, the maximum SCK frequency is 2 MHz. 20. Serial Programming Algorithm To program and verify the AT89S52 in the serial programming mode, the following sequence is recommended: 1. Power-up sequence: a. Apply power between VCC and GND pins. b. Set RST pin to H. If a crystal is not connected across pins XTAL1 and XTAL2, apply a 3 MHz to 33 MHz clock to XTAL1 pin and wait for at least 10 milliseconds. 2. Enable serial programming by sending the Programming Enable serial instruction to pin MOSI/P1.5. The frequency of the shift clock supplied at pin SCK/P1.7 needs to be less than the CPU clock at XTAL1 divided by 16. 3. The Code array is programmed one byte at a time in either the Byte or Page mode. The write cycle is self-timed and typically takes less than 0.5 ms at 5V. 4. Any memory location can be verified by using the Read instruction which returns the content at the selected address at serial output MISO/P1.6.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

5. At the end of a programming session, RST can be set low to commence normal device operation. Power-off sequence (if needed): 1. Set XTAL1 to L (if a crystal is not used). 2. Set RST to L. 3. Turn VCC power off. Data Polling: The Data Polling feature is also available in the serial mode. In this mode, during a write cycle an attempted read of the last byte written will result in the complement of the MSB of the serial output byte on MISO.

21. Serial Programming Instruction Set


The Instruction Set for Serial Programming follows a 4-byte protocol and is shown in Table 24-1.

22. Programming Interface Parallel Mode


Every code byte in the Flash array can be programmed by using the appropriate combination of control signals. The write operation cycle is self-timed and once initiated, will automatically time itself to completion. Most major worldwide programming vendors offer support for the Atmel AT89 microcontroller series. Please contact your local programming vendor for the appropriate software revision.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

Notes: 1. Each PROG pulse is 200 ns - 500 ns for Chip Erase. 2. Each PROG pulse is 200 ns - 500 ns for Write Code Data. 3. Each PROG pulse is 200 ns - 500 ns for Write Lock Bits. 4. RDY/BSY signal is output on P3.0 during programming. 5. X = dont care.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

*NOTICE: Stresses beyond those listed under Absolute Maximum Ratings may cause permanent dam-age to the device. This is a stress rating only and functional operation of the device at these or any other conditions beyond those indicated in the operational sections of this specification is not implied. Exposure to absolute maximum rating conditions for extended periods may affect device reliability.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

7.3 MC78XX/LM78XX/MC78XXA 3-Terminal 1A Positive Voltage Regulator Description: The MC78XX/LM78XX/MC78XXA series of three terminal positive regulators are available in the TO-220/D-PAK package and with several fixed output voltages, making them useful in a wide range of applications. Each type employs internal current limiting, thermal shut down and safe operating area protection, making it essentially indestructible. If adequate heat sinking is provided, they can deliver over 1A output current. Although designed primarily as fixed voltage regulators, these devices can be used with external components to obtain adjustable voltages and currents.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

Absolute Maximum Ratings Absolute maximum ratings are those values beyond which damage to the device may occur. The datasheet specifications should be met, without exception, to ensure that the system

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

design is reliable over its power supply, temperature, and output/input loading variables. Fairchild does not recommend operation outside datasheet specifications.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

Notes:1. Load and line regulation are specified at constant junction temperature. Changes in VO due to heating effects must be taken into account separately. Pulse testing with low duty is used. 2. These parameters, although guaranteed, are not 100% tested in production.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

Notes: 3. Load and line regulation are specified at constant junction temperature. Changes in VO due to heating effects must be taken into account separately. Pulse testing with low duty is used. 4. These parameters, although guaranteed, are not 100% tested in production.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

7.4 ULN2003 HIGH VOLTAGE AND HIGH CURRENT DARLINGTON TRANSISTOR ARRAY DESCRIPTION The ULN2003 is a monolithic high voltage and high current Darlington transistor arrays. It consists of seven NPN darlington pairs that features high-voltage outputs with commoncathode clamp diode for switching inductive loads. The collectorcurrent rating of a single darlington pair is 500mA. The darlington pairs may be parrlleled for higher current capability. Applications include relay drivers,hammer

drivers, lampdrivers,display drivers(LED gas discharge),line drivers, and logic buffers. The ULN2003 has a 2.7kW series base resistor for each darlington pair for operation directly with TTL or 5V CMOS devices.

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

M.SUNILKUMAR (9666822581)

MICROCONTROLLER BASED DAM GATE CONTROL SYSTEM

M.SUNILKUMAR (9666822581)

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