FB_SPA
At the input all available values for the location definition and type of calculation are specified.
The calculation is performed during a function block cycle. The
results are immediately available at the output.
Due to the complex internal calculation steps processing takes
system performance.
VAR_INPUT
VAR_INPUT
stTime :ST_SPA_TIMESTRUCT; (* local date and time (year, month, day, hour, minute, second) *)
fTimezone :LREAL; (* Observer time zone (negative west of Greenwich) *)
(* valid range: -18 TO 18 hours, error code: 8 *)
fDelta_t :LREAL:=66; (* Difference between earth rotation time and terrestrial time *)
(* It is derived from observation only and is reported in this *)
(* bulletin: http://maia.usno.navy.mil/ser7/ser7.dat, *)
(* where delta_t = 32.184 + (TAI-UTC) + DUT1 *)
(* valid range: -8000 to 8000 seconds, error code: 7 *)
fLongitude :LREAL; (* Observer longitude (negative west of Greenwich) *)
(* valid range: -180 to 180 degrees, error code: 9 *)
fLatitude :LREAL; (* Observer latitude (negative south of equator) *)
(* valid range: -90 to 90 degrees, error code: 10 *)
fElevation :LREAL; (* Observer elevation [meters] *)
(* valid range: -6500000 or higher meters, error code: 11 *)
fPressure :LREAL:=1000; (* Annual average local pressure [millibars] *)
(* valid range: 0 to 5000 millibars, error code: 12 *)
fTemperature :LREAL; (* Annual average local temperature [degrees Celsius] *)
(* valid range: -273 to 6000 degrees Celsius, error code; 13 *)
fSlope :LREAL; (* Surface slope (measured from the horizontal plane) *)
(* valid range: -360 to 360 degrees, error code: 14 *)
fAzm_rotation :LREAL; (* Surface azimuth rotation (measured from south to projection of *)
(* surface normal on horizontal plane, negative west) *)
(* valid range: -360 to 360 degrees, error code: 15 *)
fAtmos_refract :LREAL:=0.5667; (* Atmospheric refraction at sunrise and sunset (0.5667 deg is typ.)*)
(* valid range: -5 to 5 degrees, error code: 16 *)
eFunction :E_SPA_FunctionCode:=eSPA_ZA;(* Switch to choose functions for desired output *)
END_VAR
stTime |
The date and the local time are specified via stTime. This structure is of type ST_SPA_TIMESTRUCT. |
fTimezone |
The required date with the corresponding time can be specified in local time via the above variable. The respective time zone is added via fTimezone. The time zone is always based on Greenwich (London). (The prime meridian, i.e. 0° geographic longitude, also passes through Greenwich). The following applies in relation to the coordinated world time: UTC+1 = Central European Time; UTC+2 = Central European Summer Time. |
fDelta_t |
The input variable fDelta_t is used for balancing the time scales used. A standard value is 66. A more detailed description of the different time scales can be found on the overview page. |
fLongitude |
fLongitude indicates the longitude in degrees [°]. It is positive to the east of Greenwich. |
fLatitude |
fLatitude indicates the latitude in degrees [°]. It is positive to the north of the equator and negative to the south. |
fElevation |
The altitude of the location also has a small effect on the calculation of the sun angles. fElevation indicates the height in metres above mean sea level. |
fPressure |
The atmospheric pressure at the location is specified in millibar [mbar] via the input variable fPressure. The annual average is specified. |
fTemperature |
The temperature at the location is specified via the input variable fTemperature in °C. The annual average is specified. |
fSlope |
Via fSlope a surface inclination can be specified in degrees [°]. It is used for calculating the special angle of incidence fIncidence. If fSlope is zero, the angle of incidence is the same as the zenith angle. |
fAzm_rotation |
fAzm_rotation can be used to adjust the alignment (in degrees [°]) of the observer or the surface inclined by fSlope. For north alignment the value is 0°. From there the alignment angle increases clockwise (positive values, as does the azimuth of the sun angle). It is also used for calculating the special angle of incidence fIncidence. Is fSlope is zero, the angle of incidence is the same as the zenith angle, irrespective of fAzm_rotation. If fAzm_rotation is the same as the sun angle fAzimuth, the following applies: fIncidence = fZenith + fSlope. This is illustrated the following 2D diagram.
|
fAtmos_refract |
Refraction in the atmosphere can have a significant effect on the zenith angle of the sun, particularly for shallow sun angles. The input variable fAtmos_refract is used as a correction factor for the atmospheric distraction at sunrise and sunset. A standard value is 0.5667. |
eFunction |
Via this enumeration value (E_SPA_FunctionCode) the type of calculations can be selected. For example, the calculation can be limited to the sun angles, if information on sunrise etc. is not required. |
VAR_OUTPUT
VAR_OUTPUT
fZenith :LREAL; (* topocentric zenith angle [degrees] *)
fAzimuth :LREAL; (* topocentric azimuth angle (eastward from north) [ 0 to 360 degrees] *)
fAzimuth180 :LREAL; (* topocentric azimuth angle (westward from south) [-180 to 180 degrees] *)
fIncidence :LREAL; (* surface incidence angle [degrees] *)
fSuntransit :LREAL; (* local sun transit time (or solar noon) [fractional hour] *)
fSunrise :LREAL; (* local sunrise time (+/- 30 seconds) [fractional hour] *)
fSunset :LREAL; (* local sunset TIME (+/- 30 seconds) [fractional hour] *)
bError :BOOL; (* error flag *)
iErrorCode :UINT; (* error code *)
END_VAR
fZenith |
The zenith angle of the sun is defined as the angle between the
vertical above the observer (zenith) and the connecting line
between the observer and the sun. If the sun is directly vertical
above the observer, the zenith angle is 0°. |
fAzimuth |
The azimuth coincides with the horizon. North is 0°, with the value increasing in clockwise direction (east = 90°, south=180°, west=270°). A diagrammatic illustration of the sun angles can be found on the overview page. |
fAzimuth180 |
This value has the same meaning of the azimuth, although with azimuth180 the value 0° is allocated to south. From there the value increases positively in clockwise direction and negatively in counter-clockwise direction (azimuth-180° = azimuth180) |
fIncidence |
fIncidence indicates the angle of solar incidence in relation to the surface specified at the input. If the surface is horizontal fIncidence matches the value of fZenith. |
fSuntransit |
fSuntransit indicates the time of the solar apex. It is specified in hours and used the time zone created at the input. |
fSunrise |
fSunrise indicates the sunrise time. It is specified in hours and used the time zone created at the input. |
fSunset |
fSunset indicates the sunset time. It is specified in hours and used the time zone created at the input. |
bError |
bError is TRUE if an error has occurred. In this case iErrorCode indicates the respective error code. |
iErrorCode |
iErrorCode indicates the error value for the calculation. If an error has occurred this value is not equal zero. All possible error values are summarised in the enumeration E_SPA_error code. |
Note: The following typecasting can be used for converting the variable fSunrise (same procedure for fSuntransit and fSunset) to time format:
tSunrise := LREAL_TO_TIME(fbSPA.fSunrise*60*60*1000);
Requirements
Development environment |
Target platform |
PLC libraries to be linked |
---|---|---|
TwinCAT v2.10 build >= 1320 |
PC or CX (x86, ARM) |
TcSPA.Lib |