This page was generated from docs/examples/driver_examples/Qcodes example with Yokogawa GS2xx.ipynb. Interactive online version: .
QCoDeS Example with Yokogawa GS200/GS210¶
[1]:
import time
from qcodes.instrument_drivers.yokogawa import YokogawaGS200
[2]:
gs = YokogawaGS200(
"gs200", address="USB::0xB21::0x39::91RB18719::INSTR", terminator="\n"
)
Connected to: YOKOGAWA GS210 (serial:91RB18719, firmware:2.02) in 0.12s
The instrument turns on in the ‘VOLT’ mode:
[3]:
gs.source_mode()
[3]:
'VOLT'
The mode can be changed to ‘CURR’ via source_mode:
[4]:
gs.source_mode("CURR")
gs.source_mode()
[4]:
'CURR'
If the instrument is reconnected without turning it off and on, it will be connected with the previous session’s mode:
[5]:
gs.close()
gs = YokogawaGS200(
"gs200", address="USB::0xB21::0x39::91RB18719::INSTR", terminator="\n"
)
gs.source_mode()
Connected to: YOKOGAWA GS210 (serial:91RB18719, firmware:2.02) in 0.03s
[5]:
'CURR'
The source_mode can only be changed when the output is ‘off’. By default the output is off and there is no actual current is flowing:
[6]:
gs.output()
[6]:
'off'
Setting/ getting attributes/ methods of a mode (‘VOLT’ or ‘CURR’) is only possible if the source_mode is in that mode (in this case, we are in the’CURR’ mode and trying to access voltage attributes/ methods):
[7]:
try:
gs.voltage(0.1) # Set the voltage
print("Something has gone wrong.")
except Exception:
print("Exception correctly raised.")
try:
gs.voltage() # Get the voltage
print("Something has gone wrong.")
except Exception:
print("Exception correctly raised.")
try:
gs.voltage_range(10) # Set the voltage_range
print("Something has gone wrong.")
except Exception:
print("Exception correctly raised.")
try:
gs.voltage_range() # Get the voltage_range
print("Something has gone wrong.")
except Exception:
print("Exception correctly raised.")
try:
gs.ramp_voltage(5, 1, 1) # Get the voltage_range
print("Something has gone wrong.")
except Exception:
print("Exception correctly raised.")
Exception correctly raised.
Exception correctly raised.
Exception correctly raised.
Exception correctly raised.
Exception correctly raised.
We can set/ get current attributes in the ‘CURR’ mode:
[8]:
gs.current_range()
[8]:
0.01
[9]:
gs.current(0.001)
Snapshotting interactively changes when the source_mode is changed (voltage and voltage_range are excluded from snapshot in the ‘CURR’ mode and vice versa):
[10]:
gs.snapshot()
[10]:
{'functions': {'reset': {}},
'submodules': {'measure': {'functions': {},
'submodules': {},
'__class__': 'qcodes.instrument_drivers.yokogawa.GS200.GS200_Monitor',
'parameters': {'enabled': {'__class__': 'qcodes.instrument.parameter.Parameter',
'full_name': 'gs200_measure_enabled',
'value': None,
'raw_value': None,
'ts': None,
'inter_delay': 0,
'instrument': 'qcodes.instrument_drivers.yokogawa.GS200.GS200_Monitor',
'instrument_name': 'gs200_measure',
'val_mapping': {'off': 0, 'on': 1},
'label': 'Measurement Enabled',
'unit': '',
'post_delay': 0,
'name': 'enabled',
'vals': "<Enum: {'off', 'on'}>"},
'measure': {'__class__': 'qcodes.instrument.parameter.Parameter',
'full_name': 'gs200_measure_measure',
'value': None,
'raw_value': None,
'ts': None,
'inter_delay': 0,
'instrument': 'qcodes.instrument_drivers.yokogawa.GS200.GS200_Monitor',
'instrument_name': 'gs200_measure',
'label': '<unset>',
'unit': 'V/I',
'post_delay': 0,
'name': 'measure'},
'NPLC': {'__class__': 'qcodes.instrument.parameter.Parameter',
'full_name': 'gs200_measure_NPLC',
'value': None,
'raw_value': None,
'ts': None,
'inter_delay': 0,
'instrument': 'qcodes.instrument_drivers.yokogawa.GS200.GS200_Monitor',
'instrument_name': 'gs200_measure',
'label': 'NPLC',
'unit': '1/LineFreq',
'post_delay': 0,
'name': 'NPLC',
'vals': '<Ints 1<=v<=25>'},
'delay': {'__class__': 'qcodes.instrument.parameter.Parameter',
'full_name': 'gs200_measure_delay',
'value': None,
'raw_value': None,
'ts': None,
'inter_delay': 0,
'instrument': 'qcodes.instrument_drivers.yokogawa.GS200.GS200_Monitor',
'instrument_name': 'gs200_measure',
'label': 'Measurement Delay',
'unit': 'ms',
'post_delay': 0,
'name': 'delay',
'vals': '<Ints 0<=v<=999999>'},
'trigger': {'__class__': 'qcodes.instrument.parameter.Parameter',
'full_name': 'gs200_measure_trigger',
'value': None,
'raw_value': None,
'ts': None,
'inter_delay': 0,
'instrument': 'qcodes.instrument_drivers.yokogawa.GS200.GS200_Monitor',
'instrument_name': 'gs200_measure',
'val_mapping': {'READY': 'READ',
'READ': 'READ',
'TIMER': 'TIM',
'TIM': 'TIM',
'COMMUNICATE': 'COMM',
'IMMEDIATE': 'IMM',
'IMM': 'IMM'},
'label': 'Trigger Source',
'unit': '',
'post_delay': 0,
'name': 'trigger',
'vals': "<Enum: {'TIMER', 'COMMUNICATE', 'READY', 'IMMEDIATE', 'READ', 'IMM', 'TIM'}>"},
'interval': {'__class__': 'qcodes.instrument.parameter.Parameter',
'full_name': 'gs200_measure_interval',
'value': None,
'raw_value': None,
'ts': None,
'inter_delay': 0,
'instrument': 'qcodes.instrument_drivers.yokogawa.GS200.GS200_Monitor',
'instrument_name': 'gs200_measure',
'label': 'Measurement Interval',
'unit': 's',
'post_delay': 0,
'name': 'interval',
'vals': '<Numbers 0.1<=v<=3600>'}},
'name': 'gs200_measure'}},
'__class__': 'qcodes.instrument_drivers.yokogawa.GS200.GS200',
'parameters': {'IDN': {'__class__': 'qcodes.instrument.parameter.Parameter',
'full_name': 'gs200_IDN',
'value': {'vendor': 'YOKOGAWA',
'model': 'GS210',
'serial': '91RB18719',
'firmware': '2.02'},
'raw_value': {'vendor': 'YOKOGAWA',
'model': 'GS210',
'serial': '91RB18719',
'firmware': '2.02'},
'ts': '2020-09-24 13:47:53',
'inter_delay': 0,
'instrument': 'qcodes.instrument_drivers.yokogawa.GS200.GS200',
'instrument_name': 'gs200',
'label': 'IDN',
'unit': '',
'post_delay': 0,
'name': 'IDN',
'vals': '<Anything>'},
'timeout': {'__class__': 'qcodes.instrument.parameter.Parameter',
'full_name': 'gs200_timeout',
'value': 5,
'raw_value': 5,
'ts': '2020-09-24 13:47:53',
'inter_delay': 0,
'instrument': 'qcodes.instrument_drivers.yokogawa.GS200.GS200',
'instrument_name': 'gs200',
'label': 'timeout',
'unit': 's',
'post_delay': 0,
'name': 'timeout',
'vals': '<MultiType: Numbers v>=0, Enum: {None}>'},
'output': {'__class__': 'qcodes.instrument.parameter.Parameter',
'full_name': 'gs200_output',
'value': 'off',
'raw_value': 0,
'ts': '2020-09-24 13:47:53',
'inter_delay': 0,
'instrument': 'qcodes.instrument_drivers.yokogawa.GS200.GS200',
'instrument_name': 'gs200',
'val_mapping': {'off': 0, 'on': 1},
'label': 'Output State',
'unit': '',
'post_delay': 0,
'name': 'output',
'vals': "<Enum: {'off', 'on'}>"},
'source_mode': {'__class__': 'qcodes.instrument.parameter.Parameter',
'full_name': 'gs200_source_mode',
'value': 'CURR',
'raw_value': 'CURR',
'ts': '2020-09-24 13:47:53',
'inter_delay': 0,
'instrument': 'qcodes.instrument_drivers.yokogawa.GS200.GS200',
'instrument_name': 'gs200',
'label': 'Source Mode',
'unit': '',
'post_delay': 0,
'name': 'source_mode',
'vals': "<Enum: {'VOLT', 'CURR'}>"},
'current_range': {'__class__': 'qcodes.instrument.parameter.Parameter',
'full_name': 'gs200_current_range',
'value': 0.01,
'raw_value': 0.01,
'ts': '2020-09-24 13:47:53',
'inter_delay': 0,
'instrument': 'qcodes.instrument_drivers.yokogawa.GS200.GS200',
'instrument_name': 'gs200',
'label': 'Current Source Range',
'unit': 'I',
'post_delay': 0,
'name': 'current_range',
'vals': '<Enum: {0.1, 0.01, 0.2, 0.001}>'},
'range': {'__class__': 'qcodes.instrument.parameter.DelegateParameter',
'full_name': 'gs200_range',
'value': 0.01,
'raw_value': 0.01,
'ts': '2020-09-24 13:47:53',
'inter_delay': 0,
'instrument': 'qcodes.instrument_drivers.yokogawa.GS200.GS200',
'instrument_name': 'gs200',
'label': 'Current Source Range',
'unit': 'I',
'post_delay': 0,
'name': 'range',
'source_parameter': {'__class__': 'qcodes.instrument.parameter.Parameter',
'full_name': 'gs200_current_range',
'value': 0.01,
'raw_value': 0.01,
'ts': '2020-09-24 13:47:53',
'inter_delay': 0,
'instrument': 'qcodes.instrument_drivers.yokogawa.GS200.GS200',
'instrument_name': 'gs200',
'label': 'Current Source Range',
'unit': 'I',
'post_delay': 0,
'name': 'current_range',
'vals': '<Enum: {0.1, 0.01, 0.2, 0.001}>'}},
'auto_range': {'__class__': 'qcodes.instrument.parameter.Parameter',
'full_name': 'gs200_auto_range',
'value': False,
'raw_value': False,
'ts': '2020-09-24 13:47:53',
'inter_delay': 0,
'instrument': 'qcodes.instrument_drivers.yokogawa.GS200.GS200',
'instrument_name': 'gs200',
'label': 'Auto Range',
'unit': '',
'post_delay': 0,
'name': 'auto_range',
'vals': '<Boolean>'},
'current': {'__class__': 'qcodes.instrument.parameter.Parameter',
'full_name': 'gs200_current',
'value': 0.001,
'raw_value': 0.001,
'ts': '2020-09-24 13:47:53',
'inter_delay': 0,
'instrument': 'qcodes.instrument_drivers.yokogawa.GS200.GS200',
'instrument_name': 'gs200',
'label': 'Current',
'unit': 'I',
'post_delay': 0,
'name': 'current'},
'output_level': {'__class__': 'qcodes.instrument.parameter.DelegateParameter',
'full_name': 'gs200_output_level',
'value': 0.001,
'raw_value': 0.001,
'ts': '2020-09-24 13:47:53',
'inter_delay': 0,
'instrument': 'qcodes.instrument_drivers.yokogawa.GS200.GS200',
'instrument_name': 'gs200',
'label': 'Current',
'unit': 'I',
'post_delay': 0,
'name': 'output_level',
'source_parameter': {'__class__': 'qcodes.instrument.parameter.Parameter',
'full_name': 'gs200_current',
'value': 0.001,
'raw_value': 0.001,
'ts': '2020-09-24 13:47:53',
'inter_delay': 0,
'instrument': 'qcodes.instrument_drivers.yokogawa.GS200.GS200',
'instrument_name': 'gs200',
'label': 'Current',
'unit': 'I',
'post_delay': 0,
'name': 'current'}},
'voltage_limit': {'__class__': 'qcodes.instrument.parameter.Parameter',
'full_name': 'gs200_voltage_limit',
'value': None,
'raw_value': None,
'ts': None,
'inter_delay': 0,
'instrument': 'qcodes.instrument_drivers.yokogawa.GS200.GS200',
'instrument_name': 'gs200',
'label': 'Voltage Protection Limit',
'unit': 'V',
'post_delay': 0,
'name': 'voltage_limit',
'vals': '<Ints 1<=v<=30>'},
'current_limit': {'__class__': 'qcodes.instrument.parameter.Parameter',
'full_name': 'gs200_current_limit',
'value': None,
'raw_value': None,
'ts': None,
'inter_delay': 0,
'instrument': 'qcodes.instrument_drivers.yokogawa.GS200.GS200',
'instrument_name': 'gs200',
'label': 'Current Protection Limit',
'unit': 'I',
'post_delay': 0,
'name': 'current_limit',
'vals': '<Numbers 0.001<=v<=0.2>'},
'four_wire': {'__class__': 'qcodes.instrument.parameter.Parameter',
'full_name': 'gs200_four_wire',
'value': None,
'raw_value': None,
'ts': None,
'inter_delay': 0,
'instrument': 'qcodes.instrument_drivers.yokogawa.GS200.GS200',
'instrument_name': 'gs200',
'val_mapping': {'off': 0, 'on': 1},
'label': 'Four Wire Sensing',
'unit': '',
'post_delay': 0,
'name': 'four_wire',
'vals': "<Enum: {'off', 'on'}>"},
'guard': {'__class__': 'qcodes.instrument.parameter.Parameter',
'full_name': 'gs200_guard',
'value': None,
'raw_value': None,
'ts': None,
'inter_delay': 0,
'instrument': 'qcodes.instrument_drivers.yokogawa.GS200.GS200',
'instrument_name': 'gs200',
'val_mapping': {'off': 0, 'on': 1},
'label': 'Guard Terminal',
'unit': '',
'post_delay': 0,
'name': 'guard',
'vals': "<Enum: {'off', 'on'}>"},
'line_freq': {'__class__': 'qcodes.instrument.parameter.Parameter',
'full_name': 'gs200_line_freq',
'value': None,
'raw_value': None,
'ts': None,
'inter_delay': 0,
'instrument': 'qcodes.instrument_drivers.yokogawa.GS200.GS200',
'instrument_name': 'gs200',
'label': 'Line Frequency',
'unit': 'Hz',
'post_delay': 0,
'name': 'line_freq'}},
'name': 'gs200',
'address': 'USB::0xB21::0x39::91RB18719::INSTR',
'terminator': '\n',
'timeout': 5.0}
By default, auto_range is in False state. So, setting voltage or current is limitted to the present voltage_range or current_range:
[11]:
gs.auto_range()
[11]:
False
[12]:
gs.current_range(0.01)
try:
gs.current(0.009)
print("The current value is withing the present current_range")
except Exception:
print("Exception incorrectly raised.")
try:
gs.current(0.1)
print("Something has gone wrong.")
except Exception:
print(
f"Exception is correctly raised. The value is out of the present "
f"range of {gs.current_range()} A."
)
The current value is withing the present current_range
Exception is correctly raised. The value is out of the present range of 0.01 A.
auto_range can be used to set the value even if the value is out of the present range. If the value exceeds the present range, the range automatically switches to the higher range tier untill the maximum allowed limit is reached (0.2 A for current and 30 V for voltage). auto_range can be useful when one wants to ramp the value without worrying about the end value to be out of the present range. We ramp the current from 0.009 A to 0.02 A with the step of 0.001 A (delay between each step is set to 1 second) and time it. Our present range is 0.01 A, so we expect the range automatically switches to 0.1 A because of auto_range is True.
[13]:
gs.auto_range(True)
gs.current(0.009)
gs.current_range()
[13]:
0.01
[14]:
t1 = time.time()
gs.ramp_current(0.02, 0.001, 1)
t2 = time.time()
print(f"Ramping took {t2-t1:.4} seconds")
Ramping took 10.84 seconds
[15]:
gs.current()
[15]:
0.02
[16]:
gs.current_range()
[16]:
0.1
Now, we turn off auto_range and set the current value out of the present range to test if we correctly get an error
[17]:
gs.auto_range(False)
[18]:
try:
gs.current(0.15)
print("Something has gone wrong")
except Exception:
print(
f"Exception is correctly raised. The value is out of the present "
f"range of {gs.current_range()} A."
)
Exception is correctly raised. The value is out of the present range of 0.1 A.
Now, we want to test the ramping in the False state of auto_range. We expect the ramping to stop when we exceed the range and we get out of range error:
[19]:
gs.auto_range(False)
gs.current(0.007)
gs.current_range(0.01)
[20]:
try:
gs.ramp_current(0.02, 0.001, 1)
except Exception:
print(
f"Exception is correctly raised. Ramping is stopped at {gs.current()} A because the"
" range is exceeded"
)
Exception is correctly raised. Ramping is stopped at 0.01 A because the range is exceeded
Now, we switch to the ‘VOLT’ mode and test a few things:
[21]:
gs.source_mode("VOLT")
[22]:
gs.voltage()
[22]:
1.0
[23]:
gs.voltage_range()
[23]:
1.0
[24]:
gs.auto_range()
[24]:
False
We can look at the voltage_limit and current_limit limit in any source_mode:
[25]:
gs.current_limit()
[25]:
0.2
[26]:
gs.voltage_limit()
[26]:
30
Now, we turn on the output to test if we see the correct output (in the ‘CURR’ and ‘VOLT’ mode, the voltage_limit and current_limit is active, respectively):
[27]:
gs.output("on")
We can verify that our multileter is reading 0.2 A. Now, we change the current_limit and test again:
[28]:
gs.current_limit(0.1)
As expected, the multimeter is reading 0.1 A.
[29]:
gs.output("off")
[30]:
gs.close()
[ ]: