Skip to main content

Easy SCPI

A simple and robust library making communication with SCPI (Standard Control of Programmbale Instruments) instruments easy. After creating an instrument object that connects to an actual instrument, commands are sent to the instrument using a property-like format. This class is useful for inheritance when creating a controller for a specific instrument. Communication with instruments is done with PyVISA.

Install

python -m pip install easy-scpi

API

SCPI Commands

Generic SCPI commands can be executed by transforming the SCPI code in to attributes via the hierarchy relationship, then calling it. Instrument properties can be queried by passing no arguments to the call (or specifying query=True). Commands with no arguments are run by passing an empty string to the call.

Examples

For more examples see the examples folder.

Basic

# import package
import easy_scpi as scpi 

# Connect to an instrument
inst = scpi.Instrument(<port>)
inst.connect()

# Read the voltage [MEASure:VOLTage:DC?]
inst.measure.voltage.dc()
# or
inst.meas.volt.dc()

# Passing args to a query [MEASure:VOLTage:DC? MIN]
inst.measure.voltage.dc("MIN", query=True)

# Set the voltage to 1 V [MEASure:VOLTage:DC 1]
inst.measure.voltage.dc(1)
# or
inst.source.voltage('1')

# Execute a command to take a reading [SYSTem:ZCORrect:ACQuire]
inst.syst.zcor.aqc('')

Full

For use with Tektronix PWS4305

import easy_scpi as scpi

class PowerSupply( scpi.Instrument ):
    def __init__( self ):
        super().__init__( 
            port = None, 
            timeout = 5000,
            read_termination = '\n', 
            write_termination = '\n' 
        )

        # other initialization code...

    @property        
    def voltage(self):
        """
        Returns the voltage setting.
        """
        return self.source.volt.level()
    
    @voltage.setter
    def voltage(self, volts):
        """
        Sets the voltage of the instrument.
        """
        self.source.volt.level(volts)
    
    @property
    def current(self):
        """
        Returns the current setting in Amps
        """
        return self.source.current.level()
        
    @current.setter
    def current(self, amps):
        """
        Set the current of the instrument
        """
        self.source.current.level(amps)
    
    def on(self):
        """
        Turns the output on
        """
        self.output.state('on')
        
    def off(self):
        """
        Turns the output off
        """
        self.output.state('off')

Metadata

Release files for easy-scpi 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for easy-scpi 0.1.7
File Size Uploaded
easy_scpi-0.1.7.tar.gz 10.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for easy-scpi 0.1.7
File Interpreter ABI Platform
easy_scpi-0.1.7-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 21.9 kB

Release files / easy_scpi-0.1.7.tar.gz

Download URL easy_scpi-0.1.7.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0f2ceb898acb7b34b1a0038f3ffc8918ed741133b39584ca79b7332eff96566b
BLAKE2b-256 checksum
How to use checksums
f974f6eb533dc6d61a8edfbe609bb52354047b8d7cf2fa4dac6cea244fd1b517
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.28.1

Release files / easy_scpi-0.1.7-py2.py3-none-any.whl

Download URL easy_scpi-0.1.7-py2.py3-none-any.whl
Size 11.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
f69dba785acf83a5da6b09d54a400127732c9e27228e28243d198dc28d117846
BLAKE2b-256 checksum
How to use checksums
273276b8bc505b28b40a9835a04ff62d47b006fd88600a5e7d8d07d3235f74d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.28.1

Release history Release notifications | RSS feed

This release

0.1.7 This release

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page