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)

Configures 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.

disable_buffer()

Disables 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

A boolean property that controls 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 id

Get the identification of the instrument.

is_buffer_full()

Returns True if the buffer is full of measurements.

property measurement_event_enabled

An integer value that controls 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

An integer value that reads 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

An integer value that controls 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

An integer value that reads 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

A boolean property that controls 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

An integer value that controls 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

An integer value that reads 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()

Resets 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

shutdown()

Disables the output.

property source_auto_range

A boolean property that controls the auto range of the current source. Valid values are True or False.

property source_compliance

A floating point property that controls the compliance of the current source in Volts. valid values are in range 0.1 [V] to 105 [V].

property source_current

A floating point property that controls the source current in Amps.

property source_delay

A floating point property that sets 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

A boolean property that controls 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

A floating point property that controls 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

An integer value that controls 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

An integer value that controls 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

An integer value that reads 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()

Aborts 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=0)

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

Parameters

query_delay – Delay between writing and reading in seconds.

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

Blocks 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

A floating point property that controls 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

A floating point property that controls 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

A floating point property that controls the duration of the waveform in seconds. Valid values are in range 100e-9 to 999999.999.

property waveform_dutycycle

A floating point property that controls 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

A floating point property that controls the frequency of the waveform in Hertz. Valid values are in range 1e-3 to 1e5.

property waveform_function

A string property that controls the selected wave function. Valid values are “sine”, “ramp”, “square”, “arbitrary1”, “arbitrary2”, “arbitrary3” and “arbitrary4”.

property waveform_offset

A floating point property that controls the offset of the waveform in Amps. Valid values are in range -0.105 to 0.105.

property waveform_phasemarker_line

A numerical property that controls the line of the phase marker.

property waveform_phasemarker_phase

A numerical property that controls the phase of the phase marker.

property waveform_ranging

A string property that controls 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

A boolean property that controls 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.