What's wrong with Astro_Clock ???
Ad_My_Xperience
Posts: 73
Hi guys,
Before I used i!-TimeManager because his built-in triggers for sunrise and sunset to manage my Lutron lighting.
But 2 times a year I had problem with DST and I had to change my GMT offset (-5 or -4) and when I asked a solution, someone on this forum recommends to use Astro_Clock and it's what I did.
I've defined these variables :
persistent char Sunrise[8]
persistent char Sunset[8]
volatile double Gmt_Offset = -5
VOLATILE double dTmLocLong = -71.25
VOLATILE double dTmLocLat = 46.82
In DEFINE_PROGRAM section I use this syntax to retreive sunset and sunrise once a day:
IF (TIME = '00:01:00')
{
WAIT 20
{
Sunrise = ''
Sunset = ''
ASTRO_CLOCK(dTmLocLong, dTmLocLat, Gmt_Offset, ldate, Sunrise, Sunset)
}
}
After I add ':00' to sunset variable to have a value in time format ex.: 17:32:00
The first problem is : one day I received good sunrise and sunset time and the next day I received sunrise and sunset like if DST is active.
The second problem is : I want to trigger my lighting system at the sunset and I use this syntaxe in DEFINE_PROGRAM section : IF (TIME == Sunset) and trigger never happens...
Someone has an idea ?
Thanks
Mike
Before I used i!-TimeManager because his built-in triggers for sunrise and sunset to manage my Lutron lighting.
But 2 times a year I had problem with DST and I had to change my GMT offset (-5 or -4) and when I asked a solution, someone on this forum recommends to use Astro_Clock and it's what I did.
I've defined these variables :
persistent char Sunrise[8]
persistent char Sunset[8]
volatile double Gmt_Offset = -5
VOLATILE double dTmLocLong = -71.25
VOLATILE double dTmLocLat = 46.82
In DEFINE_PROGRAM section I use this syntax to retreive sunset and sunrise once a day:
IF (TIME = '00:01:00')
{
WAIT 20
{
Sunrise = ''
Sunset = ''
ASTRO_CLOCK(dTmLocLong, dTmLocLat, Gmt_Offset, ldate, Sunrise, Sunset)
}
}
After I add ':00' to sunset variable to have a value in time format ex.: 17:32:00
The first problem is : one day I received good sunrise and sunset time and the next day I received sunrise and sunset like if DST is active.
The second problem is : I want to trigger my lighting system at the sunset and I use this syntaxe in DEFINE_PROGRAM section : IF (TIME == Sunset) and trigger never happens...
Someone has an idea ?
Thanks
Mike
0
Comments
There's a little side bar issue I'll mention prior to dealing with your question. We are all moving / moved away from doing this kind of thing in the Define_Program section. The way your code is written the IF(TIME='00:01:00') conditional is firing about 5000 times a second. For the vast majority of the day it's obviously not finding the value it needs to fire. So, that's a lot of string examination for no reason. Although I would not do this in DEFINE_PROGARM myself, if you're dead-set on doing so, perhaps a better way might be to put the whole mess inside a wait 600 which will at least quit making DEFINE_PROGRAM examine the time string 5000+ times a second.
Something like this might work:
Now, to your question...
I have never had any issues with ASTRO_CLCOK myself. I'm not sure what your value for Gmt_Offset is prior to running the routine but I'd check to see what that is. Perhaps you're doing some math on that so that ASTRO_CLOCK spits out an adjusted time string. I tend to not do this myself and allow for DST/ST calculations to happen elsewhere in code. In my case I have clients who observe DST and dont'. So, my code is written in such a way that I just check the "Observes DSST" box so-to-speak and the code doesn't need to be altered further. ASTRO_CLOCK just spits out normal non-adjusted times.
You might want to set up a test bed where you can hit a fake device button that triggers the ASTRO_CLOCK rotuine and use "Send_String 0," 'Gmt_Offset is:',itoa(Gmt_Offset)"
prior to running the calculation and watch in terminal to see what value is being passed in.
Hope that helps.
Eric