Sunteți pe pagina 1din 34

1.

INTRODUCTION
Water level indicator is the one which is used to indicate the level of the water in the overhead tank. There is a need for these water level indicators because there are certain cases to act according to the level of the water like municipal water supplies, field irrigations etc. These level indicators can be used in home applications also. And the same indication scheme can be applied to all the liquids. Flow control means controlling the flow of water supplying to the tank like switching off motor automatically after the tank is filled or to reduce the flow pumping to the tank etc. In petrol bunks the petrol is pumped in this way ,depending on the quantity the flow rate changes. There are so many level indicators to indicate the water level and flow controllers to off the power supply after filling the tank, but this mini project LOW COST WATER LEVEL INDICATOR AND FLOW CONTROL SYSTEM uses a single circuit for both the process. The circuit consists of Micro controller 8051 Triac driver Triac 741 Operational amplifiers Motor The circuit is small in size and easy to process. The next sections deal with the block diagram, circuit diagram, and the description of various components used in the circuit.

2. SYSTEM DESCRIPTION 2.1-Block Diagram

Figure 2.1 Block diagram

2.2 Explanation
The water container contains a ball like the one which is used in flushing, floats on the water. This ball is connected to the potentiometer variable knob through the shaft, so for the variation of the water level the ball floats and through the shaft connected to it, varies the potentiometer resistance. Due to the variation in the resistance of potentiometer the equivalent resistance varies so the voltage drop also varies with proportion to it, this drop is connected to an operational amplifier (741) which is used as comparator in this circuit. This gives the variation in outputs of the op-amp. We get three combinations of output from the two op-amps due to variation in water level. These outputs are connected to 8051 micro controller in which a code is dumped to drive the seven segment display and triac driver using the ports 0, port 1, and port 2. Three levels of the tank are displayed from the three combinations and when the tank is at 3rd level as the triac driver gets a input low, no voltage is get applied to the triac which makes it off, and so the motor also gets off. For demonstration purpose we are using bulb instead of motor.
2

3.CIRCUIT AND WORKING 3.1 Circuit Diagram

Figure 3.1 Circuit Diagram

3.2 Working
Initially any three levels are set in the water container and they are level-1, level-2, and level-3. The level-1 indicates ground level, level-2 indicates middle level and level-3 indicates final level. The 22k potentiometer R4 is initially set at 6k and decreased to 300 ohms at the final level. The voltage drop across the R5 varies in accordance with the R4 value which is in turn depends on the water level of container as explained in the block diagram. Case-1: If the water is at level-1 then the value of R4 is 6kohm, Voltage drop across R5=R5*V/ (R4+R5)
3

As V=9v, R4=6k, R5=1k Drop V1=2v. Case-2: If the water is at level-2 then the value of R4 is1.5kohm, Voltage drop across R5=R5*V/ (R4+R5) As V=9v, R4=1.5k, R5=1k Drop V1=3.5v. Case-3: If the water is at level-3 then the value of R7 is 300ohm, Voltage drop across R5=R5*V/ (R4+R5) As V=9v, R4=300k, R5=1k Drop V1=7v. These drops are applied to the non inverting terminals of the two 741 op amps in each level and the voltage applied for the inverting terminal of 1st op amp is 6v and for the 2nd op amp is 3v. As the op amp is using as a comparator, it compares the voltages at the 2 and 3 pins, (inverting and non inverting terminals). If the voltage at 3rd pin is high it gives vice as output if the voltage at 2nd pin is high it gives 0v as the output. So for the first case: As the drop is 2v which is less than both 6v, 3v the outputs of the op-amps are 0 and 0, so at the first level the output is 00. For the second case: The voltage drop is 3.5v which is less than 6v and greater than 3v, so the outputs are 0 and 1. The output at the second level is 01.And for the 3rd case: The drop is 7v which is greater than both 6v, 3v .the outputs are 1 and 1. The output at the second level is 11. These values are given to the micro controller 8051 port 1 through 1 and 2 pins. The code for the micro controller is written such that, if the outputs are 00 then it displays 1 in the seven segment display, if the outputs are 10 it displays 2 and if 11 it displays 3 through the equivalent seven segment display code transferred through the port2: 21 to 27 pins and the 28th pin is given to the vcc. Also if the water is at 3rd level it resets the p0.1 (39th pin port 0).
4

