Academia.eduAcademia.edu

PIC MICROCONTROLLER BASED AUTOMATED WATER LEVEL CONTROL SYSTEM

ijetrm journal

https://doi.org/10.5281/zenodo.3352817

The objective of this project is to design an automatic water level control system. It indicates the level of water in the tank and automatically controls it by using PIC microcontroller IC 16F887Aand water level sensor. Seven segment displays show the current water level in the overhead tank. When the underground tank water is empty, motor is turn off and buzzer on. In this condition, display indicator shows the ERROR (E) character. Three digit seven segment displays are used to show different water levels in percentage. Desire water level is stored in the EEPROM memory of PIC 16F887A. The code developed for the PIC is written in the C language. INTRODUCTION Water level controller is equipment used to control the water level in an overhead tank. The level of the water is controlled by using a microcontroller. In this research project, resistors divider is used as water level sensor. The sensors sense the presence of water level in overhead tank and underground tank. This reading information is send to the microcontroller. The micro-controller produces the control signals to drive the motor. If there is no water in the underground tank then microcontroller gives control signal to stop the motor and the character "E" appear on the display indicator. Desire water level is stored in the EEPROM memory of PIC 16F887A microcontroller IC by use of three push button switches. A water-level-controller circuit monitors the level of the overhead tank and spontaneously switches on the water pump whenever the level goes below a specific limit. When the desire water level is reached, motor is turn off. Hence the level of water in an overhead tank can be automatically controlled. The water level controller circuit does not allow the pump to start if the water inside the underground tank is empty. Indicates the level of water and the motor switches off automatically. The tone system attached to the alarm system gives level information as "tank is empty" so that a user can easily recognize the level of the water in the underground tank. The main components used in this equipment are PIC microcontroller, sensor and motor. PIC 16F887A contains a flash program memory which can easily be programmed using a suitable programmer devices. There is no need to erase the memory with an UV light. This makes the development and testing an easy and a relatively quick task [1, 3]. This paper is divided into five sections including this section. In section 2, Basic concept of PIC microcontroller, and Microcontroller Unit (PIC 16F887A) connection, Display devices (LED), Sensor, Interfacing an Electromagnetic Relay with PIC Microcontroller are displayed. Section 3 describes Design and Implementation of water level control system, and Operation Description and Complete Circuit Diagram. Section 4 simulate by using Matlab programming and C program of control implementation. Section 5 includes Results and Discussion of this system.

