ATO based off salinity

Do you have a question on how to do something.
Ask in here.
Post Reply
dazza1304
Posts: 154
Joined: Sat Aug 04, 2012 4:22 am

ATO based off salinity

Post by dazza1304 »

Hi guys,

Was hoping someone here could help.

I would like to perform ATO based off salinity.

What I would like to do is set the controller so that when my salinity reaches 35.2ppt consistently for x mins, it will activate one of my relay box outputs for x seconds (which will pump in RO water) .

Can anyone help with the coding for this please?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ATO based off salinity

Post by rimai »

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 <PH.h>
#include <WaterLevel.h>
#include <ReefAngel.h>

unsigned long lastLowSal=now();

void setup()
{
  ReefAngel.Init();  
}

void loop()
{
  if (ReefAngel.Params.Salinity<352) lastLowSal=now();
  ReefAngel.Relay.Set(Port1,(now()-lastLowSal>120));
  ReefAngel.ShowInterface();
}
Roberto.
dazza1304
Posts: 154
Joined: Sat Aug 04, 2012 4:22 am

Re: ATO based off salinity

Post by dazza1304 »

rimai wrote: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 <PH.h>
#include <WaterLevel.h>
#include <ReefAngel.h>

unsigned long lastLowSal=now();

void setup()
{
  ReefAngel.Init();  
}

void loop()
{
  if (ReefAngel.Params.Salinity<352) lastLowSal=now();
  ReefAngel.Relay.Set(Port1,(now()-lastLowSal>120));
  ReefAngel.ShowInterface();
}
Thanks Roberto,

OK, I am a Reef Angel Novice, and with the Reef Angel wizard have basically used the system "out of the box".

So, I am guessing that I would get my current code up on the arduino software and paste in the different bits from above?

I can see the bit that relates to 35.2ppt salinity, but can you point me to the bits that define:

time that salinity is at 35.2 or greater (ideally I would like to be maybe 10 - 60 secs before the port is triggered - this is to "debounce the signal")

Actual time that the port will be activated - also would it be possible to set this such that the pump runs for x seconds or the salinity reaches 35ppt for y seconds - which comes first?

Sorry if they are stupid questions, but I guess I have to learn somewhere!!

Your help would be much appreciated!!
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ATO based off salinity

Post by rimai »

120 is the number of seconds that it will have to maintain 35.2 continually to be able to trigger and turn Port1 on.
If the value drops to 35.1 at any time, even if the countdown is at 119s, it will reset the timer.
It must have 35.2 or greater continuously to be able to trigger it.
Then it will run as long as salinity is equal or above 35.2.
It will stop and start the timer again when the salinity drops to 35.1 again.
Roberto.
dazza1304
Posts: 154
Joined: Sat Aug 04, 2012 4:22 am

Re: ATO based off salinity

Post by dazza1304 »

rimai wrote:120 is the number of seconds that it will have to maintain 35.2 continually to be able to trigger and turn Port1 on.
If the value drops to 35.1 at any time, even if the countdown is at 119s, it will reset the timer.
It must have 35.2 or greater continuously to be able to trigger it.
Then it will run as long as salinity is equal or above 35.2.
It will stop and start the timer again when the salinity drops to 35.1 again.
Thanks Roberto,

I get it! Thanks! Although not sure how the port gets turned off when salinity drops to <35.2?

If I wanted to set so that the pump runs for x seconds when the salinity is 35.2 or higher or the salinity reaches 35ppt for y seconds - whichever comes first - how would I do this?

thanks!!
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ATO based off salinity

Post by rimai »

Can you explain y??
I don't follow.
Roberto.
dazza1304
Posts: 154
Joined: Sat Aug 04, 2012 4:22 am

Re: ATO based off salinity

Post by dazza1304 »

rimai wrote:Can you explain y??
I don't follow.
From looking at my salinity history, it seems that the salinity does bounce around a bit - maybe 0.2ppt.

So, ideally, when the salinity reaches 35.2, I would like to operate the ATO until the salinity reaches a steady 35.0ppt.

