Apex AOS 5.02 and Apex Classic firmware 4.52, which was released in May 2017, introduces two important changes in the available programming commands.

  • A new command is now available: ‘When
  • The syntax of the If Error command has changed





THE WHEN COMMAND

The ‘When’ command is a simple and effective way of programming an outlet to turn OFF if it has been ON or OFF for longer than it should be:

  • Turn the output OFF if it is ON for longer than a specified length of time


The ‘When’ statement, if true, causes the output to go to the manual OFF state, not just to turn OFF while in Auto mode. Previously it was not possible in any way to cause an output to change state to manual OFF through programming.

This capability eliminates the need to do complex programming with latching virtual outputs, reset virtual outputs, and other forms of difficult or confusing programming. You may have seen some forum users doing this, and also advocating that practice to other users - forget about all that; it's too hard to understand and to get right. 'When' will help you do things smarter, not harder!

A common scenario in which 'When' is of immense value is in programming for ATO. Using a ‘When’ statement, it is now much easier to program your ATO output to turn off if it runs longer than a specified period of time. When the ‘When’ command changes an outlet state to manual OFF (or manual ON), it will stay that way until you, the Apex user, deliberately position the slider for that output back to the Auto position.

The syntax of the new ‘When’ command is: When [ON/OFF] > MMM:SS Then [OFF/ON]

The maximum value for MMM:SS is 999:59 (16 hours, 39 minutes, & 59 seconds), although such a long period of time will rarely be used. Typically, periods between a few minutes and a few hours will be specified in a 'When' statement.

The most common usage of 'When' will be to force an output to the OFF state if it has been ON for more than a specified duration:

When On > 005:00 Then OFF

Here is how a simple ATO program using two switch inputs (one for ATO control, and another for a high water level backup) looks with a ‘When’ statement added to it:

[ATO_PUMP]
Fallback OFF
Set OFF
If SwATO OPEN Then ON
If SwHIGH CLOSED Then OFF
When On > 005:00 Then OFF

If the output is ON for more than 5 minutes, the When statement will become true, and force the ATO_PUMP output to manual OFF. This might occur, for example, if the ATO reservoir is empty. This prevents your ATO pump from running dry. Because the output is forced to manual OFF, the ATO_PUMP output will not turn on again without your manual intervention, which you would do after you have refilled the ATO reservoir. To return the ATO_PUMP output to normal operation, all you need to do is move the slider for ATO_PUMP to AUTO using Apex Fusion, the APEX Fusion iOS app, Apex Local, or the Classic Dashboard.

Here is a more advanced ATO pump program using ‘When’:

[ATO_PUMP]
Fallback OFF
Set OFF
If SwATO OPEN Then ON
If SwHIGH CLOSED Then OFF
When On > 005:00 Then OFF
Defer 000:10 Then ON
Defer 000:06 Then OFF
Min Time 060:00 Then OFF

The latter example is similar to the programming that will be created by using the APEX Fusion ATK Task. (If you have not yet seen the Tasks feature, click on the Home menu in Fusion, then choose Tasks from the drop-down list)


Less commonly used will be:

When Off > 005:00 Then OFF

One scenario in which a When OFF > MMM:SS Then OFF statement might be used is in the programming for a denitrator feed pump. If a denitrator's feed pump has not been operating for a few hours, the liquid inside the reactor may stagnate and become excessively sulfurous; that contaminated liquid should be flushed out by running the reactor output into a drain or bucket until it is purged and the reactor is refilled with "clean" saltwater. The 'When' command can be used to prevent the feed pump from being powered up if it has been shut off for too long, for example, for 3 or more hours. Here is an example of such a program:

[NO3_Reactor]
Set ON
If FeedA 020 Then OFF
If Output Maintenance = ON Then OFF
When OFF > 180:00 Then OFF

Let's say that the output named "Maintenance" is a virtual outlet that you slide to ON, which in turn shuts off return pump, skimmer, and reactors. You sometimes forget to turn the Maintenance virtual output back OFF when you are done with your tank maintenance. With this programming, if the denitrator feed pump outlet is OFF for more than 3 hours, for example if you forgot to turn the Maintenance VO's slider OFF, the When statement will become true, the outlet will be forced to manual OFF, and it will stay OFF until you take the appropriate action (flush the reactor), and then you would place the pump outlet slider back into the AUTO position.

This concept may also be used for other reactors and devices which could have stagnated water inside if the corresponding pump is shut off for too long: bio-pellet reactors, UV sterilizers, chillers, etc.


This variation of the 'When' statement is valid, but will rarely be useful, and if used, must be used with careful forethought and caution:

When On > 005:00 Then ON

This variation is not valid, and must never be used:

When Off > 005:00 Then ON

One last point about 'When' - It does not matter where in a output program the 'When' statement is used (just like Defer and Min Time statements).

'When' is to be used as a safety measure. Do not attempt to use it as general-purpose timer!





IF ERROR

The If Error statement has been available for some time, but in previous AOS/firmware, it was only used to trigger the email outlet to send an alert if a WAV error was detected. The former syntax was:

If Error modulename Then [ON/OFF]

Example: If Error WAV_5 Then ON

The new syntax is:

If Error outputname Then [ON/OFF]

Note that the old syntax utilized a module name, and that the new syntax now requires an output (outlet) name.

Examples:
If Error WAV_5_1 Then ON
If Error LinkA_7_1 Then ON
If Error ATO_PUMP Then ON

While an If Error statement may be used in some other outlets, the most common usage will be in the email output, to trigger an alert.

A corresponding ‘When’ statement must be present in the output name specified in the If Error statement if an If Error statement is used which references any output other than a WAV, COR or Trident.

Let’s go back to the basic ATO programming example given earlier:

[ATO_PUMP]
Fallback OFF
Set OFF
If SwATO OPEN Then ON
If SwHIGH CLOSED Then OFF
When On > 005:00 Then OFF

Assume that the ATO reservoir is empty, and the ATO_PUMP output turns on, but then the outputs stays on for more than the 5 minutes specified in the when statement. The output will shut off, in turn powering down the ATO pump to prevent it from overheating or otherwise being damaged from being run dry. Now, you definitely want to know that this has happened, right?!? This is where the If Error statement comes into play.

Let’s say you have a typical email program:

Set OFF
If Temp > 82.0 Then ON
If Temp < 77.5 Then ON
If pH > 8.35 Then ON
If pH < 7.85 Then ON

We’ll add an If Error statement:

Set OFF
If Temp > 82.0 Then ON
If Temp < 77.5 Then ON
If pH > 8.35 Then ON
If pH < 7.85 Then ON
If Error ATO_PUMP Then ON

Now, you’ll get an email, text message, or Apple push notification from APEX Fusion, alerting you if the ATO_PUMP output has been on too long and has shut itself OFF.

Similarly, if you go back to the example given earlier for using 'When' in nitrate reactor programming, you'd also put a suitable statement in your email program: If Error NO3_Reactor Then ON

One final note about If Error: If you have any If Error statements for your WAVs in your email output, upgrading to Apex AOS version 5.02 (or higher) or Apex Classic firmware version 4.52 (or higher) from an earlier version will automatically convert your existing programming from the old syntax to the new syntax.