Skip to content

Yokogawa GS200

Bases: VisaDriver

A driver for controlling the Yokogawa GS200 source measure unit via VISA interface.

This class provides an interface to control and query the Yokogawa GS200, including setting its operation mode, output state, output range, and output level. The device can operate in either current or voltage mode.

Usage:

from driverlib.yokogawa import YokogawaGS200

yoko = YokogawaGS200("address")

yoko.output = True
yoko.voltage = 1.0

Initialize the YokogawaGS200 object with the specified resource location and mode.

Parameters:

Name Type Description Default
resource_location str

The VISA resource name used to connect to the device.

required
mode Literal['current', 'voltage']

The initial operation mode of the GS200. Defaults to 'voltage'.

'voltage'
max_level Optional[float]

The maximum voltage/current value. Defaults to None.

None
min_level Optional[float]

The minimum voltage/current value. Defaults to None.

None
Source code in driverlib/yokogawa/yokogawa_gs200.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
def __init__(
    self,
    resource_location: str,
    mode: Literal["current", "voltage"] = "voltage",
    max_level: Optional[float] = None,
    min_level: Optional[float] = None,
):
    """Initialize the YokogawaGS200 object with the specified resource location and mode.

    Args:
        resource_location (str): The VISA resource name used to connect to the device.
        mode (Literal["current", "voltage"], optional): The initial operation mode of the GS200.
            Defaults to 'voltage'.
        max_level (Optional[float], optional): The maximum voltage/current value. Defaults to None.
        min_level (Optional[float], optional): The minimum voltage/current value. Defaults to None.
    """
    super().__init__(resource_location=resource_location)
    self.mode = mode
    self.set_limits(min_level, max_level)

idn property

idn

Retrieve the identification string.

Returns:

Name Type Description
str str

The identification string of the device.

min_level property writable

min_level

Get or set the minimum voltage/current value.

max_level property writable

max_level

Get or set the maximum voltage value.

close

close()

Close the connection to the device.

Source code in driverlib/visa_driver.py
114
115
116
def close(self):
    """Close the connection to the device."""
    self.rm.close()

get_error

get_error()

Retrieve the error message from the device.

Returns:

Name Type Description
str

The error message.

Source code in driverlib/visa_driver.py
127
128
129
130
131
132
133
def get_error(self):
    """Retrieve the error message from the device.

    Returns:
        str: The error message.
    """
    return self.ask("SYST:ERR?")

print_error

print_error()

Print eventual errors occurred.

Source code in driverlib/visa_driver.py
135
136
137
def print_error(self):
    """Print eventual errors occurred."""
    print(f"Errors: {self.get_error()}", end="")

reset

reset()

Reset instrument to factory default state. Does not clear volatile memory.

Source code in driverlib/visa_driver.py
139
140
141
142
def reset(self):
    """Reset instrument to factory default state. Does not clear volatile memory."""
    self.write("*RST")
    self.write("*WAI")

clear

clear()

Clear event register, error queue -when power is cycled-.

Source code in driverlib/visa_driver.py
144
145
146
147
def clear(self):
    """Clear event register, error queue -when power is cycled-."""
    self.write("*CLS")
    self.write("*WAI")

lookup_resources

lookup_resources()

Look for all the available resources.

Source code in driverlib/visa_driver.py
149
150
151
152
153
154
155
156
157
158
159
160
def lookup_resources(self):
    """Look for all the available resources."""
    instruments = self.rm.list_resources()
    print(f"Found {len(instruments)} instruments:")
    for location in instruments:
        try:
            with OpenResource(self.rm, location, self.endline) as instr:
                idn = instr.query("*IDN?")
        except VisaIOError:
            idn = None

        print(f"Resource named: {idn if idn else 'Unable to determine'} @ '{location}'")

set_limits

set_limits(min_level, max_level)

Set the minimum and maximum voltage/current values.

