How-to: Configuring System Time on Your SDR

In this how-to, we discuss configuring system time to use an external reference (GPS discilpined oscillator) for a 10MHz reference and PPS that depends on the Network Time Protocol (NTP) for precise timekeeping and time measurement and/or synchronizing multiple software defined radios (SDRs) and/or host system computers. To learn more about how we manage system time on our SDRs, see this Application Note.

1. How-to configure the correct absolute time on Per Vices SDRs

There are two options for this:

  1. Option A: Configure the SDR to use an External 10MHz reference, PPS and NTPd for system time on the SDR. See the NTPd how-to guide and how-to configure system time guide for configuring your SDR for this.
  2. Option B: Sets the system time on the SDR to an approximation of NTPD (within +/- 0.5s), and subsequently uses external PPS and (soft) correction to correctly set the fractional and integer time to absolute (NTPD/GPS) time.

1. How to Setup External Reference and PPS

1.1 Crimson

To manually setup external reference and PPS on Crimson TNG, first ensure you’re injecting a 10MHz reference to the REF (External Clock Input) SMA, and do the following commands:

  1. SSH into the unit:

    $ ssh dev0@192.168.10.2
    
  2. Echo to set external:

    $ echo external > /var/volatile/crimson/state/time/source/ref
    

1.2 Cyan

To manually setup external reference and PPS on Crimson TNG, first ensure you’re injecting a 10MHz reference at the REF (External Clock Input) SMA, and do the following commands:

  1. SSH into the unit:

    $ ssh dev0@192.168.10.2
    
  2. Echo to set external:

    $ echo external > /var/cyan/state/time/source/ref
    

2. How to Configure External Reference and PPS using UHD (using the get/set commands)

UHD is what specifies the reference clock source, seen in the following lines of code. As a user, you will not want to modify this code, but you can change your reference source using our example program rx_samples_to_file.

When using the rx_samples_to_file program, you can see that the name of reference source, can be “internal”, “external”, or “mimo” (by default it is “internal”). Provided you’ve passed all the other arguments in, you can pass one in for “–ref”. As an example:

    $ sudo ./rx_samples_to_file --file rx_file.dat --nsamps 100000 --duration --freq 1000000 --ref external

Alternatively, you can use an example program to set clock reference.

This program will automatically configure your reference clock and will return “EXIT_SUCCESS” upon changing reference clock to external.

3. How to also configure using NTPD

To configure your SDR with Network Time Protocol Daemon, see here.

Note

There’s also a SYSTEMD service that synchronizes time between Linux and FPGA.

4. Example: Set the Start of Burst (SOB) Time

One example demonstrating the purpose of system time is setting the SOB time. When using the SDR to start transmitting or SOB at a specific absolute date and time in the future, there are a couple options:

  1. One option is using the program’s command line flags to state the SOB time argument, as discussed in subsection 4.1
  2. Another option is to code into the actual UHD program when you want the SOB to occur, as discussed in subsection 4.2

4.1. SOB time using command line flags

When running a program such as Tx_waveforms, one can use the command line flags to specify a number of parameters such as gain, number of samples to be transmitted, wave frequency, channels as well as a few important flags important for our purpose: pps, ref, and first. To see all these flags, you can run the following:

    $ ./tx_waveforms.cpp --help

To actually set up your program to have an absolute SOB time, you will need to provide specifics. For example, to use all four channels and the external PPS/reference we set up above, and to start transmitting 10 seconds into the future, 10,000,000 samples every second, and stop at 20 seconds, you can run the following:

    $ ./tx_waveforms.cpp --rate 10000000 --channels "0,1,2,3" --freq 15000000 --gain 25 --wave-type SINE --wave-freq 1000000 --nsamps 10000000 --pps external --ref external --first 10 --increment 1 --last 20

4.2 SOB time using UHD code

Another way is to actually write or modify a program to set the SOB time at a relative time in the future. This is done by first running a get time and then adding, some seconds to that time, and then setting the SOB time to be the get time + seconds of additional time.

For example, in the line shown in tx_waveforms.cpp, one can change to be 10 seconds into the future by writing the following: