GPS NTP time server unit

introducing the GPS NTP time server that can be provided using STM32minShield.
By Unknown
Hardware Components
STM32miniShiled Kit
X 1
X 1
TM1637 Display module
X 1
USB cable + USB power adapter
X 1
Stereo mini jack connector
X 1

gps ntp.PNG

Here, we will introduce the GPS NTP time server that can be provided using STM32minShield.

Original link:

* January 15, 2021 Title change We have added the word NTP.
* December 25, 2020 Some specifications have been changed.

High-performance time servers are provided by Citizen and Seiko, but they are very expensive.
A simple, stable, and inexpensive time server is a good choice, as long as it fits your purpose.
Therefore, I would like to introduce a time server unit built using STM32minShield.
There are various ways to synchronize the time, but I will introduce the one with an inexpensive GPS module connected.


table of contents

[Define the purpose of use. ]
  • Connect to equipment used in factories, etc. so that the time on the PC or PLC does not deviate.
  • GPS radio waves can be received if it is in the factory window.
  • 19 “General purpose as a rack mounting unit
  • It supports SNTP and can synchronize the time even with a unit such as OMRON PLC. Of course, the time synchronization of Windows PC and Linux PC has also been confirmed to work.
[2036 problem]

The 2036 problem is a problem that the date and time after a specific date and time in 2036 AD cannot be handled correctly due to the specifications of NTP (Network Time Protocol) used for time adjustment on IP networks such as the Internet. In addition, problems such as computer malfunctions and social disruptions that are feared to be caused by it. * Quoted from

NTP uses UTC (Coordinated Universal Time). This manages the number of seconds elapsed since midnight (GMT) on January 1, 1900, using an unsigned 32-bit integer. Therefore, at 6:28:15 on February 6, 2036, and at 15:28:15 on the same day in Japan time (JST), the digits will overflow and the date and time cannot be written correctly.
For the time being, countermeasures have been proposed, and in SNTP version 4 (RFC 4330), a method to change the treatment to indicate the number of seconds elapsed from 6:28:16 on February 6, 2036 when the most significant bit is 0 is proposed. It has been.
Care must be taken to ensure that the implementation meets RFC 4330.

There was a year 2000 problem in the past. This issue was application-specific, but the 2036 issue is a system limitation and not an individual issue.

[Year 2038 problem]

The Year 2038 problem is a problem in which some computer systems may malfunction after a certain moment in 2038 AD. * Quoted from

When handling time with time_t type in C language, the elapsed time from midnight (GMT) on January 1, 1970 is 3:14 am on January 19, 2038 because of a 32-bit signed integer. It will overflow in 8 seconds (12:14:08 pm on the same day in Japan time).
There is a thing that the C language compiler treats time_t type as a 64-bit signed integer, and it may be possible to take measures by recompiling, but it is necessary to be careful including how to check if it is taken measures in the first place. is.