This p0.1 is connected to the triac driver, the driver consists of photo diode and triac, if the output of p0.1 is low then the diode is off and doesnt sends light signals to the triac in the driver, so that the triac is off ,so the output is zero which is connected to the gate terminal of triac and makes the triac off, so the motor is also off and no water thus flows in to the tank if it is at 3rd level. Thus it is working continuously and displaying the level and controlling the flow.

4. COMPONENT EXPLANATION
4.1 List of Components
COMPONENT 1. ResistorsVALUE 10kohm 1kohm 2. Potentiometer3. Capacitors 22kohm 10 microf 33picof 4.741-operational amplifier 5. Triac driver 6. Triac 7. Micro controller 8051 With crystal oscillator 12 MHz 8. Seven segment display (cc) 9. 9v to 5v regulator (7805) 10. Resister bank,10K 10. Motor (load) (load can be motor or bulb) 9A103G 1 1 1 1 MOC2030 BT134 ATMEL QUANTITY 11 1 1 1 2 2 1 1 1

4.2 8051 MICRO CONTROLLER [1] Introduction


The 8051 is an 8-bit microcontroller which means that most available operations are limited to 8 bits. There are 3 basic "sizes" of the 8051: Short, Standard, and Extended. The Short and Standard chips are often available in DIP form, but the Extended 8051 models often have a different form factor, and are not "drop-in compatible". All these things are called 8051 because they can all be programmed using 8051 assembly language, and they all share certain features (although the different models all have their own special features). Some of the features that have made the 8051 popular are:

8-bit data bus 16-bit address bus 32 general purpose registers each of 8 bits 16 bit timers (usually 2, but may have more, or less). 3 internal and 2 external interrupts. Bit as well as byte addressable RAM area of 16 bytes. Four 8-bit ports, (short models have two 8-bit ports). 16-bit program counter and data pointer 8051 models may also have a number of special, model-specific features, such as UARTs, ADC, OpAmps, etc...

Typical applications 8051 chips are used in a wide variety of control systems, telecom applications, and robotics as well as in the automotive industry. By some estimation, 8051 family chips make up over 50% of the embedded chip market.

Pin Diagram
7

Figure 4.1 Pin diagram of the 8051 DIP

BASIC PINS PIN 9: PIN 9 is the reset pin which is used reset the microcontrollers internal registers and ports upon starting up.2 machine cycle should be high at this pin. PINS 18 & 19: The 8051 has a built-in oscillator amplifier hence we need to only connect a crystal at these pins to provide clock pulses to the circuit. PIN 40 and 20: Pins 40 and 20 are VCC and ground respectively. The 8051 chip needs +5V 500mA to function properly, although there are lower powered versions like the Atmel 2051 which is a scaled down version of the 8051 which runs on +3V. PINS 29, 30 & 31: As described in the features of the 8051, this chip contains a built-in flash memory. In order to program this we need to supply a voltage of +12V at pin 31. If external memory is connected then PIN 31, also called EA/VPP, should be connected to ground to indicate the presence of external memory. PIN 30 is called ALE (address latch enable), which is used when multiple memory chips are connected to the controller and only one of them needs to be selected. We will deal with this in depth in the later chapters. PIN 29 is called PSEN. This is "program select enable". In order to use the external memory it is required to provide the low voltage (0) on both PSEN and EA pins.

Ports
There are 4 8-bit ports: P0, P1, P2 and P3.
8

Using Ports for I/O Operation 8051 is TTL logic device. TTL logic has two levels: Logic "High" (1) and logic "Low" (0). The voltage and current involved for the two levels are as follows:
Table 4.1 TTL Logic levels

Level High

Voltage Above 2.4V

Current Virtually no current flow 1.6mA Sinking current from TTL input

Low

Below 0.9V

to (Depends on logic family)

ground

Port functions The 8051 internal ports are partly bi-directional (Quasi-bi-directional). The following is the internal circuitry for the 8051 port pins:

Figure 4.1 Internal circuit for 8051 port pins

1. Configuring for output P0 is open drain. Has to be pulled high by external 10K resistors.
9

Not needed if P0 is used for address lines Writing to a port pin loads data into a port latch that drives a FET connected to the

