Ultrasonic water level controller using 8051


Ultrasonic water level controller using 8051 microcontroller.

A simple water level controller using ultrasonic  range finder module and 8051 microcontroller is discussed in this article.Many projects based on ultrasonic range finder and water level controllers have bee already discussed here. This is just another application of the ultrasonic ranging module. This water level controller can monitor and control water tanks up to 2m deep and the accuracy of measuring is as low as 1cm.  Since no mechanical float switches or electrodes are used here, there will not be any mechanical wearing or corrosion and this makes the system highly reliable. Any way proper care must be given to insulate the ultrasonic ranging module from damping as it contains a lot of electronics.

HC-SR04 ultrasonic ranging module.

HC-SR04 is the ultrasonic ranging module used here. HC-SR04 consists of an ultrasonic transmitter, receiver and necessary electronics for making it a stand alone system. The operating principle is very simple. It sends 8 pulses of 40KHz sound waves, and picks up the reflected wave. The time lag between the transmission and reception is measured and the distance is calculated from the  equation D=TS/2. Where D is the distance, T is the time lag and S is the speed of sound. The output of the HC-SR04 will be a pulse whose width is proportional to the distance. From the datasheet, width of the output signal will be 58uS for a distance of 1cm. What we need to do is to just send a 10uS wide trigger signal to the trigger pin of the module and wait for the output pulse at the echo pin of the module. Timing diagram and pin out of the ultrasonic module is given below.

Ultrasonic rangefinder timing diagram












For knowing more about the HC-SR04 ultransonic module and its interfacing to 8051 microcontroller, go through this article. Ultrasonic range finder using 8051. Full circuit diagram of the ultrasonic water level controller is shown below.

















Circuit diagram ultrasonic water level controller

Trigger pin of the ultrasonic module is connected to P3.0 of the microcontroller. Echo pin of the module is connected to P3.1 of the microcontroller. Data lines of the LCD is module is interfaced through Port0 of the microcontroller. The control lines RS, RW and E of the LCD module are connected to P2.7, P2.6 and P2.5 pins of the microcontroller respectively. The pump is controlled using Port 2.0 of the microcontroller. The pump used here is a 12V automobile windscreen washer pump.Mains operated pumps will also go with this circuit but their current rating must match with the relay you are using.Anyway  be careful to avoid the risk of electric shock while working working with mains operated devices.

Here the ultrasonic ranging module is placed on top of the tank facing the water surface. The water reflects the ultrasonic pulses emitted by the module.The module pics the reflected waves and also measures the time lag. The distance between the water surface and the sensor is calculated from the collected data and the module outputs a pulse whose width is proportional to the distance. The microcontroller reads the width of this output pulse and does necessary maths on it to get the distance. Here we can see that the water level is measured from top to bottom unlike most sensors which measure the level from bottom to top. This is done to make this device suitable for a wide range of depths. Since the sensor is placed on top of the tank we need to subtract the distance from the sensor  to the water surface from the total depth of the tank in order get the level of water from bottom to top. Since different tanks have different depths the individual user has to measure the depth of the tank manually  and alter the program with this data.

This problem is solved by measuring the level from top to bottom. Here the device switches  ON the pump when the level falls below 20 cm from top and switches OFF the pump when the level rises to 5 cm from top. The level displayed on the LCD screen is actually the depth of the water surface from top. Tanks with depth up to 1.5 meters will go well with this project.
Share:

No comments: