Topic: DMD0039

Help File Version: 2.9.4.37

NETTIME - SNTP Client


The SNTP Client (NETTIME) instruction is used to retrieve clock and calendar information from a Time Server using the Simple Network Time Protocol (SNTP) This instruction can use either an NTP Server or an SNTP Server as the time server. After the date and time have been successfully read from the time server, the retrieved values will be used to recalculate the local time ($Now) and set the PC's real-time clock to this calculated value. This instruction can be used in conjunction with TimeSync operation to synchronize the real-time clocks in multiple Do-more PLCs with the date and time of a master PLC.

 

The local time ($Now) is calculated by applying a local Time Zone offset value ($TimeZone, DST384), and optionally adjusting for Daylight Savings time ($SummerTime, ST768) to the value retrieved via the NETTIME instruction.

 

 


Parameters:

Note: Use the F9 key to open the Default Element Selection Tool (the Element Picker or the Element Browser) or use the Down-Arrow key (Auto-Complete) on any parameter field to see a complete list of the memory locations that are valid for that parameter of the instruction.

 

Device selects which of the Ethernet Devices to use. For more information on configuring devices go to the Device Configuration Section under System Configuration.

@IntEthernet will use the on-board Ethernet port on the Do-more CPU.
 

no devices available indicates that there are no Devices that can execute this instruction, that is, the CPU does not have an on-board Ethernet port.


SNTP Server IP Address is the TCP/IP Address of the SNTP server to contact for the clock and calendar information. The default SNTP Server IP Address of 12.69.41.165 is an SNTP server (ntp2.hosteng.com) at Host Engineering. And while it is reasonable to use the default time server for testing purposes, be aware that the uptime of the default time server can not be guaranteed. It is recommended that you install your own time server or select a publicly available time server for long-term use.

 

  • Fixed Address : select this option to enter the static TCP/IP Address assigned to the SNTP server. IP addresses are canonically represented in dot-decimal notation, consisting of four decimal numbers, each ranging from 0 to 255, separated by dots. Invoking the Element Browser (F9) for this field will bring up the IP Address Lookup utility that can find the IP Address for a given SNTP Server name.

     

  • Variable IP Address : select this option if the IP Address resides in a numeric memory location in the CPU. This can be any readable DWord numeric location. This allows the IP Address to be changed at runtime. Each octet of the IP Address is stored in one byte of the Variable Address location. In the example below the Initialize Data instruction will use the :UB operator to place the 4 octet values of IP Address 192.168.26.71 into the 4 Bytes of the DWord location D0 in the proper order.

     


    The 'IP Address' format selection in a Data View can be used to see the IP Address stored in the DWord location in the traditional dot-decimal notation (000.000.000.000).

 

Clicking the IP Address Lookup button will open a dialog where the name of an SNTP server can be entered and Do-more Designer will attempt to find the TCP/IP Address assigned to that name using the Domain Name System protocol (DNS).

 

The server name needs to consist only of the server name, not a fully qualified URL. For example, the Name field should contain only the text "time.nist.gov", not "https://time.nist.gov".


UDP Port Number is the UDP/IP port number the SNTP Server uses to communicate. The default UDP Port Number of 123 is the default port number used by the SNTP protocol. This value can be any constant in the range of 1 to 65535, or any readable numeric location containing a value in that range.

 

Network Timeout specifies the maximum amount of time in milliseconds to allow the instruction to wait before signaling a completion. This value can be any constant in the range of 1 to 65535.

 


The On Success and On Error parameters specify what action to perform when this instruction completes. You do not have to use the same type of selection for both On Success and On Error.

 

If the Set Bit selection is used for either On Success or On Error, the specified BIT location will be SET OFF when the instruction is first enabled and will remain OFF until the instruction completes. Once complete, the appropriate Success or Error bit location ON. The specified Bit location is enabled with a SET (Latch) operation meaning that it will remain ON even if the input logic for the instruction goes OFF.

 

If the JMP to Stage selection is used for either On Success or On Error the target Stage must be in the same Program code-block as this instruction, you cannot specify a target Stage that exists in a different Program code-block. When the operation finishes, the target Stage will be enabled the same way as a standalone Jump to Stage (JMP) instruction would do it. The JMP to Stage option will only be available if this instruction is placed in a Program code-block.

 

On Success selects which of the following actions to perform if the operation is successful:

  • Enable SET Bit then specify any writable bit location.
  • Enable JMP to Stage then specify any Stage number from S0 to S127 in the current Program code-block.

 

On Error selects which of the following actions to perform if the operation is unsuccessful:
 

  • Enable SET Bit then specify writable bit location.
  • Enable JMP to Stage then specify any Stage number from S0 to S127 in the current Program code-block.

 

If either the On Success or On Error selections are set to JMP to Stage, Automatically create the SG box for any NEW stage number will be enabled which will automatically create any target stage that does not already exist.

  • Below this rung will create the new target stage on a new rung following this instruction.
  • At end of code-block will create the new target stage as the last rung of this Program.

 


Status Display:

 

The red triangle in the upper left corner of the status display indicates this is a Fully Asynchronous instruction.

 

The gray triangle at the right end of the input leg indicates the input is edge-triggered, meaning this instruction will execute each time the input logic transitions from OFF to ON.

 


See Also:

NETTIME - SNTP Client

 

SETTIME - Set PLC Date / Time

 

Date and Time Overview

 

Date / Time Structures and Structure Fields



Related Topics:

DT2EPOCH - Convert Date / Time to 1970 Epoch

 

EPOCH2DT - Convert 1970 Epoch Time to Date / Time

 

DTCMP - Compare Date / Time

 

DTDIFF - Difference between two Date / Times

 

DTOFFSET - Add Offset to Date / Time

 


Example Using Stages:

Rung Example: