Consider adding following function (working for Keysight DSO-X 2004A and DSO-X 3034A, not tested for other oscis):
def set_trigger(self, mode='EDGE', sweep_mode='NORMal', noise_reject_filter='ON', channel=1,
slope='POSitive', level=10):
'''Sets a trigger with all needed subcommands, default is the setup needed for a rising
edge measurement with trigger level at 10 (Volt) on Channel 1,
see Keysight Command Expert for details.
:param mode: trigger mode, can be e.g. EDGE, GLITch or PATTern, defaults to 'EDGE'
:type mode: str, optional
:param sweep_mode: can be AUTO or NORMal, defaults to 'NORMal'
:type sweep_mode: str, optional
:param noise_reject_filter: can be 'ON' or 'OFF', defaults to 'ON'
:type noise_reject_filter: str, optional
:param channel: choose a channel from 1 to 4, defaults to 1
:type channel: int, optional
:param slope: can be POSitive, NEGative, EITHer or ALTernate, defaults to 'POSitive'
:type slope: str, optional
:param level: defines which level has to be met to trigger at all, defaults to 10
:type level: int, optional
:return: response of the trigger-query
:rtype: str
'''
# pylint: disable=too-many-arguments
# all 7 optional arguments are needed here to set the trigger respectively
# Setting the trigger mode, can be e.g. EDGE, GLITch or PATTern
self.write_raw(f':TRIGger:MODE {mode}')
# Selects the trigger sweep mode (called "Mode" on the front panel)
# In auto trigger mode, the trigger will be forced if the specified conditions are not met.
# In normal trigger mode, the trigger will never be forced and a trigger will only
# occur if the specified conditions are met.
self.write_raw(f':TRIGger:SWEep {sweep_mode}')
# Turns the noise reject filter off and on
self.write_raw(f':TRIGger:NREJect {noise_reject_filter}')
# Setting the channel source that produces the trigger
self.write_raw(f':TRIGger:{mode}:SOURce CHANnel{channel}')
# Sets the trigger level for the active trigger source
self.write_raw(f':TRIGger:{mode}:LEVel {level}')
if mode == 'EDGE':
# Specifies the slope of the trigger-edge: POSitive, NEGative, EITHer or ALTernate
self.write_raw(f':TRIGger:EDGE:SLOPe {slope}')
if mode == 'GLITch':
# Sets the minimum pulse width duration to 1 ms (filters out short pulses)
self.write_raw(':TRIGger:GLITch:Greaterthan 1 MS')
response = self.query_raw(':TRIGger?')
return response
Consider adding following function (working for Keysight DSO-X 2004A and DSO-X 3034A, not tested for other oscis):