two sensor and two pump sump question

Hi all

got this bug that I cant find an answer two, all the sump posts I can read use on sesor and one pump.

I need to via two pumps,

Drain Tank one when the high sensor is triggered and keep the pump running until the low sensor is triggered,

then

Start Pump two (from a second tank to refill tank 1) keep it running until the high level sensor is again triggered. (without starting pump one again when the high level sensore is again triggered)

then when all that is completed, turn off pump 2, start normal operation, ie the third pump.

Now I can do this in hand wiring and ladder logic, I am having trouble doing it in C++ Arduino

parts,

Sensor 1 (High Level)
Sensor 2 (Low Level)
Pump 1 Drain tank
Pump 2 refill tank
Pump 3 normal operation restart after pump 1 and 2 complete

Cheers

any links or examples or help

thanks Ben

on

Just to clarify: I can understand that you don't want to start draining tank 1 when it gets full from tank 2, since obviously the solution to that is to stop filling. Fair enough... But then I ask myself, what is the criterion for draining tank 1.

That aside, this project is crying out for a state diagram, but if not then at very least a table.

Thanks Yes

the sump in question is on an 8 ft Marine tank, weekly I need to do a water change (around 100 ltrs)

so when the main pump is stopped water form the main display tank drains into the sump,

once this reaches the high level I want to turn the drain pump on and leave it running until the low level sensor is triggered,

at that time I want the new water pump to start and re fill the sump to the high level sensor.

after that the main pump will start circulating the water again.

My problem is my original trigger codes need the high level sensor to start the pump, but when is starts to drain the sensor is uncovered and the pump stops. in ladder logic you would wrap the high level sensor in a second logic bit called pump start, then use this to also start the pump until the low level is reached

jabmel:
in ladder logic you would wrap the high level sensor in a second logic bit called pump start, then use this to also start the pump until the low level is reached

You need similar logic for your Arduino.

The high level sensor just starts the process and once started it ignores the high-level sensor.

Have a boolean variable called (say) pumpRunA and set it to true when the high level sensor is triggered. But don't set it back to false until the low level sensor is triggered, Then the function that runs your pump would be something like

void operatePumpA() {
  if (pumpRunA == true) {
    digitalWrite(pumpApin, HIGH);
  }
  else {
   digitalWrite(pumpApin, LOW);
  }
}

...R

Hi,
Welcome to the forum.

the sump in question is on an 8 ft Marine tank, weekly I need to do a water change (around 100 ltrs)

Drain Tank one when the high sensor is triggered and keep the pump running until the low sensor is triggered,

  • You need to stop pump3 and start pump1 in the marine tank when you press a button to do a water change, as long as the low water sensor is not active.
  • The marine tank pump1 is switched off when the low water sensor is active.
  • The refill pump2 then needs to pump into the marine tank from the supply tank.
  • The refill pump2 is switched off when the marine tank full sensor is active.
  • Pump3 is then started.

I think that is what you need?

Tom.. :slight_smile:

ok ill try it,

so even when the high level is low, (water level is below sensor) the digitalWrite pumpApin will stay high as the pumpApin is holding it up

thanks Cheers Ben

Thanks Tom

to clarify

1.You need to stop pump3 and start pump1 in the marine tank when you press a button to do a water change, as long as the low water sensor is not active.

(Note the interface and buttons are via a Nextion)
The (Main) pump is stopped by pressing water change
this stops the main pump
When the water drains from the main display to the sump the high level water sensor is activated
this then starts pump (drain)

2.The marine tank pump1 is switched off when the low water sensor is active.

the drain pump is switched off

3.The refill pump2 then needs to pump into the marine tank from the supply tank.

the refill pump pumps back into the sump

4.The refill pump2 is switched off when the marine tank full sensor is active.

the refill pump switches off when the water level reaches the high level again

5.Pump3 is then started. Yes

Ok O have tried the code, and cant get it to work

assume all the set up and alike is ok

if (waterchangesw == HIGH && drainsw == HIGH && sumpwchg == LOW) { // this is the waterchange switch, the drain pump switch and the high level switch mode
digitalWrite(drainPin, HIGH); // Sump Drain bit on PinOutput // this works the sump drains
dbSerialPrintln("drainsump OK");  // I get drainsump OK in the monitor
}
else {
  dbSerialPrintln("drainsump NOT OK"); 
digitalWrite(drainPin, LOW);
}

but when the high level switch is high the pump turns off, correct, just testing the logic


now when I add the extra code below, the entire code does not work

if (waterchangesw == HIGH && drainsw == HIGH && sumpwchg == LOW) {
digitalWrite(drainPin, HIGH); // Sump Drain bit on // this time the output remains off
dbSerialPrintln("drainsump OK"); 
}
else {
  dbSerialPrintln("drainsump NOT OK");  // I get drainsump Not OK in the Monitor
digitalWrite(drainPin, LOW);
}

if (drainPin == true) {
  digitalWrite(drainPin, HIGH); // the output does not turn on
    dbSerialPrintln("Pin OK"); 
}else{
  digitalWrite(drainPin, LOW);
    dbSerialPrintln("Pin NOT OK"); // I get Pin Not OK in the Monitor
}

