Modular Water Automation System
1009 7
Santhosh Sivan D

Modular Water Automation System

There are many reinventing of wheel scenario is happening in the field of water tank level...

Description:-

There are many reinventing of wheel scenario is happening in the field of water tank level controller. It is decades old project now, still, there is not a single product to solve one main problem. There are products in the market with a maximum 2 tank (not exactly), 1 tank as a sump, and 1 tank as OHT. For multi tank, multi pump users, there is a serious issue known as valve operation. The valves had to be frequently operated (either opened or closed) for the water to go to another tank when the current one is filled and so on. This is the main problem that is faced by the Multi-Tank, Multi Pump and Multi Sump system owners. Don't worry anymore, we have a solution. We designed and developed our indigenous Modular Water Automation System. It can control maximum number of tanks and pumps available in any domestic and commercial house or office. We had tried and tested up-to of 4 Individual Tanks and 1 Pump (Maximum control of tank and pump is not limited to 4) at the same time using our one and only Modular Water Automation Controller.

Project Used Hardware

System Hardware

Modular Water Management Controller (Designed and Developed by us), SSR-75DA, 12V-2A SMPS, IP65 190x140x70 Enclosure, GX-16 4 Pin Connector, Float Switches, Direction Control Valves.

Project Used Software

Platform IO, EagleCAD, Fusion360

Water Automation Hardware

Project Hardware software selection

Modular Water Automation System

1. ATMega328P Controller - We had selected this controller among other controllers is wide range of community and support, availability of the IC (Going to be used by the developers and hobbyists at-least for the rest of their lives). 2. SSR-75DA - Relays don't work well in high power environment that too with motors, For reliable and continuous operation of the system for at least 10 years, PCB trace for high power requirements are bulky and produce RFI which affects the controller and needs more filter circuits, For Easy replacement (Plug and Play type). 3. Direction Control Valve - It is a closed loop control since the opening and closing of the valve is done by the controller. Ball float valves are open loop and produce mechanical errors and failures. In case of the float switch above the ball float, the pump continuously runs and the ball float will be in closed condition which results in catastrophic failure of the pump and piping systems. 4. GX-16 Connector - Misconnection of wire failures is also catastrophic and causes major failure. We don't give space to that also. Just plug and play. The polarity is not a pain anymore.

Circuit Diagram

Water Automation Circuit Diagram

Our Modular Water Automation System. Here, the single pump unit controls the water to 4 Individual Over Head Tanks.

Code

#include <avr/wdt.h>
#define on LOW
#define off HIGH
const int firstdown = 2;
const int firstup = 3;
const int seconddown = 4;
const int secondup = 5;
const int mytanksol = 8;
const int tenantsol = 9;
const int motoron = 10;
const int motoroff = 11;
int temp;
int temporary;
int i = 0;
void setup() {
pinMode(firstdown, INPUT_PULLUP);
pinMode(firstup, INPUT_PULLUP);
pinMode(seconddown, INPUT_PULLUP);
pinMode(secondup, INPUT_PULLUP);
pinMode(motoron, OUTPUT);
pinMode(motoroff, OUTPUT);
pinMode(mytanksol, OUTPUT);
pinMode(tenantsol, OUTPUT); 
digitalWrite(motoron, off);
delay(2000);
digitalWrite(mytanksol, off);
delay(500);
digitalWrite(tenantsol, off);
delay(500);
digitalWrite(motoroff, off);
wdt_enable(WDTO_4S);}
void loop() {
  i = 1;
  temp = digitalRead(firstdown);
  temporary = digitalRead(seconddown);
  if ((temp == off) && (temporary == off)){
    i = 0;
    normaltankfill();}
  else if (temp == off){
    i = 0;
    mytankautofill();}
  else if (temporary == off){
    i = 0;
    tenanttankautofill();}
  else if (i == 0){
      safetyprog();
      i += 1;}
  wdt_reset();}
void mytankautofill(){
  i = 0;
  while (digitalRead(firstup) == off){
    if (digitalRead(firstdown) == off){
      digitalWrite(mytanksol, on);
      delay(1000);
      if (i == 0){
      digitalWrite(motoron, on);
      delay(1000);
      digitalWrite(motoron, off);
      delay(1000);}
      i = 1;
      wdt_reset();}
    if (digitalRead(seconddown) == off){
      normaltankfill();}
    if (digitalRead(firstup) == on){
      delay(3000);
      wdt_reset();
      if (digitalRead(firstup) == on){
        digitalWrite(motoroff, on);
        delay(1000);
        digitalWrite(motoroff, off);
        delay(1000);
        digitalWrite(mytanksol, off);
        delay(1000);
        wdt_reset();}}}
        safetyprog();}
void tenanttankautofill(){
  i = 0;
  while (digitalRead(secondup) == off){
    if (digitalRead(seconddown) == off){
      digitalWrite(tenantsol, on);
      delay(1000);
      if (i == 0){
      digitalWrite(motoron, on);
      delay(1000);
      digitalWrite(motoron, off);
      delay(1000);
      wdt_reset();}
      i = 1;
      wdt_reset();}
    if (digitalRead(firstdown) == off){
      normaltankfill();}
    if (digitalRead(secondup) == on){
      delay(3000);
      wdt_reset();
      if (digitalRead(secondup) == on){
        digitalWrite(motoroff, on);
        delay(1000);
        digitalWrite(motoroff, off);
        delay(1000);
        digitalWrite(tenantsol, off);
        delay(1000);
        wdt_reset();}}}
        safetyprog();}
        void normaltankfill(){
i = 0;
  while ((digitalRead(firstup) == off) || (digitalRead(secondup) == off)){
      digitalWrite(mytanksol, on);
      delay(1000);
      digitalWrite(tenantsol, on);
      delay(1000);
      wdt_reset();
      if (i == 0){
      digitalWrite(motoron, on); 
      delay(1000);
      digitalWrite(motoron, off);
      delay(1000);
      i = 1;
      wdt_reset();}
    if (digitalRead(firstup) == on){
      delay(3000);
      wdt_reset();
      if (digitalRead(firstup) == on){
        digitalWrite(mytanksol, off);
        delay(1000);
        wdt_reset();
        tenanttankcontrol();}}
    if (digitalRead(secondup) == on){
      delay(3000);
      wdt_reset();
      if (digitalRead(secondup) == on){
        digitalWrite(tenantsol, off);
        delay(1000);
        wdt_reset(); 
        mytankcontrol();}}}}
void mytankcontrol(){
  do{
    if (digitalRead(firstup) == on){
      digitalWrite(motoroff, on);
      delay(1000);
      digitalWrite(motoroff, off);
      delay(1000);
      digitalWrite(mytanksol, off);
      delay(1000);
      wdt_reset();
      safetyprog();}
      wdt_reset();}while (digitalRead(firstup) == off);}
void tenanttankcontrol(){
  do{
    if (digitalRead(secondup) == on){
      digitalWrite(motoroff, on);
      delay(1000);
      digitalWrite(motoroff, off);
      delay(1000);
      digitalWrite(tenantsol, off);
      delay(1000);
      wdt_reset();
      safetyprog();}
      wdt_reset();}while (digitalRead(secondup) == off);}
void safetyprog(){
digitalWrite(motoroff, on);
delay(1000);
digitalWrite(motoroff, off);
delay(1000);
digitalWrite(motoron, off);
delay(1000);
wdt_reset();
digitalWrite(mytanksol, off);
delay(1000);
digitalWrite(tenantsol, off);
wdt_reset();
loop();}