Page 1 of 1
pH controlled kalkwasser dosing
Posted: Sun Apr 22, 2012 10:25 am
by gaberosenfield
I am trying to get a single dosing pump to pump in saturated kalkwasser.
What I want: when the pH drops below xyz, dosing pump on for 10 seconds, then off for 5 minutes. Then if pH still below xyz, repeat. If pH above abc, dosing pump stays off until it drops below xyz again.
I tried to write my own code for this using 2 If loops and 2 timers (one for the 10 seconds on, one for the 300 seconds off), but once the dosing pump turns on, it doesn't turn off after 10 seconds
Help please!
Re: pH controlled kalkwasser dosing
Posted: Sun Apr 22, 2012 5:09 pm
by rimai
Assuming you are not using any Dosing Pump functions.
Try this:
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 <ReefAngel.h>
boolean dosing=false;
void setup()
{
ReefAngel.Init();
ReefAngel.Timer[1].SetInterval(10);
ReefAngel.Timer[2].SetInterval(310);
}
void loop()
{
if (ReefAngel.Params.PH<800 && !dosing)
{
ReefAngel.Timer[1].Start();
ReefAngel.Timer[2].Start();
ReefAngel.Relay.On(Port1);
dosing=true;
}
if (ReefAngel.Timer[1].IsTriggered())
{
ReefAngel.Relay.Off(Port1);
}
if (ReefAngel.Timer[2].IsTriggered())
{
dosing=false;
}
ReefAngel.ShowInterface();
}
Just change the Port you are using.
Re: pH controlled kalkwasser dosing
Posted: Tue Apr 24, 2012 8:24 am
by gaberosenfield
This code has exactly the same problem as the code I wrote. The dosing pump doesn't turn off when the appropriate timer should be triggered. I am using timers 3 and 5, with timer 5 set to 1 second and timer 3 set to 600 seconds. It should turn on port8 for one second when the pH drops below 8.00, and then wait 10 minutes, and then reassess the pH and repeat as necessary. But instead, if the pH drops below 8.00, port8 comes on and stays on for a really long time (I'm not sure how long exactly it would stay on, but it stays on for at least 5 or 6 minutes as I have observed it staying on for that long). Here is my code:
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 <ReefAngel.h>
boolean dosing=false;
void setup()
{
ReefAngel.Init(); //Initialize controller
ReefAngel.FeedingModePorts = Port3Bit | Port4Bit | Port5Bit | Port6Bit | Port8Bit;
ReefAngel.WaterChangePorts = Port3Bit | Port4Bit | Port5Bit | Port6Bit | Port8Bit;
ReefAngel.OverheatShutoffPorts = 0;
ReefAngel.LightsOnPorts = Port1Bit | Port2Bit;
ReefAngel.Timer[1].SetInterval(8);//Wavemaker Timer
ReefAngel.Timer[1].Start();
ReefAngel.Timer[2].SetInterval(8);
ReefAngel.Timer[5].SetInterval(1);//Kalk dosing timer
ReefAngel.Timer[3].SetInterval(600);//Kalk dosing delay timer
// Ports that are always on
ReefAngel.Relay.On(Port4); // Return, Circulation Pump, and Aqualifter
ReefAngel.Relay.On(Port5); // Skimmer
// Initialize and start the RA Client logging timer
ReefAngel.Timer[4].SetInterval(15); // set interval to 15 seconds
ReefAngel.Timer[4].Start();
}
void loop()
{
// Specific functions
ReefAngel.StandardLights(Port1,10,00,20,00); // White Lights
ReefAngel.StandardLights(Port2,9,00,21,00); // Blue Lights
ReefAngel.StandardHeater(Port3,788,792); //Heater
ReefAngel.ShowInterface();
if (ReefAngel.Timer[1].IsTriggered())//Wavemakers' Control
{
ReefAngel.Timer[2].Start();
ReefAngel.Relay.On(Port6);//Wavemaker 2
}
if (ReefAngel.Timer[2].IsTriggered())//Wavemakers' Control
{
ReefAngel.Relay.Off(Port6);
ReefAngel.Timer[1].Start();
}
if (ReefAngel.Params.PH<800 && !dosing)
{
ReefAngel.Timer[5].Start();
ReefAngel.Timer[3].Start();
ReefAngel.Relay.On(Port8);
dosing=true;
}
if (ReefAngel.Timer[5].IsTriggered())
{
ReefAngel.Relay.Off(Port8);
}
if (ReefAngel.Timer[3].IsTriggered())
{
dosing=false;
}
// Dump Params
if(ReefAngel.Timer[4].IsTriggered())
{
Serial.flush();
Serial.print("<RA><T1>");
Serial.print(ReefAngel.TempSensor.ReadTemperature(ReefAngel.TempSensor.addrT1));
Serial.print("</T1><T2>");
Serial.print(ReefAngel.TempSensor.ReadTemperature(ReefAngel.TempSensor.addrT2));
Serial.print("</T2><T3>");
Serial.print(ReefAngel.TempSensor.ReadTemperature(ReefAngel.TempSensor.addrT3));
Serial.print("</T3><PH>");
Serial.print(ReefAngel.Params.PH);
Serial.print("</PH><R>");
Serial.print(ReefAngel.Relay.RelayData,DEC);
Serial.print("</R><RON>");
Serial.print(ReefAngel.Relay.RelayMaskOn,DEC);
Serial.print("</RON><ROFF>");
Serial.print(ReefAngel.Relay.RelayMaskOff,DEC);
Serial.print("</ROFF></RA>");
ReefAngel.Timer[4].Start();
}
}
Any idea why it won't work?
Re: pH controlled kalkwasser dosing
Posted: Tue Apr 24, 2012 9:08 am
by rimai
Timer 3 and 5 are reserved.
They are used by the controller. In fact only timer 1 and 2 should be used.
I was assuming you were not using timer 1 and 2.
In this case, just declare new timers for you to use above setup():
Code: Select all
Timer DosingTimer;
Timer DelayTimer;
Re: pH controlled kalkwasser dosing
Posted: Tue Apr 24, 2012 9:20 am
by gaberosenfield
I get the error message: "Timer" does not name a type.
Re: pH controlled kalkwasser dosing
Posted: Tue Apr 24, 2012 9:29 am
by rimai
Hurr... Sorry
Code: Select all
TimerClass DosingTimer;
TimerClass DelayTimer;
Re: pH controlled kalkwasser dosing
Posted: Tue Apr 24, 2012 9:41 am
by gaberosenfield
rimai wrote:Hurr... Sorry
No worries! It works now! Hurrah! I'll post again if it goes awry as time moves on. Thanks!