Please login or register.

Login with username, password and session length

Author Topic: Artificial Sunset and Sunrise  (Read 45734 times)

steven r

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 74
  • Posts: 2189
  • Halloween with X10
Artificial Sunset and Sunrise
« on: April 02, 2008, 08:33:42 PM »

Objective dim or brighten a light over a period of 30 minutes.

This uses 2 macros programed with the AHP software.

First you will need to determine what the minimum brightness that is visible for your light at night. This will likely be higher than you think. Let's say for example that your light is no longer visible at 10%. It could easily be higher but this is a good figure for this example. This will mean your dusk range will need to be from 100% down to 10%. Likewise your dawn range will be from 10% to 100%. That means for this example you have a range of 90 to divide by 30 min or 15 every 5 min. So this is how I would do it...

Dusk   P11 On   
(C9) Steven Lamp   
Brighten then dim to 98%                       ;Absolute setting of 98% brightness
Delay for 05:00
(C9) Steven Lamp   Dim by 15%             ;relative dim by 15%
Delay for 05:00
(C9) Steven Lamp   Dim by 15%
Delay for 05:00
(C9) Steven Lamp   Dim by 15%
Delay for 05:00
(C9) Steven Lamp   Dim by 15%
Delay for 05:00
(C9) Steven Lamp   Dim by 15%
Delay for 05:00
(C9) Steven Lamp   Dim by 15%
(C9) Steven Lamp   OFF                        ;If you are not using a soft start module, omit this step
                                                           ;and say a prayer that you don't have a power interruption

Dawn   P12 On   
(C9) Steven Lamp   On                         ;Omit if not using a soft start module
(C9) Steven Lamp   Brighten by 15%      ;relative brighten by 15%
Delay for 05:00
(C9) Steven Lamp   Brighten by 15%
Delay for 05:00
(C9) Steven Lamp   Brighten by 15%
Delay for 05:00
(C9) Steven Lamp   Brighten by 15%
Delay for 05:00
(C9) Steven Lamp   Brighten by 15%
Delay for 05:00
(C9) Steven Lamp   Brighten by 15%
Delay for 05:00
(C9) Steven Lamp   Brighten by 15%

Keep in mind that the percent "dimming" or "brightening" is an incremental amount of full brightness and not based on the current light level. i.e. Unlike your elementary math problem where a 10% loss of money from a starting point of $100 would leave you with $90 followed by another 10% loss of money leaving you with $81, a 10% dim from 100% is 90% followed another dim of 10% is 80%.
( This piece of trivia presented for all the math teachers out there.  ;) )

If the above light change is too abrupt, use increments in smaller amounts with a shorter delay between the increments.
e.g. A 3% change every minute. I don't think a change this small would be noticeable at least not for most lighting situations for most people. That said, the perceptional change may not be linear. i.e. A 3% increase from a level of 10% light may be more noticeable than from 95% to 98%.

For any other arrangements, I'll leave the math to you.  ;)


Now simply program an on time for each macro and there you have it.

Teaser: A smaller looping macro could be made to handle dusk and dawn but the above is easier to understand. The looping macro would need an exit built in with flags or time. A timed window approach would be the easiest but would only work for a regular wakeup time. One using flags would be a lot trickier and might involve the using so many else macros that the above would be more practical.
« Last Edit: April 03, 2008, 08:06:55 PM by steven r »
Logged
BVC let's me tell my camera where to go!
:) Murphy is my beta testing pal. He helps me find problems whether I like it or not. :)

steven r

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 74
  • Posts: 2189
  • Halloween with X10
Re: Artificial Sunset and Sunrise
« Reply #1 on: April 03, 2008, 07:50:40 PM »

Timed Window Loop Approach

This assumes that the softstart module was predimmed the night before and turned off.
This example also assumes the start of your artificial dawn to be at 6:00 AM and uses a similar brightness range to before.
Uses one macro and a dummy module for triggering the loop.

Macro P14 ON - Triggers On P14 on between 5:55 AM and 6:40 AM
(C9) Steven Lamp   On                           
(C9) Steven Lamp   Brighten by 3%      ;relative brighten by 3%     
delay 1 minute
P14 ON                                              ;Triggers dummy module set as P14 which in turn loops the macro.

Nothing will happen if an attempt to trigger the macro is made outside the time window and all brightening will stop at 6:40 AM regardless of the light state.

You would set the macro time to come on at 6:00 AM in this case.

