Auto Water change.

Do you have a question on how to do something.
Ask in here.
Post Reply
User avatar
DrewPalmer04
Posts: 818
Joined: Tue May 29, 2012 2:12 pm
Location: Christopher, IL

Auto Water change.

Post by DrewPalmer04 »

Ok. I know how to program the ATO status to trigger a relay...

But how to I get it to do a auto change when I press the water change button on my simple menu?

I want.

Relay 2 on until low ATO open...
Then relay 2 off...
Then relay 4 on until ATO high Closed


With a 2 min timeout on each.
Out for now...but not over.

VISIT: Ethernet Module/Wifi Alternative
User avatar
DrewPalmer04
Posts: 818
Joined: Tue May 29, 2012 2:12 pm
Location: Christopher, IL

Re: Auto Water change.

Post by DrewPalmer04 »

:( lol
Out for now...but not over.

VISIT: Ethernet Module/Wifi Alternative
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Auto Water change.

Post by rimai »

This is what I came up with:

Code: Select all

#include <Salinity.h>
#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_NokiaLCD.h>
#include <RA_ATO.h>
#include <RA_Joystick.h>
#include <LED.h>
#include <RA_TempSensor.h>
#include <Relay.h>
#include <RA_PWM.h>
#include <Timer.h>
#include <Memory.h>
#include <InternalEEPROM.h>
#include <RA_Colors.h>
#include <RA_CustomColors.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <PH.h>
#include <WaterLevel.h>
#include <ReefAngel.h>

byte wc_status=0;

// 0 - Draining
// 1 - Filling up
// 2 - Finish
void setup()
{
  ReefAngel.Init();  
}

void loop()
{
  if (ReefAngel.DisplayedMenu==WATERCHANGE_MODE)
  {
    byte TempRelay = ReefAngel.Relay.RelayData;
    TempRelay &= ReefAngel.Relay.RelayMaskOff;
    TempRelay |= ReefAngel.Relay.RelayMaskOn;
    ReefAngel.LCD.DrawOutletBox(10, 100, TempRelay);

    switch (wc_status)
    {
    case 0:
      ReefAngel.Relay.On(2);
      if (ReefAngel.LowATO.IsActive()) wc_status++;
      break;
    case 1:
      ReefAngel.Relay.Off(2);
      ReefAngel.Relay.On(4);
      if (!ReefAngel.HighATO.IsActive()) wc_status++;
      break;
    case 2:
      ReefAngel.Relay.Off(2);
      ReefAngel.Relay.Off(4);
      wc_status=0;
      ButtonPress++;
    }
  }
  ReefAngel.ShowInterface();
}

Roberto.
User avatar
DrewPalmer04
Posts: 818
Joined: Tue May 29, 2012 2:12 pm
Location: Christopher, IL

Re: Auto Water change.

Post by DrewPalmer04 »

Wow that's involved! I really appreciate it. I'll test ASAP. Still need floats and the connectors.
Out for now...but not over.

VISIT: Ethernet Module/Wifi Alternative
alexwbush
Posts: 327
Joined: Tue Mar 22, 2011 12:45 am
Location: San Diego, CA

Re: Auto Water change.

Post by alexwbush »

it's really not too hard, but I need to figure out the timer function. I haven't been able to work on it much, but I will when I return home next month.

I think a good place to start would be... how can I say turn on or off port 7 for 15 minutes?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Auto Water change.

Post by rimai »

You can use Timer 1 for this.
On setup():

Code: Select all

ReefAngel.Timer[1].SetInterval(900);
When you want to start, you call:

Code: Select all

ReefAngel.Timer[1].Start();
Then on loop(), you check if it is expired:

Code: Select all

if (ReefAngel.Timer[1].IsTriggered())
{
// Do something
}
Roberto.
alexwbush
Posts: 327
Joined: Tue Mar 22, 2011 12:45 am
Location: San Diego, CA

Re: Auto Water change.

Post by alexwbush »

interesting. Does it reset when the timer is up (for the next iteration)? What other timers are available?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Auto Water change.

Post by rimai »

it doesn't reset, but you can easily restart it:

Code: Select all

if (ReefAngel.Timer[1].IsTriggered())
{
ReefAngel.Timer[1].Start();
// Do something
}
Roberto.
User avatar
DrewPalmer04
Posts: 818
Joined: Tue May 29, 2012 2:12 pm
Location: Christopher, IL

Re: Auto Water change.

Post by DrewPalmer04 »

I knew about the timers. But I don't trust it over long periods of time. Ex. The pump may only pump 1 gallon a minute and a month later pump 3/4 gallon a min due to the pump aging. I have an independent ATO for freshwater. I'm thinking about doing the floats for water change only and that way the same amount of saltwater is always changed.
Out for now...but not over.

VISIT: Ethernet Module/Wifi Alternative
alexwbush
Posts: 327
Joined: Tue Mar 22, 2011 12:45 am
Location: San Diego, CA

Re: Auto Water change.

Post by alexwbush »

that's another way to do it. I have a couple float switches and the I/O expansion, so I may mess with the same thing. I just want to give some time in between "phases".

Phase 1: Mix water and check parameters of new water
Phase 2: Pump out water
Phase 3: Pump in water

The problem I have is transitioning phases since I was intending to use the same pump for mixing and pumping in new water, so I have to have a pause or something to allow me to connect the hose.

I guess I'll also have to add in a pump permanently to pump water out.

What kind of pumps were you using? I am debating a maxijet or aqualifter. Maxijet would obviously be better for mixing and quicker for pumping.
User avatar
DrewPalmer04
Posts: 818
Joined: Tue May 29, 2012 2:12 pm
Location: Christopher, IL

Re: Auto Water change.

Post by DrewPalmer04 »

Oh got you. You're going an entire different level than I. I'll still be making up my water the old fashioned way. The code above will just allow me to push a button and change the water via two pumps and float switches.
Out for now...but not over.

VISIT: Ethernet Module/Wifi Alternative
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Auto Water change.

Post by lnevo »

I think i need the phased approach but only looking to do the two parts that Drew is doing. I only have one outlet free so without another relay box...
User avatar
DrewPalmer04
Posts: 818
Joined: Tue May 29, 2012 2:12 pm
Location: Christopher, IL

Re: Auto Water change.

Post by DrewPalmer04 »

Yeah. I'm starting simple and can always build on the idea.
Out for now...but not over.

VISIT: Ethernet Module/Wifi Alternative
User avatar
DrewPalmer04
Posts: 818
Joined: Tue May 29, 2012 2:12 pm
Location: Christopher, IL

Re: Auto Water change.

Post by DrewPalmer04 »

Just wanted to say THANKS Roberto. The code works like a charm!

FYI for everyone. This is just a basic code to trigger relays (which ever you want) to drain, fill, then off the relays. (based on ATO position)

I still mix my own salt in large batches, but this allows me to hit the button for water change...a pump drains (into custom plumbing) then fills from the basement...then turns both relays off and my return pump goes back on... Easy water changes as I make about 2 months worth of water change water at a time.
Out for now...but not over.

VISIT: Ethernet Module/Wifi Alternative
User avatar
DrewPalmer04
Posts: 818
Joined: Tue May 29, 2012 2:12 pm
Location: Christopher, IL

Re: Auto Water change.

Post by DrewPalmer04 »

Ok I have a thought on this topic. It's getting annoying to watch my return pump kick back on and water/bubbles slosh everywhere.
What would the code be for:

== water change mode
Return pump stays on
DrainAWC drains continuously
High ATO float HIGH state to LOW then
FillAWC pump on until High ATO HIGH state. FillAWC off ATO high. FillAWC on ATO LOW etc
Repeat 6 times with ATO float (HIGH/LOW) sequence
End water change

My thought is. This will allow for small water changes while the return stays on. No more breaking siphon and bubbles.
Out for now...but not over.

VISIT: Ethernet Module/Wifi Alternative
User avatar
DrewPalmer04
Posts: 818
Joined: Tue May 29, 2012 2:12 pm
Location: Christopher, IL

Re: Auto Water change.

Post by DrewPalmer04 »

With the idea above: one float could maintain a water change. AND the amounts of speed On the pumps won't matter because the float regulates how much water is going out/in.
Out for now...but not over.

VISIT: Ethernet Module/Wifi Alternative
User avatar
DrewPalmer04
Posts: 818
Joined: Tue May 29, 2012 2:12 pm
Location: Christopher, IL

Re: Auto Water change.

Post by DrewPalmer04 »

No one like this idea of small partial changes to = a total change. Without turning Off return pump?


I= float active & !active count

Considering I'll be using high float only and counting
I guess this will take a for(I=0; I <=6; I++) type function?
Out for now...but not over.

VISIT: Ethernet Module/Wifi Alternative
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Auto Water change.

Post by lnevo »

The method I like is similar to what Nick has done. What I suggest is the following:

1) disable ro/di ato pump
2) enable s/w ato pump
3) start drain pump for x amount of time.
4) disable s/w ato pump
5) enable ro/di ato pump

