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
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.
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
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
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
}
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.
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.
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.