One advantage / disadvantage to this is the built-in 1 minute sleep switch. Should you manually turn off the light at any time while the macro is running, the light will come back on at the previous brightness and continue to brighten within a minute.
« Last Edit: April 03, 2008, 08:43:33 PM by steven r »
Logged
BVC let's me tell my camera where to go!
:) Murphy is my beta testing pal. He helps me find problems whether I like it or not. :)

steven r

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 74
  • Posts: 2189
  • Halloween with X10
Re: Artificial Sunset and Sunrise
« Reply #2 on: April 03, 2008, 08:42:24 PM »

Called Loop Approach
( In the continuing saga of ways to wakeup gently to light.  :) )

This assumes that the softstart module was predimmed the night before and turned off.
Uses 2 macros and a dummy module for triggering the loop.

Macro P13 ON                                   ;This macro starts and stops the loop.
Flag 9 On                                           ;Sets the flag needed for the loop to run
P14 On
delay 40 minutes
Flag 9 Off                                           ;Clears the flag to stop the loop

Macro P14 ON - Triggers on P14 On and flag 9 set
(C9) Steven Lamp   On                           
(C9) Steven Lamp   Brighten by 3%      ;relative brighten by 3%     
delay 1 minute
P14 ON                                              ;Triggers dummy module set as P14 which in turn loops the macro.

In this case, the light will continue to brighten by 3% every minute till flag 9 is cleared.

Set your wakeup time(s) as one or more of the timers for macro P13.

A third optional macro could be used as an escape macro. It would be set as the same HC/UC as the light you were controlling.

*Macro C9 OFF - Triggers on C9 Off and flag 9 set
Clear flag 9                                          ;Manually sending an X10 signal to turn off the light would also stop the loop
delay 70 sec
C9 Off                                                 ;Makes sure light is left off

*I'm doing more testing but there appears to be a bug, possibly in AHP, causing this macro to execute and clear the flag. In my test, my flag clears when this macro is present. I haven't found anywhere an off signal is being sent. When I renamed the macro as A4 to test, the flag isn't cleared.
« Last Edit: April 03, 2008, 10:42:22 PM by steven r »
Logged
BVC let's me tell my camera where to go!
:) Murphy is my beta testing pal. He helps me find problems whether I like it or not. :)

bilyth

  • Full Member
  • ***
  • Helpful Post Rating: 2
  • Posts: 63
Re: Artificial Sunset and Sunrise
« Reply #3 on: April 12, 2008, 11:06:13 AM »

edited:

ok, i'm getting it partially (the called loop method)...

it appears as though the macro is looping- ie when i test it p14 triggers c9 on & after the delay it appears to trigger p14 again (the macro icon flashes)..but it doesn't carry out a further % brighten.

not sure why...

as with your p14 macro, do you have c9 on first (to a set low %) & then C9 brighten 3% (two separate steps)? i was wondering whether or not it was looping but bringing it back down to the original starting level (so instead than continually brightening by 3%..it would go back to the orginal & bump it up 3%)- thus no visual difference.

i tried removing the c9 on first step & leaving my light on & executing the brighten 3% only...it still seems to only bring it up once by 3%...so maybe it's not looping at all; i don't know.

i might be missing something. any input?
« Last Edit: April 12, 2008, 01:19:33 PM by bilyth »
Logged

steven r

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 74
  • Posts: 2189
  • Halloween with X10
Re: Artificial Sunset and Sunrise
« Reply #4 on: April 12, 2008, 01:59:28 PM »

No the the flag and UC numbers do not need to be the same. It was just a coincidence that the I was controlling a module numbered 9 and the next flag I had available was 9 also.

I'd suggest that you try it again but do not make the optional 3rd macro as I'm still debating as to why it's not working the way I expected. I'm leaning to it being an AHP bug as I can't find anything wrong with my logic.

If you continue to have problems, try creating an entire new AHP file (save your current one first), program it exactly as I have, and temporally change the UC of your module to test.

AHP can execute multiple macros at the same time but I'm not sure as to how it handles priorities in extreme cases.

Again this did work in my test with a soft start wall switch when I removed the 3rd optional macro.

Logged
BVC let's me tell my camera where to go!
:) Murphy is my beta testing pal. He helps me find problems whether I like it or not. :)

bilyth

  • Full Member
  • ***
  • Helpful Post Rating: 2
  • Posts: 63
Re: Artificial Sunset and Sunrise
« Reply #5 on: April 12, 2008, 11:10:33 PM »