No float switch involved and no change in level if your s/w ato pump is equal or greater than drain pump.

Return pump keeps going the whole time.

Small gradual continuous changes are definitely preferred and pretty efficient when compared to single larger changes.

http://reefkeeping.com/issues/2005-10/rhf/index.php#13
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Auto Water change.

Post by lnevo »

I guess i just rephrased what you wrote but if you are using your two float switches as usual with primary / failsafe, i wouldnt disable that feature, but if you switch which pump is doing your ato function then you get the same functionality leverage both ato switches and get the failsafe timeout using the ato functions...
User avatar
DrewPalmer04
Posts: 818
Joined: Tue May 29, 2012 2:12 pm
Location: Christopher, IL

Re: Auto Water change.

Post by DrewPalmer04 »

My floats are for water change mode only. Just trying to figure out how to do what I want with the high float. My ATO is via stand alone system. If someone can help with code for the high float repeating active - inactive 6 times then wc mode ends. I can then use my other float elsewhere.
Out for now...but not over.

VISIT: Ethernet Module/Wifi Alternative
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Auto Water change.

Post by lnevo »

You'll need a variable for a counter. Set it to 6. Start wc mode. Drain goes on. When ato high is low, trip counter and start filling. Stop filling when the ato high is up position..when it triggers in low again, counter goes up. When counter reaches 0, stop draining...

