Go Down

Topic: want a program for probe type Water Level controller to start and stop Motor (Read 1 time) previous topic - next topic

JaspreetMatrix

Hi all,

i want to make an automatic start stop of pump using probes in water tank. Please guide me. I am new to Arduino UNO programming.

My inputs are

PIN2 = Low Level Water Sensor (LLWS)
PIN3 = High Level Water Sensor (HLWS)


OUTPUT :

Pin 13 = A relay of 5 VDC connected to this pin Which start n stop the motor.


LOGIC:-

While Water in Tank is going LOW (consuming Water)
when water go below LLWS the motor Should ON

While Water in Tank coming and Motor is ON (Tank Filling)

When Water GO Above LLWS level nothing will change.
when water go Above HLWS the motor Stops.


AGAIN Water in Tank is going LOW (consuming Water)
When water go below HLWS nothing will change
When water go below LLWS Motor starts.
 
Please Help Me.

Thanks in Advance.
JSB

GrooveFlotilla

Write what you wrote above in C, and then try compiling it.
If it doesn't compile, post your code here and we'll try to help you fix it.

If you want someone to write the code for you, ask a moderator to move this topic to the gigs section of the forum.
Some people are like Slinkies.

Not really good for anything, but they bring a smile to your face when pushed down the stairs.

Coding Badly


@JaspreetMatrix, do not cross-post.  Other thread removed.

Thread moved as requested.


Anshu_Raj

This shouldn't be a difficult task.
If you are still interested in doing this PM me and we can work this out.

cedarlakeinstruments

You're overcomplicating this: your logic reduces to:

If water level is below LLWL, start pump
If water level is above HLWL, stop pump

Now, I would add checks that when the pump is on, you should see the transition of LLWL from on to off (make sure that pump is running and water is flowing) and also timeout if HLWL is not active in time (safety behavior in case HLWL sensor fails).

Anyway:
Code: [Select]

#define LL 2
#define HL 3
#define PUMP 4
#define ON HIGH
#define OFF LOW

pinMode(LL, INPUT_PULLUP);
pinMode(HL, INPUT_PULLUP);
pinMode(PUMP, OUTPUT);

digitalWrite(PUMP, OFF);

while(1)
{
    delay(100);
    // Assume sensors active LOW
    if (digitalRead(LL) == LOW)
    {
        digitalWrite(PUMP, ON);
    }
    else if (digitalRead(HL == LOW)
    {
        digitalWrite(PUMP, OFF);
     }
}


Have fun. If you need more detail than this, PM me. I have literally spent years doing motion control and fluid management & flow controllers.

Electronics and firmware/software design and assistance. No project too small

shridattdudhat

It's So easy, Same as you I was making this too complicated but one of my friend corrected me.

Here is the code (Active Low Logic):

Code: [Select]

void setup() {
  // put your setup code here, to run once:

  pinMode(2, INPUT_PULLUP);
  pinMode(3, INPUT_PULLUP);
  pinMode(A0, OUTPUT);          // Motor Digital Pin

}

void loop() {
  // put your main code here, to run repeatedly:
 
  int L = digitalRead(2); // Low Level Water Sensor (LLWS)
  int H = digitalRead(3); // High Level Water Sensor (HLWS)

  if(L == 0 && H == 0)
  {
    digitalWrite(A0, LOW);
  }

  if(L == 1 && H == 1)
  {
    digitalWrite(A0, HIGH);
  }
 
  delay(100);
}


wvmarle

Code of #4 is the far more readable version, for using pin names and so.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

IndianaTux

From experience you will also want to add an hysteresis type of algorithm of else as you add liquid in the tank it will create turbulence that will make the level detecter go into a series of true/false/true states.

Paul_KD7HB

From experience you will also want to add an hysteresis type of algorithm of else as you add liquid in the tank it will create turbulence that will make the level detecter go into a series of true/false/true states.
This is exactly the system I use in my irrigation system and I had to add code to fix that exact problem.

One other thing the OP has not told us: is the water supply rate greater than the rate you are taking water out?

Paul

Go Up