# devices.keithley:Keithley6221


Keithley 6221 AC and DC Current Source interface.


Usage

``` python
devices.keithley:Keithley6221(
    interface,
    **kwargs,
)
```


Provides methods to control the Keithley 6221 current source for generating waveforms, arbitrary waveforms, constant currents, and performing delta and pulse delta measurements.


## Methods

| Name | Description |
|----|----|
| [__init__()](#__init__) | Initialize the Keithley 6221 device. |
| [abort()](#abort) | Abort the emission of the wavelet. |
| [constGo()](#constGo) | Turn on output for constant current. |
| [deltaGo()](#deltaGo) | Arm delta mode and run measurement, waiting for the result. |
| [deltaStop()](#deltaStop) | Abort delta mode. |
| [fetchData()](#fetchData) | Get data trace and return as array. |
| [generateArbWave()](#generateArbWave) | Generate an arbitrary waveform and launch it. |
| [generateConstant()](#generateConstant) | Set a constant current output. |
| [generateDelta()](#generateDelta) | Initialize K6221 into delta mode. |
| [generatePulseDelta()](#generatePulseDelta) | Initialize K6221 into pulse delta mode. |
| [generateWave()](#generateWave) | Generate a waveform signal and launch it. |
| [getConstCurrent()](#getConstCurrent) | Read current setting (no measurement readback). |
| [pulseGo()](#pulseGo) | Arm pulse mode and run measurement, waiting for the result. |
| [pulseStop()](#pulseStop) | Abort pulse mode. |
| [queryCompliance()](#queryCompliance) | Check if compliance limit has been reached. |
| [queryDone()](#queryDone) | Check if measurement has finished. |
| [setConstCurrent()](#setConstCurrent) | Set constant current output level. |
| [waveGo()](#waveGo) | Initialize wave mode and turn on output. |

------------------------------------------------------------------------


### \_\_init\_\_()


Initialize the Keithley 6221 device.


Usage

``` python
__init__(
    interface,
    **kwargs,
)
```


#### Parameters


`interface: str`  
VISA resource name for the instrument

`**kwargs: dict`  
Additional parameters to pass to the VISA driver. Defaults for write_termination, read_termination, and timeout are provided if not specified.


------------------------------------------------------------------------


### abort()


Abort the emission of the wavelet.


Usage

``` python
abort()
```


#### Returns


`None`  


------------------------------------------------------------------------


### constGo()


Turn on output for constant current.


Usage

``` python
constGo()
```


#### Returns


`None`  


------------------------------------------------------------------------


### deltaGo()


Arm delta mode and run measurement, waiting for the result.


Usage

``` python
deltaGo()
```


#### Returns


`None`  


------------------------------------------------------------------------


### deltaStop()


Abort delta mode.


Usage

``` python
deltaStop()
```


#### Returns


`None`  


------------------------------------------------------------------------


### fetchData()


Get data trace and return as array.


Usage

``` python
fetchData(wait=True)
```


#### Parameters


`wait: bool = ``True`  
Whether to wait for measurement completion. Default is True.


#### Returns


`numpy.ndarray`  
2D array containing the data trace.


------------------------------------------------------------------------


### generateArbWave()


Generate an arbitrary waveform and launch it.


Usage

``` python
generateArbWave(
    points=None,
    amplitude=None,
    frequency=None,
    offset=None,
    dutyCycle=None,
    rangingMode=None,
    durationTime=None,
    durationCycles=None,
    compliance=None,
    reset=True,
)
```


Note: This function has not been fully tested.


#### Parameters


`points: array_like = None`  
Points that the current source should set, between -1 and 1, maximum length 65535.

`amplitude: float = None`  
Amplitude of the wavelet in amps, range 2e-12 to 0.105.

`frequency: float = None`  
Frequency of the wavelet in Hz, range 0 to 1e5.

`offset: float = None`  
Offset of the wavelet in amps, range -0.105 to 0.105.

`dutyCycle: float = None`  
Duty cycle for the waveform (if applicable).

`rangingMode: str = None`  
'best' automatically selects the best range for the wavelet, 'fixed' uses the current range.

`durationTime: float = None`  
Duration of wavelet emission in seconds, range 100e-9 to 999999.999, or -1 for infinity.

`durationCycles: float = None`  
Number of cycles to emit the wavelet, range 0.001 to 99999999900, or -1 for infinity.

`compliance: float = None`  
Compliance level in volts, range 0.1 to 105.

`reset: bool = ``True`  
Reset the device before configuring the wave. Default is True.


#### Raises


`ValueError`  
If the points list has fewer than 2 elements or more than 65535 elements.


------------------------------------------------------------------------


### generateConstant()


Set a constant current output.


Usage

``` python
generateConstant(
    amplitude=None,
    autoRanging=None,
    sourceRange=None,
    compliance=None,
    reset=True,
)
```


#### Parameters


`amplitude: float = None`  
Current amplitude in amps. Range: -0.105 to 0.105.

`autoRanging: bool = None`  
Whether to enable auto ranging. If True, the measurement range may change while performing measurements.

`sourceRange: float = None`  
The measurement range to use in amps. Range: -0.105 to 0.105. This determines the output current range that will be sourced.

`compliance: float = None`  
The compliance level in volts. Range: 0.1 to 105.

`reset: bool = ``True`  
Whether to reset the device before setting the current. Default is True.


#### Returns


`None`  


------------------------------------------------------------------------


### generateDelta()


Initialize K6221 into delta mode.


Usage

``` python
generateDelta(
    i,
    nplc,
    sdel,
    count,
    rang,
    compliance=10,
    comp_abort=True,
    reset=False,
)
```


#### Parameters


`i: float`  
Peak pulse current in amps. Range: -0.105 to 0.105.

`nplc: int`  
Resolution on 2182 (integer power line cycles).

`sdel: float`  
Source delay in seconds.

`count: int`  
Count of delta measurements.

`rang: str`  
Range of nanovoltmeter in volts.

`compliance: float = ``10`  
Voltage compliance level in volts. Default is 10.

`comp_abort: bool = ``True`  
Whether to abort on compliance trigger. Default is True.

`reset: bool = ``False`  
Whether to reset the device before configuring. Default is False.


#### Returns


`None`  


------------------------------------------------------------------------


### generatePulseDelta()


Initialize K6221 into pulse delta mode.


Usage

``` python
generatePulseDelta(
    ihigh,
    ilow,
    width,
    sdel,
    count,
    rang,
    interval,
    compliance=10,
    sweep="OFF",
    lme=1,
    reset=False,
)
```


#### Parameters


`ihigh: float`  
Peak pulse current in amps. Range: -0.105 to 0.105.

`ilow: float`  
Low current (i.e., outside of pulse) in amps. Range: -0.105 to 0.105.

`width: float`  
Pulse width in seconds. Range: 50us to 12ms.

`sdel: float`  
Source delay in seconds.

`count: int`  
Count of pulses.

`rang: str`  
Range setting. Options are "BEST" or "FIX".

`interval: int`  
Cycle time in PLCs. Range: 5 to 999999.

`sweep: str = ``"OFF"`  
Sweep mode. Options are "ON" or "OFF". Default is "OFF".

`compliance: float = ``10`  
Voltage compliance level in volts. Default is 10.

`lme: int = ``1`  
Number of low measurements (0 to 2). Default is 1.

`reset: bool = ``False`  
Whether to reset the device before configuring. Default is False.


#### Returns


`None`  


------------------------------------------------------------------------


### generateWave()


Generate a waveform signal and launch it.


Usage

``` python
generateWave(
    function="sinusoid",
    dutyCycle=None,
    amplitude=None,
    offset=None,
    frequency=None,
    rangingMode=None,
    durationTime=None,
    durationCycles=None,
    compliance=None,
    reset=True,
)
```


#### Parameters


`function: str = ``"sinusoid"`  
Type of wavelet to generate: 'sinusoid', 'square', 'ramp'. Default is 'sinusoid'.

`dutyCycle: float = None`  
Percentage (0-100) of the amplitude that will be high. The remaining percentage will be low.

`amplitude: float = None`  
Amplitude of the wavelet in amps. Range: 2e-12 to 0.105.

`offset: float = None`  
Offset of the wavelet in amps. Range: -0.105 to 0.105.

`frequency: float = None`  
Frequency of the wavelet in Hz. Range: 0 to 1e5.

`rangingMode: str = None`  
Measurement range selection mode: 'best': automatically select the best range for the wavelet 'fixed': use the current range for the wavelet

`durationTime: float = None`  
Duration of wavelet emission in seconds. Range: 100e-9 to 999999.999, or -1 for infinity.

`durationCycles: float = None`  
Number of cycles to emit the wavelet. Range: 0.001 to 99999999900, or -1 for infinity.

`compliance: float = None`  
Compliance level in volts. Range: 0.1 to 105.

`reset: bool = ``True`  
Whether to reset the device before configuring the wave. Default is True.


#### Returns


`None`  


------------------------------------------------------------------------


### getConstCurrent()


Read current setting (no measurement readback).


Usage

``` python
getConstCurrent()
```


#### Returns


`float`  
Current setting in amps.


------------------------------------------------------------------------


### pulseGo()


Arm pulse mode and run measurement, waiting for the result.


Usage

``` python
pulseGo()
```


#### Returns


`None`  


------------------------------------------------------------------------


### pulseStop()


Abort pulse mode.


Usage

``` python
pulseStop()
```


#### Returns


`None`  


------------------------------------------------------------------------


### queryCompliance()


Check if compliance limit has been reached.


Usage

``` python
queryCompliance()
```


#### Returns


`bool`  
True if compliance has been reached, False otherwise.


------------------------------------------------------------------------


### queryDone()


Check if measurement has finished.


Usage

``` python
queryDone()
```


#### Returns


`bool`  
True if measurement is complete, False otherwise.


------------------------------------------------------------------------


### setConstCurrent()


Set constant current output level.


Usage

``` python
setConstCurrent(current)
```


#### Parameters


`current: float`  
Current level in amps.


#### Returns


`None`  


------------------------------------------------------------------------


### waveGo()


Initialize wave mode and turn on output.


Usage

``` python
waveGo()
```


#### Returns


`None`
