SCPI PSU Agent
This agent uses Standard Commands for Programmable Instruments (SCPI) It works for many power supplies, including the Keithley 2230G and BK Precision 9130. It connects to the PSU over ethernet, and allows users to set current, voltage, and turn channels on/off. It also allows for live monitoring of the PSU output.
usage: python3 agent.py [-h] [--ip-address IP_ADDRESS] [--gpib-slot GPIB_SLOT]
Agent Options
- --ip-address
- --gpib-slot
Configuration File Examples
Below are configuration examples for the ocs config file and for running the Agent in a docker container.
OCS Site Config
To configure the SCPI PSU Agent we need to add a block to our ocs configuration file. Here is an example configuration block using all of the available arguments:
{'agent-class': 'ScpiPsuAgent',
'instance-id': 'psuK',
'arguments': [
['--ip-address', '10.10.10.5'],
['--gpib-slot', '1']
]},
Most power supplies (including the Keithley 2230G and BK Precision 9130) have GPIB ports rather than ethernet ports. Therefore a GPIB-to-ethernet converter is required, and the gpib slot must be specified in the ocs configuration file. The IP address is then associated with the converter.
Docker Compose
The SCPI PSU Agent should be configured to run in a Docker container. An example docker compose service configuration is shown here:
ocs-psuK:
image: simonsobs/socs:latest
hostname: ocs-docker
network_mode: "host"
environment:
- INSTANCE_ID=psuK
volumes:
- ${OCS_CONFIG_DIR}:/config:ro
Agent API
- class socs.agents.scpi_psu.agent.ScpiPsuAgent(agent, ip_address, gpib_slot)[source]
-
- monitor_output(wait=1, channels=[1, 2, 3], test_mode=False)[source]
Process - Continuously monitor PSU output current and voltage.
- Parameters:
wait (float, optional) – Time to wait between measurements [seconds].
channels (list[int], optional) – Channels to monitor. [1, 2, 3] by default.
test_mode (bool, optional) – Exit process after single loop if True. Defaults to False.
- set_voltage(channel, volts)[source]
Task - Set the voltage of the power supply.
- Parameters:
channel (int) – Channel number (1, 2, or 3).
volts (float) – Voltage to set. Must be between 0 and 30.
Example Clients
Below is an example client demonstrating full agent functionality. Note that all tasks can be run even while the data acquisition process is running.:
from ocs.ocs_client import OCSClient
# Initialize the power supply
psuK = OCSClient('psuK', args=[])
psuK.init.start()
psuK.init.wait()
# Turn on channel 1
psuK.set_output.start(channel = 1, state=True)
psuK.set_output.wait()
# Set channel 1 voltage
psuK.set_voltage.start(channel=1, volts=30)
psuK.set_voltage.wait()
# Set channel 1 current
psuK.set_current.start(channel=1, current=0.1)
psuK.set_current.wait()
# Get instantaneous reading of current and voltage output
statusK, messageK, sessionK = psuK.monitor_output.status()
print(sessionK['data']['data'])
# Start live monitoring of current and voltage output
statusK, messageK, sessionK = psuK.monitor_output.start()
print(sessionK)