How do I code delayed start from feed mode, i.e. for skimmer

Do you have a question on how to do something.
Ask in here.
Post Reply
b_s_c1
Posts: 16
Joined: Fri Mar 25, 2011 7:00 pm

Re: How do I code delayed start from feed mode, i.e. for ski

Post by b_s_c1 »

Has there been any development on this matter. I have the same problem as the original poster. For now I do not plan on using feed mode so I really just need a delay for starting up the skimmer after power is restored to the controller.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: How do I code delayed start from feed mode, i.e. for ski

Post by binder »

b_s_c1 wrote:Has there been any development on this matter.
No development yet on my end. I've mostly just been talking things out on the possible logic for this. Investigation/testing still needs to be done and then long-term maintenance needs to be thought out a bit too. Don't want to implement something and not have it be functional or not end accomplishing what we want it to do. :)
lucaeff
Posts: 2
Joined: Tue Apr 12, 2011 8:42 am

Re: How do I code delayed start from feed mode, i.e. for ski

Post by lucaeff »

Hello everyone
I would very delay on a skimmer in the event of restart after blackout we tried with this, What do you say?

void RitardoSkimmer(byte SKPort, byte SKDelay)
{
if (now()-RAStart < SKDelay) ReefAngel.Relay.On(SKPort);
}


RitardoSkimmer(Port8,120);
alexwbush
Posts: 327
Joined: Tue Mar 22, 2011 12:45 am
Location: San Diego, CA

Re: How do I code delayed start from feed mode, i.e. for ski

Post by alexwbush »

