OSCAT_BASIC.SUN_TIME

Begonnen von S1ack, 08. Mai 2019, 16:36:20

Vorheriges Thema - Nächstes Thema

0 Mitglieder und 2 Gäste betrachten dieses Thema.

S1ack

Guten Abend,

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 times
osrCalcSunTime( CLK := xPLCqCalcSunTime);
IF osrCalcSunTime.Q THEN
fbSunTime( LATITUDE := 47, // Charlotte NC 35.2271
LONGITUDE := 122, // Charlotte NC 80.8431
UTC := D#1970-01-01 );
END_IF
dsDPS_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.

Any insight / help is greatly appreciated.

S1ack

ZitatWhen 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 should add that when I add my time zone-utc offset to these (4 hours while in daylight time) it still makes no sense.

S1ack

 :-[

Never mind - sign issue on the coordinates. I was testing with a loale East of the prime meridian, my locale is WEST.
Sometimes it helps to just type it all out.