Basic ElectronicsCommunicationControlElectrical DesignElectrical ProjectElectronics Engineering ProjectHow ToMeasuring InstrumentsMotors

Fully Automatic Water Level Controller using SRF04

Full Automatic Water Level Controller using SRF04, L293D & PIC16F84A

Introduction to the Automatic Water Level Controller

Monitoring and controlling the level of water in water tanks is one of the most important work in almost many residential as well as commercial areas. In most cases, especially in residential buildings, due to unavailability of any automatic means, it becomes tiresome and inconvenient to frequently monitor the water level in the tanks. In fact, for places with water scarcity, overflow of water would be quite an expensive thing to pay for.

The only solution to the above problem is to have an automatic way to monitor and control the level of water. While there are many techniques like using distance sensors, using current probes, using ultrasonic ranger etc., here we are going to focus on using ultrasonic ranger.

Automatic Water Level Controller using SRF04, PIC16F84A & L293D Driver

System Overview of Water Level Controller

The system consists of an ultrasonic ranging sensor placed on top of the tank such that once triggered, it sends out an ultrasonic signal. Water present in the tank would reflect off the signal. The sensor would receive this signal and the time taken between these two signals give an estimate about the distance travelled by the signals, thus the water level from top.

Here a microcontroller is used to send trigger signal to the ultrasonic ranger. Once an echo is received, the time lag between the two pulses is calculated and this is directly proportional to the water level. The time lag is calculated with help of Timer, whose number of counting pulses denote the distance travelled by signal, or the water level.

Since here the ranger is placed on top of the tank, control of water flow is done considering the level of water from top of the tank. For example, if measured range is found to be between 0 to 1 cm, the tank is overflowing and the microcontroller sends a control signal to rotate the motor in reverse direction, to remove the excess water. ‘

If range is between 2 to 5 cm, the tank is full and the microcontroller sends a control signal to switch off the motor. If the range is above 5cm, the tank is almost empty and the microcontroller sends a control signal to rotate the motor in forward direction.

Circuit Diagram of Automatic Water Level Controller

Click image to enlarge

Circuit Diagram of Fully Automatic Water Level Controller using SRF04, PIC16F84A , L293D

Figure 1: Water Level Controller

Parts Description

The following components would be used for designing the circuit.

  1. Ultrasonic Range Finder SRF04
  2. PIC Microcontroller PIC16F84A
  3. Motor Driver L293D
  4. DC Motor
  5. Two 1K Resistors

Let us have a brief idea about each component

Ultrasonic Range Finder SRF04:

The SRF04 is a high quality ultrasonic ranger which is used in many robotic applications for easy detection of obstacles. It requires 10 microseconds signal to be triggered.SRF04 Ultrasonic Range Finder for Aotomatic Water Level Controller

                                                             Figure 2: SRF04 Ultrasonic Range Finder

Once triggered, it sends out 8 pulses of ultrasound, at a frequency of 40 KHz and simultaneously sends raises it echo line to HIGH. Once it receives the reflected signal or echo, it lowers the echo line to LOW.

Thus, width of the echo pulse denotes the distance travelled by the signal or in other words distance from the ranger to the object. The echo line is therefore a pulse whose width is proportional to the distance to the object. For 1cm, the echo pulse width would be 58 microseconds.SRF04 Timing Diagram

                                Figure 3: SRF04 Timing Diagram

PIC Microcontroller PIC16F84A:

Figure 4: PIC Microcontroller PIC16F84A

It is a CMOS compatible, 8-bit, 18 pin Flash Microcontroller with a single 8-bit Timer (with 8-bit programmable prescaler). The Timer operation is controlled using the following registers – OPTION_REG, TMR0 and INTCON. The OPTION_REG is an 8-bit register whose 5th bit (T0CS) selects the required timer or counter operation.

Setting the bit selects counter operation whereas clearing it selects timer operation. TMR0 is the timer register, whereas INTCON is the interrupt register whose 5th bit (T0IE) denotes the timer flag, i.e. it sets when the Timer overflows.PIC16F84A Microcontroller

