Output channel configuration#

Create channel settings, define pulse timing, and select synchronization and counter values with the Python API.

opensync.get_pulse_params()#

Retrieve the default pulse parameters for the pulse generator.

This function initializes and returns a dictionary containing the configuration and pulse data for each output channel.

Returns:

pulse_params – A dictionary containing channels ‘channel_0’ through ‘channel_7’. Each channel contains:

  • ’name’ : str The channel name.

  • ’state’ : bool Whether the channel is enabled (default is False).

  • ’divider’ : int The channel clock divider (default is 1).

  • ’data’ : list[float] Flattened rising/falling edge times in seconds.

  • ’wcounter’ : int The initial synchronization events to skip (default is 0).

  • ’bcounter’ : int The total waveform buffers to execute (default is 0).

  • ’pcounter’ : int The ON synchronization event count (default is 1).

  • ’ocounter’ : int The OFF synchronization event count (default is 0).

  • ’sync’ : str The synchronization source (default is ‘t0’).

  • ’output_level’ : str The output logic level (default is ‘lvttl’).

Return type:

dict

Notes

  • Python channel indices 0 through 7 correspond to firmware output channels 1 through 8, or CHA through CHH.

opensync.config_pulse_state(pulse_params, state, channel_id=0)#

Configure the pulse channel state.

This function updates the pulse parameters to enable or disable the selected output channel.

Parameters:
  • pulse_params (dict) – A dictionary containing pulse parameters from get_pulse_params.

  • state (bool) – True enables the channel. False disables it.

  • channel_id (int, optional) – The index of the channel to configure, from 0 through 7.

Returns:

pulse_params – The updated pulse parameters dictionary.

Return type:

dict

Notes

  • The function modifies the selected channel’s ‘state’ key.

opensync.config_pulse_divider(pulse_params, divider=1, channel_id=0)#

Configure the pulse channel clock divider.

This function updates the pulse parameters to set the clock divider of the selected output channel.

Parameters:
  • pulse_params (dict) – A dictionary containing pulse parameters from get_pulse_params.

  • divider (int) – The desired clock divider, from 1 through 65500.

  • channel_id (int, optional) – The index of the channel to configure, from 0 through 7.

Returns:

pulse_params – The updated pulse parameters dictionary.

Return type:

dict

Notes

  • The function modifies the selected channel’s ‘divider’ key.

opensync.config_pulse_insert(pulse_params, pulse_train, channel_id=0, channel_name=None, units='s')#

Insert pulse timing information into the specified channel.

This function updates the pulse parameters dictionary by inserting the start and end times of one or two pulses into the specified channel. Edge times are converted to seconds and rounded to the nearest nanosecond before being validated and stored.

Parameters:
  • pulse_params (dict) – A dictionary containing pulse parameters from get_pulse_params.

  • pulse_train (list[tuple[float, float]]) – One or two rising/falling edge pairs in the selected units. Edge times are measured from the start of the sequence.

  • channel_id (int, optional) – The index of the channel to configure, from 0 through 7.

  • channel_name (str, optional) – The name to assign to the channel.

  • units (str, optional) – The pulse timing units: ‘ns’, ‘us’, ‘ms’, or ‘s’.

Returns:

pulse_params – The updated pulse parameters dictionary.

Return type:

dict

Raises:

PulseParamsError – If the pulse train size, edge pairs, widths, or delays are invalid.

Notes

  • Each rounded pulse width must be between 44 nanoseconds and 8 seconds, inclusive.

  • The initial delay and gaps between pulses must satisfy the same limits. The first pulse may start at zero without an initial delay.

  • Pulses must be supplied in chronological order.

  • The function replaces the selected channel’s existing pulse data.

  • The ‘data’ key stores flattened rising/falling edge times in seconds.

opensync.config_pulse_wcounter(pulse_params, count, channel_id=0)#

Configure the initial wait counter.

This function updates the pulse parameters to set the number of synchronization events skipped before the channel starts its P/O cycle.

Parameters:
  • pulse_params (dict) – A dictionary containing pulse parameters from get_pulse_params.

  • count (int) – The initial number of events to skip, from 0 through 1000000000. A value of 0 starts on the first accepted event.

  • channel_id (int, optional) – The index of the channel to configure, from 0 through 7.

Returns:

pulse_params – The updated pulse parameters dictionary.

Return type:

dict