ok thanks.

i will try that. I just thought i'd post a screen capture of the loop macro to make sure i have it right.



(i'm using 3 second delay for convenience while testing everything)

i didn't post the macro to start & stop the loop because it seems to work fine. So, what i can see happening is start/stop macro is triggered..it turns on the dummy switch..i can see that it triggers the loop macro..& then the light brightens one step..i can see the dummy switch go off then back on..then the loop macro icon flashes (as if it's triggered)..but the next increment in brightening doesn't turn on. Nothing happens after that..then the flag gets cleared.

While nothing is happening- if i manually flick the dummy switch on & off (by clicking the dummy icon)..it will trigger the rest of the macro making it jump incrementally each time i manually flick on & off. So, the steps seem to be all there. It's just not "triggering" the loop.

Anyways, i will try what you suggested.. but here's the screen capture just to see if i'm missing something.

ps yes, i'm avoiding the 3rd macro. if i can get it to work..these 2 macros should suffice for my purposes.
Logged

bilyth

  • Full Member
  • ***
  • Helpful Post Rating: 2
  • Posts: 63
Re: Artificial Sunset and Sunrise
« Reply #6 on: April 12, 2008, 11:33:37 PM »

yeah, i tried it again. new file..different UC code for module & macros.

still no looping action.
Logged

steven r

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 74
  • Posts: 2189
  • Halloween with X10
Re: Artificial Sunset and Sunrise
« Reply #7 on: April 13, 2008, 12:14:34 AM »

....i can see the dummy switch go off then back on.....
While it shouldn't matter, the dummy switch shouldn't be receiving an off signal at all. It makes me wonder if something else is going on at the same time.

What do you see happening in the activity monitor?

In AHP under Tools / Preferences / Macro Operations check the box that says "'Issue 'On' instead of 'bright 100%'".

Then try adding an on command before the brighten command in the loop. Also even for the test I'd use a delay of at least 5-10 sec.

« Last Edit: April 13, 2008, 12:31:18 AM by steven r »
Logged
BVC let's me tell my camera where to go!
:) Murphy is my beta testing pal. He helps me find problems whether I like it or not. :)

bilyth

  • Full Member
  • ***
  • Helpful Post Rating: 2
  • Posts: 63
Re: Artificial Sunset and Sunrise
« Reply #8 on: April 13, 2008, 03:22:13 PM »

ok, your suggestions are helping. i can get some loop action now.

the issue i'm having is this: let's say my macro is set to slowly brighten 3% at a time.

if i run the macro with the lamp "on" but at 0%- it runs beautifully. But if i run it with the lamp starting as "off"..it will jump to ~40% level first, then slowly brighten by 3%.

This is a problem because i prefer to have this whole thing work from starting with the light "off" (& your instructions sound like they're geared towards a soft start module starting in the off position anyway).

Any ideas?

edit:
ok, experimented a bit more..i also notice this- if i run the macro starting at lamp "on" but 0%..the lamp will reach a visual brightness similar to %100 when it gets to around %50 (weird).

While, if i start the macro at lamp "off"..it will start at a visual brightness similar to %40 & brighten from there.

don't know if this hints at all to a solution to my problem. The biggest issue is that starting from "off" it won't start at 3% but rather similar to %40. i need to fix this.

ps i know you can't get a macro to call itself- that's why we're using this whole loop thing...but is it possible for a macro to call another macro?
« Last Edit: April 13, 2008, 04:40:48 PM by bilyth »
Logged

steven r

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 74
  • Posts: 2189
  • Halloween with X10
Re: Artificial Sunset and Sunrise
« Reply #9 on: April 13, 2008, 06:24:24 PM »

I use a combination of my above suggestions for my setup.
One thing I've discovered for my soft start wall switch is that is takes way more than 10 dims by 10% to go from full brightness down to almost no light. I don't know if this is true with all switches or just a unique feature / quirk  of the new switches.

Once I do dim to the minimum, I can turn off the light and the example I gave does work for the brightening.

...i know you can't get a macro to call itself- that's why we're using this whole loop thing...but is it possible for a macro to call another macro?
Yes. Via a dummy module of the same name just like when a macro uses a dummy module to call itself.
e.g. If you want macro M1 to call macro M2 you need a dummy module set as M2.
Logged
BVC let's me tell my camera where to go!
:) Murphy is my beta testing pal. He helps me find problems whether I like it or not. :)

bilyth

  • Full Member
  • ***
  • Helpful Post Rating: 2
  • Posts: 63
Re: Artificial Sunset and Sunrise
« Reply #10 on: April 14, 2008, 11:12:07 AM »

ok, i got it finally.  :D

for me, to make it work..i had to add a "lamp on at 1%" in the trigger macro before setting the flag. If i didn't, the loop would start with the lamp jumping to around 40% (don't know why). This way, the lamp goes on at 1%..then the loop starts & brightens from there.

This is for my bedside lamp. For the ceiling (wall switch)..i can't get it to work (because it isn't acting like soft start). Even if i keep it on a low % during the night, when the dawn trigger & loop kick in.. it seems like the "on" step (in the loop macro-before "brighten") causes the light to go to full (100%) & back each time it increases by 1%. I'm no sure how to make the loop work without a soft start switch. (i tried removing the "on" but the loop won't start). hopefully the ws12a that i'm getting will work properly.

I've got a nice dusk loop working for both though. (although the overhead needs to go to full brightness before it starts to dim too..kinda annoying when getting ready for bed)...

Now, i'm wondering if i can add some advanced features...for ex. a way to add a snooze feature: turning off lamp module during dawn loop will turn off both lamp & overhead (when i get it working) for x minutes..then turn both back on to its same level of brightness & continue the loop. have you tried anything like this?

i'm guessing it will be something like condition: lamp module off & dummy module on..macro turns off both lights & flag for "x" minutes..then set flag. But i'm not sure it will go back to the same brightness...i guess i could just make it go to a certain brightness..chances are i won't be snoozing unless it's near full brighness anyways...
Logged

zatomik

  • Newbie
  • Helpful Post Rating: 0
  • Posts: 1
Re: Artificial Sunset and Sunrise
« Reply #11 on: October 31, 2011, 11:44:04 PM »

I am trying the OP's looping macro using the "Pro Inductive Dimmer Switch" (pretty sure it's softstart).  Tested tonight with shortened delay times (1 sec between issuing the "brighten 3%" commands and 25 sec delay in the flagging macro that start/stops the loop) and it worked really well.

I already use a macro triggered from my remote to shut off the lights in the bedroom at night so I modified it to: [[MODULE ID]] dim 88%|delay 1 s|[[MODULE ID]] dim 88%|delay 1 s|[[MODULE ID]] dim 88%|delay 1 s| [[MODULE ID]] OFF.  This prepares the lights much better than my previous approach which was to set them ON them DIM in the beginning of the sunrise macro (used to give a bright flash at the beginning of the "sunrise" sequence which defeats the purpose a bit). 

Thanks for posting this - looping and exiting the loop using flags are extremely useful.

Let's hope I wake more naturally to the "sunrise" tomorrow - I'm really tired of that "Sting" CD in my alarm clock radio and I hope to be awake in time to preemptively switch it off.


Called Loop Approach
( In the continuing saga of ways to wakeup gently to light.  :) )

This assumes that the softstart module was predimmed the night before and turned off.
Uses 2 macros and a dummy module for triggering the loop.

Macro P13 ON                                   ;This macro starts and stops the loop.
Flag 9 On                                           ;Sets the flag needed for the loop to run
P14 On
delay 40 minutes
Flag 9 Off                                           ;Clears the flag to stop the loop

Macro P14 ON - Triggers on P14 On and flag 9 set
(C9) Steven Lamp   On                           
(C9) Steven Lamp   Brighten by 3%      ;relative brighten by 3%     
delay 1 minute
P14 ON                                              ;Triggers dummy module set as P14 which in turn loops the macro.

In this case, the light will continue to brighten by 3% every minute till flag 9 is cleared.

Set your wakeup time(s) as one or more of the timers for macro P13.

A third optional macro could be used as an escape macro. It would be set as the same HC/UC as the light you were controlling.

*Macro C9 OFF - Triggers on C9 Off and flag 9 set
Clear flag 9                                          ;Manually sending an X10 signal to turn off the light would also stop the loop
delay 70 sec
C9 Off                                                 ;Makes sure light is left off

*I'm doing more testing but there appears to be a bug, possibly in AHP, causing this macro to execute and clear the flag. In my test, my flag clears when this macro is present. I haven't found anywhere an off signal is being sent. When I renamed the macro as A4 to test, the flag isn't cleared.
Logged
 

X10.com | About X10 | X10 Security Systems | Cameras| Package Deals
© Copyright 2014-2016 X10.com All rights reserved.