Monday, November 22, 2010

Water Level Controller and motor Protector

Many a time we forget to switch off the motor pushing water into the overhead tank (OHT) in our households. As a result, water keeps overflowing until we notice the overflow and switch the pump off. As the OHT is usually kept on the topmost floor, it is cumbersome to go up frequently to check the water level in the OHT.

Here’s a microcontroller-based water level controller-cum-motor protector to solve this problem. It controls ‘on’ and ‘off’ conditions of the motor depending upon the level of water in the tank. The status is displayed on an LCD module. The circuit also protects the motor from high voltages, low voltages, fluctuations of mains power and dry running.

Circuit description:
Fig. 1 shows the circuit of the microcontroller-based water level controller and motor protector. It comprises operational amplifier LM324, microcontroller AT89C51, optocoupler PC817, regulator 7805, LCD module and a few discreet components.

The AT89C51 (IC2) is an 8-bit microcontroller with four ports ( 32 I/O lines), two 16-bit timers/counters, on-chip oscillator and clock circuitry. Eight pins of port-1 and three pins of
port-3 are interfaced with data and control lines of the LCD module. Pins P3.0, P3.1 and P3.6 are connected to RS (pin 4), R/W (pin 5) and E (pin 6) of the LCD, respectively. Pin EA (pin 31) is strapped to Vcc for internal program executions. Switch S2 is used for backlight of the LCD module.

Power-on-reset is achieved by connecting capacitor C8 and resistor R14 to pin 9 of the microcontroller. Switch S1 is used for manual reset.

The microcontroller is operated with a 12MHz crystal. Port pins P2.0 through P2.2 are used to sense the water level, while pins P2.3 and P2.4 are used to sense the under-voltage and over-voltage, respectively. Pin P3.4 is used to control relay RL1 with the help of optocoupler IC3 and transistor T5 in the case of under-voltage, over-voltage and different water level conditions. Relay RL1 operates off a 12V supply. Using switch S3, you can manually switch on the motor.

The LM324 (IC1) is a quad operational amplifier (op-amp). Two of its op-amps are used as comparators to detect under- and over-voltage. In normal condition, output pin 7 of IC1 is low, making pin P2.3 of IC2 high. When the voltage at pin 6 of N1 goes below the set reference voltage at pin 5 (say, 170 volts), output pin 7 of N1 goes high. This high output makes pin P2.3 of IC2 low, which is sensed by the microcontroller and the LCD module shows ‘low voltage.’


In normal condition, pin 1 of N2 is high. When the voltage at pin 2 of N2 goes above the set voltage at pin 3, output pin 1 of N2 goes low. This low signal is sensed by the microcontroller and the LCD module shows ‘high voltage.’

Presets VR1 and VR2 are used for calibrating the circuit for under and over-voltage, respectively.


The AC mains is stepped down by transformer X1 to deliver a secondary output of 12V at 500 mA. The transformer output is rectified by a full wave bridge rectifier comprising diodes D5 through D8, filtered by capacitor C2, and used for the under and over-voltage detection circuitry.

The transformer output is also rectified by a full-wave bridge rectifier comprising diodes D1 through D4, filtered by capacitor C1 and regulated by IC4 to deliver regulated 5V for the
circuit.


When water in the tank rises to come in contact with the sensor, the base of transistor BC548 goes high. This high signal drives transistor BC548 into saturation and its collector goes low. The low signal is sensed by port pins of microcontroller IC2 to detect empty tank, dry sump and full tank, respectively.


Operation:
When water in the tank is below sensor A, the motor will switch on to fill water in the tank. The LCD module will show ‘motor on.’ The controller is programmed for a 10 minute time interval to check the dry-run condition of the motor. If water reaches sensor B within 10 minutes, the microcontroller comes out of the dry-run condition and allows the motor to keep pushing water in the tank.

The motor will remain ‘on’ until water reaches sensor C. Then it will stop automatically and the microcontroller will go into the standby mode. The LCD module will show ‘tank full’ followed by ‘standby mode’ after a few seconds. The ‘standby mode’ message is displayed
until water in the tank goes below sensor A.


In case water does not reach sensor B within 10 minutes, the microcontroller will go into the dryrunning mode and stop the motor for 5 minutes, allowing it to cool down. The LCD module will show ‘drysump1.’


After five minutes, the microcontroller will again switch on the motor for 10 minutes and check the status at sensor B. If water is still below sensor B, it will go into the dryrunning
mode and the LCD module will show ‘dry-sump2.’


The same procedure will repeat, and if the dry-run condition still persists, the display will show ‘drysump3’ and the microcontroller will not start the motor automatically. Now you have to check the line for water and manually reset the microcontroller to start operation.