port pin. P0: Note that the pull-up is absent on Port 0 except when functioning as the external address/data bus. When a "0" is written to a bit in port 0, the pin is pulled low. But when a "1" is written to it, it is in high impedance (disconnected) state. So when using port 0 for output, an external pull-up resistor is needed, depending on the input characteristics of the device driven by the port pin. P1, P2, P3 have internal pull-ups: When a "0" is written to a bit in these port , the pin is pulled low ( FET-ON) ,also when 1 is written to a bit in these port pin becomes high (FET-OFF) thus using port P1,P2,P3 is simple. 2. Configuring for input When power is on all are output ports by default. To configure any port for input, write all 1s (0xFF) to the port Latch bit=1, FET=OFF, Read Pin asserted by read instruction. You can use a port for output any time. But for input, the FET must be off. Otherwise, you will be reading your own latch rather than the signal coming from the outside. Therefore, a "1" should be written to the pin if you want to use it as input, especially when you have used it for output before. If you don't does this input high voltage will get grounded through FET so you will read pin as low and not as high. An external device cannot easily drive it high so; you should not tide a port high directly without any resistor. Otherwise, the FET would burn.

Oscillator Circuits
The 8051 requires the existence of an external oscillator circuit. The oscillator circuit usually runs around 12MHz, although the 8051 (depending on which specific model) is capable of running at a maximum of 40MHz. Each machine cycle in the 8051 is 12 clock cycles, giving an effective cycle rate at 1MHz (for a 12MHz clock) to 3.33MHz (for the maximum 40MHz clock).

10

Figure 4.3 Oscillator circuit

Internal Architecture
Data and Program Memory The 8051 Microprocessor can be programmed in PL/M, 8051 Assembly, C and a number of other high-level languages. Many compilers even have support for compiling C++ for an 8051. Program memory in the 8051 is read-only, while the data memory is considered to be read/write accessible. When stored on EEPROM or Flash, the program memory can be rewritten when the microcontroller is in the special programmer circuit.

11

Figure 4.4 Internal Architecture of 8051

12

Program Start Address The 8051 starts executing program instructions from address 0x00 in the program Direct Memory The 8051 has 256 bytes of internal addressable RAM, although only the first 128 bytes are available for general use by the programmer. The first 128 bytes of RAM (from 0x00 to 0x7F) are called the Direct Memory, and can be used to store data. Special Function Register The Special Function Register (SFR) is the upper area of addressable memory, from address 0x80 to 0xFF. This area of memory cannot be used for data or program storage, but is instead a series of memory-mapped ports and registers. All port input and output can therefore be performed by memory mov operations on specified addresses in the SFR. Also, different status registers are mapped into the SFR, for use in checking the status of the 8051, and changing some operational parameters of the 8051. General Purpose Registers The 8051 has 4 selectable banks of 8 addressable 8-bit registers, R0 to R7. This means that there are essentially 32 available general purpose registers, although only 8 (one bank) can be directly accessed at a time. To access the other banks, we need to change the current bank number in the flag status register. A and B Registers The A register is located in the SFR memory location 0xE0. The A register works in a similar fashion to the AX register of x86 processors. The A register is called the accumulator, and by default it receives the result of all arithmetic operations. The B register is used in a similar manner, except that it can receive the extended answers from the multiply and divide operations. When not being used for multiplication and Division, the B register is available as an extra general-purpose register. Programming There are various high-level programming language compilers for the 8051. Several C compilers are available for the 8051, most of which feature extensions that allow the
13

programmer to specify where each variable should be stored in its six types of memory, and provide access to 8051 specific hardware features such as the multiple register banks and bit manipulation instructions. There are many commercial C compilers. SDCC is a popular open source C compiler. Other high level languages such as Forth, BASIC, Pascal/Object Pascal, PL/M and Modula-2 are available for the 8051, but they are less widely used than C and assembly. Because IRAM, XRAM, and PMEM all have an address 0, C compilers for the 8051 architecture provide compiler-specific pragmas or other extensions to indicate where a particular piece of data should be stored (i.e. constants in PMEM or variables needing fast access in IRAM). Since data could be in one of three memory spaces, a mechanism is usually provided to allow determining to which memory a pointer refers, either by constraining the pointer type to include the memory space, or by storing metadata with the pointer.

