How To Synchronize Time Between A NJ And NS Using A NTP Server In Windows 7 Or Via The Internet
This article explains how to synchronize time between a NJ-NS using a NTP Server. A NTP Server can be a running on a Windows 7 platform or from a server on the internet.
How to Setup a NTP Server in Windows 7
Omron products that have Ethernet connection support auto adjustment of the internal clock by using SNTP (Simple Network Time Protocol) however this requires a NTP (Network Time Protocol) server. For example, windows 7 can be used as a NTP server.
To setup a NTP server in Windows 7, please follow the next steps:
For more information about creating a NTP server in Windows 7 please read this article at MyOmron: How to Use Windows 7 as SNTP Timeserver.
For more information about NTP please visit: Wikipedia.
How to Configure the NJ
The NJ Motion Controller supports time synchronization with a SNTP or NTP server such as a NTP server running on Windows 7. The configurations of the NTP Settings are done in the programming platform for the NJ; Sysmac Studio.
The designated NTP Server for the NJ can be configured in the section: Configurations and Setup > Controller Setup > Built-in Ethernet/IP Port Settings > NTP Setting, this is also shown in the illustration below.
Within the NTP Settings the NTP Server Clock Information can be enabled or disabled, it is disabled by default. To enabled time synchronization select ‘Get’ NTP Server Clock Information as shown in the illustration below.
When the NTP Server Clock Information is enabled the settings can be configured. The port no. is by default 123 this should not be changed because this port number is used for Network Time Protocol (NTP). Other notable port numbers are 161 which is used for Simple Network Time Protocol (SNTP) and 162 which is used for Simple Network Time Protocol Trap (SNTPTRAP).
For more information about TCP and UDP port numbers please visit: UDP and TCP port numbers.
The second setting is specifying the server method, in other words how the NJ does addresses the NTP server; this can be via an IP-address or via a Host Name. The third setting is the NTP operation timing, within this setting the time can be set to execute the time synchronization. This can be achieved by specifying a time or specifying a time interval.
With the above settings the NJ is ready to synchronize time with a NTP Server. However it is important to know that the NJ also uses time zone as a reference for its internal clock. The time region is by default set to Japan but this can be easily modified. However to modify the time zone reference for the internal clock, Sysmac Studio needs to be connected to the NJ. While Sysmac Studio is online, the internal clock can be modified in: Controller > Controller Clock… as shown in the illustration below. This feature does not work while Sysmac Studio is offline.
The controller clock time zone can be modified as shown in the illustration below. Sysmac Studio also recognizes the time zone of the operating system that runs Sysmac Studio.
Time synchronization is also possible by executing the ‘Synchronize with computer’ as shown in the illustration below. Be aware that when the time zone of the NJ is changed after synchronizing with the computer, the internal clock will also change according to the time difference between the time zones. Make sure to first set the time zone and then manually synchronize with the computer if needed.
How to Synchronize Time between the NJ and NS HMI
For the NJ-series Controllers, tag data types can be set to TIME, DATE, TIME_OF_DAY, or
The NJ is able to convert the data from DATE_AND_TIME to Seconds and store the converted data in a LINT data type as shown in the illustration below.
The function ‘TimeToNS’ contains the following code:
Variables used in TimeToNS function
NS HMI Macro
The time between the NS HMI and the NJ can be synchronized by executing the following macro code in the NS:
The attached files contain a demo application to synchronize time between a NS HMI and NJ using Windows 7 as a NTP Server.
How to connect the NJ to a NTP server on the internet
The Sysmac NJ has also the possibility to directly synchronize time with a NTP server on the internet.
The following NTP server is used as an example to explain how it works: nl.pool.ntp.org.
As the internet address implies (nl.pool.ntp.org) the NTP server consists out of multiple servers which mean that the IP-address can vary. The illustration below displays one of the IP-addresses of nl.pool.ntp.org is 184.108.40.206.
Sysmac Studio Configuration
The following example is based on a fixed IP-address.
Currently the IP-address of the NTP server is known which 220.127.116.11 is. However, likely the NTP server is not within the same network as the NJ. This will result that the NJ cannot find the NTP server within its network therefore the gateway needs to be configured.
A gateway is a node (a router) on a TCP/IP network that serves as an access point to another network. A default gateway is the node on the computer network that the network software uses when an IP-address does not match any other routes in the routing table.
The default gateway of the Ethernet adapter can be verified by using the ipconfig command in command prompt. This will provide an overview of all windows IP configurations. In this example the default gateway is 192.168.250.200 as it is shown in the illustration below.
For more information about default gateways please visit: Default Gateway (wikipedia).
As explained in the previous paragraph the IP-address is fixed. The settings of the fixed IP address are:
The above settings are configured in the ‘TCP / IP’ tab. Furthermore, the ‘NTP’ tab contains a host name called nl.pool.ntp.org with the following IP-address 18.104.22.168. The host name is defined in the ‘Host Name – IP address’ section of the TCP / IP tab.
The illustration below illustrates the usage of a Host Name named; nl.pool.ntp.org. The NTP operation timing is set to synchronize time with an interval of one minute.