Keithley 6221 AC and DC Current Source

class pymeasure.instruments.keithley.Keithley6221(adapter, name='Keithley 6221 SourceMeter', **kwargs)

Bases: KeithleyBuffer, SCPIMixin, Instrument

Represents the Keithley 6221 AC and DC current source and provides a high-level interface for interacting with the instrument.

keithley = Keithley6221("GPIB::1")
keithley.clear()

# Use the keithley as an AC source
keithley.waveform_function = "square"   # Set a square waveform
keithley.waveform_amplitude = 0.05      # Set the amplitude in Amps
keithley.waveform_offset = 0            # Set zero offset
keithley.source_compliance = 10         # Set compliance (limit) in V
keithley.waveform_dutycycle = 50        # Set duty cycle of wave in %
keithley.waveform_frequency = 347       # Set the frequency in Hz
keithley.waveform_ranging = "best"      # Set optimal output ranging
keithley.waveform_duration_cycles = 100 # Set duration of the waveform

# Link end of waveform to Service Request status bit
keithley.operation_event_enabled = 128  # OSB listens to end of wave
keithley.srq_event_enabled = 128        # SRQ listens to OSB

keithley.waveform_arm()                 # Arm (load) the waveform

keithley.waveform_start()               # Start the waveform

keithley.adapter.wait_for_srq()         # Wait for the pulse to finish

keithley.waveform_abort()               # Disarm (unload) the waveform

keithley.shutdown()                     # Disables output
beep(frequency, duration)

Sounds a system beep.

Parameters:
  • frequency – A frequency in Hz between 65 Hz and 2 MHz

  • duration – A time in seconds between 0 and 7.9 seconds

property buffer_data

Get a numpy array of values from the buffer.

property buffer_points

Control the number of buffer points. This does not represent actual points in the buffer, but the configuration value instead.

check_errors()

Read all errors from the instrument.

Returns:

List of error entries.

check_get_errors()

Check for errors after having gotten a property and log them.

Called if check_get_errors=True is set for that property.

If you override this method, you may choose to raise an Exception for certain errors.

Returns:

List of error entries.

check_set_errors()

Check for errors after having set a property and log them.

Called if check_set_errors=True is set for that property.

If you override this method, you may choose to raise an Exception for certain errors.

Returns:

List of error entries.

clear()

Clear the instrument status byte.

property complete

Get the synchronization bit.

This property allows synchronization between a controller and a device. The Operation Complete query places an ASCII character 1 into the device’s Output Queue when all pending selected device operations have been finished.

config_buffer(points=64, delay=0)

Configure the measurement buffer for a number of points, to be taken with a specified delay.

Parameters:
  • points – The number of points in the buffer.

  • delay – The delay time in seconds.

define_arbitary_waveform(datapoints, location=1)

Define the data points for the arbitrary waveform and copy the defined waveform into the given storage location.

Parameters:
  • datapoints – a list (or numpy array) of the data points; all values have to be between -1 and 1; 100 points maximum.

  • location – integer storage location to store the waveform in. Value must be in range 1 to 4.

delta_abort()

Stop delta and place the Model 2182A in the local mode.

delta_arm()

Arm delta.

property delta_buffer_points

Control the size of the buffer (integer strictly from 1 to 1000000).

Buffer size should be the same value as Delta count.

property delta_cold_switch_enabled

Control if cold switching mode is enabled (boolean).

property delta_compliance_abort_enabled

Control if compliance abort is enabled (boolean).

property delta_connected

Get connection status to 2182A.

property delta_cycles

Control the number of cycles to run for the delta measurements (integer strictly from 1 to 65536, or “INF”).

property delta_delay

Control the delta delay in seconds (float strictly from 0 to 9999.999, or “INF”).

property delta_high_source

Control the delta high source value in A (float strictly from 0 to 0.105).

Set high source value will automatically set the low source value to minus the high source value.

property delta_low_source

Control the delta low source value in A (float strictly from -0.105 to 0).

Usually no need to manually set this. By default, the low source value is minus the high source value.

property delta_measurement_sets

Control the number of measurement sets to repeat for delta measurements (integer strictly from 1 to 65536, or “INF”).

