pH control linked to water level and timed safety

Do you have a question on how to do something.
Ask in here.

Posts: 51
Joined: Sun Aug 20, 2017 6:19 am
PostPosted: Wed Sep 06, 2017 3:22 pm
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.

Posts: 12200
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Wed Sep 06, 2017 3:24 pm
What is the code you are using for the dosing pump?
Roberto.

Posts: 51
Joined: Sun Aug 20, 2017 6:19 am
PostPosted: Wed Sep 06, 2017 3:32 pm
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.

Posts: 51
Joined: Sun Aug 20, 2017 6:19 am
PostPosted: Thu Sep 07, 2017 5:22 am
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();

Posts: 16
Joined: Fri Nov 11, 2016 11:08 am
PostPosted: Thu Sep 07, 2017 9:05 pm
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);
}

Posts: 51
Joined: Sun Aug 20, 2017 6:19 am
PostPosted: Thu Sep 07, 2017 11:34 pm
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.

Posts: 16
Joined: Fri Nov 11, 2016 11:08 am
PostPosted: Sat Sep 09, 2017 11:10 am
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 );

Posts: 51
Joined: Sun Aug 20, 2017 6:19 am
PostPosted: Mon Sep 11, 2017 4:40 am
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 ?

Posts: 12200
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Mon Sep 11, 2017 8:22 am
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.

Posts: 51
Joined: Sun Aug 20, 2017 6:19 am
PostPosted: Mon Sep 11, 2017 2:15 pm
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?
Next

Return to How do I code ...

Who is online

Users browsing this forum: No registered users and 2 guests