GPS NTP time server unit
GPS NTP time server unit
0
Components
Hardware componentsSTM32miniShiled Kit
x 1
W850ioModule
x 1
TM1637 Display module
x 1
USB cable + USB power adapter
x 1
Stereo mini jack connector
x 1
Project description
Here, we will introduce the GPS NTP time server that can be provided using STM32minShield. Original link:?https://www.toolsbox.biz/product/STM32MINIShieldEvaluation/GPSTimeServerUnit.html * 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. column
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 https://e-words.jp/ 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 https://e-words.jp/ 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】[Installation】I will clarify what kind of components the contents written here will be realized. Roughly, it can be achieved with the following component elements.[System example]
- STM32miniShiled Kit
- W850ioModule
- GPS antenna module (stereo mini plug type)
- TM1637 Display module
- USB cable + USB power adapter
- Stereo mini jack connector
- Suitable housing
[specification】
GPS time server remarks Time adjustment method GPS Read and adjust sentence $ xxRMC Operating state SNTP server (time synchronization) HTTP server (setting) Time accuracy According to the accuracy of the GPS module Internal time is delayed by processing time LAN interface 10 / 100BASE-TX RJ-45 Supported protocols SNTPv4 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 antenna Reception frequency (MHz) 1575.42 ± 5 I'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 method Magnet 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 example explanation meaning GP RMCExistence like GPS positioning summary data 085120.307 Times of Day 8: 51: 20.307 A Data validity A / B / V / W A = valid current data 3541.1493 Latitude DDMM.MMM format Latitude: 35 degrees 41.1493 minutes N Latitude direction N / S N = North latitude 13945.3994 longitude Longitude; 139 degrees 45.3994 minutes E Latitude direction E / W E = East longitude 000.0 Speed ??of movement on the surface of the earth Movement speed: 000.0 [knot] 240.3 True direction of movement on the surface of the earth True direction of movement: 240.3 degrees 181211 Date DDMMYY UTC 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 A Positioning mode N / A / D / E / M / S / A = autonomous method * 6A Checksum Sentence example 2: $ GNRMC,004055.000,A,3430.62710,N,13316.68285,E,0.05,115.20,251220 ,,, A, V * 0BWe actually investigated the target GPS modules available on amazon.
Word example explanation meaning GN RMCExistence like GPS positioning summary data 004055.000Times of Day 00: 40: 55.000V Data validity A / B / V / W V = navigation receiver warming 3430.62710Latitude DDMM.MMM format Latitude: 34 degrees 30.627 10 minutes N Latitude direction N / S N = North latitude 13316.68285longitude Longitude; 133 degrees 16.68285 minutes E Latitude direction E / W E = East longitude 0.05 Speed ??of movement on the surface of the earth Movement speed: 0.05 [knot] 115.20True direction of movement on the surface of the earth True direction of movement: 115.20 degrees 251220Date DDMMYY UTC 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 N Positioning mode N / A / D / E / M / S / A = Data invalid VNavigation status S / C / U / V V: Disabled (RAIM function OFF) * 0B Checksum
brand Reference model number price cable length Photos, etc. ThiEYE CV3-GPS 2999 VANBAR A2000 1499 Superbat GA50-180-35MRA 1380 1.8m Crosstour 5823920520 1499 VANBAR D164 1300 NZACE 999 YAZACO YG30 1790 AZDOME JPDOME-GS01 1999 AKEEYO AKY-X2-GPS 2088 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)]
[set up】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 the IP address of the NTP server
- 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 192.168.0.199. You need to change this value to suit your environment / network zone.
- Prepare a PC whose IP address can be changed freely, and connect the PC and NTP server directly with a LAN cable.
- Temporarily change the IP address on the PC side to 192.168.0.1.
![[ Power on]](https://www.toolsbox.biz/product/STM32MINIShieldEvaluation/SetIPAddress.gif)
- Ping the NTP server from the PC.
Start a command prompt on the desktop on the PC side, enter ping 192.168.0.199, 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. - 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 192.168.250.1, so this zone is often adopted.
In this case, the NTP server should be 192.168.250.199.
Access https://192.168.0.199 from a browser (Chrome is good) from a PC.
Click the Setup1 link to open the setup screen.
Change the IP address to 192.168.250.199 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 0.0.0.0. - This completes the settings on the NTP server side.
Is it recognized in the new environment??Check with ping and browser.
![[ Power on]](https://www.toolsbox.biz/product/STM32MINIShieldEvaluation/setup.gif)
- 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
- 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.
- Set the IP address of the NTP server
-
-
- 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 name Content (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 address Set the IP address of the SNTP server. Enter the IP address of the NTP server according to the actual environment ⑤ hostname Set 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.
|
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: 192.168.0.199There are introductory articles on various sites about commands for task scheduler, so I will omit them.?I refer to the article of @IT. https://www.atmarkit.co.jp/ait/articles/1207/12/news146.html I also referred to the following @IT site for the mechanism of NTP. https://www.atmarkit.co.jp/ait/articles/0508/12/news089.html
-
- 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 = 192.168.0.199 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. https://www.soundhouse.co.jp/products/detail/item/53980/
![[ Power on]](https://www.toolsbox.biz/product/STM32MINIShieldEvaluation/GPSNTP-2U.gif)

[specification】
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.










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.![[ Power on]](https://www.toolsbox.biz/product/STM32MINIShieldEvaluation/GPSNTP_Sysmac.gif)
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.
“?
There are introductory articles on various sites about commands for task scheduler, so I will omit them.?I refer to the article of @IT.
https://www.atmarkit.co.jp/ait/articles/1207/12/news146.html
I also referred to the following @IT site for the mechanism of NTP.
https://www.atmarkit.co.jp/ait/articles/0508/12/news089.html