Generic SCPI Instruments¶
SCPIInstrument
- Base class for instruments using the SCPI protocol¶
-
class
instruments.generic_scpi.
SCPIInstrument
(filelike)[source]¶ Base class for all SCPI-compliant instruments. Inherits from from
Instrument
.This class does not implement any instrument-specific communication commands. What it does add is several of the generic SCPI star commands. This includes commands such as
*IDN?
,*OPC?
, and*RST
.Example usage:
>>> import instruments as ik >>> inst = ik.generic_scpi.SCPIInstrument.open_tcpip('192.168.0.2', 8888) >>> print(inst.name)
-
class
ErrorCodes
[source]¶ Enumeration describing error codes as defined by SCPI 1999.0. Error codes that are equal to 0 mod 100 are defined to be generic.
-
block_data_error
= -160¶
-
block_data_not_allowed
= -168¶
-
character_data_error
= -140¶
-
character_data_not_allowed
= -148¶
-
character_data_too_long
= -144¶
-
command_error
= -100¶
-
command_header_error
= -110¶
-
data_type_error
= -104¶
-
exponent_too_large
= -123¶
-
expression_error
= -170¶
-
expression_not_allowed
= -178¶
-
get_not_allowed
= -105¶
-
header_separator_error
= -111¶
-
header_suffix_out_of_range
= -114¶
-
invalid_block_data
= -161¶
-
invalid_character
= -101¶
-
invalid_character_data
= -141¶
-
invalid_character_in_number
= -121¶
-
invalid_expression
= -171¶
-
invalid_inside_macro_definition
= -183¶
-
invalid_outside_macro_definition
= -181¶
-
invalid_separator
= -103¶
-
invalid_string_data
= -151¶
-
invalid_suffix
= -131¶
-
macro_error
= -180¶
-
macro_parameter_error
= -184¶
-
missing_parameter
= -109¶
-
no_error
= 0¶
-
numeric_data_error
= -120¶
-
numeric_data_not_allowed
= -128¶
-
operation_complete
= -800¶
-
parameter_not_allowed
= -108¶
-
power_on
= -500¶ Raised when the instrument detects that it has been turned from off to on.
-
program_mnemonic_too_long
= -112¶
-
request_control_event
= -700¶
-
string_data_error
= -150¶
-
string_data_not_allowed
= -158¶
-
suffix_error
= -130¶
-
suffix_not_allowed
= -138¶
-
suffix_too_long
= -134¶
-
syntax_error
= -102¶
-
too_many_digits
= -124¶
-
undefined_header
= -113¶
-
unexpected_number_of_parameters
= -115¶
-
user_request_event
= -600¶
-
-
check_error_queue
()[source]¶ Checks and clears the error queue for this device, returning a list of
SCPIInstrument.ErrorCodes
orint
elements for each error reported by the connected instrument.
-
reset
()[source]¶ Reset instrument. On many instruments this is a factory reset and will revert all settings to default.
-
trigger
()[source]¶ Send a software trigger event to the instrument. On most instruments this will cause some sort of hardware event to start. For example, a multimeter might take a measurement.
This software trigger usually performs the same action as a hardware trigger to your instrument.
-
wait_to_continue
()[source]¶ Instruct the instrument to wait until it has completed all received commands before continuing.
-
display_brightness
¶ Brightness of the display on the connected instrument, represented as a float ranging from 0 (dark) to 1 (full brightness).
Type: float
-
display_contrast
¶ Contrast of the display on the connected instrument, represented as a float ranging from 0 (no contrast) to 1 (full contrast).
Type: float
-
line_frequency
¶ Gets/sets the power line frequency setting for the instrument.
Returns: The power line frequency Units: Hertz Type: Quantity
-
name
¶ The name of the connected instrument, as reported by the standard SCPI command
*IDN?
.Return type: str
-
scpi_version
¶ Returns the version of the SCPI protocol supported by this instrument, as specified by the
SYST:VERS?
command described in section 21.21 of the SCPI 1999 standard.
-
class
SCPIMultimeter
- Generic multimeter using SCPI commands¶
-
class
instruments.generic_scpi.
SCPIMultimeter
(filelike)[source]¶ This class is used for communicating with generic SCPI-compliant multimeters.
Example usage:
>>> import instruments as ik >>> inst = ik.generic_scpi.SCPIMultimeter.open_tcpip("192.168.1.1") >>> print(inst.measure(inst.Mode.resistance))
-
class
InputRange
[source]¶ Valid device range parameters outside of directly specifying the range.
-
automatic
= 'AUTO'¶
-
default
= 'DEF'¶
-
maximum
= 'MAX'¶
-
minimum
= 'MIN'¶
-
-
class
Mode
[source]¶ Enum of valid measurement modes for (most) SCPI compliant multimeters
-
capacitance
= 'CAP'¶
-
continuity
= 'CONT'¶
-
current_ac
= 'CURR:AC'¶
-
current_dc
= 'CURR:DC'¶
-
diode
= 'DIOD'¶
-
fourpt_resistance
= 'FRES'¶
-
frequency
= 'FREQ'¶
-
period
= 'PER'¶
-
resistance
= 'RES'¶
-
temperature
= 'TEMP'¶
-
voltage_ac
= 'VOLT:AC'¶
-
voltage_dc
= 'VOLT:DC'¶
-
-
class
Resolution
[source]¶ Valid measurement resolution parameters outside of directly the resolution.
-
default
= 'DEF'¶
-
maximum
= 'MAX'¶
-
minimum
= 'MIN'¶
-
-
class
SampleCount
[source]¶ Valid sample count parameters outside of directly the value.
-
default
= 'DEF'¶
-
maximum
= 'MAX'¶
-
minimum
= 'MIN'¶
-
-
class
SampleSource
[source]¶ Valid sample source parameters.
- “immediate”: The trigger delay time is inserted between successive
- samples. After the first measurement is completed, the instrument waits the time specified by the trigger delay and then performs the next sample.
- “timer”: Successive samples start one sample interval after the
- START of the previous sample.
-
immediate
= 'IMM'¶
-
timer
= 'TIM'¶
-
class
TriggerCount
[source]¶ Valid trigger count parameters outside of directly the value.
-
default
= 'DEF'¶
-
infinity
= 'INF'¶
-
maximum
= 'MAX'¶
-
minimum
= 'MIN'¶
-
-
class
TriggerMode
[source]¶ Valid trigger sources for most SCPI Multimeters.
“Immediate”: This is a continuous trigger. This means the trigger signal is always present.
“External”: External TTL pulse on the back of the instrument. It is active low.
“Bus”: Causes the instrument to trigger when a
*TRG
command is sent by software. This means calling the trigger() function.-
bus
= 'BUS'¶
-
external
= 'EXT'¶
-
immediate
= 'IMM'¶
-
-
measure
(mode=None)[source]¶ Instruct the multimeter to perform a one time measurement. The instrument will use default parameters for the requested measurement. The measurement will immediately take place, and the results are directly sent to the instrument’s output buffer.
Method returns a Python quantity consisting of a numpy array with the instrument value and appropriate units. If no appropriate units exist, (for example, continuity), then return type is
float
.Parameters: mode ( Mode
) – Desired measurement mode. If set toNone
, will default to the current mode.
-
input_range
¶ Gets/sets the device input range for the device range for the currently set multimeter mode.
Example usages:
>>> dmm.input_range = dmm.InputRange.automatic >>> dmm.input_range = 1 * pq.millivolt
Units: As appropriate for the current mode setting. Type: Quantity
, orInputRange
-
mode
¶ Gets/sets the current measurement mode for the multimeter.
Example usage:
>>> dmm.mode = dmm.Mode.voltage_dc
Type: Mode
-
relative
¶ Gets/sets the status of relative measuring mode for the multimeter. This is an abstract method.
Type: bool
-
resolution
¶ Gets/sets the measurement resolution for the multimeter. When specified as a float it is assumed that the user is providing an appropriate value.
Example usage:
>>> dmm.resolution = 3e-06 >>> dmm.resolution = dmm.Resolution.maximum
Type: int
,float
orResolution
-
sample_count
¶ Gets/sets the number of readings (samples) that the multimeter will take per trigger event.
The time between each measurement is defined with the sample_timer property.
Note that if the trigger_count propery has been changed, the number of readings taken total will be a multiplication of sample count and trigger count (see property
SCPIMulimeter.trigger_count
).If specified as a
SampleCount
value, the following options apply:- “minimum”: 1 sample per trigger
- “maximum”: Maximum value as per instrument manual
- “default”: Instrument default as per instrument manual
Note that when using triggered measurements, it is recommended that you disable autorange by either explicitly disabling it or specifying your desired range.
Type: int
orSampleCount
-
sample_source
¶ Gets/sets the multimeter sample source. This determines whether the trigger delay or the sample timer is used to dtermine sample timing when the sample count is greater than 1.
In both cases, the first sample is taken one trigger delay time period after the trigger event. After that, it depends on which mode is used.
Type: SCPIMultimeter.SampleSource
-
sample_timer
¶ Gets/sets the sample interval when the sample counter is greater than one and when the sample source is set to timer (see
SCPIMultimeter.sample_source
).This command does not effect the delay between the trigger occuring and the start of the first sample. This trigger delay is set with the
trigger_delay
property.Units: As specified, or assumed to be of units seconds otherwise. Type: Quantity
-
trigger_count
¶ Gets/sets the number of triggers that the multimeter will accept before returning to an “idle” trigger state.
Note that if the sample_count propery has been changed, the number of readings taken total will be a multiplication of sample count and trigger count (see property
SCPIMulimeter.sample_count
).If specified as a
TriggerCount
value, the following options apply:- “minimum”: 1 trigger
- “maximum”: Maximum value as per instrument manual
- “default”: Instrument default as per instrument manual
- “infinity”: Continuous. Typically when the buffer is filled in this
- case, the older data points are overwritten.
Note that when using triggered measurements, it is recommended that you disable autorange by either explicitly disabling it or specifying your desired range.
Type: int
orTriggerCount
-
trigger_delay
¶ Gets/sets the time delay which the multimeter will use following receiving a trigger event before starting the measurement.
Units: As specified, or assumed to be of units seconds otherwise. Type: Quantity
-
trigger_mode
¶ Gets/sets the SCPI Multimeter trigger mode.
Example usage:
>>> dmm.trigger_mode = dmm.TriggerMode.external
Type: TriggerMode
-
class
SCPIFunctionGenerator
- Generic multimeter using SCPI commands¶
-
class
instruments.generic_scpi.
SCPIFunctionGenerator
(filelike)[source]¶ This class is used for communicating with generic SCPI-compliant function generators.
Example usage:
>>> import instruments as ik >>> import quantities as pq >>> inst = ik.generic_scpi.SCPIFunctionGenerator.open_tcpip("192.168.1.1") >>> inst.frequency = 1 * pq.kHz
-
frequency
¶ Gets/sets the output frequency.
Units: As specified, or assumed to be \(\text{Hz}\) otherwise. Type: float
orQuantity
-
function
¶ Gets/sets the output function of the function generator
Type: SCPIFunctionGenerator.Function
-
offset
¶ Gets/sets the offset voltage of the function generator.
Set value should be within correct bounds of instrument.
Units: As specified (if a Quantity
) or assumed to be of units volts.Type: Quantity
with units volts.
-
phase
¶ Gets/sets the output phase of the function generator. This is an abstract property.
Type: Quantity
-