Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched.
Close
I am having trouble with understanding the OSCAT_BASIC.SUN_TIME outputs:
2 Issues
1) Sunrise and Sunset outputs are TOD in UTC, I wish to convert them to TOD in local time: It escapes me.
2) When I change the locale and date the output UTC TOD for sunrise and sunset make no sense to me.
1) If I can combine TOD with a date format, and get UTC (UDINT) out, I can use SysTimeRtcConvertUtcToLocal to get local time.
2) For testing I have this simple setup...
When I enter the locale and date as in the OSCAT Basic documentation - the output data matches, and makes some sense - i.e. sunrise is before sunset.
osrCalcSunTime:Standard.R_TRIG;fbSunTime:OSCAT_BASIC.SUN_TIME;//  Calculate sunrise and sunset timesosrCalcSunTime(CLK:=xPLCqCalcSunTime);IFosrCalcSunTime.Q  THEN  fbSunTime(  LATITUDE  :=   47,            //  Charlotte NC 35.2271          LONGITUDE  :=  122,          //  Charlotte NC 80.8431          UTC      :=  D#1970-01-01);END_IFdsDPS_Sun[1].todMidday    :=  fbSunTime.MIDDAY;dsDPS_Sun[1].todSunRise   :=   fbSunTime.SUN_RISE;dsDPS_Sun[1].todSunSet    :=  fbSunTime.SUN_SET;
This makes sense
Midday = 11:16 (noon-ish)
Rise = 6:22 (morning)
Sun = 16:09 (afternoon
When I enter my locale, and today's date. The outputs make no sense to me.
Midday = 06:32
Rise = 16:12
Set = 13:56
I also tried using the CALENDER_CALC function as the rise and set times are listed as being in local time.
However when I compared outputs with alamanc data from my locale at 3 dates in this year (2 in standard time 1 in daylight time) I saw ~45 minute offset. When I checked that this offset held after adjusting locale and time zone to Seatlle, WA - the offsets were completely different, and not consistent.
I have done sunrise sunset calcs in Siemens S7 portal, and in LabVIEW and while getting standard/daylight correct can be an issue to fight with, I was always able to correlate the computed times within a few minutes of almanac times available online.
The target is a Parker PAC controller. It has a RTC and from what I see by way of SysTimeRtcGetTimeZone function it is modern in it's handling of daylight time.
Nevermind - The function block locale coordinates are REAL. My locale is West (negative real) of prime meridian - I was testing with a value that is East (positive real).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am having trouble with understanding the OSCAT_BASIC.SUN_TIME outputs:
2 Issues
1) Sunrise and Sunset outputs are TOD in UTC, I wish to convert them to TOD in local time: It escapes me.
2) When I change the locale and date the output UTC TOD for sunrise and sunset make no sense to me.
1) If I can combine TOD with a date format, and get UTC (UDINT) out, I can use SysTimeRtcConvertUtcToLocal to get local time.
2) For testing I have this simple setup...
When I enter the locale and date as in the OSCAT Basic documentation - the output data matches, and makes some sense - i.e. sunrise is before sunset.
This makes sense
Midday = 11:16 (noon-ish)
Rise = 6:22 (morning)
Sun = 16:09 (afternoon
When I enter my locale, and today's date. The outputs make no sense to me.
Midday = 06:32
Rise = 16:12
Set = 13:56
I also tried using the CALENDER_CALC function as the rise and set times are listed as being in local time.
However when I compared outputs with alamanc data from my locale at 3 dates in this year (2 in standard time 1 in daylight time) I saw ~45 minute offset. When I checked that this offset held after adjusting locale and time zone to Seatlle, WA - the offsets were completely different, and not consistent.
I have done sunrise sunset calcs in Siemens S7 portal, and in LabVIEW and while getting standard/daylight correct can be an issue to fight with, I was always able to correlate the computed times within a few minutes of almanac times available online.
The target is a Parker PAC controller. It has a RTC and from what I see by way of SysTimeRtcGetTimeZone function it is modern in it's handling of daylight time.
Any insight / help is greatly appreciated.
Related
Talk.ru: 1
I'll add that when I add my tie zone -utc offset to these times it still makes no sense to me. I'm thinking I need to read up more on UTC.
Nevermind - The function block locale coordinates are REAL. My locale is West (negative real) of prime meridian - I was testing with a value that is East (positive real).