Instruction set

The 8051 instruction set offers several addressing modes, including


Direct register, using ACC (the accumulator) and R0-R7 Direct memory, which access the internal RAM or the SFR's, depending on the address Indirect memory, using R0, R1, or DPTR to hold the memory address. The instruction used may vary to access internal RAM, external RAM, or program memory.

Individual bits of a range of IRAM and some of the SFR's

Because the 8051 is an accumulator-based architecture, all arithmetic operations must use the accumulator, e.g. ADD A, 020h will add the value in memory location 0x20 in the internal RAM to the accumulator. One does not need to master these instructions to program the 8051. With the availability of good quality C compilers, including open source SDCC, virtually all programs can be written with high-level language. The process of writing program for the microcontroller mainly consists of giving instructions (commands) in the specific order in which they should be executed in order to carry out a specific task. As electronics cannot understand what for example an
14

instruction if the push button is pressed- turn the light on means, then a certain number of simpler and precisely defined orders that decoder can recognise must be used. All commands are known as INSTRUCTION SET. All microcontrollers compatibile with the 8051 have in total of 255 instructions, i.e. 255 different words available for program writing. Types of instructions Depending on operation they perform, all instructions are divided in several groups: Arithmetic Instructions Branch Instructions Data Transfer Instructions Logic Instructions Bit-oriented Instructions The first part of each instruction, called MNEMONIC refers to the operation an instruction performs (copy, addition, logic operation etc.). Mnemonics are abbreviations of the name of operation being executed. For example:

INC R1 - Means: Increment register R1 (increment register R1); LJMP LAB5 - Means: Long Jump LAB5 (long jump to the address marked as LAB5)

JNZ LOOP - Means: Jump if Not Zero LOOP (if the number in the accumulator is not 0, jump to the address marked as LOOP) The other part of instruction, called OPERAND is separated from mnemonic by at

least one whitespace and defines data being processed by instructions. Some of the instructions have no operand, while some of them have one, two or three. If there is more than one operand in an instruction, they are separated by a comma. For example: RET - return from a subroutine; JZ TEMP - if the number in the accumulator is not 0, jump to the address marked as TEMP;
15

ADD A,R3 - add R3 and accumulator; CJNE A,#20,LOOP - compare accumulator with 20. If they are not equal, jump to the address marked as LOOP

Arithmetic instructions Arithmetic instructions perform several basic operations such as addition, subtraction, division, multiplication etc. After execution, the result is stored in the first operand. For example:ADD A,R1 - The result of addition (A+R1) will be stored in the accumulator. Branch Instructions There are two kinds of branch instructions: Unconditional jump instructions: upon their execution a jump to a new location from where the program continues execution is executed. Conditional jump instructions: a jump to a new program location is executed only if a specified condition is met. Otherwise, the program normally proceeds with the next instruction. Data Transfer Instructions Data transfer instructions move the content of one register to another. The register the content of which is moved remains unchanged. If they have the suffix X (MOVX), the data is exchanged with external memory. Logic Instructions Logic instructions perform logic operations upon corresponding bits of two registers. After execution, the result is stored in the first operand. Bit-oriented Instructions Similar to logic instructions, bit-oriented instructions perform logic operations. The difference is that these are performed upon single bits.

Addressing Modes
16

An "addressing mode" refers to how you are addressing a given memory location. In summary, the addressing modes are as follows, with an example of each:
Table 4.2 Addressing Modes

Immediate Addressing Each of these modes addressing flexibility. Immediate Addressing Direct Addressing

MOV A,#20h MOV A,30h MOV A,@R0 MOVX A,@DPTR MOVC A,@A+DPTR

provides important Indirect Addressing External Direct Code Indirect

Immediate addressing is so-named because the value to be stored in memory immediately follows the operation code in memory. That is to say, the instruction itself dictates what value will be stored in memory. For example, the instruction: MOV A,#20h Direct Addressing Direct addressing is so-named because the value to be stored in memory is obtained by directly retrieving it from another memory location. For example: MOV A,30h This instruction will read the data out of Internal RAM address 30 (hexidecimal) and store it in the Accumulator.Direct addressing is generally fast since, although the value to be loaded isnt included in the instruction, it is quickly accessable since it is stored in the 8051s Internal RAM. It is also much more flexible than Immediate Addressing since the value to be loaded is whatever is found at the given address--which may be variable. Indirect Addressing