Source code in driverlib/yokogawa/yokogawa_gs200.py
73
74
75
76
def set_limits(self, min_level: Optional[float], max_level: Optional[float]):
    """Set the minimum and maximum voltage/current values."""
    self._min_level = min_level
    self._max_level = max_level

get_output

get_output()

Query the output state of the Yokogawa GS200.

Returns:

Name Type Description
bool bool

True if the output is on, False otherwise.

Source code in driverlib/yokogawa/yokogawa_gs200.py
78
79
80
81
82
83
84
def get_output(self) -> bool:
    """Query the output state of the Yokogawa GS200.

    Returns:
        bool: True if the output is on, False otherwise.
    """
    return self.ask("OUTPUT?").strip() == "1"

set_output

set_output(value)

Set the output state of the Yokogawa GS200.

Parameters:

Name Type Description Default
value ONOFF_TYPE

The desired output state. True to turn on the output, False to turn it off.

required
Source code in driverlib/yokogawa/yokogawa_gs200.py
86
87
88
89
90
91
92
93
94
95
def set_output(self, value: ONOFF_TYPE):
    """Set the output state of the Yokogawa GS200.

    Args:
        value (ONOFF_TYPE): The desired output state. True to turn on the output, False to turn it off.
    """
    if self._value_to_bool(value):
        self.write("OUTPUT ON")
    else:
        self.write("OUTPUT OFF")

get_range

get_range()

Query the output range of the Yokogawa GS200.

Returns:

Name Type Description
int float

The current output range setting of the device.

Source code in driverlib/yokogawa/yokogawa_gs200.py
 99
100
101
102
103
104
105
def get_range(self) -> float:
    """Query the output range of the Yokogawa GS200.

    Returns:
        int: The current output range setting of the device.
    """
    return float(self.ask(":SOURce:RANGe?").strip())

set_range

set_range(value)

Set the output range of the Yokogawa GS200.

Parameters:

Name Type Description Default
value float

The desired output range.

required
Source code in driverlib/yokogawa/yokogawa_gs200.py
107
108
109
110
111
112
113
def set_range(self, value: float):
    """Set the output range of the Yokogawa GS200.

    Args:
        value (float): The desired output range.
    """
    self.write(f":SOURce:RANGe {value:.4f}")

set_level

set_level(value, check_mode=None)

Set the output level of the Yokogawa GS200.

Parameters:

Name Type Description Default
value float

The desired output level.

required
Source code in driverlib/yokogawa/yokogawa_gs200.py
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
def set_level(self, value: float, check_mode: Optional[str] = None):
    """Set the output level of the Yokogawa GS200.

    Args:
        value (float): The desired output level.
    """
    if check_mode is not None and self.mode != check_mode:
        raise TypeError(
            f"Yoko is configured in {self.mode} mode, while it should be {check_mode}"
        )
    if self.max_level is not None and value > self.max_level:
        raise ValueError(f"Level value {value} is greater than the maximum allowed value")
    if self.min_level is not None and value < self.min_level:
        raise ValueError(f"Level value {value} is smaller than the minimum allowed value")

    self.write(f":SOURce:Level {value:.8f}")

get_level

get_level(check_mode=None)

Query the output level of the Yokogawa GS200.

Returns:

Name Type Description
float float

The current output level of the device.

Source code in driverlib/yokogawa/yokogawa_gs200.py
134
135
136
137
138
139
140
141
142
143
144
def get_level(self, check_mode: Optional[str] = None) -> float:
    """Query the output level of the Yokogawa GS200.

    Returns:
        float: The current output level of the device.
    """
    if check_mode is not None and self.mode != check_mode:
        raise TypeError(
            f"Yoko is configured in {self.mode} mode, while it should be {check_mode}"
        )
    return float(self.ask(":SOURce:Level?"))

get_voltage

get_voltage()

Get the output voltage level.

