FB_CalcSunriseSunset
Function block for calculating sunrise and sunset based on the longitude, latitude, reference meridian and time.
The earth is divided into several time zones. Each time zone is associated with a reference meridian. Reference meridian for some of the time zones:
Time zone | Reference meridian |
---|---|
GMT (Greenwich Mean Time) | λGMT = 0° |
CET (Central European Time) | λMEZ = 15° |
CEST (Central European Summer Time) | λCEST = 30° |
In specifying the time, the time according to Greenwich Mean Time (GMT) must be given.
This function block is only available in the PC version of the library. |
VAR_INPUT
fDegreeOfLongitude : LREAL := 8.5;
fDegreeOfLatitude : LREAL := 51.9;
fReferenceMeridian : LREAL;
dCurrentDate : DATE;
fDegreeOfLongitude: Longitude in degrees.
fDegreeofLatitude: Latitude in degrees.
fReferenceMeridian: Reference meridian of the time zone.
dCurrentDate: current date.
VAR_OUTPUT
todSunrise : TOD;
todSunset : TOD;
todSunrise: Sunrise. Output of hour and minute.
todSunset: Sunset. Output of hour and minute.
Example
PROGRAM MAIN
VAR
fbCalcSunriseSunset : FB_CalcSunriseSunset;
todSunrise : TOD;
todSunset : TOD;
fbGetSystemTime : GETSYSTEMTIME;
fileTime : T_FILETIME;
dtCurrentDate : DT;
END_VAR
fbGetSystemTime(timeLoDW =>fileTime.dwLowDateTime,
timeHiDW =>fileTime.dwHighDateTime);
dtCurrentDate:=FILETIME_TO_DT(fileTime);
fbCalcSunriseSunset( fDegreeOfLongitude := 8.5, (* Longitude of Verl *)
fDegreeOfLatitude := 51.9, (* Latitude of Verl *)
fReferenceMeridian := 30.0, (* Central European Summer Time *)
dCurrentDate := DT_TO_DATE(dtCurrentDate),
todSunrise => todSunrise,
todSunset => todSunset);