Welcome to Slave

This is the documentation of the Slave library, a micro framework designed to simplify instrument communication and control. It is divided into three parts, a quick overview, the user guide and of course the api reference.


Slave provides an intuitive way of creating instrument api’s, inspired by object relational mappers.

from slave.iec60488 import IEC60488, PowerOn
from slave.core import Command
from slave.types import Integer, Enum

class Device(IEC60488, PowerOn):
    """An iec60488 conforming device api with additional commands."""
    def __init__(self, connection):
        super(Device, self).__init__(connection)
        # A custom command
        self.my_command = Command(
            'QRY?', # query message header
            'WRT',  # command message header
            # response and command data type
            [Integer, Enum('first', 'second')]

Commands mimic instance attributes. Read access queries the device, parses and converts the response and finally returns it. Write access parses and converts the arguments and sends them to the device. This leads to very intuitive interfaces.

Several device drivers are already implemented, and many more are under development. A short usage example is given below:

import time
import visa
from slave.sr830 import SR830

lockin = SR830(visa.instrument('GPIB::08'))
# configure the lockin amplifier
lockin.reserve = 'high'
lockin.time_constant = 3
# take 60 measurements and print the result
for i in range(60):
    print lockin.x

For a complete list of built-in device drivers, see Builtin Device Drivers.

What’s New in slave

slave 0.4

  • A compatibility layer for the asyncronous communication framework tornado was implemented. See Asyncronous IO for more details.

Indices and tables