SolarNrel (FB)
FUNCTION_BLOCK SolarNrel EXTENDS AbbLConC3
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 which can be found on the NERLs website: https://midcdmz.nrel.gov/spa/
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: https://www.nrel.gov/
- 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. Execution will continue forever until a falling edge (Enable = FALSE) aborts the operation. During Aborting the Busy is still TRUE. Afterward all outputs are reset.
AbbLConC3
Output
BusyBOOLFALSE
Operation is running (while output Error is FALSE)
AbbLConC3
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.
AbbLConC3
Input
YearINT2022
2: Year. Range 2000 to 6000
MonINT6
3: Month. Range 1 to 12
DayINT1
4: Day. Range 1 to 31
HourINT10
5: Hour. Range 0 to 23
MinuteINT10
6: Minute. Range 0 to 59
SecINT25
7: Second. Range 0 to 59
TimeZoneLREAL0
8: Observer time zone(negative west of Greenwich) in hours. Timezone = Standard Time - Universal Time. Maximum value 12
DeltaTimeLREAL0
- 9: Difference between the earth rotation time and terrestrial time. It is derived from observation only and it is reported in this bulletin, where _T = 32.184 + (TAI-UTC) + _UT1
DeltaTime = Terrestrial Time (TT) - Universal Time (UT). [Range -8000 to 8000, Unit: Seconds]
LatitudeLREAL0
10: Observer latitude. Negative south of equator. [Range: -90 to 90. Unit: Degress]
LongitudeLREAL0
11: Observer longitude Nnegative west of Greenwich. [Range: -180 to 180. Unit: Degress]
AltitudeLREAL0
12: Observer elevation or Altitude. [Range: -5000 to 5000. Unit: Meters]
PressureLREAL0
13: Local pressure. [Range: 0 to 5000. Unit: Millibars]
TemperatureLREAL0
14: Local temperature. [Range: -273 to 6000. Unit: Celsius]
AtmosRefractionLREAL0
15: Atmospheric refraction at sunrise & sunset. Typical:0.5667. [Range: -5 to 5. Unit: Degress]
Output
ErrorID3 : Error code which indicates which input is erroneous
AzimuthLREAL0
4 : Topocentric azimuth angle. Eastward from north. [Range of values 0 to 360. Unit: Degrees]
ElevationUncorrectedLREAL0
5 : Topocentric elevation angle.(uncorrected) [Range of values -90 to 90. Unit: Degrees]. Error: ±0.0004°
ElevationCorrectedLREAL0
6 : Topocentric elevation angle.(corrected) [Range of values -90 to 90. Unit: Degrees]. Error: ±0.0004°
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)