metronomo

Entry point for controlling the Metronomo hardware.

class metronomo.Metronomo(address, port=7879, *, err_on_ver_mismatch=True)

Bases: object

A handle to the Metronomo hardware.

Warning

This class is designed to be instantiated with Python’s with statement, see Examples section.

Parameters:
  • address (str) – IP address or hostname of the hardware

  • port (int) – port number of the server running on the hardware. If None, use factory default 7879

  • err_on_ver_mismatch (bool) – if True (default), raise an exception if the firmware version on the hardware does not match the version expected by this API. Set to False to instead just print a warning message.

Raises:

RuntimeError – if the version of the API is incompatible with the version of the firmware running on Metronomo

Examples

Connect to Metronomo, select external reference clock, wait for a lock, and output a synchronization pulse:

>>> from metronomo import Metronomo
>>> with Metronomo("172.23.40.1") as mtr:
>>>     mtr.set_ref_external(10e6)
>>>     mtr.wait_for_lock()
>>>     mtr.sync_out()
close()

Close the connection to Metronomo.

This method is called automatically upon exit from a with block.

get_firmware_version()

Version of the firmware running on Metronomo.

Return type:

str

is_locked()

Check whether Metronomo is locked to a reference clock.

Return type:

bool

reset()

Reset the clocks to the default configuration.

set_out_clk_freq(out_freq)

Set frequency of all output clocks.

Parameters:

out_freq (float) – output clock frequency in hertz

Returns:

the output clock frequency that was configured, in hertz

Notes

Not all output clock frequencies are supported. If the user requests an unsupported clock frequency, it will be rounded to the nearest supported frequency. The frequency that is actually programmed is returned.

Examples

1 GHz is a supported frequency

>>> mtr.set_out_clk_freq(1e9)
1000000000.0

700 MHz is not supported, rounded to 750 MHz

>>> mtr.set_out_clk_freq(700e6)
750000000.0
set_ref_external(ref_freq=10000000.0)

Program Metronomo to use an external reference clock.

Parameters:

ref_freq (float) – frequency in Hz of the external reference, default 10 MHz

Return type:

float

Returns:

the reference clock frequency that was configured, in hertz

Notes

Not all reference clock frequencies are supported. If the user requests an unsupported clock frequency, it will be rounded to the nearest supported frequency. The frequency that is actually programmed is returned.

Examples

100 MHz is a supported frequency

>>> mtr.set_ref_external(100e6)
100000000.0

17 MHz is not supported, rounded to 15 MHz

>>> mtr.set_ref_external(17e6)
15000000.0
set_ref_internal()

Program Metronomo to use the internal reference clock.

Return type:

float

Returns:

the internal reference clock frequency in hertz

Examples

>>> mtr.set_ref_internal()
10000000.0
sleep(secs)

Tell Metronomo to sleep for secs seconds.

Like time.sleep(), except the sleep is done on Metronomo rather than on the local computer.

Parameters:

secs (float) – duration of sleep in seconds

sync_out()

Output a synchronization pulse (sysref pulse) on all Sync ports.

wait_for_lock()

Wait for Metronomo to lock to the reference clock.

The current thread on the local computer will block until the PLL locks.

Return type:

int