Notes

  • The function modifies the selected channel’s ‘wcounter’ key.

  • The initial wait is performed once per program run.

opensync.config_pulse_bcounter(pulse_params, count, channel_id=0)#

Configure the waveform buffer counter.

This function updates the pulse parameters to set the total number of waveform buffers the channel will execute.

Parameters:
  • pulse_params (dict) – A dictionary containing pulse parameters from get_pulse_params.

  • count (int) – The number of waveform buffers to execute, from 0 through 30000000. A value of 0 selects infinite operation.

  • channel_id (int, optional) – The index of the channel to configure, from 0 through 7.

Returns:

pulse_params – The updated pulse parameters dictionary.

Return type:

dict

Notes

  • The function modifies the selected channel’s ‘bcounter’ key.

opensync.config_pulse_pcounter(pulse_params, count, channel_id=0)#

Configure the ON duty cycle counter.

This function updates the pulse parameters to set the number of synchronization events that execute the channel’s waveform buffer before the OFF portion of the P/O cycle.

Parameters:
  • pulse_params (dict) – A dictionary containing pulse parameters from get_pulse_params.

  • count (int) – The ON synchronization event count, from 0 through 1000000000. The firmware treats a value of 0 as 1.

  • channel_id (int, optional) – The index of the channel to configure, from 0 through 7.

Returns:

pulse_params – The updated pulse parameters dictionary.

Return type:

dict

Notes

  • The function modifies the selected channel’s ‘pcounter’ key.

opensync.config_pulse_ocounter(pulse_params, count, channel_id=0)#

Configure the OFF duty cycle counter.

This function updates the pulse parameters to set the number of synchronization events skipped after the ON portion of the P/O cycle.

Parameters:
  • pulse_params (dict) – A dictionary containing pulse parameters from get_pulse_params.

  • count (int) – The OFF synchronization event count, from 0 through 1000000000. A value of 0 means no OFF events are skipped.

  • channel_id (int, optional) – The index of the channel to configure, from 0 through 7.

Returns:

pulse_params – The updated pulse parameters dictionary.

Return type:

dict

Notes

  • The function modifies the selected channel’s ‘ocounter’ key.

opensync.config_pulse_sync(pulse_params, sync, channel_id=0)#

Configure the pulse synchronization source.

This function updates the pulse parameters to select the source whose rising events control the output channel.

Parameters:
  • pulse_params (dict) – A dictionary containing pulse parameters from get_pulse_params.

  • sync (str) – The synchronization source. Accepted values are ‘t0’, ‘cha’, ‘chb’, ‘chc’, ‘chd’, ‘che’, ‘chf’, ‘chg’, and ‘chh’.

  • channel_id (int, optional) – The index of the channel to configure, from 0 through 7.

Returns:

pulse_params – The updated pulse parameters dictionary.

Return type:

dict

Notes

  • The function modifies the selected channel’s ‘sync’ key.

  • A channel cannot select itself as its synchronization source.

opensync.config_pulse_output_level(pulse_params, level, channel_id=0)#

Configure the pulse output logic level.

This function updates the pulse parameters to select the output logic level of the channel.

Parameters:
  • pulse_params (dict) – A dictionary containing pulse parameters from get_pulse_params.

  • level (str) – The selected output logic level: ‘ttl’ or ‘lvttl’.

  • channel_id (int, optional) – The index of the channel to configure, from 0 through 7.

Returns:

pulse_params – The updated pulse parameters dictionary.

Return type:

dict

Notes

  • The function modifies the selected channel’s ‘output_level’ key.

Plotting#

opensync.get_pulse_plot(pulse_params, axis, skip_empty=False, units='us')#

Generate a plot of pulse timing for each channel.

This function takes pulse timing data for multiple channels and generates a plot that visually represents the timing of pulses for each channel on the provided Matplotlib axis. Each channel’s pulse timing is displayed on the y-axis, while the x-axis represents time.

Parameters:
  • pulse_params (dict) – A dictionary containing pulse parameters from get_pulse_params.

  • axis ('matplotlib.axis') – A Matplotlib axis object on which the pulse timing plot will be drawn.

  • skip_empty (bool) – Skip plotting empty channels.

  • units (str) – The units for the x axis. They may be ns, us, ms or s.

Returns:

This function does not return a value. It modifies the provided axis to display the pulse timing plot.

Return type:

None