17

Indirect addressing is a very powerful addressing mode which in many cases provides an exceptional level of flexibility. Indirect addressing is also the only way to access the extra 128 bytes of Internal RAM found on an 8052. Indirect addressing appears as follows: MOV A,@R0 This instruction causes the 8051 to analyze the value of the R0 register. The 8051 will then load the accumulator with the value from Internal RAM which is found at the address indicated by R0. External Direct External Memory is accessed using a suite of instructions which use what I call "External Direct" addressing. I call it this because it appears to be direct addressing, but it is used to access external memory rather than internal memory. There are only two commands that use External Direct addressing mode: MOVX A,@DPTR MOVX @DPTR, A As you can see, both commands utilize DPTR. In these instructions, DPTR must first be loaded with the address of external memory that you wish to read or write. Once DPTR holds the correct external memory address, the first command will move the contents of that external memory address into the Accumulator. The second command will do the opposite: it will allow you to write the value of the Accumulator to the external memory address pointed to by DPTR.

External Indirect External memory can also be accessed using a form of indirect addressing which I call External Indirect addressing. This form of addressing is usually only used in relatively small projects that have a very small amount of external RAM. An example of this addressing mode is:
18

MOVX @R0,A

Interrupts
As the name implies, an interrupt is some event which interrupts normal program execution. Program flow is always sequential, being altered only by those instructions which expressly cause program flow to deviate in some way. However, interrupts give us a mechanism to "put on hold" the normal program flow, execute a subroutine, and then resume normal program flow as if we had never left it. This subroutine, called an interrupt handler, is only executed when a certain event (interrupt) occurs. The event may be one of the timers "overflowing," receiving a character via the serial port, transmitting a character via the serial port, or one of two "external events." The 8051 may be configured so that when any of these events occur the main program is temporarily suspended and control passed to a special section of code which presumably would execute some function related to the event that occured. Once complete, control would be returned to the original program. The main program never even knows it was interrupted. The ability to interrupt normal program execution when certain events occur makes it much easier and much more efficient to handle certain conditions. If it were not for interrupts we would have to manually check in our main program whether the timers had overflown, whether we had received another character via the serial port, or if some external event had occured. Besides making the main program ugly and hard to read, such a situation would make our program inefficient since wed be burning precious "instruction cycles" checking for events that usually dont happen.

What Events can trigger interrupts, and where do they go? We can configure the 8051 so that any of the following events will cause an interrupt: Timer 0 Overflow. Timer 1 Overflow. Reception/Transmission of Serial Character.
19

External Event 0. External Event 1. In other words, we can configure the 8051 so that when Timer 0 overflows or

when a character is sent/ received, the appropriate interrupt handler routines are called. Obviously we need to be able to distinguish between various interrupts and executing different code depending on what interrupt was triggered. This is accomplished by jumping to a fixed address when a given interrupt occurs.
Table 4.3 Interrupt Types

Interrupt Flag Interrupt Handler Address External 0 IE0 Timer 0 0003h

TF0 000Bh 0013h

External 1 IE1 Timer 1 Serial

TF1 001Bh RI/TI 0023h

By consulting the above chart we see that whenever Timer 0 overflows (i.e., the TF0 bit is set), the main program will be temporarily suspended and control will jump to 000BH. It is assumed that we have code at address 000BH that handles the situation of Timer 0 overflowing. Setting up Interrupts By default at powerup, all interrupts are disabled. This means that even if, for example, the TF0 bit is set, the 8051 will not execute the interrupt. Your program must specifically tell the 8051 that it wishes to enable interrupts and specifically which interrupts it wishes to enable. Your program may enable and disable interrupts by modifying the IE SFR (A8h):
Table 4.4 Interrupt Enabling

20

Bit Name 7 6 5 4 3 2 1 0 EA ES ET1 EX1 ET0 EX0

Bit Address AFh AEh ADh ACh ABh AAh A9h A8h

Explanation of Function Global-Interrupt Enable/Disable Undefined Undefined Enable Serial Interrupt Enable Timer 1 Interrupt Enable External 1 Interrupt Enable Timer 0 Interrupt Enable External 0 Interrupt