binder wrote:
alexwbush wrote: This sounds like a great idea. I can't imagine that I am the first one to stumble on this problem (the fact that all equipment turns back on at the same time). What happens with your skimmers when you exit feeding or water change mode?? Does your sump not rise?
I don't ever shut my sump off when I'm in feeding mode. My sump area can hold all the additional water overflow/backflow if all pumps are off. My sump contains my protein skimmer as well. So if the sump is off, I'm still skimming but it doesn't increase any additional skimmate in my skimmer. So it doesn't affect me.
Now if I were to shut off my sump in feeding mode, I would have to stop several of my filters because they would be halfway out of the water (because my water level drops about 2 inches or so when the sump is off.
I'm curious to see your setup Curt. If I shut off the return pump my water level rises in my sump due to siphoning from the return. And when the water level rises the skimmer starts wet skimming or sucking the water up into the collection cup (which I now have drilled to drain to another bucket). I could drill a small hole or something, but it doesn't really bother me that much and is kind of the basis for how I know how much to drain during water changes.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: How do I code delayed start from feed mode, i.e. for ski

Post by rimai »

Ok, after a good refreshing vacation, I think I know how to solve this problem.
Drawback, you must have at least another socket controlled by the feeding mode.
Example:
Socket 8: Return
Socket 7: Skimmer
On Ragen, you only select socket 8 as being part of feeding mode.
Then you will use a custom function called DelayStart(), which I'll create tonight.
The sole purpose of this function is going to be monitoring socket 8 and turn on socket 7 after x seconds everytime socket 8 turns on.
Does it make sense?
Roberto.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: How do I code delayed start from feed mode, i.e. for ski

Post by rimai »

Sorry to raise expectations, but this idea also did not work on my tests.
Roberto.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: How do I code delayed start from feed mode, i.e. for ski

Post by rimai »

This is not a real solution for the problem, but it can be used while Curt is working on a more permanent solution:

Code: Select all

void DelayStart(byte DelayedPort, int SecsDelay)
{
  static unsigned long lastCheck;
  static unsigned long lastOff;
  
  if (lastCheck!=0 && (now()-lastCheck>100)) 
  {
    lastOff=now();
    ReefAngel.Relay.Off(DelayedPort);
  }
  lastCheck=now();
  if (lastOff!=0 && now()-lastOff>SecsDelay)
  {
    ReefAngel.Relay.On(DelayedPort);
  } 
}
What this function does is actually monitor for the last time it was called. If it was last called 100 seconds ago, it probably means it was in feeding/water change mode. This triggers the delay start.
The problem you will encounter is if you go to the setup menu and spend more than 100 seconds in one of the setup screens, it will be counted towards the 100 seconds and when you exit from the setup screen, you will see the port being turned off and start the delay too.
I hope this can help some.
Attached is a code with an example on how to use it.
Attachments
DelayStart.pde
(1.07 KiB) Downloaded 462 times
Roberto.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: How do I code delayed start from feed mode, i.e. for ski

Post by binder »

alexwbush wrote:I'm curious to see your setup Curt.
Here is an old shot of my sump / filtration area. I'll try to take a more recent photo next week to show you, but you should at least get the idea. The major difference is the divider on the far right has been removed and there is not a refugium anymore. It's just a larger reservoir area.

Image
Image

And it's not as full as it gets. This shot was taken while I was still testing out the water levels in my tank before I got it running. The water comes up just below the black rim after everything is shut off. So no worries about anything skimming too much because the water level stays below where all the skimming action takes place.

curt
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: How do I code delayed start from feed mode, i.e. for ski

Post by binder »

lucaeff wrote:Hello everyone
I would very delay on a skimmer in the event of restart after blackout we tried with this, What do you say?

void RitardoSkimmer(byte SKPort, byte SKDelay)
{
if (now()-RAStart < SKDelay) ReefAngel.Relay.On(SKPort);
}
That code would have to be modified to be Greater Than the delay then turn on the port, otherwise it would only be on while the delay is in effect. The delay would be in minutes (just like with the MHLights). If you didn't want a minute delay, then you would need to remove the timer variable and place the Delay variable back in the if statement. So it should be changed to this:

Code: Select all

void DelayedOn(byte Port, byte Delay)
{
  unsigned int timer = Delay;
  timer *= SECS_PER_MIN;
  if ( (now() - RAStart) > timer ) ReefAngel.Relay.On(Port);
  else ReefAngel.Relay.Off(Port);  // this is probably overkill but ensures it is off 
}
If you implemented this, then you would not have the ReefAngel.Relay.On line in the setup, you would have to use the DelayedOn function in the Loop code. So that would look something like this:

Code: Select all

void loop()
{
  // ... other stuff here
  DelayedOn(Port4, 2);  // 2 minute delay for starting up Port4
  // ... other stuff here
}
I have not tested this, but it should work.

This solution, however, would not work for the entering and exiting of feeding mode and water change mode. It would only work on power outage / loss. I still have to work on the feeding mode & water change mode solutions. It will require some other changes and modifications and I have some ideas in my head, so be patient please.... :geek:

curt
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: How do I code delayed start from feed mode, i.e. for ski

Post by binder »

I created a poll to see what delay interval would be most useful for people: seconds or minutes.
Your feedback will help determine how it gets coded. All feedback is welcomed.

Here's a link to the poll.

http://forum.reefangel.com/viewtopic.php?f=9&t=30
lucaeff
Posts: 2
Joined: Tue Apr 12, 2011 8:42 am

Re: How do I code delayed start from feed mode, i.e. for ski

Post by lucaeff »

thanks guys, I know you're working hard, I'll wait patiently
alexwbush
Posts: 327
Joined: Tue Mar 22, 2011 12:45 am
Location: San Diego, CA

Re: How do I code delayed start from feed mode, i.e. for ski

Post by alexwbush »

Curt, mine rises about 4-6" as well in my skimmer compartment when the return is shut off. The change in water level will cause more skimmate and eventually start wet skimming. I'm surprised you hadn't run into this issue. I actually use mine now for water changes. I'll let it wet skim out what I want to change out, then unplug my ATO and plug in a pump to pump in new saltwater. I'd like to automate the process, but it's much easier than it used to be before anyhow.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: How do I code delayed start from feed mode, i.e. for ski

Post by binder »

I just finished coding in a DelayedOn function. :ugeek:

I've tested it and it appears to be working the way it should but will need some further testing to be certain. It currently has a minute delay and is in my latest code on my github account (https://github.com/curtbinder/ReefAngel).

I also have a PDE file created that shows how to use the function. It is attached to this post.

Here is how the function is designed to work:

// Always on ports that have a delay
// These ports will delay turning on for the specified MINUTE_DELAY during the following modes:
// Controller Power Up
// Feeding Mode (if toggled during mode)
// Water Change Mode (if toggled during mode)
//
// This function needs to be placed inside loop() and not inside setup()
//
// Usage is DelayedOn(PORT, MINUTE DELAY)

So that means that at controller startup, any port that is specified as a DelayedOn port will delay starting up for the given minute delay. The Feeding and Water Change modes will only do the delay if the port was actually turned off during those modes.

Here is an example scenario:
If you don't turn off your skimmer during feeding mode but do during water change mode, the skimmer will only be delayed in turning on when the controller powers up and after leaving water change mode. Nothing happens during feeding mode because it was never turned off for feeding mode.

curt
Attachments
DelayedOn.pde
DelayedOn function example
(1.58 KiB) Downloaded 456 times
alexwbush
Posts: 327
Joined: Tue Mar 22, 2011 12:45 am
Location: San Diego, CA

Re: How do I code delayed start from feed mode, i.e. for ski

Post by alexwbush »

Curt, your delay on function seems to work great... however, it doesn't seem to work for power losses just as the halide does. I have a float switch on my collection bucket so that if it's full, the skimmer turns off. If the float switch is triggered, then cleared, the skimer will turn off for one minute. But, I also want it to delay start if the power goes out just as the halide function does. Any suggestions?

my PDE

Code: Select all

// Autogenerated file by RAGen (v1.0.4.92), (05/08/2011 17:03)
// RA_050811_1703.pde
//
// This version designed for v0.8.5 Beta 12 or later

/* The following features are enabled for this PDE File: 
#define DisplayImages - ok
#define WavemakerSetup - ok
#define DateTimeSetup - ok
#define ATOSetup - ok, but probably not needed since the ato timeouts are not used
#define MetalHalideSetup - ok
#define DirectTempSensor - ok
#define RelayExp - ok
#define SingleATOSetup - ok, but probably not needed since the single ato function isn't used
#define StandardLightSetup -ok
#define CUSTOM_MAIN - ok
#define COLORS_PDE - ok
*/

//Custom colors
#include <ReefAngel_Colors.h>
#include <ReefAngel_CustomColors.h>

#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <ReefAngel_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <ReefAngel_EEPROM.h>
#include <ReefAngel_NokiaLCD.h>
#include <ReefAngel_ATO.h>
#include <ReefAngel_Joystick.h>
#include <ReefAngel_LED.h>
#include <ReefAngel_TempSensor.h>
#include <ReefAngel_Relay.h>
#include <ReefAngel_PWM.h>
#include <ReefAngel_Timer.h>
#include <ReefAngel_Memory.h>
#include <ReefAngel.h>

/*
#define Box1_Port1    11    Fuge LED
#define Box1_Port2    12    Carbon Reactor
#define Box1_Port3    13    
#define Box1_Port4    14    Vortech
#define Box1_Port5    15    WC Heater
#define Box1_Port6    16    WC Pump
#define Box1_Port7    17    Actinic LED
#define Box1_Port8    18    
*/

/*
//#include <avr/pgmspace.h>
prog_char id_label[] PROGMEM = "wolfpack1206";
prog_char probe1_label[] PROGMEM = "Water";
prog_char probe2_label[] PROGMEM = "Room";
prog_char probe3_label[] PROGMEM = "Not%20Used";
prog_char relay1_label[] PROGMEM = "ATO";
prog_char relay2_label[] PROGMEM = "Moonlight";
prog_char relay3_label[] PROGMEM = "Actinic";
prog_char relay4_label[] PROGMEM = "Halide";
prog_char relay5_label[] PROGMEM = "Sump%20Light";
prog_char relay6_label[] PROGMEM = "Powerhead";
prog_char relay7_label[] PROGMEM = "Heater";
prog_char relay8_label[] PROGMEM = "Return";
#ifdef RelayExp
prog_char relay11_label[] PROGMEM = "Fuge%20LED";
prog_char relay12_label[] PROGMEM = "Carbon%20Reactor";
prog_char relay13_label[] PROGMEM = "Not%20Used";
prog_char relay14_label[] PROGMEM = "Vortech";
prog_char relay15_label[] PROGMEM = "WC%20Heater";
prog_char relay16_label[] PROGMEM = "WC%20Pump";
prog_char relay17_label[] PROGMEM = "Actinic%20LED";
prog_char relay18_label[] PROGMEM = "Not%20Used";
#endif  // RelayExp

PROGMEM const char *webbanner_items[] = {
    id_label, probe1_label, probe2_label, probe3_label, 
    relay1_label, relay2_label, relay3_label, relay4_label, 
    relay5_label, relay6_label, relay7_label, relay8_label,
#ifdef RelayExp
    relay11_label, relay12_label, relay13_label, relay14_label, 
    relay15_label, relay16_label, relay17_label, relay18_label,
#endif  // RelayExp
};
*/

void DrawCustomMain()
{
  // Change the 30 to adjust the horizontal position of the text on the screen, max 20-21 chars
  ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 35, 2, "Alex's Cube");
  ReefAngel.LCD.DrawDate(6, 119);
  pingSerial();
  ReefAngel.LCD.DrawMonitor(15, 63, ReefAngel.Params,
                            ReefAngel.PWM.GetDaylightValue(), 
                            ReefAngel.PWM.GetActinicValue());
  pingSerial();
  // draw main relay
  byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay |= ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawOutletBox(12, 93, TempRelay);
#ifdef RelayExp
  // draw 1st expansion relay
  TempRelay = ReefAngel.Relay.RelayDataE[0];
  TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
  TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
  ReefAngel.LCD.DrawOutletBox(12, 105, TempRelay);
#endif  // RelayExp
}

