Project tutorial

TANK_CONTROL with Arduino © GPL3+

This project consists of the assembly of a level control system in a tank

  • 13 respects

Components and supplies

Ph a000066 iso (1) ztbmubhmho
Arduino UNO
09939 01
Rotary potentiometer (generic)
Fairchild semiconductor pn2222abu. image
General Purpose Transistor NPN
08377 02 l
Resistor 330 ohm
Mfr 25frf52 1k sml
Resistor 1k ohm
Mfr 25frf52 47k5 sml
Resistor 47.5k ohm
Hex Inverter, 74HC04 IC
Capacitor 0.1µF
Relay SPDT, 12 Volts
ITR-9606 DIP-4 Opto Switch
Submersible Pump, BOYU SP-1500, 120 Vac
Diode 1N4001

About this project

TANK_CONTROL project presents some of the basic concepts of control commonly used in industry, and provides the foundation to understand more complex control processes. Common terms and concepts relating to process control are defined in this project. Control loop, Process variable, Setpoint, Measured variable and Error definitions are considered. Also you will learn about the three tasks necessary for process control: Measure, Compare and Adjust.

Project Scope

This project consists of the assembly of a level control system in a tank.

Level measurement is an important and common variable in the industry environment.

There are many ways to sense level. You could use pressure, ultrasonic, capacitance, or discrete (switches) sensors. For this project we will consider a potentiometer, as a sensor, attached to a floating mechanism to bring data information to the controller.

In the next figure you can see the block diagram for the project. There are two tanks: TANK_1 and TANK_2. In TANK_1 we measure the level and TANK_2 is used to recirculate the liquid.

There are two valves, one to control the stream to TANK_1 and the other which is the drain to TANK_2. RL and RSP are two potentiometers which inform to the controller of the status of the level and the set point. Finally the pump keeps recirculating the liquid to maintain the desire level in TANK_1.

Principle of Operation

To understand how this system operates, we have to consider the following control definitions:

  • Process Value (PV): The value to be measured; in this case, the tank level.
  • Set Point (SP): The required value.
  • Output (OUT): The controller output.
  • Error: the difference between the measured variable (PV) and the set point (SP) and can be either positive or negative.
  • Closed Control Loop: A closed control loop is a configuration of a control system where the process variable is measured, compared with a set point, and action is taken to correct any deviation from set point.
  • Controller: A device capable of read data from a measurement instrument, compare with the set point and then generates an output value, which is the result of that comparison.

There are 2 main control types:

ON-OFF and PID, where P: Proportional, I: Integral and D: Derivative are the modes of control.

These 3 modes are used in different combinations:

  • P – Only proportional
  • PI – Proportional + Integral
  • PID – Proportional + Integral + Derivative
  • PD – Proportional + Derivative

The diagram show in Fig. 2 is a typical ON_OFF control block.

Float position (PV) can vary from 0 to 100%. With the SP (Set Point), we can fix the desire value of level.

If the level is lower than the SP value, then the pump is activated (OUT = 1) until the SP value is reached.

If the level is greater than the SP value, then the pump is stopped (OUT = 0) until the SP value is reached.

We can represent the operation of this control loop through the following equation:

PV – SP = Δ; if Δ > 0, then OUT = 0 (Boolean)

if Δ < 0, then OUT = 1 (Boolean)

Where Δ is the Error.

Fig. 3 shows graphically the operation of the controller.

If the process value is less than the set point, output value will be “1” (activated pump)

If the process value is greater than the set point, output value will be “0” (pump off)

HMI (Human Machine Interface)

At this time HMI (Human Machine Interface) is considered.

There is much software developed for HMI applications available in the market. LabVIEW, Wonderware, Panel Studio, FoxView, eLogger and Infilink are some of them

For the HMI of this project I found an application for micro-controllers in the web, called SerialComInstruments4 and develop by Ulrich Albert Maassen.

The web address to download this application is:

In the next figure I show the screen for the project. There, you can see the tanks, valves and the pump, in the left side are the numeric values expressed in % (0%-100%). At the top-right of the screen you can see the trending of the variables of the tank. Status of the pump can be observed in the indicator above the pump.

SerialComInstruments4 allows you to create environments to build process displays where you can see the process values, set points, Trends, X-Y Graphics, Numeric Displays, Vertical Meters and Digital Displays.

In the main menu you will find six fields to access the different functions of this application: File, Interface, Terminal, Settings, Test Tools and Help.

You also can perform the following functions:

  • COM: If you select “COM”, you will be able to Connect and Disconnect the interface
  • LAN: Network connection
  • Start /Stop Trend: Start or Stop the trending of process variables
  • Design Toggle: In this field you can go to the Edit Mode. In this mode you can build your display
  • List: Displays a list of all the instruments that you used in your design
  • Display1, 2, 3, 4, 5: Allows you to select the desired display (display 1, display 2, etc.)

If you select “File” you can start a new Project, Load and Save a Project.

You can select the Serial “Interface”, where you specify: Com Port, Baud Rate, also you can change the Data Protocol.

Terminal menu allows you to visualize serial data in the screen.

In Settings you can activate the Carriage Return and the Line Feed.

In Test Tools menu you can simulate process changes through a sinewave generator and a ramp wave generator.

