added examples

This commit is contained in:
2024-01-19 11:24:04 +01:00
parent 6bd8e71985
commit b74d540032
65 changed files with 7053 additions and 16 deletions

View File

@@ -133,9 +133,16 @@ class DG2052( pyvisa.resources.MessageBasedResource ):
def set_sweep(
self,
channel: OutputChannel, # Sets the output channel of the sweep function
amp: float = 5, # Sets the amplitude of the sweeped signal
offset: float = 0, # Sets the offset voltage of the sweeped signal
phase: int = 0, # Sets the phase shift of the sweeped signal
signal_type: SweepSignalType = SweepSignalType.SINE, # Sets the type of signal being sweeped
htime_start: float = 0, # Sets the start hold time of the sweep function
htime_stop: float = 0, # Sets the stop hold time of the sweep function
freq_start: float = 100, # Sets the sweep starting frequency
freq_stop: float = 1e3, # Sets the sweep stopping frequency
marker: bool = False, # Enables/Disables setting the marker frequency manually
freq_marker: float = 550, # Sets the marker frequency at whic the Sync signal changes from high to low
rtime: float = 0, # Sets the return time of the sweep function
time: float = 1, # Sets the sweep time
spacing: SweepSpacing = SweepSpacing.LIN, # Sets the sweep type
@@ -150,6 +157,20 @@ class DG2052( pyvisa.resources.MessageBasedResource ):
check_bounds(time_bounds, rtime)
check_bounds((2, 1024), step)
check_bounds((1e-3, 599.0), time)
match signal_type:
case SweepSignalType.SINE:
self.set_sine_wave(channel, amp=amp, offset=offset, phase=phase)
case SweepSignalType.SQUARE:
self.set_square_wave(channel, amp=amp, offset=offset, phase=phase)
case SweepSignalType.RAMP:
self.set_ramp(channel, amp=amp, offset=offset, phase=phase)
self.write( f":SOUR:FREQ:STAR {freq_start}" )
self.write( f":SOUR:FREQ:STOP {freq_stop}" )
if marker:
self.write( f":SOUR:MARK ON" )
self.write( f":SOUR:MARK:FREQ {freq_marker}" )
else:
self.write( f":SOUR:MARK OFF" )
self.write( f"{command_header}:SPAC {spacing}" )
self.write( f"{command_header}:STEP {step}" )
match trigger_source:
@@ -175,17 +196,3 @@ class DG2052( pyvisa.resources.MessageBasedResource ):
def trigger_sweep(self, channel: OutputChannel):
self.write( f":SOUR{channel.value}:SWE:TRIG:IMM" )
# def set_pulse(self, channel: OutputChannel, duty_cycle: float, transition_leading: float, transition_trailing: float, pulse_width: float):
# transition_bounds = (8e-9, 0.625*pulse_width)
# duty_cycle_bounds = (0.001, 99.999)
# pulse_width_bounds = (16e-9, 999.999e3)
# command_header = f":SOUR{channel.value}:PULS"
# check_bounds(duty_cycle_bounds, duty_cycle)
# check_bounds(transition_bounds, transition_leading)
# check_bounds(transition_bounds, transition_trailing)
# check_bounds(pulse_width_bounds, pulse_width)
# self.write( f"{command_header}:WIDT {pulse_width}" )
# self.write( f"{command_header}:DCYC {duty_cycle}" )
# self.write( f"{command_header}:TRAN:LEAD {transition_leading}" )
# self.write( f"{command_header}:TRAN:TRA {transition_trailing}" )