Power cycling Zurich Instruments’ devices remotely

Because of the pandemic outbreak of Covid-19, many of us are working from home. Two weeks ago, we have shown you how to access and control our instruments remotely using LabOne. However, we didn’t discuss how to properly shut down, or restart the instruments remotely. The main reason: once an instrument is powered down, the only way to restart it is to flip the power switch in the back.

So let me tell you how we from Zurich Instrument turn off/on our instruments remotely.

We use external powerswitches that can be accessed via our local network in combination with a controlled soft power down of the instrument. In specific, we find that theĀ AP7920B from APC work well and reliably for our means. They can be accessed directly through a web interface, SNMP or a Telnet connection using their IP address in the network, and distribute power to up to 8 instruments.

The following Python script allows you to remotely connect to any Zurich Instruments device, and then perform an (of course hardly ever needed) power cycle before reconnecting. You might need to be connected to your laboratory network through a virtual private network (VPN) connection.

import time
import zhinst.ziPython as zi
import telnetlib
class powerSwitchAPC() :
    def __init__(self, host = '') :
        self.host = host
        self.user = b'apc'
        self.password = b'apc'
        self.conn = None
    def logon(self) :
        self.conn = telnetlib.Telnet(self.host)
        self.conn.read_until(b"User Name", 5)
        self.conn.write(self.user + b"\r\n")
        self.conn.read_until(b"Password", 5)
        self.conn.write(self.password + b" -c\r\n")
        self.conn.read_until(b"APC>", 5)
    def logoff(self) :
    def onSingle(self, channel) :
        self.conn.write(b"on %d\r\n" % (channel))
    def offSingle(self, channel) :
        self.conn.write(b"off %d\r\n" % (channel))
# parameters
IP_switch=''  #IP-address of switch
port=4  #port on powerswitch
IP_server=''  #IP-address of device
device='DEV2496'  #device ID
# establish connection with device through daq session
daq = zi.ziDAQServer(IP_server, 8004, 6)
daq.connectDevice(device, '1gbe')
# soft shut down of the instrument
while True:
        daq.setInt('/%s/SYSTEM/SHUTDOWN' %device,int(1))
        print('instrument shutting down')
# turn off powerswitch port
print('waiting for hard reboot')
# turn the instrument back on
print('wait for instrument to power up')
# reconnect to device if detected
while True:
    if daq.getString('/zi/devices/visible').find(device)  != -1:
        daq.connectDevice(device, '1gbe')

The script can be run as is after changing the settings in the section ‘parameters’. Note, the class ‘powerSwitchAPC’ comes in handy if several powerswitches are managed.

After establishing connection with the powerswitch through Telnet, we first perform a soft shut down of the instrument by enabling the /SYSTEM/SHUTDOWN node, and then turn off the port of the powerswitch. After a long enough wait time, the port is turned back on again and the connection with the device is reestablished as soon as the device is detected by the data server.

We from Zurich Instruments hope that this blog post will help you operating our devices remotely.

All the best, and stay healthy!