FP_NTP_SET_TIME_ZONE

Set local time zone of NTP server

NOTE

Setting a local time zone is only necessary for flexible time zones.

This FP instruction temporarily overwrites the time zone set by system register 530 Ethernet > Time synchronization with a local time zone. This local time zone is used when the PLC time is set by FP_NTP_SYNCHRONIZE.

Parameters

Input

sTimeZone (STRING)

Specifies the time zone based on GMT (Greenwich Mean Time).

Syntax:+HHMM/-HHMM

Values: format: sign (+/-) and HHMM (HH=hours (00–23), MM=minutes (00–59))

Examples:

  1. For France, Italy, Spain, Germany: '+0100'

  2. For Japan: '+0900'

  3. For Hawaii: '-1000'

Output

bError (BOOL)

Set to TRUE when the operation ends abnormally without execution, e.g. when sys_bIsEthernetInitializing is TRUE

When an error occurs, check the system variable sys_iEthernetConnectionErrorCode for the error code number.

Remarks

  • This instruction is not available in interrupt programs.

  • This instruction does not delete or permanently overwrite the time zone set in system register 530, but replaces it temporarily by the value specified by sTimeZone.

  • The PLC returns to the settings from the system registers in the following cases:

    • The power is turned off.

    • You switch from PROG mode to RUN mode.

    • You switch to a different project.

  • The setting data will not be lost even if the instruction FP_IPV4_SET_ADDRESS is executed.

  • Before you execute the instruction, make sure that sys_bIsEthernetInitializing is FALSE. sys_bIsEthernetInitializing turns to TRUE when the instruction is executed. When you execute the instruction while sys_bIsEthernetInitializing is TRUE, an error occurs.

  • When this instruction has been executed successfully, the system variables sys_bIsCarry and sys_iEthernetConnectionErrorCode are reset.

  • When an error occurs, check the system variable sys_iEthernetConnectionErrorCode for the error code number.

Error flags

sys_bIsOperationErrorHold (turns to TRUE and remains TRUE)
  • if a value specified for a parameter is outside the permissible range.

  • if the instruction is executed in an interrupt program

  • if the system is synchronizing the time with the NTP server.

sys_bIsOperationErrorNonHold (turns to TRUE for one scan)
  • if a value specified for a parameter is outside the permissible range.

  • if the instruction is executed in an interrupt program

  • if the system is synchronizing the time with the NTP server.

sys_bIsCarry (turns to TRUE for one scan)

if the instruction is executed during the initialization of Ethernet, sys_iEthernetConnectionErrorCode is set to "11: Ethernet is being initialized".

Example

POU header

All input and output variables used for programming this function have been declared in the POU header.The same POU header is used for all programming languages.

	VAR
		sTimeZone: STRING[32]:='+0100';
		bIsError: BOOL:=FALSE;
		bEnable: BOOL:=FALSE;
			END_VAR

LD body

When the system variable sys_bIsEthernetInitializing is FALSE and the variable bEnable changes from FALSE to TRUE, the function is carried out.

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 7 ;
        NETWORK_BODY
B(B_CONTACT,,sys_bIsEthernetInitializing,6,4,8,6,N);
B(B_CONTACT,,bEnable,14,4,16,6,R);
B(B_F,FP_NTP_SET_TIME_ZONE!,,18,3,31,7,,?DEN?DsTimeZone?AENO?AbError);
B(B_VARIN,,sTimeZone,16,5,18,7,);
B(B_VAROUT,,bIsError,31,5,33,7,);
L(1,0,1,7);
L(1,5,6,5);
L(8,5,14,5);
L(16,5,18,5);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

if (NOT (sys_bIsEthernetInitializing) AND DF(bEnable)) then
    FP_NTP_SET_TIME_ZONE(sTimeZone := sTimeZone,
    bError => bIsError);
end_if;

Modified on: 2024-03-11Feedback on this pagePanasonic hotline