LGF_SetTime (FB / V3.0.3)

Overview

Author: Siemens Digital Industry

Short description

This block combines the functions of system time, local time, and set time zone.

Block Interface

LGF_SetTime (FB)
Bool  execute done  Bool
    
DTL  systemTime busy  Bool
    
Bool  isLocalTime error  Bool
    
Int  timeZone lastSetTimeZone  String
    
Bool  isDaylightSavingTime status  Word
    
   subFunctionStatus  Word
    
   

Input parameter

IdentifierData type Default value Description
executeBool FALSE Rising edge starts action once
systemTimeDTL --- System time to be set in PLC
isLocalTimeBool FALSE TRUE: `systemTime` is local time, FALSE: `systemTime` is UTC time
timeZoneInt 0 Timezones HHMM [-1200.. -330.. 0.. 930.. 1200.. 1300]
isDaylightSavingTimeBool FALSE Daylight saving time changeover, TRUE: activated, FALSE: deactivated (more infos at "Adjusting parameters in the `statTimeZone` variable")

Output parameter

IdentifierData type Description
doneBool TRUE: Commanded functionality has been completed successfully
busyBool TRUE: FB is active and new output values can be expected
errorBool FALSE: No error / TRUE: An error occurred during the execution of the FB
lastSetTimeZoneString Time zone that was set last by this block
statusWord 16#0000-16#7FFF: Status of the FB / 16#8000-16#FFFF: Error identification (see following Table)
subFunctionStatusWord Status or return value of called FB's, FC's and system blocks

Status & Error codes

Code / ValueIdentifier / Description
16#0000STATUS_EXECUTION_FINISHED_NO_ERROR
Execution finished without errors
16#7000STATUS_NO_CALL
No job being currently processed
16#7001STATUS_FIRST_CALL
First call after incoming new job (rising edge 'execute')
16#7002STATUS_SUBSEQUENT_CALL
Subsequent call during active processing without further details
16#8201ERR_SET_TIME_LOCAL
Error instruction WR_LOC_T: Write local time, check `subFunctionStatus` code
16#8202ERR_SET_TIME_UTC
Error instruction WR_SYS_T: Set time-of-day, check `subFunctionStatus` code
16#8203ERR_SET_TIMEZONE
Error instruction SET_TIMEZONE, check subFunctionStatus code
16#8600ERR_UNDEFINED_STATE
Error due to an undefined state in state machine
16#8601ERR_WRONG_TIMEZONE
Error due to an undefined time zone

Functional description

NOTE
The status of called commands is output in subFunctionStatus. In this case, the output value in status indicates which command caused the error. In this case, refer to the TIA Portal Online Help section for information on the respective commands.

NOTE
The function uses internally the system function WR_LOC_T to write the local time of the CPU or WR_SYS_T to write the coordinated world time (UTC). Further it uses the system function SET_TIMEZONE to set the time zone of the PLC.

This block combines the functions of system time, local time, and set time zone.


The following time zones are possible on the timeZone input:

Input timeZone Time zone
-1200 (UTC -12:00) Eniwetok, Kwajalein
-1100 (UTC -11:00) Midway Island
-1000 (UTC -10:00) Hawaii
-930 (UTC -09:30) (French) Polynesia
-900 (UTC -09:00) Alaska
-800 (UTC -08:00) Tijuana, Los Angeles, Seattle, Vancouver
-700 (UTC -07:00) Arizona, Denver, Salt Lake City, Calgary
-600 (UTC -06:00) Chicago, Dallas, Kansas City, Winnipeg
-500 (UTC -05:00) Eastern Time (USA & Canada)
-400 (UTC -04:00) La Paz, Georgetown
-330 (UTC -03:30) Newfoundland
-300 (UTC -03:00) Brasilia, Buenos Aire
-200 (UTC -02:00) Mid-Atlantic
-100 (UTC -01:00) Azores, Cape Verde Is.
0 (UTC) Dublin, Edinburgh, Lisbon, London
100 (UTC +01:00) Berlin, Bern, Brussels, Rome, Stockholm, Vienna
200 (UTC +02:00) Athens, Istanbul, Minsk, Bucharest
300 (UTC +03:00) Moscow, St. Petersburg, Baghdad, Kuwait, Riyadh
330 (UTC +03:30) Iran: Tehran
400 (UTC +04:00) Abu Dhabi, Muscat
430 (UTC +04:30) Afghanistan: Kabul
500 (UTC +05:00) Islamabad, Karachi, Tashkent
530 (UTC +05:30) India, Sri Lanka
545 (UTC +05:45) Nepal
600 (UTC +06:00) Astana, Almaty, Dhaka, Colombo
630 (UTC +06:30) Coco Island, Myanmar
700 (UTC +07:00) Bangkok, Hanoi, Jakarta
800 (UTC +08:00) Beijing, Chongqing, Hong Kong, Urumqi
830 (UTC +08:30) North Korea old
845 (UTC +08:45) Western Australia: Eucla
900 (UTC +09:00) Yakutsk, Osaka, Sapporo, Tokyo, Seoul
930 (UTC +09:30) Australia: Northern Territory, South Australia
1000 (UTC +10:00) Brisbane, Canberra, Melbourne, Sydney
1030 (UTC +10:30) Australia: Lord Howe Island
1100 (UTC +11:00) Vladivostok, Magadan, Solomon Is., New Caledonia
1200 (UTC +12:00) Auckland, Wellington
1245 (UTC +12:45) Chatham Islands
1300 (UTC +13:00) Tonga, Samoa
1400 (UTC +14:00) Kiribati
Note
Daylight saving time/standard time
The parameters (time difference, start summer time, start winter time) must be adapted to the desired time zone in the static variable statTimeZone.

####### Adjusting parameters in the statTimeZone variable

The static variable statTimeZone in the block interface is of the system data type TimeTransformationRule. In this system data type, the parameters for the local time zone and the summer/winter time changeover are stored.

The default values of the static variable statTimeZone are set to Central European Summer Time in the block interface:

The following Figure shows the settings for the summer/winter time changeover of Central European Summer Time.

The parameter Bias is determined by the input parameter timeZone. The parameter DaylightBias depends on the input parameter daylightSavingTime and is either 0 or 60.

For other time zones, the parameters for summer/winter time changeover must be adjusted (marked below).

LGF_SetTime - Adjusting parameters in the 'statTimeZone' variable

Change log

Version & DateChange description
01.00.00Siemens Industry Online Support
08.06.2015First released version
01.00.01Siemens Industry Online Support
02.01.2017Upgrade: TIA V14 Update 1
01.00.02Siemens Industry Online Support
02.03.2017Bugfix: FB number: automatic
01.00.03Siemens Industry Online Support
17.08.2018Upgrade: TIA V15 Update 2
01.00.04Siemens Industry Online Support
23.11.2018Upgrade: TIA V15.1
01.00.05Siemens Industry Online Support
20.02.2019Bugfix: Rising edge at input REQ of SET_TIMEOUT
01.00.06Simatic Systems Support
23.08.2019Reworked interface to PLC Open "execute" behavior
Magic numbers removed, tag naming added, code reworked
03.00.00Simatic Systems Support
23.04.2020Set version to V3.0.0, harmonize the version of the whole library
03.00.02Simatic Systems Support
13.01.2020Bug fix - bias correction for time offsets (330)
Insert documentation
03.00.03Simatic Systems Support
03.06.2022Bug fix - bias correction for time offsets (200)