Devices & Components
Arduino Uno Rev3
Hex Inverter, 74HC04 IC
Resistor 47.5k ohm
Submersible Pump, BOYU SP-1500, 120 Vac
Capacitor 0.1µF
ITR-9606 DIP-4 Opto Switch
Resistor 330 ohm
Diode 1N4001
Relay SPDT, 12 Volts
Rotary potentiometer (generic)
General Purpose Transistor NPN
Resistor 1k ohm
Project description
Code
untitled
arduino
1// This routine let you to CONTROL level in a tank: 2// Standard protocol 3 to select instruments: 4 void SendString (byte InstrNr, int MW) { 5Serial.print 6 ('#'); 7Serial.print (InstrNr); 8Serial.print ('M'); 9Serial.print (MW); 10 11Serial.print ('<'); } 12 void SendString (byte InstrNr, int f, int d, int 13 m) { 14Serial.print ('#'); 15Serial.print (InstrNr); 16Serial.print ('M'); 17Serial.print 18 (f); 19Serial.print (d); 20Serial.print (m); 21Serial.print ('<') ;} 22void 23 setup () 24 { // initialize serial communication at 9600 bits per second: 25Serial.begin 26 (9600); } 27void loop () { 28int RL = A0; // select the input pin for the 29 LEVEL potentiometer 30int RSP = A1; // select the input pin for the SET POINT 31 potentiometer 32int X = 8; // select the pin for the pump control (ON - OFF) 33int 34 LEVEL = 0.0; // variable to store the value coming from RL 35int SETPOINT = 0.0; 36 // variable to store the value coming from RSP 37 // declare X as an OUTPUT: 38 39 pinMode(X, OUTPUT); 40 // read the values from RL and RSP: 41 LEVEL = analogRead 42 (RL); 43 SETPOINT = analogRead (RSP); 44 // compare sensor values: 45int F; 46int 47 D; 48int M; 49 if (LEVEL < SETPOINT - 21){digitalWrite(X, HIGH); } 50 if 51 (LEVEL < SETPOINT) {F = 2; } 52 if (LEVEL < SETPOINT) {M = 0; } 53 if 54 (LEVEL > SETPOINT + 21) {digitalWrite(X, LOW); } 55 if (LEVEL > SETPOINT) {F 56 = 3 ;} 57 if (LEVEL > SETPOINT) {M = 1 ;} 58float TRUE_LEVEL = LEVEL * (100.00 59 / 1023.00); 60float TRUE_SETPOINT = SETPOINT * (100.00 / 1023.00); 61 // print 62 out the value you read: 63 SendString (2, TRUE_LEVEL); // Instrument #02 – Vert_Meter 64SendString 65 (3, TRUE_LEVEL); // Instrument #03 – Tank_Meter 66SendString (4, F, D, M); // Instrument 67 #04 - LED 68SendString (5, TRUE_LEVEL); // Instrument #05 – Num_Display 69SendString 70 (6, TRUE_SETPOINT); // Instrument #06 - Num_Display 71SendString (12, TRUE_LEVEL); 72 // Instrument #12 - Trend 73SendString (13, TRUE_SETPOINT); // Instrument #13 - 74 Trend 75delay (500); } 76
untitled
arduino
1// This routine let you to CONTROL level in a tank: 2// Standard protocol to select instruments: 3 void SendString (byte InstrNr, int MW) { 4Serial.print ('#'); 5Serial.print (InstrNr); 6Serial.print ('M'); 7Serial.print (MW); 8Serial.print ('<'); } 9 void SendString (byte InstrNr, int f, int d, int m) { 10Serial.print ('#'); 11Serial.print (InstrNr); 12Serial.print ('M'); 13Serial.print (f); 14Serial.print (d); 15Serial.print (m); 16Serial.print ('<') ;} 17void setup () 18 { // initialize serial communication at 9600 bits per second: 19Serial.begin (9600); } 20void loop () { 21int RL = A0; // select the input pin for the LEVEL potentiometer 22int RSP = A1; // select the input pin for the SET POINT potentiometer 23int X = 8; // select the pin for the pump control (ON - OFF) 24int LEVEL = 0.0; // variable to store the value coming from RL 25int SETPOINT = 0.0; // variable to store the value coming from RSP 26 // declare X as an OUTPUT: 27 pinMode(X, OUTPUT); 28 // read the values from RL and RSP: 29 LEVEL = analogRead (RL); 30 SETPOINT = analogRead (RSP); 31 // compare sensor values: 32int F; 33int D; 34int M; 35 if (LEVEL < SETPOINT - 21){digitalWrite(X, HIGH); } 36 if (LEVEL < SETPOINT) {F = 2; } 37 if (LEVEL < SETPOINT) {M = 0; } 38 if (LEVEL > SETPOINT + 21) {digitalWrite(X, LOW); } 39 if (LEVEL > SETPOINT) {F = 3 ;} 40 if (LEVEL > SETPOINT) {M = 1 ;} 41float TRUE_LEVEL = LEVEL * (100.00 / 1023.00); 42float TRUE_SETPOINT = SETPOINT * (100.00 / 1023.00); 43 // print out the value you read: 44 SendString (2, TRUE_LEVEL); // Instrument #02 – Vert_Meter 45SendString (3, TRUE_LEVEL); // Instrument #03 – Tank_Meter 46SendString (4, F, D, M); // Instrument #04 - LED 47SendString (5, TRUE_LEVEL); // Instrument #05 – Num_Display 48SendString (6, TRUE_SETPOINT); // Instrument #06 - Num_Display 49SendString (12, TRUE_LEVEL); // Instrument #12 - Trend 50SendString (13, TRUE_SETPOINT); // Instrument #13 - Trend 51delay (500); } 52
Downloadable files
Tank_Control
Tank_Control
Circuit Diagram of Tank Control
Circuit Diagram of Tank Control
Circuit Diagram of Tank Control
Circuit Diagram of Tank Control
Tank_Control
Tank_Control
Comments
Only logged in users can leave comments