Saturday, November 24, 2018

Day 7, and then there was light, and heat.

So two things need to be programmed for the aquarium.  The heaters, and the moonlights.  We will start with the heaters, because that's the easier of the two.

I have 3 Finnex 300W heaters.  I located my temperature probe up in the top of the tank, in one of the overflows.  I wanted it pretty far from the heaters, so the readings would be stable, and unaffected by the heater, and anything else down in the sump. I also don't want all the heaters turning on and off constantly, trying to keep the temperature in check and vastly overdoing it.  I'd prefer to not run 900 watts of power all at once, as that gets expensive.

So there was a pretty good thread on the Neptune forums about a multiple heater setup that pretty much did what I wanted.  So I hacked it up, and we have the following:

 Heater1Left

Fallback OFF
If Tmp < RT+0.0 Then ON
Defer 001:15 Then ON
If Tmp > RT+0.1 Then OFF
If Time 16:00 to 03:59 Then OFF
If Tmp < RT+-0.1 Then ON
If Output Heater2On030 = ON Then ON
If Tmp > 80.0 Then OFF
If Tmp < 70.1 Then OFF
If Output LeftReturn = OFF Then OFF
If Output LeakDetected = ON Then OFF
When On > 060:00 Then OFF

Heater2Right

Fallback OFF
If Tmp < RT+0.0 Then ON
Defer 001:15 Then ON
If Tmp > RT+0.1 Then OFF
If Time 04:00 to 15:59 Then OFF
If Tmp < RT+-0.1 Then ON
If Output Heater1On030 = ON Then ON
If Tmp > 80.0 Then OFF
If Tmp < 70.1 Then OFF
If Output RightReturn = OFF Then OFF
If Output LeakDetected = ON Then OFF
When On > 060:00 Then OFF

BkupHeaterR

Fallback OFF
If Tmp < RT+-0.2 Then ON
Defer 003:00 Then ON
If Output RightReturn = OFF Then OFF
If Output LeakDetected = ON Then OFF
If Tmp > 80.0 Then OFF
If Tmp < 70.1 Then OFF
If Tmp > RT+0.1 Then OFF
When On > 045:00 Then OFF

Heater1On030 and Heater2On030

Set OFF
If Output Heater1Left = ON Then ON
Defer 030:00 Then ON

These three heaters have a pretty slick setup IMHO.  The right/left ones are split, so for 12 hours, one is primary, and then for the next 12 hours the other one is primary.  There is a virtual outlet for each, that triggers when the heater has been running for 30 minutes.  When this happens, the second heater kicks in, and helps out, even though it's outside of it's timeframe. When the temp is far too low, we also have the backup heater, so in theory all three can be running at once, but only if things are getting a bit chilly.  Finally the When statement at the bottom of each, is a failsafe.  If any of the main heaters run for an hour straight, they shut off.  But not just off, they flip off Auto in the Apex, so they have to be manually reset.  You can use this to generate an email alarm with the If Error statement.

So now I'm pretty happy with that, lets move on to the moonlight.  In my previous setup, because the Apex is still broken after all these years and won't let you access the moon intensity values, I had to kinda hack up a lunar phase.  In my case, it's simple, I follow the moonrise/set times, but the intensity is on a 1 week schedule.  Low intensity on Sunday, highest on Wed, coming back down to Saturday with no moonlight at all.  However, I don't just want the moon to flicker on into existence, I want it to very slowly fade in and out, like a rise.  This required some very overcomplex programming.  I don't actually recommend anyone do this.  It's slightly insane, and required so many virtual outlets it was absolutely absurd.  It might be possible to tighten this code up a bit too, but anyhow, here it is.  Quick note, I have my moonlight offset by 2 hours, so that is why you see the 120/120 statements.  If you don't offset, you would use slightly different code there.

Outlet: LED_Moon

Fallback OFF
Set OFF
If Moon 120/120 Then ON
If Tmp > 82.0 Then OFF

VDM: Var_LEDMoon

