# Ntp Server Setup

**URL:** <https://community.br-automation.com/t/ntp-server-setup/3651>\
**Category:** Controls & Vision\
**Tags:** automation-studio, plc\
**Created:** [June 28, 2024, 11:44am UTC](https://community.br-automation.com/t/ntp-server-setup/3651 "2024-06-28T11:44:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![omer.alumur](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/omer.alumur/32/7383_2.png) [@omer.alumur](https://community.br-automation.com/u/omer.alumur)\
**Post date:** [June 28, 2024, 11:44am UTC](https://community.br-automation.com/t/ntp-server-setup/3651/1 "2024-06-28T11:44:11Z")

</div>

Hello everyone,

I want to make an NTP server application. In this application I am using a 5APC3100\_KBU3\_000 model controller and my controller will be an NTP server. Another computer will be connected to my controller via ethernet as NTP client. However, in the function block I found with the help of B&R help, although there are helpful contents about starting the NTP server, I could not find where to write this time information or what is the ip address of the NTP Server I installed. I started the NTP server from the controller configuration, but I could not see any sign that the server was running. I am sharing the function structure I got help from here as .pdf. I would be very grateful if anyone has made such an application before or if anyone can help.

[cfgsetntpserver.pdf](https://community.br-automation.com/uploads/short-url/ovUZmV2nO6FCx0tTfgdGKjbdRBm.pdf) (67.0 KB)

---

<div class="post-metadata">

**Author:** ![corne.geerts](https://avatars.discourse-cdn.com/v4/letter/c/FF8800/32.png) [@corne.geerts](https://community.br-automation.com/u/corne.geerts)\
**Post date:** [June 28, 2024, 12:16pm UTC](https://community.br-automation.com/t/ntp-server-setup/3651/2 "2024-06-28T12:16:32Z")

</div>

In the AsArCfg library other function blocks are available:

# AsArCfg - CfgGetNtpsData()

This function block provides information about whether the NTP server running locally on the controller is active.

# AsARCfg - CfgGetIPAddr()

The CfgGetIPAddr() function block is used to read the IP address from the AR registry for a configured Ethernet device.

In the AsTime library the functions blocks:

# AsTime - DTGetTime

# AsTime - DTSetTime

could be usefull.

---

<div class="post-metadata">

**Author:** ![omer.alumur](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/omer.alumur/32/7383_2.png) [@omer.alumur](https://community.br-automation.com/u/omer.alumur)\
**Post date:** [June 28, 2024, 1:33pm UTC](https://community.br-automation.com/t/ntp-server-setup/3651/3 "2024-06-28T13:33:04Z")

</div>

In the CfgGetNtpsData function, I can see that the server is running and I am sharing the screenshot with you. I also set the IP address of the controller in the ETH configuration. However, the NTP Client application that I use on the other computer wants it on a port. In this case, how can I find out the port number?

However, I am not sure whether ntpclient should connect to the IP address of the controller. For example, I normally connect to the controller from 192.168.1.1 to transfer the project. In this case, should I set the server IP to which ntpclient should also connect? Also, which function can I use to find out the time information that the NTP Server transfers to the clients?

![ntpss](https://europe1.discourse-cdn.com/brcommunity/original/2X/9/938e3838ead5696fbe0b7649af3c4a7d7a6f56f3.png)

---

<div class="post-metadata">

**Author:** ![austin.carpenter](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/austin.carpenter/32/1196_2.png) [@austin.carpenter](https://community.br-automation.com/u/austin.carpenter)\
**Post date:** [June 28, 2024, 3:30pm UTC](https://community.br-automation.com/t/ntp-server-setup/3651/4 "2024-06-28T15:30:45Z")

</div>

> [@omer.alumur](#):
>
> However, the NTP Client application that I use on the other computer wants it on a port. In this case, how can I find out the port number?

The port used is the standard SNTP port is 123, and that is the port used by the B&R PLC SNTP server. You can find a full map of ports used by B&R PLCs in the Automation Studio help.  
[Ethernet Ports - B&R Online Help (br-automation.com)](https://help.br-automation.com/#/en/4/communication%2Fethernet%2Fethernet_ports.html)

> [@omer.alumur](#):
>
> For example, I normally connect to the controller from 192.168.1.1 to transfer the project. In this case, should I set the server IP to which ntpclient should also connect?

The NTP client device needs to know the IP address (or host name) of the B&R controller that is reachable from the NTP client. If your NTP client device connects to the B&R controller on the same Ethernet Interface as your laptop for AS, then you would provide the same IP address to the NTP client for time synchronization.

> [@omer.alumur](#):
>
> Also, which function can I use to find out the time information that the NTP Server transfers to the clients?

The SNTPS server largely operates in the background (or ‘shadows’ if it sounds cooler). The time that is transferred to the NTP client will be the current time on the B&R controller. To set the current time with Automation Studio, you can use the top menu item Online \> Info… while connected to the B&R controller. On the Time and Date tab, you can set the PLC time.

 ![image](https://europe1.discourse-cdn.com/brcommunity/original/2X/c/c04f2652748762ec92450cf7f9da7851ce54b23d.png)

 ![image](https://europe1.discourse-cdn.com/brcommunity/original/2X/f/fe5ae3661ae1f39c20ba017f851c17b2a79cf42a.png)

Note that setting the time via Online \> Info is only available if the B&R PLC is not an NTP client to another NTP server.

-Austin

---

<div class="post-metadata">

**Author:** ![omer.alumur](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/omer.alumur/32/7383_2.png) [@omer.alumur](https://community.br-automation.com/u/omer.alumur)\
**Post date:** [July 1, 2024, 11:05am UTC](https://community.br-automation.com/t/ntp-server-setup/3651/5 "2024-07-01T11:05:36Z")

</div>

Thank you, Austin,

In fact, we have successfully installed the NTP Server, but the application we used as ntp client required a port and ip address. I entered the ip address in the ETH1 configuration in the ip address and 123 in the port as you said. In this way, I was able to make a successful connection with the ntp client. However, I could not find how to pull the time produced by the NTP Server as a variable because I am writing my project in C. So I used the function structure of the type you will see below.

 ![image (5)](https://europe1.discourse-cdn.com/brcommunity/original/2X/0/05bf0ca301244f71366c6bbc7f4b6121034b7973.png)  
 ![image (4)](https://europe1.discourse-cdn.com/brcommunity/original/2X/b/b028c6870936b8aac35c8019ada6d2b938ec3811.png)