As you can see, each of the 8051s interrupts has its own bit in the IE SFR. You enable a given interrupt by setting the corresponding bit. Interrupt Priorities The 8051 offers two levels of interrupt priority: high and low. By using interrupt priorities you may assign higher priority to certain interrupt conditions. For example, you may have enabled Timer 1 Interrupt which is automatically called every time Timer 1 overflows. Additionally, you may have enabled the Serial Interrupt which is called every time a character is received via the serial port. However, you may consider that receiving a character is much more important than the timer interrupt. In this case, if Timer 1 Interrupt is already executing you may wish that the serial interrupt itself interrupts the Timer 1 Interrupt. When the serial interrupt is complete, control passes back to Timer 1 Interrupt and finally back to the main program. You may accomplish this by assigning a high priority to the Serial Interrupt and a low priority to the Timer 1 Interrupt. Interrupt priorities are controlled by the IP SFR (B8h). The IP SFR has the following format:
Table 4.5 Interrupt Priorities 21

Bit Name Bit Address Explanation of Function 7 6 5 4 3 2 1 0 PS PT1 PX1 PT0 PX0 BCh BBh BAh B9h B8h Undefined Undefined Undefined Serial Interrupt Priority Timer 1 Interrupt Priority External 1 Interrupt Priority Timer 0 Interrupt Priority External 0 Interrupt Priority

When considering interrupt priorities, the following rules apply: Nothing can interrupt a high-priority interrupt--not even another high priority interrupt. A high-priority interrupt may interrupt a low-priority interrupt. A low-priority interrupt may only occur if no other interrupt is already executing. If two interrupts occur at the same time, the interrupt with higher priority will execute first. If both interrupts are of the same priority the interrupt which is serviced first by polling sequence will be executed first.

4.3 741 Operational Amplifier [2]


An operational amplifier, which is often called an op-amp, is a DC-coupled high-gain electronic voltage amplifier with a differential input and, usually, a single-ended output. [1] An op-amp produces an output voltage that is typically millions of times larger than the voltage difference between its input terminals. Typically the op-amp's very large gain is controlled by negative feedback, which largely determines the magnitude of its output ("closed-loop") voltage gain in amplifier
22

applications, or the transfer function required (in analog computers). Without negative feedback, and perhaps with positive feedback for regeneration, an op-amp essentially acts as a comparator. High input impedance at the input terminals (ideally infinite) and low output impedance at the output terminal(s) (ideally zero) are important typical characteristics. Op-amps are among the most widely used electronic devices today, being used in a vast array of consumer, industrial, and scientific devices. Many standard IC op-amps cost only a few cents in moderate production volume; however some integrated or hybrid operational amplifiers with special performance specifications may cost over $100 US in small quantities. Op-amps sometimes come in the form of macroscopic components, (see photo) or as integrated circuit cells; patterns that can be reprinted several times on one chip as part of a more complex device. The op-amp is one type of differential amplifier. Other types of differential amplifier include the fully differential amplifier (similar to the op-amp, but with two outputs), the instrumentation amplifier (usually built from three op-amps), the isolation amplifier (similar to the instrumentation amplifier, but with tolerance to common-mode voltages that would destroy an ordinary op-amp), and negative feedback amplifier (usually built from one or more op-amps and a resistive feedback network).

Circuit notation

Figure 4.5 Circuit diagram symbol for an op-amp

The circuit symbol for an op-amp is shown to the right, where:


: non-inverting input : inverting input


23

: output : positive power supply : negative power supply

Pin diagram of 741 Op-amp

Figure 4.6 DIP pin out for 741-type operational amplifier

Internal circuitry of 741 type op-amp Though designs vary between products and manufacturers, all op-amps have basically the same internal structure, which consists of three stages:

Figure 4.7 A component level diagram of the common 741 op-amp.

Dotted lines outline: current mirrors (red); differential amplifier (blue); class A gain stage (magenta); voltage level shifter (green); output stage (cyan).

24

Differential amplifier provides low noise amplification, high input impedance, usually a differential output.

Voltage amplifier provides high voltage gain, a single-pole frequency roll-off, usually single-ended output.

