float sensor time delay - new question

Do you have a question on how to do something.
Ask in here.
Post Reply
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

float sensor time delay - new question

Post by rossbryant1956 »

Been following a post from a user about a situation where he wants the ATO to NOT turn on until the float sensor has been tripped for few seconds and it is sure the tank needs a decent amount of water. Roberto suggested this bit of code:

Code: Select all

static time_t LastATO=millis();
  if (!ReefAngel.LowATO.IsActive()) LastATO=millis();
  if (millis()-LastATO<5000 && millis()-LastATO>100)
    ReefAngel.Relay.Off(Port1);
  else
    ReefAngel.SingleATO(true,Port1,10,0);
I use a different method of monitoring my float switches. How would I add Roberto's code to it?

Code: Select all

 //turn on GT Fill when switch is tripped 
     ReefAngel.Relay.Set(GT_Fill,ReefAngel.IO.GetChannel(2));
Variable GT_Fill, of course, is the name of my ATO pump. Thx
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: float sensor time delay - new question

Post by rimai »

Try this:

Code: Select all

static time_t LastATO=millis();
  if (!ReefAngel.IO.GetChannel(2)) LastATO=millis();
  if (millis()-LastATO<5000 && millis()-LastATO>100)
    ReefAngel.Relay.Off(GT_Fill);
  else
    ReefAngel.SingleATO(true,GT_Fill,10,0);
Roberto.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: float sensor time delay - new question

Post by rossbryant1956 »

are we sure about that last line? Not using SingleATO.
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: float sensor time delay - new question

Post by rimai »

I simply changed the LowATO.IsActive() for IO.GetChannel(2).
I don't know what you want to do.
Try it and see if it works.
Roberto.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: float sensor time delay - new question

Post by rossbryant1956 »

OK...as always thx very much for your help!!
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: float sensor time delay - new question

Post by rossbryant1956 »

1. my wires are down, should I be using false instead of true in that code line?
2. what does the 10 stand for? Run for 10 seconds and stop? 10 minutes?

thx
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: float sensor time delay - new question

Post by rimai »

Yes, remove the ! if you have the float wires down.
10 is 10 seconds for ATO timeout.
Roberto.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: float sensor time delay - new question

Post by rossbryant1956 »

yes to both?

yes - change true to false

AND

yes - remove the !
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: float sensor time delay - new question

Post by rimai »

Ahh. Now I saw what you mean by true or false...
Please look here for a quick view of what each parameter in the function is about:
http://www.easte.net/RA/html/class_reef ... 545a376e92
And here is the code for it:
https://github.com/reefangel/Libraries/ ... .cpp#L1364
bLow is for true for Low ATO port and false for High ATO port.
The ! sign means not: http://arduino.cc/en/Reference/Boolean
So, if (!ReefAngel.IO.GetChannel(2)) means if Channel 2 is not active and if (ReefAngel.IO.GetChannel(2)) means if Channel 2 is active.
Active means the float switch contacts are closed.
Roberto.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: float sensor time delay - new question

Post by rossbryant1956 »

Still need your help. I tried this code both ways, using both the ! you originally suggested and just now took out the ! and tried it again. Of course, if that 5000 in the code means wait 5000 seconds before actually doing anything then I didn't count to 5000 :P

Here is the code you wrote:

Code: Select all

     //turn on GT Fill when switch is tripped 
           static time_t LastATO=millis();
           if (ReefAngel.IO.GetChannel(2)) LastATO=millis();
           if (millis()-LastATO<5000 && millis()-LastATO>100)
           ReefAngel.Relay.Off(GT_Fill);
           else
           ReefAngel.SingleATO(true,GT_Fill,10,0);
            
Plus I still really don't understand the use of true and false in the SingleATO line. Thx again.
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: float sensor time delay - new question

Post by rimai »

true is Low ATO port and false is High ATO port. It tells which port you are using for ATO.
5000 is 5000 milliseconds.
Roberto.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: float sensor time delay - new question

Post by rossbryant1956 »

any idea why this is not working?
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: float sensor time delay - new question

Post by lnevo »

Can we start over... I just re-read the thread, and I have no clue what you're trying to accomplish. What does GT_Fill mean?

What was the ATO code you were using before you added this delay that worked? I feel like you copied Roberto's sample code and it may not fit the original needs. You stated you weren't using SingleATO... and both your wires are pointed down.

Thanks,
Lee
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: float sensor time delay - new question

Post by rossbryant1956 »

Thanks Lee;

I do a series of things with the I/O expansion unit and float valves. Here is some of my working code:

Code: Select all

 // I_O Expansion & Float Valves
  
          ReefAngel.CustomVar[7]=1;
  
       //turn off DT pump when switch is tripped and sound buzzer
           ReefAngel.Relay.Set(DT_Pump,ReefAngel.IO.GetChannel(0));
           ReefAngel.PWM.SetDaylight(100-(ReefAngel.IO.GetChannel(0)*100));
           ReefAngel.CustomVar[0]=ReefAngel.IO.GetChannel(0); //tell the portal we have a overflow problem
       
        //turn off GT pump when switch is tripped and sound buzzer
           ReefAngel.Relay.Set(GT_Pump,ReefAngel.IO.GetChannel(1));
           ReefAngel.PWM.SetDaylight(100-(ReefAngel.IO.GetChannel(1)*100));
           ReefAngel.CustomVar[1]=ReefAngel.IO.GetChannel(1); //tell the portal we have a overflow problem 
           
In other words, when those I/O floats trip, they turn off the pumps DT & GT to keep those tanks from overflowing. I have had trouble in the past with my Glass-Holes overflows slowing due to junk in the pipes. Works like a charm. Then I added another float valve to my I/O expansion, wires pointed down, that would turn on another pump and refill evaporated water from my RODI system. I originally used this line of code:

Code: Select all

          ReefAngel.Relay.Set(GT_Fill,ReefAngel.IO.GetChannel(2));
          ReefAngel.PWM.SetDaylight(100-(ReefAngel.IO.GetChannel(2)*100));
Worked like a charm. THEN under the auspices of one of the primary engineering tenets "if it ain't broke, fix it anyway" I decided it would be better to implement some method of instead of toggling that pump every time that tank needed a little water it would be better to have it wait until it needed a decent top off before turning on.

So that's where I am. Roberto suggested a bit of code that seems like it should work but I'm not able to understand it well enough to do my own troubleshooting. Appreciate any advice you provide. Thanks
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: float sensor time delay - new question

Post by rossbryant1956 »

bump...any thoughts?
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: float sensor time delay - new question

Post by lnevo »

Yeah, sorry no I haven't had a chance to look at it yet... so what does GT_Fill mean (just so it's clear in my brain...

And the code you had before.. what is the SetDaylight command doing? is that for a buzzer? or something else?
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: float sensor time delay - new question

Post by rossbryant1956 »

GT_Fill is the name of my pump on a relay. And don't worry about the buzzer, I am in the midst of changing that to your WiFiAlert code. Basically I want it to alert me when the pump comes on (and goes off)

Thx, Lee
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: float sensor time delay - new question

Post by lnevo »

So is GT_Fill always running unless the switch is tripped?
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: float sensor time delay - new question

Post by lnevo »

Also, is the LowATO switch involved or just the Channel 2 on the expansion?

I think it's not working because Roberto assumed you were using the ATO switch as well...
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: float sensor time delay - new question

Post by rossbryant1956 »

No GT_Fill is off unless tripped by channel two and then no LowATO at all only the expansion and the float valve
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: float sensor time delay - new question

Post by lnevo »

Ok, yeah, so that's why this isn't working... the SingleATO function is not made to be used by other channels...

Roberto should actually fix that ;) Instead of taking a boolean it could take an int where 0 is high, 1 is low, rest are remaining channels... That would fix that..

In the meantime, let me look at that code soon...
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: float sensor time delay - new question

Post by lnevo »

Ok, yeah, so that's why this isn't working... the SingleATO function is not made to be used by other channels...

Roberto should actually fix that ;) Instead of taking a boolean it could take an int where 0 is high, 1 is low, rest are remaining channels... That would fix that..

In the meantime, let me look at that code soon...
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: float sensor time delay - new question

Post by rossbryant1956 »

Okay I have been working with your switchalert code and it is now working beautifully with my I/O expansion. This is how I modified it:

Code: Select all

    void CheckSwitches() {
       static boolean GT_OverFillOverride=true;
       static WiFiAlert switchAlert, skimmerAlert;
       skimmerAlert.SetDelay(3600); 
       switchAlert.SetDelay(3600);
       
       if (ReefAngel.DisplayedMenu==FEEDING_MODE || ReefAngel.DisplayedMenu==WATERCHANGE_MODE)
       GT_OverFillOverride=true;
       
       // Turn off GT_OverFill if sump overflowing 
       
       if (!ReefAngel.IO.GetChannel(3)) {
         if (!GT_OverFillOverride) {
         switchAlert.Send("GT_Sump+level+alarm!+MixPump+disabled.");
         ReefAngel.Relay.Override(GT_OverFill,0);
         GT_OverFillOverride=true;
    } 
  } else {
    GT_OverFillOverride=false;
  }
So in this app, when that float valve trips, it sends the wifialert and turns off GT_Overfill (my pump.) I can then use the portal or the web app to reset that relay once the obstruction is cleared.

So my question is in another application I'd like to use this same snip of code but would like the relay sent back to "auto" automatically once the obstruction is cleared. Is there a way to do that? As always thanks in advance.
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: float sensor time delay - new question

Post by rimai »

Are you sure you want to go back on automatically?
Roberto.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: float sensor time delay - new question

Post by lnevo »

I would just put the relay back in auto mode from your phone once the obstruction is clear....
rossbryant1956
Posts: 471
Joined: Sat Jan 14, 2012 2:08 pm
Location: Montgomery Village, MD

Re: float sensor time delay - new question

Post by rossbryant1956 »

Post by lnevo » Tue Oct 01, 2013 10:04 pm

I would just put the relay back in auto mode from your phone once the obstruction is clear....
For the application above that will work fine. For the new app
Are you sure you want to go back on automatically?
Yes I do. Roberto, this is that app we did some time ago for my overflows that would slow but not stop up. I want the pumps to turn off while the overflow is catching up but then to come back on once clear. If I have to, I can continue using my existing code but I really like the work Lee is doing and trying to improve my coding style.

Remember this?

Code: Select all

//turn off GT pump when switch is tripped and sound buzzer
           ReefAngel.Relay.Set(GT_Pump,ReefAngel.IO.GetChannel(1));
           ReefAngel.PWM.SetDaylight(100-(ReefAngel.IO.GetChannel(1)*100));
           ReefAngel.CustomVar[1]=ReefAngel.IO.GetChannel(1); //tell the portal we have a overflow problem 
Thanks again
Roscoe's Reefs - Starting Over Again:

Building new 29g Nano after landlord went berserk over my 4 75 gallon tanks, Multiple RA's, Water mixing stations, etc. Your help welcomed in remembering all I've forgotten.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Post by lnevo »

So in the else section where GTOverride=false add the following line

ReefAngel.Relay.Override(GT_OverFill,2);
Post Reply