property delta_sense

Get the latest delta reading results from 2182/2182A.

delta_start()

Start delta measurements.

property delta_unit

Control the reading unit (string strictly in ‘V’, ‘Ohms’, ‘W’ and ‘Siemens’).

property delta_values

Get delta sense readings stored in 6221 buffer.

disable_buffer()

Disable the connection between measurements and the buffer, but does not abort the measurement process.

disable_output_trigger()

Disables the output trigger for the Trigger layer

disable_source()

Disables the source of current or voltage depending on the configuration of the instrument.

property display_enabled

Control (boolean) whether or not the display of the sourcemeter is enabled. Valid values are True and False.

enable_source()

Enables the source of current or voltage depending on the configuration of the instrument.

property error

Get the next error from the queue.

Deprecated since version 0.15: Use next_error instead.

property id

Get the identification of the instrument.

is_buffer_full()

Return True if the buffer is full of measurements.

property measurement_event_enabled

Control which measurement events are registered in the Measurement Summary Bit (MSB) status bit. Refer to the Model 6220/6221 Reference Manual for more information about programming the status bits.

property measurement_events

Get which measurement events have been registered in the Measurement event registers. Refer to the Model 6220/6221 Reference Manual for more information about programming the status bits. Reading this value clears the register.

property next_error

Get the next error in the queue. If you want to read and log all errors, use check_errors() instead.

property operation_event_enabled

Control which operation events are registered in the Operation Summary Bit (OSB) status bit. Refer to the Model 6220/6221 Reference Manual for more information about programming the status bits.

property operation_events

Get which operation events have been registered in the Operation event registers. Refer to the Model 6220/6221 Reference Manual for more information about programming the status bits. Reading this value clears the register.

property options

Get the device options installed.

property output_low_grounded

Control (boolean) whether the low output of the triax connection is connected to earth ground (True) or is floating (False).

output_trigger_on_external(line=1, after='DEL')

Configures the output trigger on the specified trigger link line number, with the option of supplying the part of the measurement after which the trigger should be generated (default to delay, which is right before the measurement)

Parameters:
  • line – A trigger line from 1 to 4

  • after – An event string that determines when to trigger

property questionable_event_enabled

Control which questionable events are registered in the Questionable Summary Bit (QSB) status bit. Refer to the Model 6220/6221 Reference Manual for more information about programming the status bits.

property questionable_events

Get which questionable events have been registered in the Questionable event registers. Refer to the Model 6220/6221 Reference Manual for more information about programming the status bits. Reading this value clears the register.

read(**kwargs)

Read up to (excluding) read_termination or the whole read buffer.

read_binary_values(**kwargs)

Read binary values from the device.

read_bytes(count, **kwargs)

Read a certain number of bytes from the instrument.

Parameters:
  • count (int) – Number of bytes to read. A value of -1 indicates to read the whole read buffer.

  • kwargs – Keyword arguments for the adapter.

Returns bytes:

Bytes response of the instrument (including termination).

reset()

Resets the instrument and clears the queue.

reset_buffer()

Reset the buffer.

set_timed_arm(interval)

Sets up the measurement to be taken with the internal trigger at a variable sampling rate defined by the interval in seconds between sampling points

property shield_to_guard_enabled

Control if shield is connected to the guard(boolean).

If not, the shield is connected to the output-low.

shutdown()

Disables the output.

property source_auto_range

Control (boolean) the auto range of the current source. Valid values are True or False.

property source_compliance

Control (floating) the compliance of the current source in Volts. valid values are in range 0.1 [V] to 105 [V].

property source_current

Control (floating) the source current in Amps.

property source_delay

Control (floating) a manual delay for the source after the output is turned on before a measurement is taken. When this property is set, the auto delay is turned off. Valid values are between 1e-3 [seconds] and 999999.999 [seconds].

property source_enabled

Control (boolean) whether the source is enabled, takes values True or False. The convenience methods enable_source() and disable_source() can also be used.

property source_range

Control (floating) the source current range in Amps, which can take values between -0.105 A and +0.105 A. Auto-range is disabled when this property is set.