Output amplifier provides high current driving capability, low output impedance, current limiting and short circuit protection circuitry.

4.4 TRIAC [3]


The Triac is a three terminal semiconductor device for controlling current. It is effectively a development of the SCR or thyristor, but unlike the thyristor which is only able to conduct in one direction, the triac is a biriectional device. As such the triac is an ideal device to use for AC switching applications because it can control the current flow over both halves of an alternating cycle. A thyristor is only able to control them over one half of a cycle. During the remaining half no conduction occurs and accordingly only half the waveform can be utilised. There are three terminals on a triac. These are the Gate and two other terminals. These other triac terminals are often referred to as an "Anode" or "Main Terminal".

Figure 4.8 Circuit symbol for the triac

The gate acts as the trigger to turn the device on. The current then flows betweent he two anodes or main terminals. These are usually designated Anode 1 and Anode 2 or Main Terminal 1 and Main Terminal 2 (MT1 and MT2). It can be imagined from the circuit symbol that the triac consists of two thyristors back to back. The operation of the triac can be looked on in this fashion, although the actual operation at the semiconductor level is rather complicated. When the voltage on the MT1 is positive with regard to MT2 and a positive gate voltage is applied, one of the SCRs conducts. When the voltage is reversed and a negative voltage is applied to the
25

gate, the other SCR conducts. This is provided that there is sufficient voltage across the device to enable a minimum holding current to flow. Triac structure The structure of a triac may be considered as a p-n-p-n structure and the triac may be considered to consist of two conventional SCRs fabricated in an inverse parallel configuration.

Figure 4.9 structure of a triac

Triac operation Triac do not fire symmetrically as a result of slight differences between the two halves of the device. This results in harmonics being generated and the less symmetrical the triac fires, the greater the level of harmonics produced. It is generally undesirable to have high levels of harmonics in a power system and as a result triacs are not favoured for high power systems. Instead two thyristors may be used as it is easier to control their firing. To help in overcoming this problem, a device known as a diac (diode AC switch) is often placed in series with the gate. This device helps make the switching more even for both halves of the cycle. This results from the fact that the diac switching characteristic is far more even than that of the triac. Since the diac prevents any gate current flowing until the trigger voltage has reached a certain voltage in either direction, this makes the firing point of the triac more even in both directions.

4.5 Seven Segment Display


A seven-segment display, or seven-segment indicator, is a form of electronic display device for displaying decimal numerals that is an alternative to the more complex dotmatrix displays.
26

Seven-segment displays are widely used in digital clocks, electronic meters, and other electronic devices for displaying numerical information. Concept and visual structure A seven segment display, as its name indicates, is composed of seven elements. Individually on or off, they can be combined to produce simplified representations of the Arabic numerals. Often the seven segments are arranged in an oblique (slanted) arrangement, which aids readability. In most applications, the seven segments are of nearly uniform shape and size (usually elongated hexagons, though trapezoids and rectangles can also be used), though in the case of adding machines, the vertical segments are longer and more oddly shaped at the ends in an effort to further enhance readability. Each of the numbers 0, 6, 7 and 9 may be represented by two or more different glyphs on seven-segment displays.

Figure 4.10 Individual segments of a seven-segment display