Should be a relatively easy while loop...

I can help mock up some code if you need, but does that sound like what you need?
User avatar
DrewPalmer04
Posts: 818
Joined: Tue May 29, 2012 2:12 pm
Location: Christopher, IL

Re: Auto Water change.

Post by DrewPalmer04 »

Sounds good to me. Sure please do
Out for now...but not over.

VISIT: Ethernet Module/Wifi Alternative
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Auto Water change.

Post by lnevo »

Something like this should work... it's not the best and you'll probably have to troubleshoot some, and hopefully some others can add to it, but it's a quick shot...

Code: Select all

if (ReefAngel.DisplayedMenu==WATERCHANGE_MODE) {
  atoCount=6;
  ReefAngel.Relay.On(DrainAWC);
  if (atoCount > 0) {
   ReefAngel.Relay.On(FillAWC); 
  }
  if (ReefAngel.HighATO.IsActive()) {
    ReefAngel.Relay.Off(FillAWC);
    atoCount--;
  }
  if(atoCount==0) {
    ReefAngel.Relay.Off(DrainAWC);
    ReefAngel.DisplayedMenu=DefaultMenu;
  }
}
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Auto Water change.

Post by lnevo »

I do see some problems with the code block.. I need to sleep on the logic a little bit, because I think as soon as the float switch opens back up then it will start filling again... may need some kind of delay in.. That's part of the problem with using just one float for something like this and not being able to have a range. I'll let you think on it as well and come back with your thoughts...
User avatar
DrewPalmer04
Posts: 818
Joined: Tue May 29, 2012 2:12 pm
Location: Christopher, IL

Re: Auto Water change.

Post by DrewPalmer04 »

Ok thanks. I see a few probs but I'll look at it this afternoon. Thanks a ton.
Out for now...but not over.

VISIT: Ethernet Module/Wifi Alternative
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Auto Water change.

Post by lnevo »

Sitting back while my water change happens... Very nice :)
User avatar
DrewPalmer04
Posts: 818
Joined: Tue May 29, 2012 2:12 pm
Location: Christopher, IL

Re: Auto Water change.

Post by DrewPalmer04 »

Haha. I've stalled on trying to get mine improved to allow my return to not turn off during the change out. I've been building my arduino based controller based on mega 2560. It's taking all my time :) lol
Out for now...but not over.

VISIT: Ethernet Module/Wifi Alternative
Post Reply