Jump to content

Good Programming Technique?


SteveSBE

Recommended Posts

Posted

After some help with others in this forum I created the following programs to control the bathroom lights using a version 2 2420M Motion Sensor and a 2476D SwitchLinc Dimmer. The Sensing Mode for the Motion Sensor is set to "On commands only (unchecked)". We wanted varying dimming levels depending on the time of day. Therefore I created and used the "Bath Master" scene that includes just the 2476D. The 2476D "Bath Master" SwitchLinc is also managed by a 2440 RemoteLinc (they are linked).

 

I'd appreciate comments about the efficiency of this technique since I may clone it for the other 3 MS I will be using.

 

Also I noticed the MS takes not just a second...but a couple seconds...to respond. Could this be enhanced with a better programming, linking, and scene techniques?

 

Thanks,

 

Steve

 

Start of Programs

BathMstr1 5:30-Sunrise 80%

If
       On Mon, Tue, Wed, Thu, Fri
       From     5:15:00AM
       To      Sunrise + 19 minutes and 59 seconds (same day)
   And Control 'Bath - Sensor' is switched On
   And Program 'BathMstr6 Switch On' is False
   And Program 'BathMstr9 Motion Timer Enable' is True
Then
       In Scene 'Bath Master' Set 'Bath Master' 8.5 Sec (Ramp Rate)
       In Scene 'Bath Master' Set 'Bath Master' 80% (On Level)
       Set Scene 'Bath Master' On
       Wait  5 minutes 
       In Scene 'Bath Master' Set 'Bath Master' 30.0 Sec (Ramp Rate)
       Set Scene 'Bath Master' Off
       Run Program 'BathMstr1 5:30-Sunrise 80%' (If)
Else
  - No Actions - (To add one, press 'Action')

BathMstr2 Sunrise/set 40%

If
       From    Sunrise + 20 minutes
       To      Sunset  - 20 minutes (same day)
   And Control 'Bath - Sensor' is switched On
   And Program 'BathMstr6 Switch On' is False
   And Program 'BathMstr9 Motion Timer Enable' is True

Then
       In Scene 'Bath Master' Set 'Bath Master' 0.2 Sec (Ramp Rate)
       In Scene 'Bath Master' Set 'Bath Master' 40% (On Level)
       Set Scene 'Bath Master' On
       Wait  5 minutes 
       In Scene 'Bath Master' Set 'Bath Master' 30.0 Sec (Ramp Rate)
       Set Scene 'Bath Master' Off
       Run Program 'BathMstr2 Sunrise/set 40%' (If)
Else
  - No Actions - (To add one, press 'Action')

BathMstr3 Sunset-8pm 30%

If
       From    Sunset  - 19 minutes and 59 seconds
       To       7:59:59PM (same day)
   And Control 'Bath - Sensor' is switched On
   And Program 'BathMstr6 Switch On' is False
   And Program 'BathMstr9 Motion Timer Enable' is True

Then
       In Scene 'Bath Master' Set 'Bath Master' 2.0 Sec (Ramp Rate)
       In Scene 'Bath Master' Set 'Bath Master' 30% (On Level)
       Set Scene 'Bath Master' On
       Wait  5 minutes 
       In Scene 'Bath Master' Set 'Bath Master' 19.0 Sec (Ramp Rate)
       Set Scene 'Bath Master' Off
       Run Program 'BathMstr3 Sunset-8pm 30%' (If)
Else
  - No Actions - (To add one, press 'Action')

BathMstr4 8-12 pm 10%

If
       From     8:00:00PM
       To      11:59:59PM (same day)
   And Control 'Bath - Sensor' is switched On
   And Program 'BathMstr6 Switch On' is False
   And Program 'BathMstr9 Motion Timer Enable' is True
Then
       In Scene 'Bath Master' Set 'Bath Master' 4.5 Sec (Ramp Rate)
       In Scene 'Bath Master' Set 'Bath Master' 10% (On Level)
       Set Scene 'Bath Master' On
       Wait  5 minutes 
       In Scene 'Bath Master' Set 'Bath Master' 19.0 Sec (Ramp Rate)
       Set Scene 'Bath Master' Off
       Run Program 'BathMstr4 8-12 pm 10%' (If)
Else
  - No Actions - (To add one, press 'Action')

BathMstr5 Switch Off

If
       Control 'Bath Master' is switched Off
    Or Control 'Bath Master' is switched Fast Off