Set OFF
Fallback OFF
If Output VMoon1Rise = ON Then PMoon1_Rise
If Output VMoon1Set = ON Then PMoon1_Set
If Output VMoon1On = ON Then PMoon1_On
If Output VMoon2Rise = ON Then PMoon2_Rise
If Output VMoon2Set = ON Then PMoon2_Set
If Output VMoon2On = ON Then PMoon2_On
If Output VMoon3Rise = ON Then PMoon3_Rise
If Output VMoon3Set = ON Then PMoon3_Set
If Output VMoon3On = ON Then PMoon3_On
If Output VMoon4Rise = ON Then PMoon4_Rise
If Output VMoon4Set = ON Then PMoon4_Set
If Output VMoon4On = ON Then PMoon4_On
If Output LED_Moon = OFF Then OFF
Then you need to setup a bunch of profiles.  By a bunch, I mean 12.  They all follow a similar setup to this:

PMoon1_On
Ramp
1 minutes
7%
7%

PMoon1_Set
Ramp
60 minutes
7%
0%

PMoon1_Rise
Ramp
60 minutes
0%
7%
Then, if that's not enough programming for you, you need 15 virtual outlets..
First, three for the moon state.

VMoonOn

Set OFF
If Moon 180/060 Then ON

VMoonRise

Set OFF
If Moon 120/-360 Then ON
If Output VMoonOn = ON Then OFF

VMoonSet

Set OFF
If Moon 360/120 Then ON

Then 12 more, like this, numbered 1-4:

VMoon1Rise

Set OFF
Fallback OFF
If DoW S------ Then ON
If Output VMoonRise = OFF Then OFF

VMoon1Set

Set OFF
If Output VMoonSet = ON Then ON
If Output VMoon2On = ON Then OFF
If Output VMoon3On = ON Then OFF
If Output VMoon4On = ON Then OFF
If Output VMoon2Set = ON Then OFF
If Output VMoon3Set = ON Then OFF
If Output VMoon4Set = ON Then OFF

VMoon1On

Set OFF
If Output VMoonOn = ON Then ON
If Output VMoon2Rise = ON Then OFF
If Output VMoon3Rise = ON Then OFF
If Output VMoon4Rise = ON Then OFF
If Output VMoon2On = ON Then OFF
If Output VMoon3On = ON Then OFF
If Output VMoon4On = ON Then OFF

VMoon2On (as an example)

Set OFF
If Output VMoonOn = ON Then ON
If Output VMoon1Rise = ON Then OFF
If Output VMoon3Rise = ON Then OFF
If Output VMoon4Rise = ON Then OFF
If Output VMoon1On = ON Then OFF
If Output VMoon3On = ON Then OFF
If Output VMoon4On = ON Then OFF
So how does this nightmare of programming all work, and why do you need so many virtual outlets and complex statements?  Well.. its "easy".  First off, VMoonOn/Set/Rise tell us what state we are in, are we rising, setting, or full-on.  Then we need to figure out if we are on bright today, or dim, or whatever.  Which of the 4 phases of the moon we have.  Thats where the VMoon1On, VMoon2On, etc all come in.

The rise outlet picks the day.  This means if moonrise is before 11:59pm, it will base the day of week on the day the moon rises.  We then have to chain the On to that particular rise.  If we use the day of week statement again, in the case where moonrise was at 11:59pm, we would rise to say 7%, but then it would be Monday, and Monday has a 14% moon, so that would then cause a sudden jump when we get to the On state.  Therefore the VMoon1On statement looks to see which state was on, and then selects which one to chain based on that.

Finally, the Set does the same thing as the On.  It chains off the previous On, so we get the same starting point for the Ramp profile as we had on the On state.

All of this madness gives us a 7 day lunar cycle, where even if the moon rise/set spans across midnight, we still get the proper ramp settings to follow the moon.  And all of this follows the seasonal Moon table, so it varies day to day automatically.  The whole reason you can't use something like the Wizard to do this, is you want the whole thing to shift by the seasonal lunar rise/set, and when the times are longer/shorter you want the right thing to automagically happen.  This does that, at the expense of say, 5 hours of programming, and some sanity you weren't using anyhow.

Do I recommend this?  No.  It's so super fiddly.  It does 100% work though, and maybe staring at it will solve a different problem you have.  I wouldn't even dream of this on a Classic Apex, as it would probably cause the CPU to give up and tell you it hates you.  But it works, and it is super slick to witness.  If only I could do a full 30 day cycle.  Sigh.  Neptune..

Day 7 comes to an end, and I drift off to sleep slightly less sane than on day 6...

No comments:

Post a Comment