many thanks Ben ???????

to assist the entire code attached Notepad file

I note you have put this bit in a void operatepump () section

can it be in the main code void loop() (currently at the bottom) or does it need to be in its on void or void loop

code.txt (11.2 KB)

I need a picture of the tank/sump/pump arrangement- I'm confused. In reply #2 you started using the word "main"- main pump and main display tank and it's not clear to me if those are ones you mentioned in the opening post.

If I were you I'd draw a few versions of a simple pen an paper sketch, one version for each phase of operation showing which pump is running and the state of the sensors (the floats and buttons...)

Hi,
A diagram of the system would be good and a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

So we can see how your sensors are wired, when I said the low sensor was active, I meant it had detected the tank as empty, this may be the other way, the high and low sensors are active when submerged.

So you may have to invert the lower sensor logic.

I'm at work at the moment, so won't be able to check back for about 6 hours.

But keep going mate, as you will know, you learn as you go.

Tom....... :slight_smile:

hi all

in Post #2 is a picture of the ladder logic I am trying to achieve

I have attached a better diagram

this is the ladder logic or physical hard wired diagram

happy if someone can write a basic outline using these bits to show me what I doing wrong

I need the Pump to trigger when the it is SWITCHED ON and the HIGH and LOW sensors (UNDER WATER)

and
only TURN OFF when both the sensors are (UNCOVERED), not when the HIGH level is UNCOVERED

I cant get it to stay on when the HIGH sensor is unversed (DRY) and the LOW sensor is still (WET)

this should out line what I am looking to do, from there I should be able to work the rest out

appreciate the help, but finding it hard to articulate what I need

jabmel:
in Post #2 is a picture

Sorry, I missed that before.

Here it is:

sorry, nothing below in your answer

Ben

Don't edit posts to add diagrams: pure luck that I saw you had changed #11 when I had replied in #12

Here's OP's new pic from #12:

I have nfc what ladder logic is, and you shouldn't assume anyone here does although I daresay some do.

I'm struggling to get my mind round the process. What kicks off the drain/refil cycle? You turning off the main pump to force the sump to go above the normal line?

sorry, nothing below in your answer

I wasn't answering, I was putting your pic inline so others can see it without downloading it.

You should do that: read this.

To test my understanding: Going by this picture and using its terminology for pump names and so on (not to confuse things with "pump 1" and the like:

Is this the way it works:

Normal operation: Main pump circulates water between FISH TANK and Tank Sump, water at Normal Level

You decide to change the water:

Stop main pump so water level in Tank Sump rises due to Water return
Water level reaches High level, High sensor activates, Drain Pump starts to empty Tank sump
Water level drops to Low Level, Low sensor activates, Drain Pump stops
Refill water pump starts, wter level in Tank sump rises
Water level reaches High sensor, Refill water pump stops
Main pump starts and normal service resumes.

Is that it?

How does the High sensor ever deactivate (or to put it another way, how does the water ever drop to normal from high?)

if (drainPin == true) {
  digitalWrite(drainPin, HIGH); // the output does not turn on
    dbSerialPrintln("Pin OK"); 
}else{
  digitalWrite(drainPin, LOW);
    dbSerialPrintln("Pin NOT OK"); // I get Pin Not OK in the Monitor
}

This is not correct. You set drain pin =8.

int drainPin = 8;

The ide uses stdbool.h and true ==1 and false ==0
Your comments are what should happen.

I don't understand why it broke the code executing before.

OK Got it, use less "Else" parts, this keeps the bits high once set

code attached for reference

//*****     ***** WATER CHANGE SET *****     *****


//byte drainsump;
//byte sumpdraintog;
//byte sumpfill;
//byte sumpfilltog;

if (waterchangesw == HIGH && sumpfill == LOW){
  drainsump = HIGH;
  
}

if (drainsump == HIGH && sumpwchg == LOW) {
  sumpdraintog = HIGH;
   dbSerialPrintln("Part 1 HIGH"); 
}

if (sumpdraintog == HIGH && sumpempty == LOW) {
  digitalWrite(drainPin, HIGH);
   dbSerialPrintln("Part 2 HIGH"); 
}else{
     dbSerialPrintln("Part 2 LOW"); 
}

if (sumpdraintog == HIGH && sumpempty == HIGH) {
  digitalWrite(drainPin, LOW);
  sumpdraintog = LOW;
   drainsump = LOW;
   sumpfill = HIGH;
   dbSerialPrintln("Part 2 HIGH"); 
}else{
     dbSerialPrintln("Part 2 LOW");   
}

if (sumpfill == HIGH && sumpwchg == HIGH) {
  sumpfilltog = HIGH;
}

if (sumpfilltog == HIGH) {
  digitalWrite(saltPin, HIGH);
}
if (sumpfilltog == HIGH && sumpwchg == LOW) {
  digitalWrite(saltPin, LOW);
waterchangesw = LOW;
sumpfilltog = LOW;  
sumpfill = LOW;
  }