Then
       Set 'Bath Master' Off
       Run Program 'BathMstr1 5:30-Sunrise 80%' (If)
       Run Program 'BathMstr2 Sunrise/set 40%' (If)
       Run Program 'BathMstr3 Sunset-8pm 30%' (If)
       Run Program 'BathMstr4 8-12 pm 10%' (If)
       Run Program 'BathMstr6 Switch On' (If)
       Run Program 'BathMstr5 Switch Off' (If)
Else
  - No Actions - (To add one, press 'Action')

BathMstr6 Switch On

If
       Control 'Bath Master' is switched On
    Or Control 'Bath Master' is switched Fast On
    Or Control 'Bath Master' is switched Fade Stop
Then
       Run Program 'BathMstr1 5:30-Sunrise 80%' (If)
       Run Program 'BathMstr2 Sunrise/set 40%' (If)
       Run Program 'BathMstr3 Sunset-8pm 30%' (If)
       Run Program 'BathMstr4 8-12 pm 10%' (If)
       Wait  30 minutes 
       Set 'Bath Master' Off
       Run Program 'BathMstr6 Switch On' (If)
Else
  - No Actions - (To add one, press 'Action')

BathMstr9 Motion Timer Enable

If
  - No Conditions - (To add one, press 'Schedule' or 'Condition')
Then
       Set Program 'BathMstr9 Motion Timer Enable' To Run At Startup
Else
       Set Program 'BathMstr9 Motion Timer Enable' To Not Run At Startup

End of Programs

Posted

The more complex the IF the longer it takes to evaluate. A bigger problem is the changing of the Scene responder Bright level and Ramp rate before turning On the Scene. All the Bright level and Ramp rate information has to be written into the responder device using powerline commands before the Scene is turned On. That all takes time and is redundant after the MS has signaled On within a given time period.

 

Perhaps something like the use of a Folder for each time period with a Program in each folder that invokes a different Scene that has been defined with the responder characteristics you want for that time period. That approach would eliminate all the setting of responder characteristics on the fly and simplify the Program If statements.

 

This is one of those questions that has many different solutions. I am sure others will have more ideas. The objective is to reduce the complexity of the If statements that have to be evaluated every time the MS turns On and eliminate all the dynamic changing of Scene responder characteristics, particularly on every MS On.

Posted

Lee -

 

Thanks a bunch. The folder technique (see http://screencast.com/t/3lPpLGOkMn) and the use of separate scenes made the responses MUCH quicker.

 

I have a different problem with my programs though. Below is an example of one of my programs (the new version). (All of my programs are coded similar to this one.) In the "then", I have a 5 minute wait in the code before turning off the scene. Indeed, after 5 minutes the "then" statement continues running the code after the "wait" and turns the scene off...that is, the lights go out. This happens even though there is motion in the room and the LED in the MS detects motion (I see it blinking). I thought that when the Sensing Mode for the Motion Sensor is set to "On commands only (unchecked)", the MS is "switched on" every time it senses motion. If so, the if statement should evaluate to true, and the "then" statement (and the 5 minute wait) re-started. Do I misunderstand how this works?

 

If
       Control 'Bath - Sensor' is switched On

Then
       Set Scene 'sc Bath Master 40%' On
       Wait  5 minutes
       In Scene 'sc Bath Master 40%' Set 'Bath Master' 30.0 Sec (Ramp Rate)
       Set Scene 'sc Bath Master 40%' Off
       In Scene 'sc Bath Master 40%' Set 'Bath Master' 0.2 Sec (Ramp Rate)
       Run Program 'p BathMstr2 Sunrise/set 40%' (If)

Else
  - No Actions - (To add one, press 'Action')

 

 

Thanks again for the advice...

 

Steve

Posted

The On Only Motion Sensor option suppresses the Off commands. The next On command still waits until the Motion Sensor Timeout interval has expired. The (Occupancy) Sense mode is the option that generates an On command for every motion detected regardless of the Timeout interval.

 

Someone else will have to cover how the If reevaluation may or may not interrupt execution. I posted how I thought it worked and someone else said that was not correct so I think it best for someone who actually knows post the impact of additional commands. Since the Control On you are using in the IF never changes True/False state that may have a bearing on the results you are seeing.

Guest
This topic is now closed to further replies.

  • Recently Browsing

    • No registered users viewing this page.
  • Forum Statistics

    • Total Topics
      37k
    • Total Posts
      371.4k
×
×
  • Create New...