Clocks and time¶
Ordering presses on one TriggerGate never depends on the time of day: each device orders its own inputs on a monotonic clock that cannot jump. The wall clock matters when you compare times between machines, such as log files laid side by side or edges reported by two devices. This page says what TriggerGate does with time, what the clock entry on the web page tells you, and how to keep each kind of TriggerGate synchronized.
What TriggerGate does with time¶
- Ordering within one device uses the device's monotonic clock: the performance counter on Windows, a microsecond timer on the ESP32. Changing or stepping the wall clock never changes the order of a faceoff.
- Every edge report carries the edge's own time, twice. Its monotonic time is the stamp taken when the edge was found: when the interrupt arrived, when the poll that found it read the inputs, or when the X-keys report arrived. Its absolute time is the same instant in UTC. Entries of a tie share one faceoff time, which is how a tie is marked, but each keeps its own stamps.
- The service turns monotonic stamps into UTC through an offset it measures once a second, so a step of the wall clock cannot reorder edges. A step is logged as a warning with the time before and after, and clients are told about it.
- Clients are told the server's clock status when they connect, and again whenever its quality, its time source or its error class changes, or the clock steps. The status names the time source, the quality, the estimated error, the last step and the reason.
- Service log lines are stamped in UTC from the same wall clock, so log lines and edges can be put on one timeline. Lines from two machines line up only as well as the two clocks agree. See Read the service log.
- Each platform states how finely it can order a faceoff, shown in the clock entry's tooltip, for example "orders presses 150 µs apart (interrupt), 10 ms (polled)" on an Advantech card. See Accuracy.
Comparing two machines¶
Two machines' times can be compared only if both follow the same time source. The separation that can then be trusted between an edge on one and an edge on the other is each machine's ordering resolution plus both clocks' stated errors. In an application that uses the WPF templates of the .NET client library, the clock entry's tooltip also says how the application's own computer compares with the server.
Millisecond-class agreement, which NTP on a LAN gives, is enough to lay logs side by side and to tell which machine's event came first by a clear margin. It is not enough to order two contestants on different machines.
Scheduled faceoff start (ESP32 board)¶
An application can ask an ESP32 board to start a faceoff at a given instant on a PTP clock, instead of at once. The request names the instant, the PTP domain, the grandmaster it expects and its timescale. The board accepts it only when:
- its PTP follower is locked to that grandmaster on that domain,
- the start is at least 100 ms in the future, and
- if the request sets a maximum clock error, the board knows its error and it is within that maximum. The board's software PTP follower states no error, so a request that sets a maximum is refused.
A refused request leaves the board's faceoff state unchanged. If the board loses its PTP source, or the source changes, after accepting the request, it cancels the faceoff, also after its start, and tells clients why ("PTP source lost or changed"). A faceoff whose participants are held down at the start is also canceled, naming the inputs. The Windows and Uno services do not schedule faceoffs and refuse such a request. See Hub API and .NET client library for the request.
The clock entry¶
The status area of each instance, on the web page ("Wall clock") and in the WPF templates of the client library ("Clock"), has an entry beside "Connection to TriggerGate" and "GPIO System" that shows the server's clock. It is information only: it never changes the instance's overall status light, because a free-running clock does not affect ordering on that machine.
| Light | Text, for example | Meaning | What to do |
|---|---|---|---|
| Green | "NTP, within 3 ms", "PTP (software), within 1 ms" | Synchronized, and the time source states its error. | Nothing. |
| Amber | "System clock, not synchronized, accuracy unknown" | The clock is free-running, or TriggerGate cannot tell what disciplines it. | See the section for the platform below. |
| Amber | "NTP synchronized · accuracy unknown" | Synchronized, but the time source states no error. | Normal on an ESP32 board. On Windows, check the time service's status. |
| Red | "...; stepped 12 s ago" | The clock jumped within the last 60 seconds. Times around the step are not comparable. It clears by itself after 60 seconds. | Find what set the clock. A disciplined clock should slew, not step. |
| Red | "Clock unusable" | The clock must not be used for comparison. On an ESP32 board, this is shown until its first NTP synchronization. | Check the board's network and NTP server. |
| Gray | "Server does not report its clock", "Not connected" | A server that sends no clock status, or no connection. | Nothing. |
The tooltip gives the time source, the monotonic clock, the last step, the reason in the server's own words, and the instance's ordering resolution. The error ("within 3 ms") is the time source's own bound, not a measurement by TriggerGate.
On an ESP32 board the web page shows more under the entry: the board's own NTP measurement (the observed offset from its NTP server and how old it is) and, under Clock diagnostics, the server, round trip and jitter. A second entry, Faceoff synchronization (PTP), shows whether the board is locked to a PTP master, the grandmaster's identity, the domain and timescale. These are observations, not guaranteed error bounds.
Both entries also show the server's current time, advanced in the browser from the latest sample and marked stale when samples stop arriving. Network delay is not corrected, so this display is not a measurement of synchronization.
Windows¶
The Windows service reads the clock's state from the Windows Time service (w32tm /query /status /verbose):
- synchronized to an NTP server: "NTP", with the time service's own bound (root dispersion plus half the root delay plus the current offset),
- synchronized to the time service's PTP provider (source
PtpProvider): "PTP (software)", with the same bound, - the local clock, a failed synchronization, or a source that is not a host name: "System clock, not synchronized",
- following a Hyper-V host: "System clock", because the host's accuracy is not reported.
The time service's output is read in English. On a Windows installation in another display language TriggerGate cannot read it, and the entry stays amber with the reason "w32tm output not recognized". Third-party time clients, such as Greyware's Domain Time II, are not recognized either: a computer disciplined by one reads as "System clock" unless Windows itself reports it synchronized.
Why a Windows computer with NTP configured is often not synchronized¶
Out of the box, a Windows computer that is not in a domain is set up for "roughly right":
- It asks its time server only every 32,768 seconds, about 9 hours: the NTP client's
SpecialPollInterval, selected by the0x1flag in a server entry such aspool.ntp.org,0x9. - Between polls the clock drifts. A crystal that is a few parts per million off drifts by a hundred milliseconds or more over nine hours.
- One failed poll leaves it unsynchronized until the next attempt, hours later. The time service then reports "not synchronized, source Local CMOS Clock", and TriggerGate shows amber. That is correct: Windows gives no error bound for a clock it is not currently steering.
To see what Windows thinks:
The first shows whether it is synchronized, to what, and when it last succeeded. The second measures the offset to a server directly, whether or not the service is synchronized.
Option 1: NTP, polled often (recommended)¶
- Use a time server on the same network where you can, and the same one for every machine in the rig. Show networks are often isolated from the internet, and machines that follow one LAN server agree with each other far better than machines that each follow a different internet server. Any machine or small appliance serving NTP will do; see A bridge.
- List more than one server when you have them, so one bad answer does not cost the synchronization.
- Poll every minute or so instead of every nine hours.
In an elevated prompt, with your own servers in place of the pool names:
w32tm /config /manualpeerlist:"0.pool.ntp.org,0x8 1.pool.ntp.org,0x8 2.pool.ntp.org,0x8" /syncfromflags:manual /update
reg add HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Config /v MinPollInterval /t REG_DWORD /d 6 /f
reg add HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Config /v MaxPollInterval /t REG_DWORD /d 10 /f
net stop w32time && net start w32time
w32tm /resync /force
w32tm /query /status
0x8means "client mode, normal polling".0x9adds "use the special poll interval", which is the nine-hour default.- The two poll values are powers of two, in seconds: 2^6 = 64 s at the shortest, 2^10 = about 17 minutes at the longest.
- The time service should start automatically (
sc qc w32time), and UDP port 123 must be allowed out.
Afterwards the entry should read "NTP, within N ms" within about a minute. Expect a few milliseconds against a LAN server and tens of milliseconds against internet servers. Two machines that list the same server name are treated as sharing a source.
Option 2: PTP on Windows (when there is a PTP master and no NTP server)¶
PTP needs a grandmaster on the network. A Dante network usually has one already, because Dante devices with AES67 enabled publish a PTPv2 clock on domain 0.
Windows 10 version 1809 and later, Windows 11, and Windows Server 2019 and later include a PTP client as a provider of the Windows Time service (ptpprov.dll). It has no user interface and is switched on in the registry. In an elevated prompt:
reg add HKLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\PtpClient /v PtpMasters /t REG_SZ /d <grandmaster IP> /f
reg add HKLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\PtpClient /v Enabled /t REG_DWORD /d 1 /f
reg add HKLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\PtpClient /v InputProvider /t REG_DWORD /d 1 /f
reg add HKLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\PtpClient /v DllName /t REG_SZ /d %SystemRoot%\System32\ptpprov.dll /f
reg add HKLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient /v Enabled /t REG_DWORD /d 0 /f
netsh advfirewall firewall add rule name="PTP-319" dir=in action=allow protocol=UDP localport=319
netsh advfirewall firewall add rule name="PTP-320" dir=in action=allow protocol=UDP localport=320
net stop w32time && net start w32time
Progress and errors are in Event Viewer under Applications and Services Logs, Microsoft, Windows, Time-Service-PTP-Provider.
Know these limits before choosing it:
- The master is named by IP address. On a Dante network the master is elected and can change, and a fixed address then stops working.
- The PTP domain must match the grandmaster's, or the provider ignores the packets without saying so.
- It only listens, and it timestamps in software. Expect millisecond-class agreement, about the same as NTP against a LAN server. On Windows, PTP mainly buys "works where there is no NTP server", not better accuracy.
- Only one program on a computer can use the PTP ports (UDP 319 and 320). Dante Virtual Soundcard runs its own PTP client, so a computer with it installed cannot also run the Windows provider.
- TriggerGate shows "PTP (software)" only when the time service names
PtpProvideras its source. Comparew32tm /query /status /verbosewith the clock entry if they disagree.
For better than a millisecond on a Windows computer itself, a commercial client with hardware timestamping is needed. TriggerGate does not recognize such clients (see above).
Advantech UNO¶
On the Uno, the settings dialog of the web page has an NTP server field when the device keeps time with systemd-timesyncd and no other time service (chrony, ntpd, ntpsec, OpenNTPD or phc2sys) is active. Enter one host name or IP address, without a port; leave it blank for the operating system's default. TriggerGate writes the server to its own file, /etc/systemd/timesyncd.conf.d/90-triggergate.conf, and restarts systemd-timesyncd. If the restart fails, it puts the previous file back. NTP servers supplied by the network (DHCP) may take precedence over this setting.
When the field cannot be offered, the dialog says why: another time service manages the clock, systemd-timesyncd is not active, or TriggerGate's file is a symbolic link. Configure the time service in the operating system then.
The UNO-220's real-time clock (an RX8010) has no driver in the current Raspberry Pi OS kernel (kernel 6.18 has no rtc-rx8010 module), so under this operating system the device has no battery-backed clock and keeps time from the network (NTP) only. Until it reaches an NTP server after a power cut, its wall clock is not reliable.
The Uno service cannot read the clock's discipline from the operating system, so its clock entry shows "System clock, not synchronized" (amber) even when the device is synchronized. The Uno does not schedule PTP faceoffs.
ESP32 board¶
An ESP32 board keeps two clocks of its own, side by side:
- Wall clock, by NTP. The board synchronizes to one NTP server,
pool.ntp.orgunless you set another in the web page's settings dialog (a host name or IP address). Set a server on the show network when the network has no internet access. The setting is saved in the board's flash. - PTP, for scheduled faceoffs. The board follows a PTP master on domain 0 by itself, with no setting: PTPv2, end-to-end delay, multicast on UDP ports 319 and 320. It takes its timestamps in software, so it states no error bound.
The clock entry shows PTP (software) while the PTP follower is locked and gives a UTC time, NTP while the NTP synchronization is fresh, and otherwise "System clock" or, before the first NTP synchronization, "Clock unusable". It is never green, because neither source states an error: "accuracy unknown" is the normal reading on a synchronized board. Single-board faceoffs need neither NTP nor PTP.
A bridge: one small box that follows PTP and serves NTP¶
Usually the better arrangement when the network has a PTP master and several Windows computers:
- One small Linux machine (a Raspberry Pi is enough) on the show network follows the grandmaster with
ptp4l, using hardware timestamps, and serves NTP to the LAN with chrony. Where there is no PTP master at all, the same box can be the grandmaster. - Every Windows computer uses Option 1 against that box, and ESP32 boards use it as their NTP server.
Each Windows computer then gets the accuracy the built-in PTP provider would give, without the fixed-master and port-conflict problems, and every machine reports the same time source, which is what lets TriggerGate compare them.