Hallo du kennst ja die funktionen in oscat, ich kenne selbst die soiemens entwicklungsumgebung nicht.
aber unter
codesys kann ich per knopfdruch zwischen den verschiedenen sprachen übersetzen. sowas gibts sicher auch bei siemens.
ich könnte zwar das ganze im codesys nach awl wndeln ist lediglich ein knopfdruck ob es dir aber hilft weis ich nicht. hier der baustein sun_time in awl wie ihn codesys auf knopfdruck umwandelt.
(* @PATH := '' *)
(* @SYMFILEFLAGS := '2048' *)
FUNCTION_BLOCK awl_sun_time
VAR_INPUT
latitude : REAL; (* latitude of geographical position *)
longitude : REAL; (* longitude of geographical position *)
utc : DT; (* world time *)
END_VAR
VAR_OUTPUT
sun_midday : TOD; (* astrological midday in hours when sun stand at south direction *)
sun_rise : TOD; (* sun rise for current day in local time *)
sun_set : TOD; (* sun set for current day in local time *)
sun_declination : REAL; (* sun declination at midday in degrees *)
END_VAR
VAR
T: INT; (* day in the year *)
DK: REAL; (* sun declination at midday *)
delta: REAL; (* delta from midday for sunrise and sunset *)
h: REAL;
B: REAL;
offset : REAL;
END_VAR
(*
version 1.2 17 apr 2007
programmer hugo
tested by tobias
this FUNCTION block calculates the sun rise, sun set, sun offset at midday sun declination for a given date
for performance reasons the algorithm has been simplified and is accurate within a few minutes only
the times are calculated in utc and have to be corrected for the given time zone
this correction is not done within sun_time because it would be a problem on days where dst is enabled or disabled
execution time on wago 750-841 is 30 us
*)
VAR
_REAL_0:REAL;
_REAL_1:REAL;
_LREAL_0:LREAL;
END_VAR
(* @END_DECLARATION := '0' *)
LD latitude
Rad
ST B
LD -0.0145
ST h
LD utc
DT_TO_DATE
day_of_year
ST T
LD 0.018234
MUL T
SUB 0.1939
SIN
ST _REAL_0
LD 0.1340
MUL _REAL_0
ST _LREAL_0
LD 0.033430
MUL T
ADD 0.5474
SIN
ST _REAL_0
LD -0.1752
MUL _REAL_0
SUB _LREAL_0
ST offset
LD longitude
DIV 15
ST _REAL_0
LD 12
ADD offset
SUB _REAL_0
hour_to_tod
ST sun_midday
LD T
SUB 79.35
ST _LREAL_0
LD 0.0172
MUL _LREAL_0
SIN
ST _REAL_0
LD 0.40954
MUL _REAL_0
ST DK
LD DK
deg
ST sun_declination
LD DK
COS
ST _REAL_0
LD B
COS
MUL _REAL_0
ST _REAL_0
LD DK
SIN
ST _REAL_1
LD B
SIN
MUL _REAL_1
ST _REAL_1
LD h
SIN
SUB _REAL_1
DIV _REAL_0
ACOS
ST _REAL_0
LD 12
MUL _REAL_0
DIV PI
ST delta
LD longitude
DIV 15
ST _REAL_0
LD 12
SUB delta
SUB offset
SUB _REAL_0
hour_to_tod
ST sun_rise
LD longitude
DIV 15
ST _REAL_0
LD 12
ADD delta
SUB offset
SUB _REAL_0
hour_to_tod
ST sun_set
END_FUNCTION_BLOCK