Clock configuration#
The internal rate timer, T0, provides synchronization events for output channels. These functions create and edit its configuration.
- opensync.get_clock_params()#
Retrieve the default clock parameters for the pulse generator.
This function initializes and returns a dictionary containing the default clock parameters for the T0 clock sequencer.
- Returns:
clock_params – A dictionary containing the default clock parameters. The structure of the dictionary includes:
’state’ : bool Whether the clock sequencer is enabled (default is False).
’divider’ : int The clock divider (default is 1).
’period’ : float The clock period in seconds (default is 0.0).
’bcounter’ : int The number of acquisitions. A value of 0 selects infinite operation (default is 0).
’pcounter’ : int The number of ON periods per acquisition (default is 1).
’ocounter’ : int The number of OFF periods per acquisition (default is 0).
’trigger_mode’ : str The external trigger mode (default is ‘disabled’).
’trigger_edge’ : str The external trigger edge (default is ‘rising’).
’gate_mode’ : str The global gate mode (default is ‘disabled’).
’gate_level’ : str The active gate input level (default is ‘low’).
- Return type:
dict
Notes
Defaults follow the SCPI reset configuration.
Set a valid period before starting the clock sequencer.
- opensync.config_clock_state(clock_params, state)#
Configure the clock sequencer state.
This function updates the clock parameters to enable or disable the clock sequencer.
- Parameters:
clock_params (dict) – A dictionary containing clock parameters from get_clock_params.
state (bool) – True enables the clock sequencer. False disables it.
- Returns:
clock_params – The updated clock parameters dictionary.
- Return type:
dict
Notes
The function modifies the ‘state’ key in the clock_params dictionary to reflect the desired clock sequencer state.
- opensync.config_clock_divider(clock_params, divider=1)#
Configure the clock divider.
This function updates the clock parameters by modifying the clock divider. The divider scales the clock resolution and the minimum and maximum clock period.
- Parameters:
clock_params (dict) – A dictionary containing clock parameters from get_clock_params.
divider (int) – The desired clock divider, from 1 through 65500.
- Returns:
clock_params – The updated clock parameters dictionary.
- Return type:
dict
Notes
The function modifies the ‘divider’ key in the clock_params dictionary to reflect the desired clock divider.
- opensync.config_clock_period(clock_params, period, units='s')#
Configure the clock period.
This function converts the supplied period to seconds and updates the clock parameters.
- Parameters:
clock_params (dict) – A dictionary containing clock parameters from get_clock_params.
period (float) – The desired clock period in the selected units.
units (str) – The period units: ‘ns’, ‘us’, ‘ms’, or ‘s’.
- Returns:
clock_params – The updated clock parameters dictionary.
- Return type:
dict
Notes
The function modifies the ‘period’ key in the clock_params dictionary to store the clock period in seconds.
The allowed period is from 320 nanoseconds multiplied by the clock divider through 10 seconds multiplied by the clock divider.
Configure the divider before configuring the period.
- opensync.config_clock_bcounter(clock_params, count)#
Configure the clock acquisition counter.
This function updates the clock parameters to set the number of acquisitions. Each acquisition contains the configured P and O counts.
- Parameters:
clock_params (dict) – A dictionary containing clock parameters from get_clock_params.
count (int) – The desired number of acquisitions, from 0 through 30000000. A value of 0 selects infinite operation.
- Returns:
clock_params – The updated clock parameters dictionary.
- Return type:
dict
Notes
The function modifies the ‘bcounter’ key in the clock_params dictionary to store the number of acquisitions.
- opensync.config_clock_pcounter(clock_params, count)#
Configure the clock ON duty cycle counter.
This function updates the clock parameters to set the number of ON periods in each acquisition.
- Parameters:
clock_params (dict) – A dictionary containing clock parameters from get_clock_params.
count (int) – The desired number of ON periods, from 0 through 1000000000. Use a count of at least 1 for T0 as recommended by the SCPI documentation.
- Returns:
clock_params – The updated clock parameters dictionary.
- Return type:
dict
Notes
The function modifies the ‘pcounter’ key in the clock_params dictionary to store the number of ON periods.
- opensync.config_clock_ocounter(clock_params, count)#
Configure the clock OFF duty cycle counter.
This function updates the clock parameters to set the number of clock periods skipped after the configured ON periods.
- Parameters:
clock_params (dict) – A dictionary containing clock parameters from get_clock_params.
count (int) – The desired number of OFF periods, from 0 through 1000000000. A value of 0 means no clock periods are skipped.
- Returns:
clock_params – The updated clock parameters dictionary.
- Return type:
dict
Notes
The function modifies the ‘ocounter’ key in the clock_params dictionary to store the number of OFF periods.
- opensync.config_clock_trigger_mode(clock_params, trigger_mode)#
Configure the external trigger mode.
This function updates the clock parameters to select how the clock sequencer’s trigger system is controlled.
- Parameters:
clock_params (dict) – A dictionary containing clock parameters from get_clock_params.
trigger_mode (str) –
A string that describes the trigger mode. The following are accepted values:
- ’disabled’
External triggering is disabled.
- ’triggered’
The selected external trigger edge starts one acquisition containing the configured P and O counts.
- Returns:
clock_params – The updated clock parameters dictionary.
- Return type:
dict
Notes
The function modifies the ‘trigger_mode’ key in the clock_params dictionary to reflect the desired trigger mode.
- opensync.config_clock_trigger_edge(clock_params, edge)#
Configure the external trigger edge.
This function updates the clock parameters to select which edge should be used when external triggering is enabled.
- Parameters:
clock_params (dict) – A dictionary containing clock parameters from get_clock_params.
edge (str) –
The selected trigger edge. The following are accepted values:
- ’rising’
The trigger system uses the rising edge.
- ’falling’
The trigger system uses the falling edge.
- Returns:
clock_params – The updated clock parameters dictionary.
- Return type:
dict
Notes
The function modifies the ‘trigger_edge’ key in the clock_params dictionary to reflect the desired edge configuration.
- opensync.config_clock_gate_mode(clock_params, gate_mode)#
Configure the global gate mode.
This function updates the clock parameters to select how the external gate affects program execution.
- Parameters:
clock_params (dict) – A dictionary containing clock parameters from get_clock_params.
gate_mode (str) –
A string that describes the gate mode. The following are accepted values:
- ’disabled’
Global gating is disabled.
- ’output’
An asserted gate suppresses T0 output events while the P/O counters continue.
- ’pulse’
An asserted gate prevents a new acquisition from starting. An acquisition already started continues.
- ’channel’
Gating is controlled by each output channel’s gate settings.
- Returns:
clock_params – The updated clock parameters dictionary.
- Return type:
dict
Notes
The function modifies the ‘gate_mode’ key in the clock_params dictionary to reflect the desired gate mode.
- opensync.config_clock_gate_level(clock_params, level)#
Configure the active gate input level.
This function updates the clock parameters to select which input level asserts the global gate.
- Parameters:
clock_params (dict) – A dictionary containing clock parameters from get_clock_params.
level (str) –
The selected gate level. The following are accepted values:
- ’high’
The gate is asserted when the input is high.
- ’low’
The gate is asserted when the input is low.
- Returns:
clock_params – The updated clock parameters dictionary.
- Return type:
dict
Notes
The function modifies the ‘gate_level’ key in the clock_params dictionary to reflect the desired gate level configuration.