Set synchronization time for NTP server
This FP instruction sets the time for executing an automatic time synchronization with the NTP server.
Input
Specifies the time for automatic time synchronization with the NTP server.
Set the time with one or more of the following keyword settings:
Daily synchronization (optional parameter)
Keyword: DAY
Syntax: 'DAY=xxx'
Values: DISABLE, HHMM
HH=hours (0–23), MM=minutes (0–59)
Examples:
No daily synchronization: 'DAY=DISABLE'
Daily at 13:30: 'DAY=1330'
Weekly synchronization (optional parameter)
Keyword: WEEK
Syntax: 'WEEK=xxxxx'
Values: DISABLE, WHHMM
W=day of week (0=Sunday, 1=Monday, 2=Tuesday, 3=Wednesday, 4=Thursday, 5=Friday, 6=Saturday), HH=hours (0–23), MM=minutes (0–59)
Examples:
No weekly synchronization: 'WEEK=DISABLE'
Every Sunday at 23:59: 'WEEK=02359'
Monthly synchronization (optional parameter)
Keyword: MONTH
Syntax: 'MONTH,xxxxxx'
Values: DISABLE, DDHHMM
DD=day (0–28), HH=hours (0–23), MM=minutes (0–59)
Examples:
No monthly synchronization: 'MONTH=DISABLE'
On every 15th day of the month at 15:30: 'MONTH=150330'
Output
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.
This instruction is not available in interrupt programs.
Do not change the order of keywords. Specify the keywords and their setting parameters in the order they are listed here.
A part of the parameter syntax can be omitted. The settings are not changed when parameters are omitted partially.
When omitting the part before a specified keyword, omit only the keyword, but not the comma "," separating the keywords: ',,MONTH=150300'
.
When omitting the part after a specified keyword, omit both the comma "," and the keyword: 'DAY=1130,WEEK=DISABLE'
.
Do not specify the same keyword more than once. If the same keyword is specified more than once, an error occurs.
The timing of the time synchronization request for the NTP server is set according to sSynchronizeTime.
The data that is already set in the system registers ( ) 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.
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.
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.
if the instruction is executed during the initialization of Ethernet, sys_iEthernetConnectionErrorCode is set to "11: Ethernet is being initialized".
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
sSynchronizeTime: STRING[32]:='DAY=1130,WEEK=62345,MONTH=280200';
bIsError: BOOL:=FALSE;
bEnable: BOOL:=FALSE;
END_VAR
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 := 5 ;
NETWORK_BODY
B(B_CONTACT,,sys_bIsEthernetInitializing,6,2,8,4,N);
B(B_CONTACT,,bEnable,14,2,16,4,);
B(B_F,FP_NTP_SET_SYNCHRONIZE_TIME!,,22,1,38,5,,?DEN?DsSynchronizeTime?AENO?AbError);
B(B_VARIN,,sSynchronizeTime,20,3,22,5,);
B(B_VAROUT,,bIsError,38,3,40,5,);
L(1,0,1,5);
L(1,3,6,3);
L(8,3,14,3);
L(16,3,22,3);
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
if NOT (sys_bIsEthernetInitializing) AND (bEnable) then
FP_NTP_SET_SYNCHRONIZE_TIME(sSynchronizeTime := sSynchronizeTime,
bError => bIsError);
end_if;