Selecting the field “Instr. Box” you can select a diversity of resources for your project:

  • Vertical, Flex and Horizontal Meters are available in Analog Meter of the Tool Box.
  • Numeric Display and LEDs are available in Digital Meter of the Tool Box.
  • Trends are available in Graph of the Tool Box.
  • Analog Sliders are available in Analog Actors of the Tool Box.
  • Switch Buttons and Button Panels are available in Digital Actors of the Tool Box.
  • Text Displays are available in Text Based of the Tool Box.
  • Background and Text Labels are available in Design of the Tool Box.

Analog Sliders are available in Analog Actors of the Tool Box.

Switch Buttons and Button Panels are available in Digital Actors of the Tool Box.

Text Displays are available in Text Based of the Tool Box.

Background and Text Labels are available in Design of the Tool Box.

Bill of Materials (BOM)


1 Arduino Uno, Rev. 3 (1)

2 Potentiometers, 10K (2)

3 Diode 1N4001 (2)

4 Transistor 2N3904 (1)

5 Resistor 330, 0.25W (1)

6 Resistor 1K, 0.25W (1)

7 Resistor 47K, 0.25W (1)

8 Hex Inverter, 74HC04 IC (1)

9 Condenser 0.1µF (1)

10 Relay SPDT, 12 Volts (1)

11 ITR-9606 DIP-4 Opto Switch (1)

12 Submersible Pump, BOYU SP-1500, 120 Vac (1)

13 Plastic float (1)

14 Plastic valves (2)

15 Metallic base (1)

16 HW (Connectors, gaskets, plastic hose, plastic tubes) (LOT)

17 Plasic water bottle (20 lts) (1)

18 Plastic container (1)


To successfully work with control systems, it is necessary to understand the concepts and principles that are typically used to explain process control.

In this project we use a very simple system which utilizes a float connected to a variable potentiometer that will change the resistance according to the amount of motion of the float. But despite the simplicity of the system, the number of principles, terms and concepts involved is immense. Many of those principles and concepts were not addressed in this project, but those who were, are the basis for continuing a deeper study in the extremely wide world of control and instrumentation.


Untitled fileArduino
// This routine let you to CONTROL level in a tank:
// Standard protocol to select instruments:
 void SendString (byte InstrNr, int MW) { 
Serial.print ('#');
Serial.print (InstrNr);
Serial.print ('M'); 
Serial.print (MW); 
Serial.print ('<');    }
 void SendString (byte InstrNr, int f, int d, int m) { 
Serial.print ('#');
Serial.print (InstrNr);
Serial.print ('M'); 
Serial.print (f);
Serial.print (d);
Serial.print (m); 
Serial.print ('<') ;}
void setup ()
 {    // initialize serial communication at 9600 bits per second:
Serial.begin (9600);   }
void loop () {
int RL = A0;    // select the input pin for the LEVEL potentiometer
int RSP = A1;    // select the input pin for the SET POINT potentiometer
int X = 8;      // select the pin for the pump control (ON - OFF)
int LEVEL = 0.0; // variable to store the value coming from RL
int SETPOINT = 0.0; // variable to store the value coming from RSP
 // declare X as an OUTPUT:
  pinMode(X, OUTPUT); 
  // read the values from RL and RSP:
  LEVEL = analogRead (RL);
  SETPOINT = analogRead (RSP);
   // compare sensor values:
int F;
int D;
int M;
  if (LEVEL < SETPOINT - 21){digitalWrite(X, HIGH);  } 
  if (LEVEL < SETPOINT) {F = 2;    } 
 if (LEVEL < SETPOINT) {M = 0;    }   
   if (LEVEL > SETPOINT + 21) {digitalWrite(X, LOW);  } 
 if (LEVEL > SETPOINT) {F = 3 ;}   
  if (LEVEL > SETPOINT) {M = 1 ;} 
float TRUE_LEVEL = LEVEL * (100.00 / 1023.00);
float TRUE_SETPOINT = SETPOINT * (100.00 / 1023.00);
  // print out the value you read:
 SendString (2, TRUE_LEVEL); // Instrument #02 – Vert_Meter
SendString (3, TRUE_LEVEL); // Instrument #03 – Tank_Meter
SendString (4, F, D, M); // Instrument #04 - LED
SendString (5, TRUE_LEVEL); // Instrument #05 – Num_Display
SendString (6, TRUE_SETPOINT); // Instrument #06 - Num_Display
SendString (12, TRUE_LEVEL); // Instrument #12 - Trend
SendString (13, TRUE_SETPOINT); // Instrument #13 - Trend
delay (500);   }


Circuit Diagram of Tank Control


Similar projects you might like

Arduino Tank Monitor

Project tutorial by zezarandrade

  • 1 comment
  • 17 respects

Weather Station v1.3 with RF Transmission

Project showcase by derapados

  • 32 respects

How to create a website communicating Arduino by using PHP

Project tutorial by Kutluhan Aktar

  • 31 respects

Arduino To Excel Communication

by Mahamudul Karim Khondaker

  • 65 respects

Audio Frequency Detector

Project tutorial by lbf20012001

  • 20 respects

Cheap portable Cocktail maker Barbot wit App!

Project tutorial by Seafox_C

  • 39 respects
Add projectSign up / Login