Turning the pump off after x seconds, is a failsafe in case something goes wrong with the salinity probe and the ATO gets constantly dumped into my tank - maybe I am better off using the float switch for this failsafe?
dazza1304
Posts: 154
Joined: Sat Aug 04, 2012 4:22 am

Re: ATO based off salinity

Post by dazza1304 »

Is this how my code should look?

#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 <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

// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port5Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port3Bit | Port4Bit | Port5Bit | Port6Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 270 );


// Ports that are always on
ReefAngel.Relay.On( Port4 );
ReefAngel.Relay.On( Port6 );

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


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

void loop()
{
ReefAngel.StandardHeater( Port1,248,250 );
ReefAngel.StandardFan( Port2,250,252 );
ReefAngel.StandardLights( Port3,0,0,23,30 );
ReefAngel.WavemakerRandom( Port5,10,60 );
ReefAngel.StandardLights( Port7,12,0,0,0 );
ReefAngel.StandardLights( Port8,13,0,22,0 );
////// Place your custom code below here


unsigned long lastLowSal=now();


void loop()
{
if (ReefAngel.Params.Salinity<352) lastLowSal=now();
ReefAngel.Relay.Set(Port1,(now()-lastLowSal>120));
ReefAngel.ShowInterface();
}

////// Place your custom code above here
dazza1304
Posts: 154
Joined: Sat Aug 04, 2012 4:22 am

Re: ATO based off salinity

Post by dazza1304 »

OK,

The above wasn't right and wouldn't compile, so think i have fixed as below.

All uploaded OK and controller runs, but when I disconnect salinity probe - simulating salinity greater than 35ppt (goes to 60ppt open circuit) nothing happens and I waited well over the 2 mins - port 5 just seems to be constantly off.

Any idea what I am doing wrong?

thanks..


#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 <ReefAngel.h>

////// Place global variable code below here
unsigned long lastLowSal=now();

////// 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

// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port5Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port3Bit | Port4Bit | Port5Bit | Port6Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 265 );


// Ports that are always on
ReefAngel.Relay.On( Port4 );
ReefAngel.Relay.On( Port6 );

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


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

void loop()
{
ReefAngel.StandardHeater( Port1,248,250 );
ReefAngel.StandardFan( Port2,250,252 );
ReefAngel.StandardLights( Port3,0,0,23,30 );
ReefAngel.StandardLights( Port7,12,0,0,0 );
ReefAngel.StandardLights( Port8,13,0,22,0 );
////// Place your custom code below here
if (ReefAngel.Params.Salinity<350) lastLowSal=now();
ReefAngel.Relay.Set(Port5,(now()-lastLowSal>120));


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

// This should always be the last line
ReefAngel.Portal( "dazza1304" );
ReefAngel.ShowInterface();
}
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ATO based off salinity

Post by rimai »

Yes, it looks good.
When you remove the probe, it actually reports 6.0ppt
It's a display glitch that didn't erase the last digit when it went from readings greater than 10 to less than 10.
Roberto.
dazza1304
Posts: 154
Joined: Sat Aug 04, 2012 4:22 am

Re: ATO based off salinity

Post by dazza1304 »

Hi Roberto - it works!!!

I will give it a try to control my ATO and see what happens!!

thanks again!!
dazza1304
Posts: 154
Joined: Sat Aug 04, 2012 4:22 am

Re: ATO based off salinity

Post by dazza1304 »

Well, it works really well - thank you roberto!!

Now, to improve, how to I incorporate a float switch in the code to shut off the ATO pump in case something goes wrong with salinity probe to stop flooding?

thanks!!
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ATO based off salinity

Post by rimai »

Try this:

Code: Select all

 if (ReefAngel.HighATO.IsActive)
 {
   if (ReefAngel.Params.Salinity<350) lastLowSal=now();
   ReefAngel.Relay.Set(Port5,(now()-lastLowSal>120));
 }
 else
 {
   ReefAngel.Relay.Off(Port5);
 }
Roberto.
Post Reply