SolarNrel (FB)
FUNCTION_BLOCK SolarNrel EXTENDS AbbLConCA
This function block calculates the position of the sun depending on the date, time, and localization. It also includes a function that corrects the value of the elevation thanks to the local pressure, temperature and refraction of atmosphere at sunrise and sunset. This function embeds the NREL’s algorithm. The limitation of this function is the number of outputs which are the azimuth, elevation (uncorrected) and corrected elevation. These outputs are the topocentric coordinates of the sun which use the observer’s location as the center of the coordinate system. Any additional information about the algorithm can be found on the NREL website
- InOut:
Scope
Name
Type
Initial
Comment
Inherited from
Input
EnableBOOLFALSE
A rising edge (Enable = TRUE) starts the operation, the output Busy goes to TRUE. All other inputs are read and considered continuously. A falling edge (Enable = FALSE) aborts the operation. During Aborting the Busy is still TRUE. Afterward all outputs are reset.
AbbLConCA
Output
BusyBOOLFALSE
Operation is running (while output Error is FALSE)
AbbLConCA
ErrorBOOLFALSE
Operation is stopped with error (while output Busy is FALSE). This output is TRUE for at least one cycle or until Enable is set to FALSE. The output ErrorID gives more details about the error.
AbbLConCA
Input
YearINT2022
2 : Year [2000..6000]
MonINT6
3 : Month [1..12]
DayINT1
4 : Day [1..31]
HourINT10
5 : Hour [0..24]
MinuteINT10
6 : Minute [0..59]
SecINT25
7 : Second [0..59]
TimezoneLREAL0
8 : Observer time zone (negative west of Greenwich) [-12..12] (degrees)
DeltaTimeLREAL0
9 : DeltaT = Terrestrial Time (TT) - Universal Time (UT) [-8000..8000] (seconds)
LatitudeLREAL0
10 : Observer latitude (negative south of equator) [-90..90] (degrees)
LongitudeLREAL0
11 : Observer longitude (negative west of Greenwich) [-180..180] (degrees)
AltitudeLREAL0
12 : Observer elevation / Altitude [-5000 .. 5000] (meters)
PressureLREAL0
13 : Local pressure [0..5000] (millibars)
TemperatureLREAL0
14 : Local temperature [-273..6000] (degrees Celsius)
AtmosRefractionLREAL0
15 : Atmospheric refraction at sunrise & sunset (typical:0.5667) [-5..5] degrees)
Output
ErrorID3 : Error code which indicates which input is erroneous
AzimuthLREAL0
4 : Topocentric azimuth angle (eastward from north) [ 0..360] (degrees)
ElevationUncorrectedLREAL0
5 : Topocentric elevation angle (uncorrected) (degrees)
ElevationCorrectedLREAL0
6 : Topocentric elevation angle (corrected) (degrees)
Methods:
A_StartAction
B_CyclicAction
C_CleaningAction
D_AbortAction
E_ResetAction
Structure:
SolarNrel.A_StartAction(METH)SolarNrel.B_CyclicAction(METH)SolarNrel.C_CleaningAction(METH)SolarNrel.D_AbortAction(METH)SolarNrel.E_ResetAction(METH)SolarNrel.zACTION_NREL_CALCULATE_EOT_AND_SUN_RISE(ACT)SolarNrel.zACTION_NREL_CALCULATE_GEOCENTRIC_SUN(ACT)SolarNrel.zACTION_NREL_VALIDATE_INPUTS(ACT)