void DrawCustomGraph()
{
  ReefAngel.LCD.DrawGraph(5, 10);
}



void setup()
{
    ReefAngel.Init();  //Initialize controller
    //ReefAngel.LoadWebBanner(pgm_read_word(&(webbanner_items[0])), SIZE(webbanner_items));

    // Initialize and start the timer
    //ReefAngel.Timer[4].SetInterval(120);  // set interval to 180 seconds
    //ReefAngel.Timer[4].Start();

    ReefAngel.FeedingModePorts = B10101000;
    //ReefAngel.WaterChangePorts = B10000010;
    ReefAngel.WaterChangePorts = B00000001;
    ReefAngel.OverheatShutoffPorts = B00000110;

    // Ports that are always on
    ReefAngel.Relay.On(Port6);
    ReefAngel.Relay.On(Port8);
    
    ReefAngel.Relay.On(Box1_Port1);
    ReefAngel.Relay.On(Box1_Port2);
    ReefAngel.Relay.On(Box1_Port4);
}

void loop()
{
    ReefAngel.ShowInterface();

    // Specific functions
    // ReefAngel.SingleATOHigh(Port1);
    if(ReefAngel.HighATO.IsActive())
    {
        ReefAngel.Relay.On(Port1);
        ReefAngel.Relay.On(Box1_Port6);
    }
    if(ReefAngel.HighATO.IsActive()==false)
    {
        ReefAngel.Relay.Off(Port1);
        ReefAngel.Relay.Off(Box1_Port6);
    }
    if(ReefAngel.LowATO.IsActive())
        ReefAngel.DelayedOn(Port6, 1);
    if(ReefAngel.LowATO.IsActive()==false)
        ReefAngel.Relay.Off(Port6);
    
    ReefAngel.StandardLights(Port2);
    ReefAngel.MHLights(Port3);
    //ReefAngel.Wavemaker1(Port4);
    ReefAngel.StandardFan(Port5);
    ReefAngel.StandardHeater(Port7);
    
    ReefAngel.StandardLights(Box1_Port7,12,15,21,45);
}
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: How do I code delayed start from feed mode, i.e. for ski

Post by binder »

alexwbush wrote:Curt, your delay on function seems to work great... however, it doesn't seem to work for power losses just as the halide does.
The code is exactly the same for both of the delays. DelayedOn uses a variable called LastStart and the Halides use a variable called RAStart. When the controller initializes, LastStart gets set with the value from RAStart.

From your code, it looks like your skimmer is on Port6. If it is, your problem is how you turn it on. If you want a DelayedOn, you cannot turn it ON in the setup. You have the ReefAngel.Relay.On(Port6) inside setup(), which turns it on every time the controller powers up.

You already have your conditional statement that checks whether or not to turn on the port. So just stop turning it on when the controller starts up and you should be fine.

curt
alexwbush
Posts: 327
Joined: Tue Mar 22, 2011 12:45 am
Location: San Diego, CA

Re: How do I code delayed start from feed mode, i.e. for ski

Post by alexwbush »

great catch! I can't believe I overlooked that, thanks!
Post Reply