Source code in driverlib/yokogawa/yokogawa_gs200.py
148
149
150
def get_voltage(self):
    """Get the output voltage level."""
    return self.get_level("voltage")

set_voltage

set_voltage(value)

Set the output voltage level.

Parameters:

Name Type Description Default
value float

The desired output voltage level.

required
Source code in driverlib/yokogawa/yokogawa_gs200.py
152
153
154
155
156
157
158
def set_voltage(self, value):
    """Set the output voltage level.

    Args:
        value (float): The desired output voltage level.
    """
    return self.set_level(value, "voltage")

get_current

get_current()

Get the output current level.

Source code in driverlib/yokogawa/yokogawa_gs200.py
162
163
164
def get_current(self):
    """Get the output current level."""
    return self.get_level("current")

set_current

set_current(value)

Set the output current level.

Parameters:

Name Type Description Default
value float

The desired output current level.

required
Source code in driverlib/yokogawa/yokogawa_gs200.py
166
167
168
169
170
171
172
def set_current(self, value):
    """Set the output current level.

    Args:
        value (float): The desired output current level.
    """
    return self.set_level(value, "current")

set_voltage_safely

set_voltage_safely(value, step=None)

Set the output voltage level safely.

This method gradually changes the output voltage level from the current level to the desired level with a specified step size.

Parameters:

Name Type Description Default
value float

The desired output voltage level.

required
step float

The step size for changing the voltage level. Defaults to self.default_safety_step.

None
Source code in driverlib/yokogawa/yokogawa_gs200.py
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
def set_voltage_safely(self, value: float, step: Optional[float] = None):
    """Set the output voltage level safely.

    This method gradually changes the output voltage level from the current level to the desired level
    with a specified step size.

    Args:
        value (float): The desired output voltage level.
        step (float, optional): The step size for changing the voltage level.
            Defaults to self.default_safety_step.
    """
    if not self.output:
        raise ValueError("The output must be on")

    if step is None:
        step = self.default_safety_step

    initial_voltage = self.voltage
    if np.round(value, self._precision) == np.round(initial_voltage, self._precision):
        return

    step = abs(step) if initial_voltage < value else -abs(step)

    for v in np.arange(initial_voltage, value + step / 2, step):
        self.set_voltage(np.round(v, self._precision))
        time.sleep(0.2)
    return

set_output_safely

set_output_safely(value)

Set the output state safely.

This method sets the voltage to 0 before setting the output to True.

Parameters:

Name Type Description Default
value ONOFF_TYPE

The desired output state. True to turn on the output, False to turn it off.

required
Source code in driverlib/yokogawa/yokogawa_gs200.py
206
207
208
209
210
211
212
213
214
215
216
217
218
def set_output_safely(self, value: ONOFF_TYPE):
    """Set the output state safely.

    This method sets the voltage to 0 before setting the output to True.

    Args:
        value (ONOFF_TYPE): The desired output state. True to turn on the output, False to turn it off.
    """
    if self._value_to_bool(value):
        self.voltage = 0
        self.output = True
    else:
        self.output = False

set_output_voltage_safely

set_output_voltage_safely(value, step=None)

Set the output voltage level safely.

This method sets the output state to True and then gradually changes the output voltage level from the current level to the desired level with a specified step size.

Parameters:

Name Type Description Default
value float

The desired output voltage level.

required
step float

The step size for changing the voltage level. Defaults to None.

None
Source code in driverlib/yokogawa/yokogawa_gs200.py
222
223
224
225
226
227
228
229
230
231
232
233
def set_output_voltage_safely(self, value: float, step: Optional[float] = None):
    """Set the output voltage level safely.

    This method sets the output state to True and then gradually changes the output voltage level
    from the current level to the desired level with a specified step size.

    Args:
        value (float): The desired output voltage level.
        step (float, optional): The step size for changing the voltage level. Defaults to None.
    """
    self.set_output_safely(True)
    self.set_voltage_safely(value, step)