FB_BA_CalcSunPos

FB_BA_CalcSunPos 1:

Calculation of sun position based on the date, time, longitude and latitude.

The position of the sun for a given point in time can be calculated according to common methods with a defined accuracy. For applications with moderate requirements, the present function block is sufficient. As the basis for this, the SUNAE algorithm was used, which represents a favorable compromise between accuracy and computing effort.

The position of the sun at a fixed observation point is normally determined by specifying two angles. One angle indicates the height above the horizon; 0° means that the sun is in the horizontal plane of the location; a value of 90° means that the is perpendicular to the observer. The other angle indicates the direction at which the sun is positioned. The SUNAE algorithm is used to distinguish whether the observer is standing on the northern hemisphere (longitude > 0 degrees) or on the southern hemisphere (longitude < 0 degrees) of the earth. If the observation point is in the northern hemisphere is, then a value of 0° is assigned for the northern sun direction and it then runs in the clockwise direction around the compass, i.e. 90° is east, 180° is south, 270° is west etc. If the point of observation is in the southern hemisphere, then 0° corresponds to the southern direction and it then runs in the counter clockwise direction, i.e. 90° is east, 180° is north, 270° is west etc.

FB_BA_CalcSunPos 2:

The time has to be specified as coordinated world time (UTC, Universal Time Coordinated, previously referred to as GMT, Greenwich Mean Time).

The latitude is the northerly or southerly distance of a location on the Earth’s surface from the equator, in degrees [°]. The latitude can assume a value from 0° (at the equator) to ±90° (at the poles). A positive sign thereby indicates a northern direction and a negative sign a southern direction. The longitude is an angle that can assume values up to ±180° starting from the prime meridian 0° (an artificially determined North-South line). A positive sign indicates a longitude in an eastern direction and a negative sign in a western direction. Examples:

Location

Longitude

Latitude

Sydney, Australia

151.2°

-33.9°

New York, USA

-74.0

40.7°

London, England

-0.1°

51.5°

Moscow, Russia

37.6°

55.7°

Peking, China

116.3°

39.9°

Dubai, United Arab Emirates

55.3°

25.4°

Rio de Janeiro, Brazil

-43.2°

-22.9°

Hawaii, USA

-155.8°

20.2°

Verl, Germany

8.5°

51.9°

If the function block FB_BA_CalcSunPos returns a negative value for the solar altitude rSunElv, the sun is invisible. This can be used to determine sunrise and sunset.

VAR_INPUT

rDegLngd    : REAL;
rDegLatd    : REAL;
stUTC       : TIMESTRUCT;

rDegLngd: Longitude [°].

rDegLatd: Latitude [°].

stUTC: Input of the current time as coordinated world time (see TIMESTRUCT). The function block FB_BA_GetTime can be used to read this time from a target system.

VAR_OUTPUT

rSunAzm     : REAL;
rSunElv     : REAL;

rSunAzm: Direction of the sun (northern hemisphere: 0° north ... 90° east ... 180° south ... 270° west ... / southern hemisphere: 0° south ... 90° east ... 180° north ... 270° west ...).

rSunElv: Height of the sun (0° horizontal - 90° vertical).

Requirements

Development environment

Required PLC library

TwinCAT from v3.1.4024.7

Tc3_BA from v1.1.6.0