#!/usr/bin/env python3 # coding=utf-8 import platform import time from pyps2000b import PS2000B DEVICE = "COM7" if platform.system() == "Windows" else "/dev/ttyACM0" # connection to the device is automatically opened print("Connecting to device at %s..." % DEVICE) XY_DEVICE = PS2000B.PS2000B(DEVICE) # create Object of class PS2000B, pass COM-port and channel to functions inside # static device information can be read print("Connection open: %s" % XY_DEVICE.is_open()) print("Device: %s" % XY_DEVICE.get_device_information()) # dynamic device status information can be read device_status_info1 = XY_DEVICE.get_device_status_information(0) device_status_info2 = XY_DEVICE.get_device_status_information(1) print("Device status 1: %s" % XY_DEVICE.get_device_status_information(0)) print("Device status 2: %s" % XY_DEVICE.get_device_status_information(1)) print("Current output 1: %0.2f V , %0.2f A" % (XY_DEVICE.voltage1, XY_DEVICE.current1)) print("Current output 2: %0.2f V , %0.2f A" % (XY_DEVICE.voltage2, XY_DEVICE.current2)) # device can be controlled if not device_status_info1.remote_control_active: print("...will enable remote control...") XY_DEVICE.enable_remote_control(0) if not device_status_info2.remote_control_active: print("...will enable remote control...") XY_DEVICE.enable_remote_control(1) print("...set voltage 1 to 12V and max current to 1A...") XY_DEVICE.voltage1 = 12 XY_DEVICE.current1 = 1 time.sleep(2) print("...now enabling the power output control 1...") XY_DEVICE.enable_output(0) time.sleep(2) print("... set voltage 2 to 5V and max current to 1A...") XY_DEVICE.voltage2 = 5 XY_DEVICE.current2 = 1 time.sleep(2) print("...now enabling the power output control 2...") XY_DEVICE.enable_output(1) time.sleep(5) print("Device status 1: %s" % XY_DEVICE.get_device_status_information(0)) print("Device status 2: %s" % XY_DEVICE.get_device_status_information(1)) print("Output 1: %0.2f V , %0.2f A" % (XY_DEVICE.voltage1, XY_DEVICE.current1)) print("Output 2: %0.2f V , %0.2f A" % (XY_DEVICE.voltage2, XY_DEVICE.current2)) time.sleep(5) XY_DEVICE.disable_output(0) XY_DEVICE.disable_output(1) print("...and disabling remote control again.") XY_DEVICE.disable_remote_control(0) XY_DEVICE.disable_remote_control(1) print("Device status 1: %s" % XY_DEVICE.get_device_status_information(0)) print("Device status 2: %s" % XY_DEVICE.get_device_status_information(1))