Interval Dosing w/ WaterLevel?
Interval Dosing w/ WaterLevel?
I am getting two dosing pumps soon, but in the mean time…..
Background: I add Kalk to my ATO water, use an aqualifter to feed the top off water and use the WaterLevel to decide when this happens.
I have seen code for the ATO switches that basically says dose for x seconds, wait x seconds, dose x seconds until ATO high is active, or a variation of that.
Does someone have a similar example using the WaterLevel add on? Right now my code is such that it starts adding top off at 43% and stops at 44%, which takes about 10 minutes. I don’t want to dose that much kalk or that much fresh water (salinity in mind) in one fell swoop.
Is there anyway to say, start relay x when water level hits 43% for 1 min, check again after 10 mins, do this until water level hits 44% and shut off relay? All while tracking the total dosing time for the WaterLevel's timout function?
Thank you!
Background: I add Kalk to my ATO water, use an aqualifter to feed the top off water and use the WaterLevel to decide when this happens.
I have seen code for the ATO switches that basically says dose for x seconds, wait x seconds, dose x seconds until ATO high is active, or a variation of that.
Does someone have a similar example using the WaterLevel add on? Right now my code is such that it starts adding top off at 43% and stops at 44%, which takes about 10 minutes. I don’t want to dose that much kalk or that much fresh water (salinity in mind) in one fell swoop.
Is there anyway to say, start relay x when water level hits 43% for 1 min, check again after 10 mins, do this until water level hits 44% and shut off relay? All while tracking the total dosing time for the WaterLevel's timout function?
Thank you!
Re: Interval Dosing w/ WaterLevel?
Try this:
Code: Select all
if (ReefAngel.WaterLevel.GetLevel()<44 && ReefAngel.WaterLevel.GetLevel()>0)
ReefAngel.Relay.Set(Port1, now()%600<60);
else
ReefAngel.Relay.Off(Port1);
Roberto.
Re: Interval Dosing w/ WaterLevel?
rimai wrote:Try this:Code: Select all
if (ReefAngel.WaterLevel.GetLevel()<44 && ReefAngel.WaterLevel.GetLevel()>0) ReefAngel.Relay.Set(Port1, now()%600<60); else ReefAngel.Relay.Off(Port1);
This is interesting code. can help me understand this code better?
if (ReefAngel.WaterLevel.GetLevel()<44 && ReefAngel.WaterLevel.GetLevel()>0) i assume that this tells the dosing pump top up till 44
ReefAngel.Relay.Set(Port1, now()%600<60); what does the value %600<60 do?
else
ReefAngel.Relay.Off(Port1);
Interval Dosing w/ WaterLevel?
Let's see if i get this right...
now()%600 divides the time by 5 minutes and gets the remainder in seconds...
If the remainder is less than 60..
now()%600<60
Then it will turn the pump on..
This means basically that every 5 minutes it will turn the pump on for 60 seconds..
I am loving the now()% method of having a time based conditional...
I use it to have things run at a specific time instead of comparing to hour() minute() and second().
So now()%SECS_PER_DAY==43200 means if its 12pm sharp
now()%600 divides the time by 5 minutes and gets the remainder in seconds...
If the remainder is less than 60..
now()%600<60
Then it will turn the pump on..
This means basically that every 5 minutes it will turn the pump on for 60 seconds..
I am loving the now()% method of having a time based conditional...
I use it to have things run at a specific time instead of comparing to hour() minute() and second().
So now()%SECS_PER_DAY==43200 means if its 12pm sharp
Re: Interval Dosing w/ WaterLevel?
Thanks Guys,
jtomasi sorry to hijack your thread.
i uploaded this code and i cant get the dosing pump to start dosing at level 59, i guess i might be missing out on something.
if (ReefAngel.WaterLevel.GetLevel()<59 && ReefAngel.WaterLevel.GetLevel()>0)
ReefAngel.Relay.Set(Port2, now()%600<60);
else
ReefAngel.Relay.Off(Port2);
jtomasi sorry to hijack your thread.
i uploaded this code and i cant get the dosing pump to start dosing at level 59, i guess i might be missing out on something.
if (ReefAngel.WaterLevel.GetLevel()<59 && ReefAngel.WaterLevel.GetLevel()>0)
ReefAngel.Relay.Set(Port2, now()%600<60);
else
ReefAngel.Relay.Off(Port2);
Re: Interval Dosing w/ WaterLevel?
It will only activate the port 2 is the level is less than 59 and only at the 1st minute of the 10 minute cycle.
For example, assuming the level is less than 59, it will turn on at 9:00am and off at 9:01am, then again at 9:10am and off at 9:11am and so on until the level reaches 59.
Make sure you have no other functions that activates port2 in your code. If you do, you need to either remove the line or comment it out.
For example, assuming the level is less than 59, it will turn on at 9:00am and off at 9:01am, then again at 9:10am and off at 9:11am and so on until the level reaches 59.
Make sure you have no other functions that activates port2 in your code. If you do, you need to either remove the line or comment it out.
Roberto.
Re: Interval Dosing w/ WaterLevel?
rimai wrote:It will only activate the port 2 is the level is less than 59 and only at the 1st minute of the 10 minute cycle.
For example, assuming the level is less than 59, it will turn on at 9:00am and off at 9:01am, then again at 9:10am and off at 9:11am and so on until the level reaches 59.
Make sure you have no other functions that activates port2 in your code. If you do, you need to either remove the line or comment it out.
Thanks Roberto
Re: Interval Dosing w/ WaterLevel?
Also is it usual for the water level sensor to fluctuate a bit. example it reads 59 then 60 then 61 then 59 and so on.. or should it be struck right at 59?
Re: Interval Dosing w/ WaterLevel?
port 2 flickers on and off at level 59% is it normal?Amos Poh wrote:Also is it usual for the water level sensor to fluctuate a bit. example it reads 59 then 60 then 61 then 59 and so on.. or should it be struck right at 59?
#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 <Salinity.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <PH.h>
#include <WaterLevel.h>
#include <ReefAngel.h>
////// Place global variable code below here
////// Place global variable code above here
void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
ReefAngel.AddWifi();//Setup Wifi
ReefAngel.SetTemperatureUnit( Celsius ); // set to Celsius Temperature
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = 0;
ReefAngel.FeedingModePortsE[0] = 0;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = 0;
ReefAngel.WaterChangePortsE[0] = 0;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
ReefAngel.LightsOnPortsE[0] = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = 0;
ReefAngel.OverheatShutoffPortsE[0] = 0;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 300 );
// Ports that are always on
ReefAngel.Relay.On( Port1 );
ReefAngel.Relay.On( Port3 );
ReefAngel.Relay.On( Port6 );
ReefAngel.Relay.On( Port7 );
ReefAngel.Relay.On( Port8 );
ReefAngel.Relay.On( Box1_Port8 );
ReefAngel.Relay.On( Box1_Port5 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.StandardLights( Box1_Port1,14,0,23,0 );
ReefAngel.StandardLights( Box1_Port6,16,0,22,0 );
ReefAngel.StandardLights( Box1_Port7,14,0,23,0 );
ReefAngel.RF.UseMemory = false;
ReefAngel.RF.SetMode( Constant,50,10 );
ReefAngel.PWM.SetDaylight( PWMParabola(10,0,4,0,50,100,50) );
ReefAngel.PWM.SetActinic( PWMParabola(10,0,4,0,50,100,50) );
if (ReefAngel.WaterLevel.GetLevel()<59 && ReefAngel.WaterLevel.GetLevel()>0)
ReefAngel.Relay.Set(Port2, now()%600<60);
else
ReefAngel.Relay.Off(Port2);
////// Place your custom code below here
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "Amos%20Poh" );
ReefAngel.ShowInterface();
}
void DrawCustomMain()
{
int x,y;
char text[10];
// Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 10, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 10, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
pingSerial();
// Salinity
ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,15,46, "SAL:" );
ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,39,46, ReefAngel.Params.Salinity );
pingSerial();
// Water Level
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,75,63, "WL:" );
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,99,63, ReefAngel.WaterLevel.GetLevel() );
pingSerial();
// Main Relay Box
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox( 12, 79, TempRelay );
pingSerial();
// Relay Expansion
TempRelay = ReefAngel.Relay.RelayDataE[0];
TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
ReefAngel.LCD.DrawOutletBox( 12, 98, TempRelay );
pingSerial();
// Date and Time
ReefAngel.LCD.DrawDate( 6, 122 );
pingSerial();
}
void DrawCustomGraph()
{
}
Re: Interval Dosing w/ WaterLevel?
Well, it will because you are using a hard value of 59.
When you use the WaterLevelATO, you set a low and a high, so the port turns off an waits until it reaches the low to turn on again.
In this case, the timer was more important than the level.
If you want, you could still use the WaterLevelATO and restrict it to work only 1min every 10 minutes, if you wish too.
You would use this code:
When you use the WaterLevelATO, you set a low and a high, so the port turns off an waits until it reaches the low to turn on again.
In this case, the timer was more important than the level.
If you want, you could still use the WaterLevelATO and restrict it to work only 1min every 10 minutes, if you wish too.
You would use this code:
Code: Select all
if (now()%600<60)
ReefAngel.WaterLevelATO(Port1,30,59,61);
else
ReefAngel.Relay.Off(Port1);
Roberto.
Re: Interval Dosing w/ WaterLevel?
rimai wrote:Well, it will because you are using a hard value of 59.
When you use the WaterLevelATO, you set a low and a high, so the port turns off an waits until it reaches the low to turn on again.
In this case, the timer was more important than the level.
If you want, you could still use the WaterLevelATO and restrict it to work only 1min every 10 minutes, if you wish too.
You would use this code:Code: Select all
if (now()%600<60) ReefAngel.WaterLevelATO(Port1,30,59,61); else ReefAngel.Relay.Off(Port1);
Can i have a code without the ATO Time out? as i realise that if i were to set it at 60s it will start to dose on the 10 min interval for 1min then the next min when it start dosing again it (timeout) and i have to clear the timeout so it will work again.
Re: Interval Dosing w/ WaterLevel?
Tried raising it to 3mins but still it happens, will try 10minslnevo wrote:Raise the timeout...
Thanks
Re: Interval Dosing w/ WaterLevel?
Hummm...
I think you will need to increase it to a really high number.
It needs to reach 61% or it will timeout.
So, if it takes about 3 hours to go from 59 to 61, you must set the timeout to 10800.
I think you will need to increase it to a really high number.
It needs to reach 61% or it will timeout.
So, if it takes about 3 hours to go from 59 to 61, you must set the timeout to 10800.
Roberto.
Re: Interval Dosing w/ WaterLevel?
Thinking about this a little more... especially with such a high timeout... perhaps you just want it to turn on every 10 minutes for the first minute and just turn off at 60%.
if ( (now()%600<60) && (ReefAngel.WaterLevel.GetLevel()<=60) )
ReefAngel.Relay.On(Port1);
else
ReefAngel.Relay.Off(Port1);
if ( (now()%600<60) && (ReefAngel.WaterLevel.GetLevel()<=60) )
ReefAngel.Relay.On(Port1);
else
ReefAngel.Relay.Off(Port1);
Re: Interval Dosing w/ WaterLevel?
lnevo wrote:Thinking about this a little more... especially with such a high timeout... perhaps you just want it to turn on every 10 minutes for the first minute and just turn off at 60%.
if ( (now()%600<60) && (ReefAngel.WaterLevel.GetLevel()<=60) )
ReefAngel.Relay.On(Port1);
else
ReefAngel.Relay.Off(Port1);
Thanks Guys will give it a try tonightrimai wrote:Hummm...
I think you will need to increase it to a really high number.
It needs to reach 61% or it will timeout.
So, if it takes about 3 hours to go from 59 to 61, you must set the timeout to 10800.