The seven segments are arranged as a rectangle of two vertical segments on each side with one horizontal segment on the top, middle, and bottom. Additionally, the seventh segment bisects the rectangle horizontally. There are also fourteen-segment displays and sixteen-segment displays (for full alphanumeric); however, these have mostly been replaced by dot-matrix displays.The segments of a 7-segment display are referred to by the letters A to G, as shown to the right, where the optional DP decimal point (an "eighth segment") is used for the display of non-integer numbers Common Cathode and Common Anode: In a simple LED package, typically all of the cathodes (negative terminals) or all of the anodes (positive terminals) of the segment LEDs are connected together and brought out to a common pin; this is referred to as a "common cathode" or "common anode" device. Hence a 7 segment plus decimal point package will only require nine pins (though
27

commercial products typically contain more pins, and/or spaces where pins would go, in order to match industry standard pinouts). Integrated displays also exist, with single or multiple digits. Some of these integrated displays incorporate their own internal decoder, though most do not each individual LED is brought out to a connecting pin as described. Multiple-digit LED displays as used in pocket calculators and similar devices used multiplexed displays to reduce the number of IC pins required to control the display. For example, all the anodes of the A segments of each digit position would be connected together and to a driver pin, while the cathodes of all segments for each digit would be connected. To operate any particular segment of any digit, the controlling integrated circuit would turn on the cathode driver for the selected digit, and the anode drivers for the desired segments; then after a short blanking interval the next digit would be selected and new segments lit, in a sequential fashion. In this manner an eight digit display with seven segments and a decimal point would require only 8 cathode drivers and 8 anode drivers, instead of sixty-four drivers and IC pins. Often in pocket calculators the digit drive lines would be used to scan the keyboard as well, providing further savings; however, pressing multiple keys at once would produce odd results on the multiplexed display. 4.6 TRIAC DRIVER(MOC3021) MOC3021 is an optotriac (product of Motorola) that is used for isolation between power and driving circuitry. Note that when C828 on the base is applied voltage>0.7V, optotriac gets triggered. As the triac gets triggered now, the positive or negative voltage (whatever maybe) get pass through the gate of BT136 (triac) and hence triggered it. Each device consists of a gallium-arsenide infrared-emitting diode optically coupled to a silicon phototriac mounted on a 6-terminal lead frame encapsulated within an electrically nonconductive plastic compound. The case can withstand soldering temperature with no deformation and device performance characteristics remain stable when operated in highhumidity conditions. Electrical characteristics at 25 0C
28

Table 4.6 Electrical characteristics of MOC3021


TEST CONDITIONS IR VF I(DRM) dv/dt dv/dt(c) VTM IH IO = 15 mA, ITM = 100 mA VR = 3 V IF = 10 mA V(DRM) = 400 V, MIN 0.05 1.2 10 100 0.15 1.4 100 3 TYP MAX 100 1.5 100 UNIT A V nA V/ s V/ s V A

Where, VF_Static forward voltage I(DRM)_Repetitive off-state current, either direction dv/dt_ Critical rate of rise of off-state voltage dv/dt(c)_Critical rate of rise of commutating voltage VTM_Peak on-state voltage, either direction IH_Holding current, either direction LOGIC DIAGRAM

Figure 4.11 Pin diagram of MOC3021

29

RESULT

30

CODE
ORG 0000H location MOV p1, #0FFH MOV p2, #0000H CLR p0.0 HERE: MOV A,p1 port 1 CJNE A, #03, L1 ; compare the value in A with value 3 and if not equal jump to L1 CLR p0.0 L1: CJNE A, #01,L2 equal jump to L2 SETB p0.0 L2: MOV DPTR, #0500H MOVC A, @A+DPTR address of A+DPTR
31

; starts program from 0 memory

; initializing port 1 as input ; initializing port 2 as output ; clearing port 0.0 ; loading register A with the contents of

; if equal set the port 0.0 ; again compare A with 1 and if not

; if equal clear port 0.0 ; loading DPTR with value 500 ; loading A with value in the effective

MOV p2, A SJMP HERE ORG 0500H DATA: DB 30,6D, 00, 79

; loading port 2 with the value in A ; jump to label HERE ; saving values at memory location 500 ; 500-30 501-6D 502-00 503-79

END

; End of the program

APPLICATIONS

It can be used at home level, industry level. And it is also difficult for continuous monitoring of the tank in the case of

municipal water supplies, which supplies water to an area and it is also important to act for the corresponding water level for the period of time to supply. So it can be applicable in such cases. It can be anywhere because it is easy to install, and also it is very useful one at a

very low cost. As the circuit is enclosed there is no problem of temperature variation, climatic conditions etc.

32

CONCLUSION
Hence this mini project Water Level Indicator and Flow Control System has been successfully completed and tested. Integrating the features of every hardware component used has devoloped it. Presence of every block has been reasoned out and placed carefully thus contributing to the best working of the unit. Secondly, the project was finished using very simple and easily available components making it very light weight and portable.

33

REFERENCES
[1]. 8051 Micro controller and Embedded systems using assembly & C, Mohammed

Ali mazidi, Janice gillipse mazidi, Second edition, Pearson education, New Delhi.
[2]. Linear Integrated circuits, Roy chowdary, New age international pltd, New

Delhi.

34

S-ar putea să vă placă și