Intelligent Water Control System Using 8051 (AT89C51) : Project Report
Intelligent Water Control System Using 8051 (AT89C51) : Project Report
Intelligent Water Control System Using 8051 (AT89C51) : Project Report
Project Report
Submitted to:
Engr. Azhar Ali Zaidi
Submitted by:
Asad Abbas 08-EE-09 Muhammad Abdullah Adnan Farooqi 08-EE-87
Abstract:
This report illustrates the construction and working of a liquid level indicator. Such an indicator is used in tanks to indicate the level of liquids and alert us when the tank is full. So by this circuit we can monitor the various levels of the tank and can avoid spillage of water and also we can configure our supplies according to the various levels of tank. Such module or circuit can be installed in big buildings where manual monitor of tanks is difficult and its indicator can be placed at some centralized place.
Description:
This circuit works on the principle that water conducts electricity. A wire connected to VCC and four other wires are dipped in tank at different levels namely quarter, half, threefourth, full and their output are taken on pins P3.0, P3.1, P3.2, P3.3 via a transistor BC547. Port P2 is connected to data pins of LCD and P1.0, P1.1, P1.2 are respectively connected to RS, RW, and EN pins of LCD. Initially when the tank is empty LCD will show the message VACANT. As the tank starts filling up wire at different levels get some positive voltage, due to conducting nature of water. This voltage is then fed to their corresponding pins on controller. When level reaches to quarter level, LCD displays the message QUARTER. On further rise of level, HALF and 3/4 QUARTER are displayed on LCD. When tank gets full LCD shows the message FULL CLOSE TAP. A buzzer is also provided to produce an alert the user when the tank gets filled. LED is connected to indicate when tank is not Full.
Circuit Diagram:
Components:
The main components used in this circuit are as follows: 1. 8051 (AT89C51) Microcontroller 2. 16x2 LCD 3. Transistor BC547,D400 4. Piezo Buzzer 5. Resistors and capacitors 6. Connecting lead
Pin Description:
Pin No 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 Function Name P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 Reset P3.0 P3.1 8 bit input/output port (P3) pins P3.2 P3.3 P3.4 P3.5 P3.6 P3.7 Crystal 2 Crystal 1 Ground P2.0/ A8 P2.1/ A9 P2.2/ A10 P2.3/ A11 P2.4/ A12 P2.5/ A13 P2.6/ A14 P2.7/ A15 PSEN ALE Prog EA Vpp P0.7/ AD7 P0.6/ AD6 P0.5/ AD5 P0.4/ AD4 P0.3/ AD3 P0.2/ AD2 P0.1/ AD1 P0.0/ AD0 Vcc
Reset pin; Active high Input (receiver) for serial RxD communication Output (transmitter) for serial TxD communication External interrupt 1 Int0 External interrupt 2 Int1 Timer1 external input T0 Timer2 external input T1 Write to external data memory Write Read from external data memory Read Quartz crystal oscillator (up to 24 MHz) Ground (0V)
8 bit input/output port (P2) pins / High-order address bits when interfacing with external memory
Program store enable; Read from external program memory Address Latch Enable Program pulse input during Flash programming External Access Enable; Vcc for internal program executions Programming enable voltage; 12V (during Flash programming)
8 bit input/output port (P0) pins Low-order address bits when interfacing with external memory
3- Transistor BC547:
BC547 is an NPN bi-polar junction transistor. A transistor, stands for transfer of resistance, is commonly used to amplify current. A small current at its base controls a larger current at collector & emitter terminals. BC547 is mainly used for amplification and switching purposes. It has a maximum current gain of 800. Its equivalent transistors are BC548 and BC549. The transistor terminals require a fixed DC voltage to operate in the desired region of its characteristic curves. This is known as the biasing. For amplification applications, the transistor is biased such that it is partly on for all input conditions. The input signal at base is amplified and taken at the emitter. BC547 is used in common emitter configuration for amplifiers. The voltage divider is the commonly used biasing mode. For switching applications, transistor is biased so that it remains fully on if there is a signal at its base. In the absence of base signal, it gets completely off.
4- Piezo Buzzer:
The piezo buzzer produces sound based on reverse of the piezoelectric effect. The generation of pressure variation or strain by the application of electric potential across a piezoelectric material is the underlying principle. These buzzers can be used alert a user of an event corresponding to a switching action, counter signal or sensor input. They are also used in alarm circuits. The buzzer produces a same noisy sound irrespective of the voltage variation applied to it. It consists of piezo crystals between two conductors. When a potential is applied across these crystals, they push on one conductor and pull on the other. This, push and pull action, results in a sound wave. Most buzzers produce sound in the range of 2 to 4 kHz. The Red lead is connected to the Input and the Black lead is connected to ground.
Block Diagram
Code
#include<reg51.h> sbit rs=P1^0; sbit rw=P1^1; sbit e=P1^2; sbit quat=P3^0; sbit half=P3^1; sbit quat_3=P3^2; sbit full=P3^3; sbit spkr_on=P3^4; sbit spkr_off=P3^5; sbit tap=P3^7; void delay(int k) { int i,j; for(i=0;i<k;i++) for(j=0;j<1275;j++); } void write(int j) { rs=1; rw=0; P2=j; e=1; delay(100); //register select pin //read/write pin //enable pin //pin connected to quarter level of tank //pin connected to half level of tank //pin connected to three -fourth level of tank //pin connected to full level of tank // pin to off speaker //pin to control Tap //delay function
//write function //selecting command register //selecting to write //putting value on the pins //strobe the enable pin
e=0; return; } void cmd(int j) { P2=j; rs=0; rw=0; e=1; delay(1); e=0; return; } void puts(char *a) { unsigned int p=0; for(;a[p]!=0;p++) write(a[p]); } //command function //put the value on pins //selecting command register //selecting to write //strobe enable pin
void lcd_init(void) { cmd(0x38); delay(50); cmd(0x0e); delay(50); cmd(0x01); cmd(0x80); } void startup(void) { cmd(0x80); puts("Welcome to IWS"); delay(50); cmd(0xC0); puts("By 08-EE-09 & 87"); delay(50); cmd(0x01); } void status(void) {
// function to initialise the LCD //setting 8-bit interface, 2 lines, 5*7 Pixels //turning on underline visible cursor //clearing screen //moving cursor to the begining of line 1 of LCD
cmd(0x85); puts("Status"); } void main() { lcd_init(); startup(); quat=1;half=1;quat_3=1;full=1;spkr_off=1; quat=0;half=0;quat_3=0;full=0;spkr_off=0; spkr_on=1; //configuring as input pins //lowering input pins // making speaker on pin high,as it // works on negative logic
tap=0; while(1) { spkr_on=1; while(quat==0&&half==0&&quat_3==0&&full==0&&spkr_off==0) //condition when tank is empty { lcd_init(); // initialising LCD status(); cmd(0xC0); puts("EMPTY; TAP ON"); //printing Empty on lcd tap=1; } while(quat==1&&half==0&&qua t_3==0&&full==0&&spkr_off==0) //condition when tank is quater { lcd_init(); status(); cmd(0xC0); puts("Tank is QUARTER"); //printing QUATER on lcd } while(quat==1&&half==1&&quat_3==0&&full==0&&spkr_off==0) //condition when tank is half { lcd_init(); status(); cmd(0xC0); puts("Tank is HALF"); //printing HALF on lcd } while(quat==1&&half==1&&quat_3==1&&full==0&&spkr_off==0) //condition when tank is three-fourth
{ lcd_init(); status(); cmd(0xC0); puts("Tank is 3/4 FULL"); //printing 3/4 FULL on lcd } while(quat==1&&half==1&&quat_3==1&&full==1&&spkr_off==0) //condition when tank is full { lcd_init(); status(); cmd(0xC0); puts("FULL;CLOSE TAP"); //printing FULL;CLOSE TAP on lcd spkr_on=0; // Enabling speaker tap=0; } while(quat==1&&half==1&&quat_3==1&&full==1&&spkr_on==0&&spkr_off==1) //enabling high speaker_off pin { spkr_on=1; //disabling speaker } } }