In the whole procedure, the microcontroller checks for high and low voltages. For example, when the voltage is high, it will scan for about two seconds to check whether it is a fluctuation. If the voltage remains high after two seconds, the microcontroller will halt running of the motor. Now it will wait for the voltage to settle down. After the voltage becomes normal, it will still check for 90 seconds whether the voltage is normal or not. After normal condition, it will go in the standby mode and start the aforementioned procedure.


Practical applications:
This controller is useful for single-phase operated motor-pumps and the pumps that suck water from the ground water tank. A small push-to-off manual switch in series with sensor A can also make it useful for pumps that suck water from Jal Board’s supply. Because of the particular timing of this water supply, the controller must be switched on within the timing of the water supply and switched off when water is not being supplied.


When the controller is ‘on’ during the supply timings, it will wait for the tank to get empty before starting the motor. However, you can also start the motor using the pushbutton. The motor will turn on ignoring the status of the water level and will go through the aforementioned procedure.


Sensor positions in the tank:
Four non-corrosive metallic sensors are installed in the tank as shown in Fig.1. Sensor COM is connected to Vcc supply from the circuit. Sensor A detects the empty tank to start the motor. Sensor B detects dry-running condition of the motor and sensor C detects the full tank to stop the motor. Make sure that sensor B is around 2 cm above sensor A to check the dry-running condition properly.


Calibration:
Care must be taken when calibrating for under- and over-voltages. Always calibrate when the relay is in ‘on’ position. If you calibrate in the standby mode, it will trip at a voltage nearly 10 volts lower than the set voltage due to the loading effect.


Software:
The source code is written in Assembly language and assembled using 8051 cross-assembler. The generated Intel hex code is burnt into microcontroller AT89C51 using a suitable
programmer. The software is well commented and easy to understand. All the messages are displayed on the LCD module.


Download: Code files


Schematic:
Water controller and motor protector


Component Required:
IC1,                                             LM324
IC2,                                             AT89C51
IC3,                                             PC817
IC4,                                             7805
R1,R2,R7,R11,R12,                   1K ohm
R3,R9,                                        560K ohm
R4,R5,R8,                                  2.7K ohm
R6,                                              330 ohm
R10,                                           470 ohm
R13,                                            100 ohm
R14,                                            10K ohm
R15-R17,                                   100K ohm
R18-R20,                                   2.2K ohm
R21,R22,                                    33 ohm
RNW1,                                        10K resistor network
C1-C3,                                        1000uF/35v electrolyte cap
C4,                                              220uF/25v electrolyte cap
C5,C6,                                        33pF ceramic cap
C7,                                              100uF/35v electrolyte cap
C8,                                              10uF/16v electrolyte cap
T1-T4,                                       BC548
T5,                                             SL100
D1-D14,                                    1N4007 Diode
VR1-VR2,                                470 ohm pot
VR3,                                          10K pot
RL1,                                          12v Relay
X1,                                             230v to 12v, 500mA transformer
Xtal,                                          12MHz
S1,                                              Push to on switch
S2,S3,                                        on/off switch
16x1 LCD

