Skip to content

Creating an SVP Driver

Estefan Apablaza edited this page Dec 13, 2018 · 7 revisions

Identification of the physical interface

Laboratory equipment is often connected to control computers using Ethernet cables (RJ45 plugs and CAT5/CAT6 cables), GPIB plugs (IEEE 488), USB connectors, serial cables (RS232/RS485), etc. Identifying the connection is important.

Establishing communications using the vendor's software

Once the equipment is connected to a computer, use the vendor's software to connect to it. Verify normal operational characteristics - can you read data/settings and write settings to the equipment?

Identification of the logical interface or instrument API

Next, it is important to determine the logical or syntactic communication protocol for the equipment. The vendor will typically have documentation on their APIs or LabVIEW/C drivers for their equipment. It is often helpful to use Wireshark to watch the traffic from the vendor's software to see if the commands are human-readable. Some common interfaces/APIs are:

  • Standard Commands for Programmable Instruments (SCPI, pronounced "skippy")
  • Virtual Instrument Software Architecture (VISA) devices that work for GPIB and VXI-11 equipment.
  • Binary commands that are encapsulated in .NET frameworks

Writing the driver

In order to create an SVP-compliant driver, two python files will need to be created:

  • A low-level communication interface to the equipment written in python. This file starts with "device_" and should be executable and testable from within python without any hooks or ties to the SVP. In some situations, this file may not be necessary. Example: https://github.com/sunspec/svp_energy_lab/blob/dev/Lib/svpelab/device_terrasas.py
  • The driver for the equipment that includes the common functions defined in the abstraction layer. This file will begin with specific prefixes for the type of equipment it is: "battsim_" for battery simulators, "das_" for data acquisition systems, "der_" for distributed energy resources, "gridsim_" for grid simulators, "loadsim_" for loadbanks, "pvsim_" for PV simulators. Example: https://github.com/sunspec/svp_energy_lab/blob/dev/Lib/svpelab/pvsim_terrasas.py

Notes:

  • The abstraction layers (battsim.py, das.py, der.py, gridsim.py, loadsim.py, pvsim.py) scan the svpelab for all the files with the associated prefix (e.g., pvsim_) and populate the list of devices with those drivers.
  • The abstraction layers include objects with methods that should be populated in the drivers. For instance, pvsim.py includes the following
class PVSim (object):

    def __init__(self, ts, group_name, params=None):
        self.ts = ts
        self.group_name = group_name

    def close(self):
        pass

    def info(self):
        pass

    def irradiance_set(self, irradiance=1000):
        pass

    def power_set(self, power):
        pass

Creating a SCPI driver

A good example is the terrasas driver.

Creating a VISA driver

A good example is the Yokogawa WT3000 driver. Using pyvisa is fairly straightforward.

Creating a .NET driver

The pythonnet (http://pythonnet.github.io/) package is preferred at this time. Pythonnet loads all imports referred within the dll file. Python and the dll must have the same bitness.