2.1. LoRa Modulation
Long-range (LoRa) modulation is a chirp spread spectrum (CSS) modulation that was developed by the Semtech Corporation [
22] and has become popular for IoT applications. Each symbol consists of a cyclically shifted frequency ramp with a bandwidth
, as shown in
Figure 1.
The information to be transmitted is modulated on the symbol by possible cyclic time shifts of the frequency ramp, whereby a symbol carries bits. The value is also termed spreading factor but does not play the same role as in code-division multiple-access (CDMA) systems, since the bandwidth can be configured independently of the spreading factor. The cyclic shift has a resolution of .
LoRa modulation is typically used in the license-free 863–870 MHz band in Europe and 902–928 MHz in North America. However, in Europe, the duty cycle is limited to 1 % and the effective radiated power (ERP) is limited to 14 dBm in most of the 863–870 MHz frequency range [
23]. Since this duty cycle limitation would not allow for a regular packet exchange as required for time synchronization, in this work, the 2.4 GHz ISM frequency band was used for implementing the time synchronization system, where no duty cycle limitation is in place.
The SX1280 transceiver of Semtech was chosen, since it operates in the 2.4 GHz ISM frequency band and incorporates a ranging engine, which is primarily intended to measure the time of flight between two SX1280 transceivers [
20]. The SX1280 supports bandwidths
and 1625 kHz and spreading factors
for ranging. With the maximum bandwidth of 1625 kHz, a distance resolution of
can be achieved; see Section 2.1.3 in [
24]. The distance resolution translates into a time-of-flight resolution of
, which seems to be too large for a time synchronization system with a targeted accuracy in the ns range. However, since the time synchronization system must not resolve different multipaths but rather compensate the time of flight as seen by the system between the transmitter and receiver, it is possible to achieve a higher time synchronization accuracy than the limited temporal resolution provided by the relatively small signal bandwidth. This is shown by the time deviation of 3 ns obtained by the proposed system in
Section 3.2, which is significantly lower than the time-of-flight resolution
. However, the accuracy will depend on the signal-to-noise ratio (SNR) [
25].
Regarding the achievable range, the best RX sensitivity of −122 dBm is obtained with
and
, resulting in a maximum coupling loss of 134.5 dB for the maximum TX power of 12.5 dBm supported by the SX1280 ranging engine [
20]. This corresponds to a range of several kilometers in a rural non-line-of-sight environment with omni-directional antennas.
2.2. Time Synchronization Protocol and Method
The time synchronization is based on the SX1280 PHY-layer ranging engine, which uses a two-way exchange for half-duplex systems according to Section 6.1 of [
24] to determine the time of flight (TOF) between two SX1280 devices. With a two-way exchange, it is also possible to measure the clock offset between two terminals with unsynchronized clocks, which will be used here to align the clock of the secondary side to the reference clock on the primary side [
26].
Figure 2 shows an overview of the developed time synchronization system. The external reference clock in the form of a 1 Hz PPS signal is input to the primary side, where it is used to synchronize the internal local clock to provide local timestamps. Using the subsequently described time synchronization protocol, the internal local clock on the secondary side is synchronized in frequency and phase to the primary side. The synchronized time is then provided as a 1 Hz PPS signal, with an additional 10 MHz reference frequency signal.
In
Figure 3, two sequential two-way exchanges between the primary and secondary side are shown, each consisting of a request, followed by a response after a fixed delay. The ranging engine of the SX1280 transceiver is primarily designed to measure the range between two devices based on the round-trip time of flight, which it determines using a single two-way exchange. To perform time synchronization with a single two-way exchange, both the transmit and receive interrupts (to determine a transmission and reception timestamp) of each of the two messages are required. However, the SX1280 ranging engine only provides transmit and receive interrupts for the response.
Therefore, we use two sequential two-way ranging exchanges of the SX1280 to mimic a single two-way ranging exchange to provide the four required timestamps. By defining the timestamp
in
Figure 3 as the timestamp number
on side
, the transmit and receive interrupts are then used to obtain the corresponding four timestamps
,
,
and
To mark the beginning of the ranging exchanges, we use a start packet. Additionally, a packet with timestamps
,
and the normalized local clock frequency
is sent from the primary to the secondary side at the end of the ranging exchanges, as described subsequently.
In the first ranging exchange, started from the primary side according to
Figure 3, the timestamp number 1 at the secondary side (2)
is measured, as well as the timestamp number 2 at the primary side (1)
. These two timestamps correspond to the transmission time of the response plus an internal delay
and to the reception time of the response plus an internal delay
on side 2 and side 1, respectively. In the second ranging exchange, started from the secondary side, the timestamps number 3 and 4 are measured, at the primary side (1) as
and at the secondary side (2) as
. These timestamps also include their corresponding internal delays.
The timestamps are measured using local unsynchronized clocks (a free running timer on the primary and secondary side), as the controller only moves the position of the one-second period start to synchronize the local clock on both sides. The one-second period start corresponds to the positions of the PPS marker shown in
Figure 3. This PPS marker corresponds on the secondary side to the synchronized time information. It should be noted that
Figure 3 shows the synchronized state, where the PPS marker positions of the primary and secondary side have been aligned. Therefore, the local timestamps from the free running timers must be corrected to reflect the correction of the control algorithm on the local clock. For the local time on the primary side (1) as an example, this corrected time is
in which the locally measured unsynchronized timestamp 2 on the primary side 1, expressed as
, is translated into timestamp 2 with the correction of the control algorithm
. The correction value is the normalized frequency of the timer on the primary side,
where
is the frequency error and
is the nominal frequency of the local timer. The local time on the secondary side can be corrected in an analogous way. Equation (2) may also be rewritten to calculate local unsynchronized times from corrected times.
Time synchronization can be achieved by minimizing the time error
between the timestamp
in the local unsynchronized time of side 2 and the nominal timestamp
, which is also in the local unsynchronized time 2 but calculated from the reference time as shown subsequently. The same time offset can also be expressed using the timestamp
, resulting in
The measured value of
is used as the control deviation by the controller of the local timer to adjust the position of the 1 s PPS marker. Using the correction in Equation (2) and by introducing the signal propagation time
between the two devices, the two nominal timestamps according to
Figure 3 become
where
corresponds to the propagation delay plus any hardware delays (due to transmission lines, filters and the low-noise amplifier on the printed circuit board and RF cables). Since the channel is assumed to remain static during the two sequential two-way ranging exchanges, the delay
is constant. Additionally,
is assumed to be identical in both directions.
Combining Equations (4)–(6) produces
Although the datasheet of the SX1280 [
20] does not specify the following values and they are not accessible to the user, based on our observations, we assume for the delays that
and
hold and that the values are
. Furthermore, with the chosen local oscillator, the normalized frequency errors are guaranteed to fulfill
and
. With these assumptions, we obtain
which is significantly smaller than the desired accuracy. An analogous statement can also be made for
and
. With the above assumptions, the terms containing the delays
,
,
and
in Equation (7) are negligible. Consequently, the time offset in Equation (7) simplifies to
which expresses
in terms of uncorrected local times on the secondary side 2. Equation (9) can be converted to the corrected local times on the secondary side 2 based on Equation (2) as
Since the goal of the time synchronization is to minimize the time offset between the secondary and primary side, either Equation (9) or (10) may be used as a control input for adjusting the position of the 1 s PPS marker.
Equation (10) corresponds to a standard two-way ranging procedure [
24], which is started from the secondary side, except for the addition of the time corrections. The correction values
and
are determined from the integral components of the employed proportional–integral (PI) controllers on the primary side 1 and secondary side 2, respectively, as described in
Section 2.3.2. The value
is transmitted at the end of the ranging exchanges together with the stamps
and
from the primary to the secondary side, as shown in
Figure 3. The initial values of
and
are set to zero.
2.3. Time Synchronization System Design
The following subsections describe the design and implementation of the wireless time synchronization system. This section is structured as follows. The first subsection provides an overview of a time synchronization device configured for primary-side and for secondary-side operation. The second subsection explains the measurement of the timestamp values , , and , as well as the 1 Hz PPS signal generation. Next, the phase offset and cable delay compensation are described. The last subsection gives an overview of the implemented LoRa communication protocol and timing.
2.3.1. Overview
Figure 4 shows the block diagram of our wireless time synchronization system based on the LoRa transceiver SX1280. Starting at the antenna, an SAW filter and low-noise amplifier are used in the receive direction to improve the immunity against out-of-band interference and to reduce the total noise figure. The necessary RF switches to change between the receive and transmit direction are controlled by the MCU.
The STM32F474 microcontroller unit (MCU) contains the application that covers the tasks for communication protocol handling, including timestamp measurement, the PPS controller and the low-level hardware drivers, as well as the visualization of the network and time synchronization status on a display. National Marine Electronics Association (NMEA) compliant time and date information can be exchanged with the help of the RS232 and USB interfaces.
The internal and external clock signals are generated within an Analog Devices AD9545 “1 PPS synchronizer and jitter cleaner” using an Abracon AOCJY3A 100 MHz oven-controlled crystal oscillator (OCXO) with a rated frequency stability of 10 ppb. The 52 MHz clock for the LoRa transceiver and the 20 MHz clock for the MCU are generated from a primary analogue phase-locked voltage-controlled oscillator (VCO) that is linked to the OCXO, while the 1 Hz PPS and 10 MHz output signals are derived from a secondary phase-locked loop (PLL) with a VCO running at 2.46 GHz. This secondary PLL digitally compares the divided 1 Hz PPS output with a 1 Hz reference input and disciplines the underlying analogue PLL, which is also linked to the OCXO. This secondary PLL contains a 10 mHz loop filter used to clean up the signal by reducing the jitter and quantization noise of the output 1 Hz PPS signal. The OCXO and AD9545 are the main energy consumers, having a total steady state power consumption of 3 W.
The secondary PLL configuration depends on the device operating mode. For the primary side, the frequency and phase synchronization are based on the external 1 Hz PPS signal of the reference clock. The cleaned-up internal 1 Hz PPS signal output of the DPLL is then synchronous to the external reference clock and is measured by an internal 32-bit hardware timer of the MCU. This measurement is used to synchronize the internal local clock of the MCU, which serves as the time base for the application. Due to the limited counting frequency of 150 MHz for the timer, a time quantization error of up to ±3.33 ns arises. This is also valid for the timestamp measurement of the interrupt signals , , and generated by the LoRa transceiver.
The secondary side uses the same timer to generate the 1 Hz PPS signal of the local clock based on the timestamps of the ranging exchanges using a PI controller. The secondary PLL uses this 1 Hz PPS signal as reference and reduces its quantization error to the sub-ns range in the 1 Hz PPS output signal.
2.3.2. Timer-Based Timestamp Measurement and 1 Hz PPS Generation
An internal 32-bit hardware timer of the MCU running at 150 MHz is used to measure the timestamps of the interrupt signals and to generate the output 1 Hz PPS signal of the MCU on the secondary side. The timer clock signal is derived from the OCXO without frequency offset correction. It is configured to count from 0 to and restarts again from 0, where is the overflow or 1 Hz period value. is initially set to , which corresponds to the nominal duration of one period of the 1 Hz PPS signal.
The frequency and phase offset measurement between the 1 Hz PPS signal of the external reference clock cleaned up by the DPLL and the internal local clock on the primary side is performed with one input capture/compare channel. The first 1 Hz PPS timestamp measurement is used to correct the coarse phase offset by adapting the overflow value
for one period and then switches back to
. The following measurements are then expected to be within some microseconds before or after an overflow (corresponding to the positions of the PPS marker shown in
Figure 3) and are fed as time error values
to the PI controller. Small positive values are measured when an overflow event occurs before receiving the reference 1 Hz PPS signal, which indicates a too-high local oscillator frequency and vice versa.
The PI controller is responsible for adapting the overflow value
to align the phase of the PPS Out signal to the phase of the reference signal and increases
in case of a too-high local oscillator frequency to compensate the deviation. This is implemented according to
where
and
are heuristically determined constants.
The normalized local clock frequency error can be determined by
and the correction value required for the time synchronization method in
Section 2.2 corresponds to
where
can stand for
or
depending on the device operation mode.
The secondary side uses the calculated time error from (9) as input to the PI controller, which adapts the timer overflow period in the same way as for the primary side. The interrupt timestamp measurements are also made using capture/compare channels.
2.3.3. Phase Offset and Cable Delays
Internal delays between the connectors and the integrated circuits, such as transmission lines on the printed circuit board, level-shifters, filters and the low-noise amplifier, have been measured and are compensated in the firmware.
However, external delays, for example, due to cables carrying PPS signals, can vary between setups. To remove setup-dependent external delays, the system was calibrated using an RF transmission over a coaxial cable of 75 m electrical length with one node placed in an RF shielding box to avoid coupling over the air between the two nodes. The PPS Out of the two devices can be measured with an oscilloscope at the cable ends to determine the time difference. This difference can be configured and compensated in one of the two devices.
2.3.4. Communication Protocol
The devices of the wireless time synchronization system use a simple protocol to identify and to help to set up the required wireless links. They randomly transmit beacon messages every 3 to 5 s containing a unique device address. These beacon messages combined with a received signal power measurement within the LoRa transceiver can be used to check the antenna setup and wireless link quality. The communication and ranging/synchronization exchanges are performed in the 2.4 GHz ISM frequency band at a bandwidth
and the LoRa spreading factor SF10, which is a compromise between time-of-flight resolution and range based on the specified sensitivity of the SX1280 [
20]. Using
obtains only half the distance resolution compared to
, but has a 6 dB higher sensitivity, which leads to a higher SNR and improved accuracy for timestamp measurements.
The primary device first sends a start packet as shown in
Figure 3, which contains the target address, and it then switches to the ranging mode to perform the two sequential two-way ranging exchanges. It finally switches back to the data transmission mode and sends the timestamp values
and
together with the normalized clock frequency
to the secondary side if the exchange could successfully be finalized. Additionally, not shown in
Figure 3, a UNIX timestamp in seconds is sent to the secondary side. This procedure is performed every second, 700 ms after the timer overflow event, and takes about 200 ms.