39 comments:

  1. plz anyone help me. Can i use this device in 1 horse power motor? How can i connect the relay with the motor?

    ReplyDelete
  2. yes you can, but then use relay that can bear 1 hp motor current easily. connection is shown in the schematic.

    ReplyDelete
  3. and one more question. on the Schematic you mention in tank as com, a, b, c are without any sensor! so current is fully passed in water, when i touch water it hurt me? and this device takes more power Consumption then other device like tv, fan, fridge?

    ReplyDelete
  4. Basically these wires act like sensor and it does not hurt also the power consumption is less; but when in use then it depends on motor hp.
    In my second version i used ground to sense the water level you can also check it.

    ReplyDelete
  5. Thanks a lot Mr. Malik Zohaib. i hope your device is good for my new home and i prefer this device to my friends to use. Thanks for invasion.

    ReplyDelete
  6. sorry this project is not working properly,after complette the project there is no display.I am using the 16X1 lampex lcd.

    ReplyDelete
  7. just connect the enable pin of LCD to P3.7 of 89c51. Mistake in schematic.

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. Are you kidding? They are in Code files; just download them.

    ReplyDelete
  10. Mr. Malik Zohaib this circuit works proper. i have a doubt about this if the water stops flowing in middle of the process how will it prevent the motor from dry run. i replace the sensor B to water inlet but i not workout. can you please reprogram the code which suitable for this change.

    ReplyDelete
  11. "In case water does not reach sensor B within 10 minutes, the microcontroller will go into the dryrunning mode and stop the motor for 5 minutes, allowing it to cool down. The LCD module will show ‘drysump1.’"

    Already in code. Have you Read this?

    ReplyDelete
  12. yes Mr. Malik i have read your code and it working properly. my question is if the water stop flowing after reach the sensor B. how it know about the dry run.

    ReplyDelete
  13. No it i 'll not. For this you have to use one more sensor between B and C sensors, and have to change the coding.

    ReplyDelete
  14. Hello sir can u pls be more specific in how to configure that high and low voltages(i.e Vr1 and Vr2). pls give me detailed procedure.And also there is some mismatch between ur program and schematic... i mean in ur program to turn on n off the motor u have used pin p3.5 but in schematic p3.5 is used for LCD n P3.4 is used for connecting motor via optocoupler.
    thank you

    ReplyDelete
  15. Sorry sir P3.5 is not used for connecting LCD I apologize for mistyping in my previous post. Also p3.5 is not used to connect motor but in ur program u have used that pin for turning on and off the motor... why it is like that..?

    ReplyDelete
  16. Sir please tell me where should i change on prog if i want "In case water does not reach sensor B within "1" minutes, the microcontroller will go into the dryrunning mode and stop the motor for 5 minutes, allowing it to cool down. The LCD module will show ‘drysump1
    SAUMEN

    ReplyDelete
  17. by using voltage divider rule we get 2.5v are on pin5 n 3 of n1 and n2, similarly by adjusting the vr1 n vr2 you can calculate the voltage on pins6 n 2. adjust the vr2 so that the o/p oh n2 in high,and set vr1 to get the low o/p of n1.but you should adjust the high n low voltage according to the motor operating voltage.

    ReplyDelete
  18. Sir please tell me where should i change on prog if i want "In case water does not reach sensor B within "1" minute, the microcontroller will go into the dryrunning mode and stop the motor for 5 minutes, allowing it to cool down. The LCD module will show ‘drysump1
    SAUMEN

    ReplyDelete
  19. after probe "A" use 1 minute delay and read the probe B, if B is not high then goto the dryrun routine and wait till your desired dead line. After this again read prob B,and so on...

    ReplyDelete
  20. Hello sir,
    I tried the above project but i got a problem with it i.e when i turn on the circuit LCD display STAND BY MODE for few sec then it starts displaying high voltage that's it further nothing else works. i tried varying VR1 and VR2 but of no use same thing will be displayed pls. wat may the mistake pls help me sir.

    ReplyDelete
  21. I tried the above project but i got a problem with it i.e when i turn on the circuit LCD display STAND BY MODE for few sec then it starts displaying high voltage that's it further nothing else works. i tried varying VR1 and VR2 but of no use same thing will be displayed. wat may be the mistake pls help me sir.

    ReplyDelete
  22. Check your sensors and op-amp. its better first to simulate the circuit, in proteus etc, then construct it.

    ReplyDelete
  23. i changed opamp and also VR1 and VR2 but not working.

    ReplyDelete
    Replies
    1. there must be a problem in your circuit, try to figure it out.

      Delete
  24. can it be made wireless?
    for large buildings the tank is far apart and cant be wired up...

    ReplyDelete
  25. i have made hardware ..but code provided by you is result in no display on lcd...
    in progran pin 3.7 is define which has no use...
    wat i have to do sir to make this project running....
    if u can provide me the code in 'c' language as i know the programming in c...

    ReplyDelete
  26. i have made hardware ..but code provided by you is result in no display on lcd...
    in progran pin 3.7 is define which has no use...
    wat i have to do sir to make this project running....
    if u can provide me the code in 'c' language as i know the programming in c...

    ReplyDelete
  27. can u provide' c ' code of this project....

    ReplyDelete

  28. I really want to appreciate the quality of this article. I love the way of your presentation of thoughts, views and helpful content. No doubt you have done a great work. Thanks. Keep it up!
    Servo Voltage Stabilizer

    ReplyDelete
  29. Check your sensors and op-amp. its better first to simulate the circuit, in proteus etc, then construct it.
    poly tanks, large water tank

    ReplyDelete
  30. Most of the blogs pretend themselves as most usable and updated blogs with new information but sometime truth might different. I want to share some facts related to this subject which will help people to enhance their skills.
    Power protection

    ReplyDelete
  31. Hey, It really is incredibly fantastic and informative website. Good to discover your site Very well article! I’m simply in love with it.
    Home theatre power filter

    ReplyDelete
  32. Yes, that’s the way I always wanted to come over such a wonderful platform where I could satisfy myself regarding my issues. I found answers of all most of my check list I prepared after having a lot of confusion. Great job.Mains power protector

    ReplyDelete
  33. Sometimes we have to face a lot of confusion when we found different opinion of different hundreds of articles related to same question. But I think now I am close to resolve my doubts after reading this blog.Power protection

    ReplyDelete
  34. KTronics controllers are specially designed for water level control and level indication purposes.Automatic water level control valve in chennai.water pumps with 1HP.

    ReplyDelete
  35. Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... Satta result

    ReplyDelete