Industrial Automation
Industrial Automation | Europe

myKnowledge

Main > Product Type > Automation Systems > Machine Controllers
Minimize Text   Default    Enlarge Text
 

Print
E-mail

How To Synchronize Time Between A NJ And NS Using A NTP Server In Windows 7 Or Via The Internet


Introduction

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.

Content

  • How to setup a NTP server in Windows 7
  • How to configure the NJ
  • How to configure the NS HMI
  • How to connect the NJ to a NTP 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:

  • Open a command prompt as Administrator.
  • Run the command "regedit"
  • Change KEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config\AnnounceFlags to "5"
  • Change HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer\Enabled to "1"
  • Change HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\VMICTimeProvider\Enabled to "0"
  • Close regedit.
  • Run the command "net stop w32time"
  • Run the command "net start w32time"
  • Close the command prompt.

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
DATE_AND_TIME. However, tags that are set to these data types cannot be used in functional objects such as Time or Date. They can be used only for the READCMEM, WRITECMEM, and LOCALTIME macros.

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:

TimeToNSInternal:=DtToSec(Time_DT);
NS_Time:=ULINT#1000000000*TimeToNSInternal;

Variables used in TimeToNS function


Internals:


 

In/Out:

Return:

NS HMI Macro

The time between the NS HMI and the NJ can be synchronized by executing the following macro code in the NS:

ReadCmem($W1200,[HOST3:TimeToNSns],4);
LOCALTIME($W1200,$W1300);
SetTime($W1300);

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 46.19.33.6.



For more information about NTP servers please visit: NTP Servers.

Sysmac Studio Configuration

The following example is based on a fixed IP-address.

Currently the IP-address of the NTP server is known which 46.19.33.6 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).

At this point all the required information is known to configure Sysmac Studio. The following Built-in Ethernet/IP Port Settings need to be configured:

  • TCP/IP
  • NTP

TCP/IP

As explained in the previous paragraph the IP-address is fixed. The settings of the fixed IP address are:

  • IP-address: 192.168.250.1
  • Subnet mask: 255.255.255.0
  • Default gateway: 192.168.250.200

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 46.19.33.6. The host name is defined in the ‘Host Name – IP address’ section of the TCP / IP tab.



NTP

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.



Attachments

NJ_Time_Sync_Demo.smc - Size: 1940841


Comments (View All Comments / Add Comment)

Related Articles
No related articles found.
Created 2013-03-27
Modified 2014-07-01
Views 11954

 

You are not logged in.