pH control linked to water level and timed safety

Do you have a question on how to do something.
Ask in here.
Post Reply
Irieivan
Posts: 51
Joined: Sun Aug 20, 2017 6:19 am

pH control linked to water level and timed safety

Post by Irieivan »

I currently have an ato based on my water level expansion, and a separate kalk container on a port for pH control via a RA dosing pump to combat night time pH drops.
I want to program a safety code that prevents the port from being on for more than a cumilative 10 minutes per hour, or alternatively to wait at least ten minutes between max 5 minute doses. Another alternative is to prevent pH control port from dosing if my water level is above for example 55 to prevent too much of a salinity drop.
Last edited by Irieivan on Wed Sep 06, 2017 3:24 pm, edited 1 time in total.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: pH control linked to water level and timed safety

Post by rimai »

What is the code you are using for the dosing pump?
Roberto.
Irieivan
Posts: 51
Joined: Sun Aug 20, 2017 6:19 am

Re: pH control linked to water level and timed safety

Post by Irieivan »

I am using the standard pH control code from the wizard. Dont have access to post code at the moment, will post tomorrow.
Personally i think the best failsafe will be the water level fail safe instead of timed failsafes?
Last edited by Irieivan on Thu Sep 07, 2017 9:03 am, edited 1 time in total.
Irieivan
Posts: 51
Joined: Sun Aug 20, 2017 6:19 am

Re: pH control linked to water level and timed safety

Post by Irieivan »

This is the code I have set up with the wizrd, have no idea how to code or where to put what.

Code: Select all

#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 <Humidity.h>
#include <DCPump.h>
#include <PAR.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.SetTemperatureUnit( Celsius );  // set to Celsius Temperature

    ReefAngel.Use2014Screen();  // Let's use 2014 Screen 
    ReefAngel.AddWaterLevelExpansion();  // Water Level Expansion Module
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port8Bit;
    ReefAngel.FeedingModePortsE[0] = Port1Bit | Port2Bit | Port4Bit | Port5Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port1Bit | Port5Bit | Port6Bit;
    ReefAngel.WaterChangePortsE[0] = Port1Bit | Port2Bit | Port4Bit | Port5Bit;
    // 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 = Port7Bit | Port8Bit;
    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( 280 );


    // Ports that are always on
    ReefAngel.Relay.On( Port1 );
    ReefAngel.Relay.On( Box1_Port1 );
    ReefAngel.Relay.On( Box1_Port2 );
    ReefAngel.Relay.On( Box1_Port5 );

    ////// Place additional initialization code below here
    

    ////// Place additional initialization code above here
}

void loop()
{
    ReefAngel.PHControl( Port2,819,821 );
    ReefAngel.StandardLights( Port4,9,0,19,0 );
    ReefAngel.Relay.DelayedOn( Port5,1 );
    ReefAngel.WaterLevelATO( Port6,225,44,46 );
    ReefAngel.StandardHeater( Port7,255,265 );
    ReefAngel.Relay.DelayedOn( Port8,1 );
    ReefAngel.Relay.DelayedOn( Box1_Port4,1 );
    ////// Place your custom code below here
    

    ////// Place your custom code above here

    // This should always be the last line
    ReefAngel.Portal( "Irieivan" );
    ReefAngel.ShowInterface();
lnevo3
Posts: 16
Joined: Fri Nov 11, 2016 11:08 am

Re: pH control linked to water level and timed safety

Post by lnevo3 »

I think the easiest way would be to constrain it. I think the way I would go is the first 10 minutes of every hour, this way it would never exceed and you'd be making hourly adjustments only.

Code: Select all

if (now%3600<600) {
  ReefAngel.PHControl(...);
} else {
  ReefAngel.Relay.Off(Port2);
}
Irieivan
Posts: 51
Joined: Sun Aug 20, 2017 6:19 am

Re: pH control linked to water level and timed safety

Post by Irieivan »

Thank you for the response.
Would that code allow it to only activate the port if pH reaches below set point or is that regardless of set point?
My day time pH reaches 8.3+ so even a 5min kalk dose is overkill during the day. Lights off at 9pm, so is there a way to add to the code above to only dise between 10pm and 9am for the 1st 5mins of every hour.
lnevo3
Posts: 16
Joined: Fri Nov 11, 2016 11:08 am

Re: pH control linked to water level and timed safety

Post by lnevo3 »

It would be based on how you setup the PH Control function. In my example it's using Internal Memory so from the portal check the high and low PH settings. If you want to hard-code it, you would do as you had before:

ReefAngel.PHControl( Port2,819,821 );
Irieivan
Posts: 51
Joined: Sun Aug 20, 2017 6:19 am

Re: pH control linked to water level and timed safety

Post by Irieivan »

Thanks for you response, but i am totally clueless when it gets to coding.
Is there not something similar to the osc function that apex users have?
Something to the effect of:
If pH<8.20, on every ten minutes for ten seconds, but if pH> thn 8.25 then OFF?
I dont know what hard coding is either. Cant one simply insert code into the sketch which is created and saved by wizard, and then export it to controller ?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: pH control linked to water level and timed safety

Post by rimai »

That's exactly what he posted above.
If you look in your code, there is a place to put custom code in the loop section.
Roberto.
Irieivan
Posts: 51
Joined: Sun Aug 20, 2017 6:19 am

Re: pH control linked to water level and timed safety

Post by Irieivan »

Thanks again for the help and apologies for always asking what might seem to you as stupid questions.
So i dont have to add anything to the code, just insert it into my current sketch where it tells me //// place custome code below here?
Irieivan
Posts: 51
Joined: Sun Aug 20, 2017 6:19 am

Re: pH control linked to water level and timed safety

Post by Irieivan »

If i wanted to only dose the kalk for 2.5 minutes every 30 minutes, i just change the code above from 1800<150?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: pH control linked to water level and timed safety

Post by rimai »

Yeap
Roberto.
Irieivan
Posts: 51
Joined: Sun Aug 20, 2017 6:19 am

Re: pH control linked to water level and timed safety

Post by Irieivan »

Thank you
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: pH control linked to water level and timed safety

Post by lnevo »

Take out or comment the line that has the original PHControl statement so you dont get confused later :) You can comment it with a // in front.
Irieivan
Posts: 51
Joined: Sun Aug 20, 2017 6:19 am

Re: pH control linked to water level and timed safety

Post by Irieivan »

Like I keep saying, I am too stupid for this.

Code: Select all

#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 <Humidity.h>
#include <DCPump.h>
#include <PAR.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.SetTemperatureUnit( Celsius );  // set to Celsius Temperature

    ReefAngel.Use2014Screen();  // Let's use 2014 Screen 
    ReefAngel.AddWaterLevelExpansion();  // Water Level Expansion Module
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port3Bit | Port8Bit;
    ReefAngel.FeedingModePortsE[0] = Port1Bit | Port2Bit | Port4Bit | Port5Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port1Bit | Port3Bit | Port5Bit | Port6Bit;
    ReefAngel.WaterChangePortsE[0] = Port1Bit | Port2Bit | Port4Bit | Port5Bit;
    // 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 = Port3Bit | Port7Bit | Port8Bit;
    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( 280 );


    // Ports that are always on
    ReefAngel.Relay.On( Port1 );
    ReefAngel.Relay.On( Box1_Port1 );
    ReefAngel.Relay.On( Box1_Port2 );
    ReefAngel.Relay.On( Box1_Port5 );

    ////// Place additional initialization code below here
    

    ////// Place additional initialization code above here
}

void loop()
{
    ReefAngel.PHControl( Port2,819,822 );
    ReefAngel.Relay.DelayedOn( Port3,2 );
    ReefAngel.StandardLights( Port4,9,0,19,0 );
    ReefAngel.Relay.DelayedOn( Port5,1 );
    ReefAngel.WaterLevelATO( Port6,225,44,46 );
    ReefAngel.StandardHeater( Port7,255,265 );
    ReefAngel.Relay.DelayedOn( Port8,1 );
    ReefAngel.Relay.DelayedOn( Box1_Port4,1 );
    ////// Place your custom code below here
 if (now%3600<600) {ReefAngel.PHControl(...);} else {
  ReefAngel.Relay.Off(Port2);
}

    ////// Place your custom code above here

    // This should always be the last line
    ReefAngel.Portal( "Irieivan" );
    ReefAngel.ShowInterface();
}
And when I try to upload, I get an error:

invalid operands of type time_t00'and'init' to binary'operator%'
Irieivan
Posts: 51
Joined: Sun Aug 20, 2017 6:19 am

Re: pH control linked to water level and timed safety

Post by Irieivan »

When I replace the (...) in the suggested code with my pH control values, I get the same error
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: pH control linked to water level and timed safety

Post by rimai »

I think there is a typo.
It should be now() and not just now
Roberto.
Irieivan
Posts: 51
Joined: Sun Aug 20, 2017 6:19 am

Re: pH control linked to water level and timed safety

Post by Irieivan »

if (now(%3600<600) {
ReefAngel.PHControl(Port2,819,822);
} else {
ReefAngel.Relay.Off(Port2);
}

Error again:

Expected primary expression before'%' token
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: pH control linked to water level and timed safety

Post by rimai »

It's now() and not now(
Roberto.
Irieivan
Posts: 51
Joined: Sun Aug 20, 2017 6:19 am

Re: pH control linked to water level and timed safety

Post by Irieivan »

Ok got it figured out thanks
Post Reply