calibrate-clock

CLI reference

glasgow run calibrate-clock

Measure clock accuracy against a stable external reference signal.

By default measures the internal Glasgow system clock. With --ext-pin, measures a second clock source (e.g. Si5351A output) against the reference instead.

Measure system clock vs GPS PPS reference (1 Hz) on pin B1:

glasgow run calibrate-clock -V 3.3 --ref-pin B1 --ref-freq 1

The reference input expects a signal that crosses the logic threshold cleanly. A 2 V pk-pk sine centred at 1 V works well with the I/O bank set to 2 V.

Measure system clock vs Rubidium reference (2^23 Hz) on pin B1:

glasgow run calibrate-clock -V 2.0 --ref-pin B1 --ref-freq 8388608

Measure Si5351A 10 MHz output on A0 vs same Rb reference on B1:

glasgow run calibrate-clock -V 2.0 \
    --ref-pin B1 --ref-freq 8388608 --ext-pin A0 --ext-freq 10000000

Apply a known rough correction to the baseline before measuring:

glasgow run calibrate-clock -V 2.0 \
    --ref-pin B1 --ref-freq 8388608 --ppm -12.5
usage: glasgow run calibrate-clock [-h] [-V SPEC] --ref-pin PIN
                                   [--ext-pin PIN] --ref-freq HZ
                                   [--ext-freq HZ] [--nominal-sys-clk HZ]
                                   [--gate-time SEC] [--ppm PPM] [--count N]
-h, --help

show this help message and exit

-V <spec>, --voltage <spec>

configure I/O port voltage to SPEC (e.g.: ‘3.3’, ‘A=5.0,B=3.3’, ‘A=SA’)

--ref-pin <pin>

stable reference clock input pin (e.g. B1 for Rb standard) (required)

--ext-pin <pin>

optional external clock to measure (e.g. A0 for Si5351A output); if omitted the system clock is measured (optional)

--ref-freq <hz>

exact frequency of the reference clock in Hz (e.g. 8388608 for 2^23 Hz)

--ext-freq <hz>

nominal frequency of the external clock in Hz (required with –ext-pin)

--nominal-sys-clk <hz>

nominal system clock frequency in Hz (default: 48000000)

--gate-time <sec>

gate window duration in seconds; longer gives more resolution (default: 10)

--ppm <ppm>

initial PPM correction applied to the nominal frequency before measuring (default: 0.0)

--count <n>

number of measurements to take then exit (default: 0 = run forever)

API reference

class glasgow.applet.measure.calibrate_clock.CalibrateClockInterface(logger: Logger, assembly: AbstractAssembly, *, ref_pin: GlasgowPin, ref_freq: float, gate_time_sec: float = MAX_GATE_TIME_SEC, nominal_sys_clk: float = 48e6, initial_ppm: float = 0.0, ext_pin: GlasgowPin | None = None, ext_freq: float | None = None)

Software interface for the clock calibration applet.

async measure() dict

Wait for one gate window and return a result dict.

The gateware sends cumulative counter snapshots; we subtract consecutive snapshots to get the counts for each window. The first snapshot is used only as a baseline and is discarded.