Float sensor time delay
-
- Posts: 14
- Joined: Sat Aug 24, 2013 10:12 pm
- Location: Arizona
- Contact:
Float sensor time delay
Is there a way to make a time delay for when the topoff pump starts? My float sensor gets tripped a little and it clicks my pump on and off immediately every time. I want the float to be tripped (open) for 30-60 seconds before the controller turns on the ATO pump. I don't think it can be good for my ATO pump to click on and off a bunch before it finally stays on long enough to move some water. I have searched the forum and was not able to find much about a time delay befor it turns on the pump. Thank in advance for your help!
Re: Float sensor time delay
The easiest way would he to use both float switches...barring that some custom code would need to be done.
-
- Posts: 14
- Joined: Sat Aug 24, 2013 10:12 pm
- Location: Arizona
- Contact:
Re: Float sensor time delay
I know the easiest way would be to use two float switches but I would really like to be able to do this with just one float. I also thought this concept might be a good idea to apply to the temp probe and other sensors that have constantly fluctuating readings. I dont know how many people have used the code for the Neptune Apex but they use a "defer" statement to make the controller wait before taking action on a sensor reading. That is what I am looking to do here with my float switch and possibly my other probes. I am new to coding for the ReefAngel but I am very willing to learn!
Re: Float sensor time delay
No problem, figured I would throw it out there. I'd help but my brain is already mush and I owe someone else my next coding time...
One other thing to think about is i think one of the ato functions might take a number of hours argument so that it only checks like once an hour so you aren't making micro adjustments.
I'm sure robeto will chime in with the options but that might be an easy way to accomplish the goal.
Overall it's not that hard but its not a one liner...
One other thing to think about is i think one of the ato functions might take a number of hours argument so that it only checks like once an hour so you aren't making micro adjustments.
I'm sure robeto will chime in with the options but that might be an easy way to accomplish the goal.
Overall it's not that hard but its not a one liner...
Re: Float sensor time delay
Actually thinking about it again...you could easily do this:
if (now()%1200<600) SingleATOLow(...);
Change 1200 and 600 to whatever "deferred" seconds you want. Basically that statement says to run for 10 minutes on and then 10 minutes off... You need some range so that it stays in ATO mode long enough to work...you could easily tweak it to say now()%1200<60 meaning run the first 60 seconds in each 20 minute interval..
if (now()%1200<600) SingleATOLow(...);
Change 1200 and 600 to whatever "deferred" seconds you want. Basically that statement says to run for 10 minutes on and then 10 minutes off... You need some range so that it stays in ATO mode long enough to work...you could easily tweak it to say now()%1200<60 meaning run the first 60 seconds in each 20 minute interval..
-
- Posts: 14
- Joined: Sat Aug 24, 2013 10:12 pm
- Location: Arizona
- Contact:
Re: Float sensor time delay
Awww I see... Thank you! I will try that!
Re: Float sensor time delay
Try this:
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);
Roberto.
Re: Float sensor time delay
One thing I missed is that if for some reason your ATO is still on when the time statement is complete the pump will stay on... add an else ReefAngel.Relay.Off for the port...
Or use Roberto's code
Code: Select all
if (now()%1200<600)
ReefAngel.SingleATOLow(...);
else
ReefAngel.Relay.Off(...);
lnevo wrote:Actually thinking about it again...you could easily do this:
if (now()%1200<600) SingleATOLow(...);
Change 1200 and 600 to whatever "deferred" seconds you want. Basically that statement says to run for 10 minutes on and then 10 minutes off... You need some range so that it stays in ATO mode long enough to work...you could easily tweak it to say now()%1200<60 meaning run the first 60 seconds in each 20 minute interval..
-
- Posts: 14
- Joined: Sat Aug 24, 2013 10:12 pm
- Location: Arizona
- Contact:
Re: Float sensor time delay
I am new to coding on RA so I will explain what I THINK the code you posted means. Please correct me and explain. I think I get the idea but I don't know the specifics.rimai wrote:Try this: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);
So... First I think you are defining something new called "millis" to store a value for future use but you are not sending and info to it. Then you used an "if" statement to say assign the value from LastATO to millis when the LowATO is active. Then you used another "if" statement to say that if your stored value "millis" - LastATO value is less than 5000 and is grater than 100, relay port1 remains off. But, "else", if that statement if false turn port1 on for 10 sec?
I am not quite sure if I totally understand the first defining part and I don't know what amount of time the values are referring to. Does the RA start a clock when the topoff is active or inactive? Also, Would this all be inserted in the loop section?
Thank you for your time!
-
- Posts: 471
- Joined: Sat Jan 14, 2012 2:08 pm
- Location: Montgomery Village, MD
Re: Float sensor time delay
great question, following...
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.
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.
Re: Float sensor time delay
No, millis() is as function.
http://arduino.cc/en/Reference/millis
It returns milliseconds from when the controller was booted up.
We use it to measure time.
http://arduino.cc/en/Reference/millis
It returns milliseconds from when the controller was booted up.
We use it to measure time.
Roberto.
Re: Float sensor time delay
Yeah, you've got it a little wrong... but good try... let's go through each line
This is declaring a variable called LastATO that we will store the current milliseconds counter into. This will be used in future tests to see when the last time the ATO float switch was triggered. static says that we will save this variable each time the loop() function is returned (so in answering your last question, yes this code goes inside the loop() section.
This line says that if the LowATO float switch is NOT (the ! means NOT) then assign the current time (in milliseconds) to the LastATO variable.
This line is doing the comparison on the current time and the variable we put the time that the float switch was not active. If the timer is within those 2 numbers we will turn off the Relay for the ATO pump:
otherwise we will enable the ATO function:
Code: Select all
static time_t LastATO=millis();
Code: Select all
if (!ReefAngel.LowATO.IsActive()) LastATO=millis();
Code: Select all
if (millis()-LastATO<5000 && millis()-LastATO>100)
Code: Select all
ReefAngel.Relay.Off(Port1);
Code: Select all
else
ReefAngel.SingleATO(true,Port1,10,0);
-
- Posts: 471
- Joined: Sat Jan 14, 2012 2:08 pm
- Location: Montgomery Village, MD
Re: Float sensor time delay
thx. For all us code-snatchers out there I wish all your code was documented this way!!
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.
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.
-
- Posts: 14
- Joined: Sat Aug 24, 2013 10:12 pm
- Location: Arizona
- Contact:
Re: Float sensor time delay
Yes! Thank you sooo much for taking the time to explain that in detail for me! Just that little explanation helps me understand the code structure so much better! Thank you! If I lived by you I would buy you lunch! lol