zezarandrade
Published © GPL3+

TANK_CONTROL with Arduino

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

IntermediateFull instructions provided14,805

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×2
General Purpose Transistor NPN
General Purpose Transistor NPN
×1
Resistor 330 ohm
Resistor 330 ohm
×1
Resistor 1k ohm
Resistor 1k ohm
×1
Resistor 47.5k ohm
Resistor 47.5k ohm
×1
Hex Inverter, 74HC04 IC
×1
Capacitor 0.1µF
×1
Relay SPDT, 12 Volts
×1
ITR-9606 DIP-4 Opto Switch
×1
Submersible Pump, BOYU SP-1500, 120 Vac
×1
Diode 1N4001
×2

Story

Read more

Schematics

Circuit Diagram of Tank Control

Tank_Control

Code

Untitled file

Arduino
// 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);   }

Credits

zezarandrade

zezarandrade

2 projects • 25 followers

Comments