FP_NTP_SET_RETRY_SETTINGS

Set retry settings for NTP server

This FP instruction sets the retry settings for NTP server time synchronization requests.

Input

nTimeout (WORD, INT, UINT)

Timeout in seconds

Values: 30–300 seconds

nNumberOfRetries (WORD, INT, UINT)

Number of retries

Values: 0–3

nRetryInterval (DWORD, DINT, UDINT, DATE, TOD, DT)

Length of an interval for a retry in seconds

Values: 10–86400 seconds

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.

  • The retry settings of the time synchronization request for the NTP server is set according to nTimeout, nNumberOfRetries and nRetryInterval.

  • The data that is already set in the system registers (Ethernet > Time synchronization) is invalid and the NTP time synchronisation request is executed at the time that is specified by this instruction.

  • 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
		bEnable: BOOL:=FALSE;
		bError: BOOL:=FALSE;
		iTimeout: INT:=60;
		iNumberOfRetries: INT:=3;
		diRetryInterval: DINT:=600;
			END_VAR

LD body

When the system variable sys_bIsEthernetInitializing is FALSE and the variable bEnable is set 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 := 6 ;
        NETWORK_BODY
B(B_CONTACT,,sys_bIsEthernetInitializing,6,1,8,3,N);
B(B_CONTACT,,bEnable,14,1,16,3,);
B(B_F,FP_NTP_SET_RETRY_SETTINGS!,,22,0,37,6,,?DEN?DnTimeout?DnNumberOfRetries?DnRetryInterval?AENO?AbError);
B(B_VARIN,,iTimeout,20,2,22,4,);
B(B_VAROUT,,bError,37,2,39,4,);
B(B_VARIN,,iNumberOfRetries,20,3,22,5,);
B(B_VARIN,,diRetryInterval,20,4,22,6,);
L(1,0,1,6);
L(1,2,6,2);
L(8,2,14,2);
L(16,2,22,2);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 5 ;
        NETWORK_BODY
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 5 ;
        NETWORK_BODY
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

if NOT (sys_bIsEthernetInitializing) AND (bEnable) then
    FP_NTP_SET_RETRY_SETTINGS(nTimeout := iTimeout,
    nNumberOfRetries := iNumberOfRetries,
    nRetryInterval := diRetryInterval,
    bError => bError);
end_if;

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