[Component part】

I will clarify what kind of components the contents written here will be realized.
Roughly, it can be achieved with the following component elements.

  1. STM32miniShiled Kit
  2. W850ioModule
  3. GPS antenna module (stereo mini plug type)
  4. TM1637 Display module
  5. USB cable + USB power adapter
  6. Stereo mini jack connector
  7. Suitable housing

[System example]


GPS time serverremarks
Time adjustment methodGPSRead and adjust sentence $ xxRMC
Operating stateSNTP server (time synchronization)
HTTP server (setting)
Time accuracyAccording to the accuracy of the GPS moduleInternal time is delayed by processing time
LAN interface10 / 100BASE-TXRJ-45
Supported protocolsSNTPv4
External dimensions (mm)483 x 44 x 120
Power supply voltage (V)DC5V
current consumption 210mA (measured value)
Provided by USB Micro B
AC adapter is 100-240VAC 50 / 60Hz
GPS antennaReception frequency (MHz)1575.42 ± 5I’m expecting a U-BLOX module that uses an inexpensive GPS antenna for car navigation, but there are no particular restrictions because it interprets a general-purpose character string (NMEA-0183).
Must be a φ3.5 mm stereotype connector. 3.3V power supply from the main unit
Gain (dBi)28 +/- 3dB
External dimensions (mm)45x38x15mm
Cable length (m)About 1.6m
Fixing methodMagnet fixing method
[GPS antenna survey]

The GPS antenna used in this device is the GPS antenna compatible with the stereo plug used in the simple mounting type car navigation system.
Although it is a GPS antenna used in car navigation systems, in the case of an inexpensive simple installation type, the GPS antenna option is often used, and it is possible to purchase the GPS antenna alone. Therefore, the distribution products will be diverted and used like this device.
When power is supplied to this antenna, the sentence string (ASCII) of NMEA-0183 can be received at serial 9600 bps.
Since the talker ID and message ID can be obtained with a fixed length using 6 characters starting with $, the necessary sentences are picked up by dividing them into sieves, and the necessary date / time information is extracted by analyzing the information to update the internal clock. It will be used.

It is known that date / time information can be obtained by ignoring the talker ID and adopting the message ID RMC (Recommended Minimum Specific GNSS Data).
Location information is important in car navigation, but it also requires accurate time. Therefore, it is considered that RMC information is used in all car navigation systems. (* This is not the finalized information, but the survey information at hand.)

By the way, the RMC sentence specifications are as follows.
* It turned out that there is a difference between GPRMC and GNRMC. You need to be careful about how to parse.

Sentence example: $ GPRMC,085120.307, A, 3541.1493, N, 13945.3994, E, 000.0,240.3,181211, ,, A * 6A
Word exampleexplanationmeaning
Existence like GPS positioning summary data
085120.307Times of Day8: 51: 20.307
AData validity A / B / V / WA = valid current data
3541.1493Latitude DDMM.MMM formatLatitude: 35 degrees 41.1493 minutes
NLatitude direction N / SN = North latitude
13945.3994longitudeLongitude; 139 degrees 45.3994 minutes
ELatitude direction E / WE = East longitude
000.0Speed ​​of movement on the surface of the earthMovement speed: 000.0 [knot]
240.3True direction of movement on the surface of the earthTrue direction of movement: 240.3 degrees
181211Date DDMMYYUTC date: December 18, 2011
The difference in angle between magnetic north and true north.
The direction of the angle difference between magnetic north and true north. E / W
APositioning mode N / A / D / E / M / S /A = autonomous method
* 6AChecksum
Sentence example 2: $ GNRMC,004055.000,A,3430.62710,N,13316.68285,E,0.05,115.20,251220 ,,, A, V * 0B
Word exampleexplanationmeaning
Existence like GPS positioning summary data
Times of Day
00: 40: 55.000
VData validity A / B / V / WV = navigation receiver warming
Latitude DDMM.MMM formatLatitude: 34 degrees 30.627 10 minutes
NLatitude direction N / SN = North latitude
longitudeLongitude; 133 degrees 16.68285 minutes
ELatitude direction E / WE = East longitude
0.05Speed ​​of movement on the surface of the earthMovement speed: 0.05 [knot]
True direction of movement on the surface of the earthTrue direction of movement: 115.20 degrees
Date DDMMYYUTC date: December 25, 2020
The difference in angle between magnetic north and true north.
The direction of the angle difference between magnetic north and true north. E / W
NPositioning mode N / A / D / E / M / S /A = Data invalid
Navigation status S / C / U / VV: Disabled (RAIM function OFF)
* 0BChecksum

We actually investigated the target GPS modules available on amazon.

brandReference model numberpricecable lengthPhotos, etc.

If the end of the GPS module is a loose wire, it can be handled with the following adapter.


[Installation of the main body (time server)]

Install it in a 19 “rack and connect it to the HUB with the included LAN cable.

[Installation of GPS antenna]

The GPS antenna is for indoor use only. Please stick it on the window near the outer wall where you can have a good examination.
Although it is an extension of the connection cable, the supply voltage may be 3.3V, and if the extension destination voltage drops below 3V, the operation will become unstable. A stereotype cable can be used for extension.
Originally it is used in the car, and I feel that the LVTTL line driver is installed on the module side.

[Power on]

Power is supplied to the GPS antenna from the main unit.
Power is supplied to the main unit using a USB cable (type A-MicroB) and a USB-AC adapter.
If the attached item is short, replace the USB cable with a cable that can supply 2A.

[set up】

      • Set the IP address of the NTP server
        1. Due to its nature, the NTP server needs to allocate a fixed IP.
          The initial value described in the EEPROM of the CPU module is
          You need to change this value to suit your environment / network zone.
        2. Prepare a PC whose IP address can be changed freely, and connect the PC and NTP server directly with a LAN cable.
        3. Temporarily change the IP address on the PC side to
        4. Ping the NTP server from the PC.
          Start a command prompt on the desktop on the PC side, enter ping, and check if there is a response.

          If there is no response, the IP address may have already been corrected. You need to investigate the changed IP address with a tool like IP Scanner.
        5. Check the network zone to connect to. At this time, the PC and NTP server are still directly connected.
          In the case of SYSMAC network, Sysmac’s own default IP is, so this zone is often adopted.
          In this case, the NTP server should be
          Access from a browser (Chrome is good) from a PC.

          Click the Setup1 link to open the setup screen.

          Change the IP address to and press the “SUBMIT” button.

          The contents of the EEPROM on the NTP server side are now rewritten.
          You need to restart the NTP server for it to take effect.
          At this point, turn off the power, connect to the new network, and restart.
          * The PC used for the setting is not useful.
          * The MASK value may need to be changed depending on the network environment.
          * Since the GW (Gateway) value is not on the external internet, leave it at
        6. This completes the settings on the NTP server side.
          Is it recognized in the new environment? Check with ping and browser.

        7. Click the Setup2 link to open the utility screen.

          I’m curious about how the sentence from GPS actually arrives, but you can check it on the Setup 2 screen.
          If the minority is 000 in the time data, it is considered that you are receiving a sentence synchronized with 1PPS.
          The out-of-sync data is not in the minority 000.
          GPS location information does not seem to move if the captured GPS is fixed. There are some changes in movement speed. You can see that there are periodic fluctuations in the direction. I think it is due to the rotation of GPS itself.
      • Connect GPS module
        1. Connect the GPS module.
          Connect a φ3.5mm stereo plug type GPS module. Install the antenna side as close to the outer wall side window as possible.
          Make sure to receive stable radio waves as much as possible.
          When the time is synchronized with GPS, the LED of LED2 (blue) shifts from lighting to blinking.
          The time display should also shift from 00:00 to the current time.
[how to use】

    • In the case of OMRON, the
      NJ series seems to have a time synchronization setting function in the CPU itself.
      The CJ2 series seems to have a setting function on the network module side.

There is a description in Chapter 10 “Clock Information Automatic Adjustment Function” of the EtherNet / IP module CJ1W-EIP21.
In the case of CJ, this module gets the time information from the configured SNTP server and updates the internal clock information of the CPU unit in which it is installed.
It seems that Sysmac Studio is required for the setting.

item nameContent (default value)
SNTP server clock information(Not acquired) Select whether to
acquire the clock information from the SNTP server and
reflect the acquired time in the CPU built-in clock .
To get you to change to.
Port No.(123)
Set the port number used to connect to the SNTP server that acquires clock information
. Please do not change.
How to specify the server(IP address)
Select how to specify the SNTP server for which clock information is to be obtained
IP address / host name Do not change, use the IP address.
IP addressSet the IP address of the SNTP server.
Enter the IP address of the NTP server according to the actual environment
hostnameSet the host name (host domain name) of the SNTP server.
Please do not enter anything.
Specified time [hour: minute: second](00:00:00)
Access the SNTP server and set the time to set the clock.
(Setting range: 00:00:00 to 23:59:59)
Timeout time [seconds]Set the timeout detection time. (Setting range: 0 to 255 seconds) If
there is no response from the remote host, the
retransmission process is performed up to 4 times at the time interval set here . Set to 1 second for the
shortest time .
Time difference adjustment(+0) If you want to set the clock information of the CPU unit
by adding the time difference to the time data acquired from the SNTP server
, set it.
Since the SNTP server is UTC, set it to +9 to make it JST .
    • For Windows PC

You can do this by going to “Date and Time”> “Internet Time” tab> “Change Settings”> Update Now.

The above method is a manual setting. Periodic settings are implemented in the task scheduler.

I think it is better to execute the command script and set it.

schtasks / create / tn "TimeDame adjustment" / tr "w32tm / resync" / sc Daily / st 15:00

The above script is a script that executes the command ” w32tm / resync ” at 15:00 every day , and registers it in the task scheduler with the name ” TimeDame adjustment “. * The name is arbitrary.
Since / create is a new creation, I think that once it is created, it should be changed to / change and registered for update. * / Sc cannot be used with / change. If you want to change the time, you can write as follows. You will be prompted for a logon password when you run.
* It seems that overwriting is also allowed.

schtasks / change / tn "TimeDame adjustment" / tr "w32tm / resync" / st 16:00

“ W32tm / resync ” requires that the ntp server is already registered in the Internet time setting.
When this command is actually executed, the command prompt will be launched. If you are worried, it seems that you can solve it by wrapping Script.

The w32tm / monitor option allows you to see the time difference between the local computer and the remote computer (NTP server) and the name of the upper NTP server.

w32tm / monitor / computers:

There are introductory articles on various sites about commands for task scheduler, so I will omit them. I refer to the article of @IT.
I also referred to the following @IT site for the mechanism of NTP.

    • For Linux PC (Raspbian)

Since RTC is not installed in Raspberry Pi hardware, it is reasonable to synchronize the time at startup.
It seems common to edit the configuration file /etc/systemd/timesyncd.conf.

NTP = LocalNTP

[Colon notation]

Since the time notation is handled as “hour and minute”, the colon notation is flashed as a way to easily indicate whether it is working or not. Currently, it is blinking for 0.5 seconds and off for 0.5 seconds.

This colon notation is said to have been applied for a patent by Suwa Seikosha in 1970. It is said that it blinks at intervals of 1 second. It’s been 20 years since I applied, so I don’t think there are any problems left here.
* From “Why was” Yukimi Daifuku “a big hit? 77” Patent “idea” by Akihiko Shigeta

I wonder if there is more demand for 2U panels
I think that the panels handled by Sound House are cheap and easy to process because they are aluminum t1.


Please Login to comment
Notify of
Reusable S/W