Skip to content

Commit ba69229

Browse files
committed
Improved specification of sync clock protocol
* Improved specification of synchronization clock protocol * Adopt requirement key words from RFC 2119 * Reorganize document sections for consistency and improve wording * Add explicit transmission packet diagram
1 parent dd9a63f commit ba69229

File tree

1 file changed

+53
-22
lines changed

1 file changed

+53
-22
lines changed

SynchronizationClock.md

Lines changed: 53 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,60 @@
11
<img src="./assets/HarpLogo.svg" width="200">
22

3-
# Synchronization Clock Protocol (1.0)
3+
# Synchronization Clock Protocol
44

5-
## Introduction
6-
The Harp Synchronization Clock is a dedicated bus that disseminates the current time to/across Harp devices. It is a serial communication protocol that relays time information. The last byte in each message can be used as a trigger, and allows a Device to align itself with the current Harp time.
5+
This document provides the specification for the Harp Synchronization Clock, a dedicated bus used to synchronize the current time across Harp devices with sub-millisecond accuracy.
76

8-
## Serial configuration
7+
## Requirements Language
98

10-
* The Baud rate used is 100kbps;
11-
* The last byte starts *exactly* 672 us before the elapse of the current second (e.g.:)
9+
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC 2119](https://www.ietf.org/rfc/rfc2119.txt).
1210

13-
!["SynchClockOscilloscope](./assets/SynchClockOscilloscope.png)
11+
## Serial Interface
1412

15-
* The packet is composed of 6 bytes (`header[2]` and `timestamp_s[4]`):
16-
- `header[2] = {0xAA, 0xAF)`
17-
- `timestamp_s` is of type U32, little-endian, and contains the previous elapsed second.
13+
The Harp Synchronization Clock is a serial communication protocol for relaying time information over RS-232. Each message transmits the current timestamp, in whole seconds. The transmission of the last byte in each message is used as a synchronization signal, allowing Harp devices to align their clocks with sub-millisecond accuracy.
1814

19-
A sample logic trace is shown below:
20-
!["SynchClockLogicAnalyzer](./assets/SyncLogicTrace.png)
15+
### Baud Rate
16+
17+
The baud rate for all transmitted data MUST be 100 kbps.
18+
19+
### Transmission Packet (6 bytes)
20+
21+
All Harp Synchronization Clock messages MUST use Little-Endian byte ordering and follow the structure below:
22+
23+
<table>
24+
<tr>
25+
<th align="center">5</th>
26+
<th align="center">4</th>
27+
<th align="center">3</th>
28+
<th align="center">2</th>
29+
<th align="center">1</th>
30+
<th align="center">0</th>
31+
</tr>
32+
<tr>
33+
<td align="center">0xAA</td>
34+
<td align="center">0xAF</td>
35+
<td align="center" colspan="4">U32</td>
36+
</tr>
37+
<tr>
38+
<td align="center" colspan="2">Header</td>
39+
<td align="center" colspan="4">Previous Elapsed Second</td>
40+
</tr>
41+
</table>
42+
43+
### Transmission Timing
44+
45+
Transmission of the last byte MUST start exactly 672 μs before the current second lapses, as shown below:
46+
47+
## Example Logic Trace
48+
49+
Example traces of the transmission signals are shown below from both a logic analyzer and an oscilloscope:
50+
51+
!["SynchClockLogicAnalyzer](./assets/SyncLogicTrace.png)
52+
53+
!["SynchClockOscilloscope](./assets/SynchClockOscilloscope.png)
2154

2255
## Example code
2356

24-
Example of a microcontroller C code dispatching the serialized data:
57+
Example microcontroller C code dispatching the serialized data:
2558

2659
```C
2760

@@ -56,7 +89,8 @@ ISR(TCD0_OVF_vect, ISR_NAKED)
5689
}
5790
```
5891
59-
Example of a microcontroller C++ code for converting the four received encoded bytes to the timestamp:
92+
Example of microcontroller C++ code for converting the four received encoded bytes to the timestamp:
93+
6094
````C
6195
#define HARP_SYNC_OFFSET_US (672)
6296
@@ -72,28 +106,25 @@ Example of a microcontroller C++ code for converting the four received encoded b
72106
73107
A full example demonstrating a state machine receiving the 6-byte sequence can be found in the [Pico Core](https://github.com/harp-tech/core.pico/blob/main/firmware/src/harp_synchronizer.cpp).
74108
75-
---
76-
77-
78-
## Physical connection
109+
## Physical Connection
79110
80-
The physical connection is made by a simple 3.5mm audio cable.
111+
The physical connection for transmission of the Harp Synchronization Clock SHOULD be made by a 3.5 mm audio cable.
81112
82113
The connector pinout for a device *receiving* the timestamp is shown below:
83114
84115
!["SynchReceiverSchematic](./assets/HarpClockSyncReceiver.png)
85116
86-
A TVS diode is also suggested for ESD protection.
117+
A TVS diode is RECOMMENDED for ESD protection.
87118
88119
> [!IMPORTANT]
89-
> The device receiving the timestamp must provide 3.3-5V (~10mA) on the audio jack **R** pin.
120+
> The device receiving the timestamp MUST provide 3.3V-5V (~10 mA) on the audio jack **R** pin.
90121
91122
The schematic snippet for a device *sending* the timestamp is shown below:
92123
93124
!["SynchSenderSchematic](./assets/HarpClockSyncSender.png)
94125
95126
> [!NOTE]
96-
> The device *sending* the timestamp isolates each clock output port, preventing ground loops from forming when connecting the audio jack between sender and receiver.
127+
> The device *sending* the timestamp SHOULD isolate each clock output port, preventing ground loops from forming when connecting the audio jack between sender and receiver.
97128
98129
A supplementary PDF [example](./assets/PhysicalConnector.pdf) of the sender and the receiver is also available.
99130
The connector used is from `Switchcraft Inc.` with PartNo. `35RASMT2BHNTRX`.

0 commit comments

Comments
 (0)