ISSN: 2456-9348 Impact Factor: 4.520 Vol (03) _Issue (07) International Journal of Engineering Technology Research & Management PIC MICROCONTROLLER BASED AUTOMATED WATER LEVEL CONTROL SYSTEM Khin Than Than Myint1, May Zaw Tun2 12 Natural Science Department, University of Computer Studies (Mandalay), Myanmar thanthannwe7667@gmail.com mayzawhtun2015@gmail.com ABSTRACT The objective of this project is to design an automatic water level control system. It indicates the level of water in the tank and automatically controls it by using PIC microcontroller IC 16F887Aand water level sensor. Seven segment displays show the current water level in the overhead tank. When the underground tank water is empty, motor is turn off and buzzer on. In this condition, display indicator shows the ERROR ( E ) character. Three digit seven segment displays are used to show different water levels in percentage. Desire water level is stored in the EEPROM memory of PIC 16F887A. The code developed for the PIC is written in the C language. KEYWORDS: PIC microcontroller IC 16F887A, Seven - Segment LED Display, Power Supply INTRODUCTION Water level controller is equipment used to control the water level in an overhead tank. The level of the water is controlled by using a microcontroller. In this research project, resistors divider is used as water level sensor. The sensors sense the presence of water level in overhead tank and underground tank. This reading information is send to the microcontroller. The micro-controller produces the control signals to drive the motor. If there is no water in the underground tank then microcontroller gives control signal to stop the motor and the character „E‟ appear on the display indicator. Desire water level is stored in the EEPROM memory of PIC 16F887A microcontroller IC by use of three push button switches. A water-level-controller circuit monitors the level of the overhead tank and spontaneously switches on the water pump whenever the level goes below a specific limit. When the desire water level is reached, motor is turn off. Hence the level of water in an overhead tank can be automatically controlled. The water level controller circuit does not allow the pump to start if the water inside the underground tank is empty. Indicates the level of water and the motor switches off automatically. The tone system attached to the alarm system gives level information as “tank is empty” so that a user can easily recognize the level of the water in the underground tank. The main components used in this equipment are PIC microcontroller, sensor and motor. PIC 16F887A contains a flash program memory which can easily be programmed using a suitable programmer devices. There is no need to erase the memory with an UV light. This makes the development and testing an easy and a relatively quick task [1, 3]. This paper is divided into five sections including this section. In section 2, Basic concept of PIC microcontroller, and Microcontroller Unit (PIC 16F887A) connection, Display devices (LED), Sensor, Interfacing an Electromagnetic Relay with PIC Microcontroller are displayed. Section 3 describes Design and Implementation of water level control system, and Operation Description and Complete Circuit Diagram. Section 4 simulate by using Matlab programming and C program of control implementation. Section 5 includes Results and Discussion of this system. BASIC CONCEPT The technique of PIC microcontroller based automatic water level control system concentrated with some basic IJETRM (http://ijetrm.com/) [49] ISSN: 2456-9348 Impact Factor: 4.520 Vol (03) _Issue (07) International Journal of Engineering Technology Research & Management parts which are softly aggregated together in our proposed method. Basic descriptions of some parts are described below. Water Level Sensor To make special water level sensor we would like to introduce some convenient materials such as Iron rod, nozzles, resistance, rubber etc. A connecting rod made by iron and steel which should be connected with ground and we need at least four nozzles which should be connected with +5v via a 1kΩ resistance. We need to bind them together and put a rubber at their joint point which will act as an insulator for every nozzle. When the sensor touches water, nozzles and connecting rod get electric connection using water conductivity [7]. Water Level Indicator For water level indication unit we can use seven-segment LEDs light which will work for water level indication. By touching different water levels through water level sensor, seven-segment LEDs should be indicated as water level in percentage [7]. Display Using LED Light-emitting diodes (LEDs) are promising lighting sources for general lighting applications with the promise of being more than ten times as efficient as incandescent lighting. Such characteristic combined with their long operating life and reliability has made them becoming a potential choice for next generation of lighting systems including automotive, emergency, backlight, indoor, and outdoor. LEDs pass current in the forward direction, but block current in the reverse direction. The cathode side of an LED is usually marked with a flat spot on the flange that rings the body of the diode. The cathode wire is also usually shorter that the anode wire of an LED. Microcontroller interfacing with a LED is shown in figure 1. +5V Microcontroller 0 1 LED Microcontroller LED R R Figure 1(a) Active low LED connection with microcontroller pin (b) Active high LED connection with microcontroller pin Seven - Segment LED Display A seven-segment display (SSD), or seven-segment indicator, is a form of electronic display device for displaying decimal numerals that is an alternative to the more complex dot-matrix displays. Standard form and notations of a seven- segment display is shown in figure 2. In Common Anode Type, all anodes of LEDs are connected together and common point is connected to + V which is positive supply voltage. A current limiting resistor is required i be connected between each LED and ground. All Common Cathode Type of LEDs are connected together and common point is connected to the ground. A current limiting resistor is connected between each LED and the supply + Vcc. The anodes of the respective segments are to be connected to + for the required operation of LEDs. LED pattern for displaying digits using a seven-segment display is shown in Table 1. IJETRM (http://ijetrm.com/) [50] ISSN: 2456-9348 Impact Factor: 4.520 Vol (03) _Issue (07) International Journal of Engineering Technology Research & Management By forward biasing different LEDs we can display the digits 0 through 9. For example, to display a zero, the LEDs A, B, C, D, E and F are forward biased. To light up a 5, we need to forward bias segments A, F, C, C, D. Thus in a seven segment display depending upon the digit to be displayed, the particular set of LEDs is forward biased. The various digits from 0 to 9 which can be displayed using seven segment display are shown in the Figure 2. Figure 2. Seven-segment displays for all numbers TABLE I Truth table for seven-segment display Segments ( ON = 1, OFF = 0) a B c d E f g 1 1 1 1 1 1 0 0 1 1 0 0 0 0 1 1 0 1 1 0 1 1 1 1 1 0 0 1 0 1 1 0 0 1 1 1 0 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 0 1 1 1 0 0 1 1 1 1 1 1 0 0 1 1 1 0 0 1 1 1` 1 0 1 1 0 0 1 1 1 1 IJETRM (http://ijetrm.com/) 7-Segment Display Outputs [51] ISSN: 2456-9348 Impact Factor: 4.520 Vol (03) _Issue (07) International Journal of Engineering Technology Research & Management 1 0 0 0 1 1 1 Interfacing an Electromagnetic Relay with PIC Microcontroller A relay is an electromagnetic switch which is used to switch high voltage/current using low power circuits. Relays isolate as well low power circuits from high power circuits, this is a good feature especially for safety reasons a section of the circuit with high dangerous voltage/current could be isolated from the user. When a low voltage is applied to the relay (coil wounded on a soft ion core), this coil becomes a magnet which in turns energizes the soft ion core which closes or open the high voltage/current contacts of the relay. Electromagnetic relays use an electromagnet to operate a switching mechanism mechanically. A relay can be used to switch higher power devices such as motors, light bulbs and solenoids. A relay should not be connected directly to a microcontroller due to following reasons: [1, 3, 6]   A microcontroller is not able to supply current required for the working of a relay. The maximum current that a PIC microcontroller can source or sink is 25mA while a relay needs about 50-100mA current. A relay is activated by energizing its coil. Microcontroller may stop working by the negative voltages produced in the relay due to its back emf. IJETRM (http://ijetrm.com/) [52] ISSN: 2456-9348 Impact Factor: 4.520 Vol (03) _Issue (07) International Journal of Engineering Technology Research & Management A relay can be easily interfaced with microcontroller using a transistor as shown in figure 3. Transistor is wired as a switch which carries the current required for operation of the relay. When the pin RB7 of the PIC microcontroller goes high, the transistor 2SC1815 turns on and current flows through the relay. The diode D1 is used to protect transistor and the microcontroller from Back EMF generated in the relays coil. Normally 1N4148 is preferred as it is a fast switching diode having a peak forward current of 450mA. This diode is also known as freewheeling diode. +VDD 12V PIC Microcontroller PORT B R1 10kΩ L RL1 D1 1N4148 12 220V AC INPUT Q1 C 1815 L1 220V N Figure 3.A relay interface with PIC microcontroller. Water Pump Controlling System Microcontroller is a computer on a chip that is programmed to perform almost any control, sequencing, monitoring and display the function. Because of its relatively low cost, it becomes the natural choice to the designer. Microcontroller is designed to be all of that in one. Its great advantage is no other external components are needed for its application because all necessary peripherals are already built into it. Thus, we can save the time, space and cost which is needed to construct low cost devices. We can control the water pump by connecting it with an output pin of microcontroller via a motor driver circuit. When microcontroller sends a positive signal (+5v) or a ground signal (0v) to the motor driver circuit, then the water pump become on or off respectively. [7] Microcontroller Unit (PIC 16F887A ) The microcontroller that has been used for this system is from PIC series. PIC microcontroller is the first RISC based microcontroller fabricated in CMOS that uses separate bus for instruction and data allowing simultaneous access of program and data memory. Various microcontrollers offer different kinds of memories. EEPROM, EPROM, FLASH etc. are some of the memories of which FLASH is the most recently developed. Technology that is used in PIC16F887A is flash technology, so that data is retained even when the power is switched off [1, 3, 6]. The PIC16F887 is one of the latest products from Microchip. It features all the components which modern microcontrollers normally have. For its low price, wide range of application, high quality and easy availability, it is an ideal solution in applications such as: the control of different processes in industry, machine control devices, measurement of different values etc. Pin connection diagram of a PIC 16F887A microcontroller is shown in figure 4. IJETRM (http://ijetrm.com/) [53] ISSN: 2456-9348 Impact Factor: 4.520 Vol (03) _Issue (07) International Journal of Engineering Technology Research & Management Its features are the PIC16F887 incorporates 256 bytes of EEPROM data memory, 368 bytes of RAM, and program memory of 8K. Apart from self-programming capability, it also contains 2 Comparators,10-bit Analogto-Digital (A/D) converter with 14 channels, and capture, compare and PWM functions. Figure 4. Pin connection diagram of a PIC 16F887A microcontroller IC. The functions that make this device unique in terms of ease of use include 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. Power-Saving Sleep mode Industrial and Extended Temperature range Wide operating voltage range (2.0V-5.5V) SR Latch mode Power-up Timer (PWRT) and Oscillator Start-up Timer (OST) Power-on Reset (POR) Ultra-Low-Power Wake-up (ULPWU) Multiplexed Master Clear with pull-up/input pin Individually programmable weak pull-ups Brown-out Reset (BOR) with software control option Enhanced low-current Watchdog Timer (WDT) DESIGN AND IMPLEMENTATION The system is divided into five main parts: regulated power supply unit, water level sensing unit, microcontroller unit, display unit and relay driver and relay switch unit. Power supply unit of the automatic water level control system is shown in Figure 5. The regulated +5V, dc power supply is used for all portion of the system. The line voltage 220V, ac is transformed to 12V,ac by using 12V ac step-down transformer. Stepdown ac voltage is converted to unregulated dc voltage by using full wave rectifier and filter circuit. To have regulated +5V, dc voltage is using fixed three-terminal positive voltage regulator IC 7805. This voltage was fed at pin 11 and pin 32 of the PIC16F887A microcontroller as a supply voltage. For experiment this design we have been using an 8 bit microcontroller, two water level sensor, an overhead tank, an underground tank ,water pump and 3-digit multiplex seven segment display. Water pump has been controlled using water level sensor. IJETRM (http://ijetrm.com/) [54] ISSN: 2456-9348 Impact Factor: 4.520 Vol (03) _Issue (07) International Journal of Engineering Technology Research & Management Two homemade water level sensors are used to detect the water level. Water level sensors output data is applied to the input Pin 8 (RE0) and Pin 18 (RC3) of PIC microcontroller 16F887A. Pin8 and pin 18 of the microcontroller were control input which coupled with water level sensors. System Architecture At the first stage of design a water level sensor is been made for sensing water level accurately. Microcontroller is used to control the overall system automatically that reduces the design and control complexity. Microcontroller takes input from the water level sensor unit which senses the water level. After processing input variables, resultant output decides the water pump‟s action (on/off) with respect to current water status of the tank. Sensor Unit Water level sensor unit consist two parts, one sensor is used in overhead water tank and other sensor placed inside underground water tank. Moreover, water level sensors are composed with series connected resistor, conducting wire and plastic plate. In underground tank water level sensor, wire is made by copper, that is connected to ground. Series connected resistors are connected with +5V. Copper wire and series connected resistors are binding together via a plastic plate. Plastic plate is used to make the electrical connection of copper wire and series resistor separate. In overhead tank water level sensor, series connected resistors are connected with input Pin 8 (RE0/AN5) of microcontroller and conducting wire to +5V. Control Unit The basic operation of control unit is the controlling water pump by microcontroller which is defined by particular program. Water pump is connected with an output pin of microcontroller via a relay circuit which is connected with a transistor. 1N 4007 12V Regulated +5V 0V 220V AC INPUT 1 0V AN 7805 3 2 1000µF 50V 12V 100µF 50V 1N 4007 Figure 6. Power supply unit of the automatic water level control system The collector of this transistor is connected with the relay circuit and the emitter is grounded. The output of relay circuit is connected to motor pump. Control unit performs following actions: (1) Off operation: When the microcontroller sends 0 volt to the base of the transistor then it becomes off and its emitter and collector becomes open. Then no ground signal (0v) is collected in the relay circuit. So, relay is deenergizing state. Therefore, the motor pump will be OFF due to getting positive signal (+5v) at one side and 220v ac at the other end. In this condition status indicator LED1 is off. (2) On operation: Transistor becomes on when the microcontroller sends positive signal (+5v) and its emitter and collector become short. So, relay is energized state. Therefore, the motor pump will be ON. In this condition, status indicator LED1 is on. Operation Description and Complete Circuit Diagram IJETRM (http://ijetrm.com/) [55] ISSN: 2456-9348 Impact Factor: 4.520 Vol (03) _Issue (07) International Journal of Engineering Technology Research & Management To implement the system we should use some necessary parts such as PIC 16F887A microcontroller, one capacitor having capacitance 0.22µF, relay, LEDs, two water tanks, water level sensors, water pump, transistor, 3-digit multiplex seven segment display and buzzer. Schematic diagram of the automatic water level controller system is shown in figure 8. RC3 input (pin 18) of the microcontroller is used to detect the existence of water in the underground tank. If the water level of the overhead tank is fall below the preset water level, RD7 output (pin 30) of the microcontroller is high. This data is send to the base of transistor Q1. Transistor Q1 turn on and relay reach the energize state. Therefore water pump is turn on until specific water level. Water level of the overhead tank is preset by using water level selector switches (S1, S2 and S3). These switches are connected to Pin 6 (RA4), Pin 5 (RA3) and Pin 4 (RA2) inputs of the microcontroller. Water level of overhead tank can be displayed by 3-digit multiplex seven segment LED indicator. If the water of the underground tank is empty, RD7 output (pin 30) of the microcontroller is low and transistor Q1 is turning off. So, water pump is not run in this mode. In this condition RC4 (Pin 23) output of microcontroller generate the pulse and make buzzer to tone alarm. At the same time character „E‟ is displayed by 3-digit multiplex seven segment display. The microcontroller is programmed using a high - level language instead of the conventional assembly language. Block diagram of the PIC microcontroller based automatic water level control system is shown in figure 7. Figure 7.PIC microcontroller based automatic water level control system. IJETRM (http://ijetrm.com/) [56] ISSN: 2456-9348 Impact Factor: 4.520 Vol (03) _Issue (07) International Journal of Engineering Technology Research & Management Figure 8.Schematic diagram of the PIC microcontroller based automatic water level control system. SOFTWARE SIMULATION In this research work, the Microchip's PIC 16F887A is used to control the automatic water level control system. The program for the automatic water level control system is written in CCS C language. The program is written in C language in the notepad and then saved with the file extension .c. The C program is converted into machine code (HEX code) by using MPASM assembler. After converting the HEX code, MPLAB simulation is essentially needed to execute properly for the source code. The window of simulation on program execution is shown in figure 9 and 10. The HEX code is downloaded into the MCU by the use of the programmer circuit. The Software which have used for this project is “Proteus” version 7.8. Proteus is one of the user friendly software in simulation world. For both electrical and electronics based circuit simulation and implementation can be done very easily with this software. Before starting the implementation and the simulation of the project circuit it is necessary to make an algorithm. Because a fruitful algorithm can makes the path easier to implement a circuit both virtually and practically. IJETRM (http://ijetrm.com/) [57] ISSN: 2456-9348 Impact Factor: 4.520 Vol (03) _Issue (07) International Journal of Engineering Technology Research & Management Figure 9.The window of simulation on program execution Figure 10.Simulation window of the automatic water level control system. IV. IJETRM (http://ijetrm.com/) RESULTS AND DISCUSSION [58] ISSN: 2456-9348 Impact Factor: 4.520 Vol (03) _Issue (07) International Journal of Engineering Technology Research & Management The hardware and software implementations have given a clue of what the result will look like. Basically, once the system is ON the microcontroller begins to scan to see which of the conditions in the code that is fulfilled. The fulfillment of any of the conditions is as a result of the condition the sensors find themselves. Whichever condition that is fulfilled, the microcontroller performs the corresponding operation. When the tank is empty, the output will be a display of “E” on the three seven-segment display. As the pump begins to pump water, the displays will be showing the system status as the level of water in the tank in the following order: 20, 40, 60, 80 and 100. At 100% the system switches OFF the pump. Again, if the underground water level falls lower than the pump, the system blows alarm and switches OFF the pump. The whole system operates automatically. So it does not need any expert person to operate it. It is not so expensive. This design has much more scope for future research and development. Though it is a project, we hope some modification in this project will lead to a reasonable diversity of usage. The photograph of the microcontroller based automatic water level control system circuit is shown in figure 11. Figure 11.Photograph of the microcontroller based water level control system REFERENCES [1] Bates M : 2006, Interfacing PIC Microcontroller (London Elsevier ) [2] Becker J, 2004 Everyday Practical Electronics, England : Winborne Publishing) [3] Microchip Technology Incorporated, 2003, "PIC 16F887A Data Sheet", (Arizona: Microchip Technology Inc.) [4] T L Floyd, 1997, "Digital Fundamentals", (New York: Prentice-Hall) [5] Mill man J and Hankies CC, 1991, Electronic Devices and circuit, (London : Mc Graw Hill ) [6] M. Javanmard, K.A. Abbas and F. Arvin, A Microcontroller-Based Monitoring System for Batch Tea Dryer, CCSE Journal of Agricultural Science, Vol. 1, No. 2, December 2009 [7] Reza, S. M. K.; Tariq,S. M.; Reza, S. M. M.; Douglas, C.; Grundfest, W. S. & Burgstone, J. (2010). Microcontroller Based Automated Water Level Sensing and Controlling: Design and Implementation Issue. IJETRM (http://ijetrm.com/) [59]