Sunday, March 25, 2007

starCOMUltra and Clearing up the RF Airspace

One of the new features of sCU is the addition of 32 software timers! This makes using the Hawkeye motion sensors with the WGL800 much more reliable. Now, I can start a software timer when a motion sensor is triggered, and rather than relying on receiving the OFF signal from the sensor, my system just waits until the timer has expired. This increases accuracy of turning off lights in rooms with no motion since there's no chance the OFF signal got lost colliding with another sensor's signal (especially since there are over 30 sensors in our system). Furthermore, since I'm not relying on the OFF signal, this allows me to change the timeout period of the sensors to their maximum (or near maximum) values. This reduces the amount of RF traffic since OFF signals won't be coming back every 1, 2, 4 or 8 minutes - especially in areas of high activity where the sensors could be triggering ON and OFF a lot. The end result is less RF traffic and better reliability for the X10 wireless part of our system.

Setting up software timers is easy in sCU. First, define them:
    ScriptTimers.Item(4).Name = "KitchenMotion";

Set them upon detection of motion:

function AUXPorts::AUX1_LineIn(Line) {
switch(Line) {
case KitchenMotionOn :
if (DarkCheck(KitchenDark)!=0 &&
Devices.X10Devices.Item("SinkLight").State==0) {
Devices.X10Devices.Item("SinkLight").State=1;
}
MotionChange(KitchenMotion,1);
ScriptTimers.Item("KitchenMotion").Time = 90;
break;
}
}

Finally, do something when the timer expires:

function ScriptTimers::Trigger(Index) {
switch(Index) {
case 4: // KitchenMotion
if (Devices.X10Devices.Item("SinkLight").State==1 &&
Devices.Flags.Item("DarkOutside").State==1) {
Devices.X10Devices.Item("SinkLight").State=0;
}
MotionChange(KitchenMotion,0);
break;
}
}

No comments:

Post a Comment