property srq_event_enabled

Control which event registers trigger the Service Request (SRQ) status bit. Refer to the Model 6220/6221 Reference Manual for more information about programming the status bits.

property standard_event_enabled

Control which standard events are registered in the Event Summary Bit (ESB) status bit. Refer to the Model 6220/6221 Reference Manual for more information about programming the status bits.

property standard_events

Get which standard events have been registered in the Standard event registers. Refer to the Model 6220/6221 Reference Manual for more information about programming the status bits. Reading this value clears the register.

start_buffer()

Starts the buffer.

property status

Get the status byte and Master Summary Status bit.

stop_buffer()

Abort the buffering measurement, by stopping the measurement arming and triggering sequence. If possible, a Selected Device Clear (SDC) is used.

triad(base_frequency, duration)

Sounds a musical triad using the system beep.

Parameters:
  • base_frequency – A frequency in Hz between 65 Hz and 1.3 MHz

  • duration – A time in seconds between 0 and 7.9 seconds

trigger()

Executes a bus trigger, which can be used when trigger_on_bus() is configured.

trigger_immediately()

Configures measurements to be taken with the internal trigger at the maximum sampling rate.

trigger_on_bus()

Configures the trigger to detect events based on the bus trigger, which can be activated by trigger().

trigger_on_external(line=1)

Configures the measurement trigger to be taken from a specific line of an external trigger

Parameters:

line – A trigger line from 1 to 4

wait_for(query_delay=None)

Wait for some time. Used by ‘ask’ to wait before reading.

Parameters:

query_delay – Delay between writing and reading in seconds. None is default delay.

wait_for_buffer(should_stop=<function KeithleyBuffer.<lambda>>, timeout=60, interval=0.1)

Block the program, waiting for a full buffer. This function returns early if the should_stop function returns True or the timeout is reached before the buffer is full.

Parameters:
  • should_stop – A function that returns True when this function should return early

  • timeout – A time in seconds after which this function should return early

  • interval – A time in seconds for how often to check if the buffer is full

waveform_abort()

Abort the waveform output and disarm the waveform function.

property waveform_amplitude

Control (floating) the (peak) amplitude of the waveform in Amps. Valid values are in range 2e-12 to 0.105.

waveform_arm()

Arm the current waveform function.

property waveform_duration_cycles

Control (floating) the duration of the waveform in cycles. Valid values are in range 1e-3 to 99999999900.

waveform_duration_set_infinity()

Set the waveform duration to infinity.

property waveform_duration_time

Control (floating) the duration of the waveform in seconds. Valid values are in range 100e-9 to 999999.999.

property waveform_dutycycle

Control (floating) the duty-cycle of the waveform in percent for the square and ramp waves. Valid values are in range 0 to 100.

property waveform_frequency

Control (floating) the frequency of the waveform in Hertz. Valid values are in range 1e-3 to 1e5.

property waveform_function

Control (string) the selected wave function. Valid values are “sine”, “ramp”, “square”, “arbitrary1”, “arbitrary2”, “arbitrary3” and “arbitrary4”.

property waveform_offset

Control (floating) the offset of the waveform in Amps. Valid values are in range -0.105 to 0.105.

property waveform_phasemarker_line

Control (numerical) the line of the phase marker.

property waveform_phasemarker_phase

Control (numerical) the phase of the phase marker.

property waveform_ranging

Control (string) the source ranging of the waveform. Valid values are “best” and “fixed”.

waveform_start()

Start the waveform output. Must already be armed

property waveform_use_phasemarker

Control (boolean) whether the phase marker option is turned on or of. Valid values True (on) or False (off). Other settings for the phase marker have not yet been implemented.

write(command, **kwargs)

Write a string command to the instrument appending write_termination.

Parameters:
  • command – command string to be sent to the instrument

  • kwargs – Keyword arguments for the adapter.

write_binary_values(command, values, *args, **kwargs)

Write binary values to the device.

Parameters:
  • command – Command to send.

  • values – The values to transmit.

  • **kwargs (*args,) – Further arguments to hand to the Adapter.

write_bytes(content, **kwargs)

Write the bytes content to the instrument.