Understanding the Set command
The Set command is the simplest command used in the Apex, but it is sometimes misused. It is used to define the default state of an outlet whenever no other program statement is true.
One thing I see commonly is confusion between the Set and Fallback statements. They are not equivalent and are not interchangeable. Fallback is a special command that has no affect on the state of an outlet during normal program execution - Fallback tells a module what to do should that module lose communications with the Apex. See this sticky post for more about Fallback.
Now, let's review proper usage of Set:
The Set requires an action to be specified - OFF, ON, or if the output being programmed supports variable intensity, a % value or a profile name.
- Set OFF
- Set ON
- Set 75
- Set Constant50
The Set statement, if used, should be used to configure the normal, default state of an output. In general, if an output should be off most of the time or under normal conditions, then a Set OFF should be used. If an output is needed to be on all or most of the time, except when certain conditions are met, then using Set ON is appropriate. In summary, use Set to assign the normal state, then use additional programming for exceptions.
These two programs do almost exactly the same thing - make an output be on for 10 hours, from 8AM to 6PM But one is the "right" way, the other is the "wrong" way.
RECOMMENDED
Set OFF
If Time 08:00 to 18:00 Then ON
NOT RECOMMENDED
Set ON
If Time 18:00 to 08:00 Then OFF
The first one is logical, and easier to understand. The second one uses a sort of backwards logic, and is not as easy to understand.
Let's look at a simple program for a lighting schedule:
Set OFF
If Time 08:00 to 17:59 Then ON
Whenever the If Time statement is true (between 08:00 and 18:00, the outlet will be ON. Whenever the If Time statement is not true, the Set OFF statement tells the outlet to be OFF. Simple enough.
I sometimes see people do this instead:
If Time 08:00 to 17:59 Then ON
If Time 18:00 to 07:59 Then OFF
So what's the difference between the first example I gave (using one Set and one If Time statements) and this one (using two If Time statements)? Functionally, the outcome is exactly the same - the outlet will be on from 8AM to 6PM, and off the rest of the day. But the first program is better, and the preferred method - it's cleaner, more efficient programming. Plus, if you need to modify the ON time, you only need to modify one statement, not two statements.
Side note: Are you wondering why I used 17:59 instead of 18:00 in the statements above? See the USING THE IF TIME STATEMENT post in this thread.
In general, you should use a Set and a conditional (If) statement whenever you can, instead of using two conditional statements.
But there are four occasions when a Set statement must not be used:
1. Never add a Set ON or Set OFF into programming which was created using a Vortech, Radion, variable, WAV, SKY, Sol, Hydra/Vega, Prime/Hydra HD, or COR scheduler wizard.
2. Never use a Set ON or Set OFF in the same program as an OSC command. A Set statement is not needed because the OSC command has explicit ON and OFF states.
3. Never use a Set On or Set OFF when it is desired to operate over a range of probe values, such as if using temperature to control a heater.
Let's take an example: we want to have an outlet used for a heater come ON if the temp drops below 77.0 degrees, and stay on until the temp exceeds 78.0 degrees.
Wrong:
Set OFF
If Temp < 77.1 Then ON
If Temp > 77.9 Then OFF
The problem with this program is that it will not cause the outlet to operate over the desired range of temperature; instead, it will operate around a single temp of 77.0 degrees. If the temp drops to 77.0, the heater outlet will turn ON, and it will shut off as soon as the temp goes up to 77.1. The If Temp > 79.9 statement does absolutely nothing here, because the Set OFF will be the only true statement as soon as the temp goes up to 77.0. The result will be that your heater gets switched on and off fairly rapidly. But that's not what we want... we want it to stay on until the temp is raised to 78.
Right:
If Temp < 77.1 Then ON
If Temp > 77.9 Then OFF
In this second simple program, we did not include a Set statement. The outlet will turn ON as soon as the temperature drops below 77.1. It will then stay ON until the temp hits 78.0, and then will turn OFF. It will then stay OFF until the temp goes below 77.1 again, then will turn ON, stay on until the temp once again exceeds 77.9, so on and so forth. This will maintain the tank temperature with the specified 1-degree range.
In summary:
A program with a Set and one If statement will operate around a single threshold.
A program with two If statements testing for low and high values of the same input will operate over a range - i.e., between the two specified thresholds.
Do not mix the two techniques.
4. Never use a Set On or Set OFF when using two switch inputs or LLS values to control an outlet, such as if using a low and high switch to control refilling of an ATO reservoir.
Wrong:
Set OFF
If ResLo CLOSED Then ON
If ResHi Open Then OFF
Right:
If ResLo CLOSED Then ON
If ResHi OPEN Then OFF
One more point about using Set... always use a Set and *one* If statement when testing for the state of a single switch input rather then using two If statements to check for both CLOSED and OPEN states of the same switch input.
This is wrong:
Set OFF
If Switch CLOSED Then ON
If Switch OPEN Then OFF
In this case, the If Switch OPEN Then OFF line is not needed - the Set OFF statement handles turning the outlet OFF whenever the If Switch CLOSED Then ON line is not true. Some people mistakenly think that this will add redundancy - it will not.
This will work, but is not the right way:
If Switch CLOSED Then ON
If Switch OPEN Then OFF
This is the right way:
Set OFF
If Switch CLOSED Then ON
One final note... The OSC (oscillate) command is used to turn an output ON and OFF at regular intervals. OSC has explicit ON and OFF states, so a Set ON or Set OFF statement is not needed and should never be used in any output program containing an OSC statement.
Wrong:
Set OFF
OSC 0:00/5:00/5:00 Then ON
Right:
OSC 0:00/5:00/5:00 Then ON
Bookmarks