Motor Driver L293D:

Figure 5: Motor Driver IC L293D

It is a 16 pin, H-bridge based DC motor driver IC. It has the capacity to drive two motors and in both directions. It consists of two enable pins (Pin1 and 9) which when set to HIGH, enable the IC operation. It basically acts as an interface between the microcontroller and the DC motor. It consists of four input pins – two for each H-bridge circuit. Given below is a table denoting the motor control.Motor Driver L293D for Water Level Controller

IN1(Pin 2) IN2 (Pin 7) EN1 (Pin 1) Motor Operation
HIGH HIGH HIGH OFF
LOW LOW HIGH OFF
HIGH LOW HIGH ON (Clockwise)
LOW HIGH HIGH ON (Anticlockwise)
X X LOW OFF

Note: Since SRF04 is a TTL compatible device and PIC16F84A is a CMOS compatible, we are using a pull up resistor of 1K value, to compensate for the voltage level change.

Working & Operation of Automatic Water Level Controller

The program is written such that a 10 microseconds pulse is sent from the microcontroller to trigger the ultrasonic ranger. This is written using a delay function. The timer register, TMR0 is loaded with decimal value 200, so that it makes 55 counts.

The output from SRF04, the echo signal is received at pin RA4 (The Timer clock pin, thus providing external clock pulse to the timer). Once the echo signal makes a transition from HIGH to LOW, the timer is activated. As the timer counts, the interrupt flag bit, T0IE, is monitored. Once set, the timer is deactivated.

The procedure is repeated for another echo pulse and so on. The number of times the timer operates is calculated and this denotes the number of echo pulses. Since each echo pulse is of 58 microseconds, it denotes 1 cm. Thus, 5 echo pulses would denote 5cm. The value of this count, stored in an integer, is used to control the DC motor.

If the value is between 2 to 5, the microcontroller sends HIGH signals to pins RB0 and RB1 (connected to IN1 and IN2 of L293D respectively), to switch OFF the motor. If value is between 5 to 20, the microcontroller sends a HIGH signal to IN1 and LOW signal to IN2, to switch ON the motor and rotate it in clockwise direction. If value is between 0 to 1, the microcontroller sends LOW signal to IN1 and HIGH signal to IN2, to switch ON the motor and rotate it in anti-clockwise direction.

Advantages of Automatic Water Level Controller using SRF04

  1. It would be a simple and convenient system.
  2. It would be a low-cost system due to use of low cost components.
  3. Using automatic technique would eliminate the hurdles faced in water level control using manual means.
  4. Since no mechanical parts are used, this would eliminate the risk of mechanical wearing or corrosion.

Disadvantages of Automatic Water Level Controller

  1. The ultrasonic range finder, SRF04, would be subjected to damping due to use of many electronics and thus should be properly insulated.
  2. This system is designed such that the sensor as well as the actuator needs to be placed in vicinity to each other. In layman’s words, this control system is for places where the water tank is near to the water pump. Thus, for many buildings where submersible pumps are used and water tanks are on the rooftops, this Automatic Water Level Controller system cannot be used. However, this can be modified by using communication circuit.

Related Posts:

➡️ READ FULL ARTICLE 📖

Electrical Technology

All about Electrical and Electronic Engineering & Technology. Join us on WhatsApp at Electrical Technology Official Channel, to receive the latest content, articles, and updates. You can also like and follow our social media networks below, or subscribe with your email to receive premium engineering articles in your mailbox.

2 Comments

  1. I do not see a disadvantage like mentioned at point 2. What prevents me from replacing the 12V motor with a contactor to supply the pump remotely?

  2. Jahabar Sadiq says:

    Nice ; Wonder this website!!!!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button

Kindly permit ads on our free website.

It appears that you are using an ad blocker. We rely on advertising to support our website, provide free information, and sustain our services. Kindly consider whitelisting our website to allow ads.