FB_BA_CalcSunriseSunset

FB_BA_CalcSunriseSunset 1:

The FB_BA_CalcSunriseSunset function block is used to calculate the sunrise and sunset by specifying 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

Time

GMT (Greenwich Mean Time)

λGMT = 0°

GMT + 0h

CET (Central European Time)

λCET = 15°

GMT + 1h

CEST (Central European Summer Time)

λCEST = 30°

GMT + 2h

FB_BA_CalcSunriseSunset 2: Inputs

VAR_INPUT
  fDegreeOfLongitude       : REAL := 8.5;
  fDegreeOfLatitude        : REAL := 51.9;
  fReferenceMeridian       : REAL;
  dCurrentDate             : DATE;
END_VAR

Name

Type

Description

fDegreeOfLongitude

REAL

Longitude in degrees. Eastern longitudes are positive, western longitudes are negative.

This input is internally limited to -180°...180°. Nevertheless, an error is displayed at the bErr output if an entry is made outside these limits.

fDegreeofLatitude

REAL

Latitude in degrees. Northern latitudes are positive, southern latitudes are negative.

This input is internally limited to -66.55°...66.55°. Nevertheless, an error is displayed at output bErr if an entry is made outside these limits.

Info: -66.55° and 66.55° are the latitudes of the Artic and Antarctic Circle. Beyond these limits, the sun may never rise or set on certain days. A statement about sunrise and sunset is then not possible.

fReferenceMeridian

TIMESTRUCT

Reference meridian of the time zone. Eastern meridians are positive, western meridians are negative.

As the reference meridian refers to longitude, this input is also limited to -180°...180°. Nevertheless, an error is displayed at the bErr output if an entry is made outside these limits.

dCurrentDate

DATE

Current date.

FB_BA_CalcSunriseSunset 3: Outputs

VAR_OUTPUT
  todSunrise    : TOD;
  todSunset     : TOD;
  bErr          : BOOL;
  sErrDescr     : T_MaxString;
END_VAR

Name

Type

Description

todSunrise

TOD

Sunrise. Output of hour and minute.

todSunset

TOD

Sunset. Output of hour and minute.

bErr

BOOL

Result verification for the entered values.

sErrDescr

T_MaxString

Contains the description of the error that has the highest internal priority.

Prerequisites

Development environment

Required PLC library

TwinCAT from v3.1.4024.62

Tc3_BA2 from v5.5.14.0