Skip to content

Commit

Permalink
Modify AWG401x driver to use 'channels' (#944)
Browse files Browse the repository at this point in the history
* Change AWG401x back to ``ch`` collection from ``channels`` because of other channel methods

* Move AWG401x to channels collection entirely
  • Loading branch information
mcdo0486 committed Feb 19, 2024
1 parent b16381d commit bbb8bd4
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions pymeasure/instruments/activetechnologies/AWG401x.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,17 +412,17 @@ class AWG401x_AFG(AWG401x_base):
wfg.reset() # Reset the instrument at default state
wfg.ch[1].shape = "SINUSOID" # Sets a sine waveform on CH1
wfg.ch[1].frequency = 4.7e3 # Sets the frequency to 4.7 kHz on CH1
wfg.ch[1].amplitude = 1 # Set amplitude of 1 V on CH1
wfg.ch[1].offset = 0 # Set the amplitude to 0 V on CH1
wfg.ch[1].enabled = True # Enables the CH1
wfg.ch[2].shape = "SQUARE" # Sets a square waveform on CH2
wfg.ch[2].frequency = 100e6 # Sets the frequency to 100 MHz on CH2
wfg.ch[2].amplitude = 0.5 # Set amplitude of 0.5 V on CH2
wfg.ch[2].offset = 0 # Set the amplitude to 0 V on CH2
wfg.ch[2].enabled = True # Enables the CH2
wfg.channels[1].shape = "SINUSOID" # Sets a sine waveform on CH1
wfg.channels[1].frequency = 4.7e3 # Sets the frequency to 4.7 kHz on CH1
wfg.channels[1].amplitude = 1 # Set amplitude of 1 V on CH1
wfg.channels[1].offset = 0 # Set the amplitude to 0 V on CH1
wfg.channels[1].enabled = True # Enables the CH1
wfg.channels[2].shape = "SQUARE" # Sets a square waveform on CH2
wfg.channels[2].frequency = 100e6 # Sets the frequency to 100 MHz on CH2
wfg.channels[2].amplitude = 0.5 # Set amplitude of 0.5 V on CH2
wfg.channels[2].offset = 0 # Set the amplitude to 0 V on CH2
wfg.channels[2].enabled = True # Enables the CH2
wfg.enabled = True # Enable output of waveform generator
wfg.beep() # "beep"
Expand Down Expand Up @@ -457,7 +457,7 @@ def __init__(self, adapter, **kwargs):
"class AWG401x")

for i in range(3, num_ch + 1):
child = self.add_child(ChannelAFG, i, collection="ch")
child = self.add_child(ChannelAFG, i)
child._protected = True


Expand All @@ -475,14 +475,14 @@ class AWG401x_AWG(AWG401x_base):
wfg.waveforms["MyWaveform"] = [1, 0] * 8
for i in range(1, wfg.num_ch + 1):
wfg.entries[1].ch[i].voltage_high = 1 # Sets high voltage = 1
wfg.entries[1].ch[i].voltage_low = 0 # Sets low voltage = 1
wfg.entries[1].ch[i].waveform = "SQUARE" # Sets a square wave
wfg.entries[1].channels[i].voltage_high = 1 # Sets high voltage = 1
wfg.entries[1].channels[i].voltage_low = 0 # Sets low voltage = 1
wfg.entries[1].channels[i].waveform = "SQUARE" # Sets a square wave
wfg.setting_ch[i].enabled = True # Enable channel
wfg.entries.resize(2) # Resize the number of entries to 2
wfg.entries[2].ch[1].waveform = "MyWaveform" # Set custom waveform
wfg.entries[2].channels[1].waveform = "MyWaveform" # Set custom waveform
wfg.enabled = True # Enable output of waveform generator
wfg.beep() # "beep"
Expand Down Expand Up @@ -763,16 +763,16 @@ def __setitem__(self, key, value):
class VoltageOutOfRangeError(Exception):
pass

if max(value) > self.parent.entries[1].ch[1].voltage_high_max:
if max(value) > self.parent.entries[1].channels[1].voltage_high_max:
raise VoltageOutOfRangeError(
f"{max(value)}V is higher than maximum possible voltage, "
f"which is "
f"{self.instrument.entries[1].ch[1].voltage_high_max}V")
if min(value) < self.parent.entries[1].ch[1].voltage_low_min:
f"{self.instrument.entries[1].channels[1].voltage_high_max}V")
if min(value) < self.parent.entries[1].channels[1].voltage_low_min:
raise VoltageOutOfRangeError(
f"{min(value)}V is lower than minimum possible voltage, "
f"which is "
f"{self.instrument.entries[1].ch[1].voltage_low_min}V")
f"{self.instrument.entries[1].channels[1].voltage_low_min}V")

self.parent.save_file(f"{key}.txt",
"\n".join(map(str, value)),
Expand Down Expand Up @@ -846,7 +846,7 @@ def __getitem__(self, key):
raise IndexError("Entry numeration start from 1")
if key > int(self.parent.values("SEQuence:LENGth?")[0]):
raise IndexError("Index out of range")
return (self.parent, self.num_ch, key)
return SequenceEntry(self.parent, self.num_ch, key)

def __len__(self):
return int(self.parent.values("SEQuence:LENGth?")[0])
Expand All @@ -863,7 +863,7 @@ def __init__(self, parent, number_of_channels, sequence_number):
self.loop_count_values = [self.loop_count_min, self.loop_count_max]

for i in range(1, self.number_of_channels + 1):
self.add_child(self.AnalogChannel, i, collection="ch",
self.add_child(self.AnalogChannel, i,
sequence_number=sequence_number)

def insert_id(self, command):
Expand Down

0 comments on commit bbb8bd4

Please sign in to comment.