Files
Helmholtz_Test_Bench/example2.py
T

65 lines
2.3 KiB
Python

#!/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)
xyDevice = 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" % xyDevice.is_open())
print("Device: %s" % xyDevice.get_device_information())
# dynamic device status information can be read
device_status_info1 = xyDevice.get_device_status_information(0)
device_status_info2 = xyDevice.get_device_status_information(1)
print("Device status 1: %s" % xyDevice.get_device_status_information(0))
print("Device status 2: %s" % xyDevice.get_device_status_information(1))
print("Current output 1: %0.2f V , %0.2f A" % (xyDevice.voltage1, xyDevice.current1))
print("Current output 2: %0.2f V , %0.2f A" % (xyDevice.voltage2, xyDevice.current2))
# device can be controlled
if not device_status_info1.remote_control_active:
print("...will enable remote control...")
xyDevice.enable_remote_control(0)
if not device_status_info2.remote_control_active:
print("...will enable remote control...")
xyDevice.enable_remote_control(1)
print("...set voltage 1 to 12V and max current to 1A...")
xyDevice.voltage1 = 12
xyDevice.current1 = 1
time.sleep(2)
print("...now enabling the power output control 1...")
xyDevice.enable_output(0)
time.sleep(2)
print("... set voltage 2 to 5V and max current to 1A...")
xyDevice.voltage2 = 5
xyDevice.current2 = 1
time.sleep(2)
print("...now enabling the power output control 2...")
xyDevice.enable_output(1)
time.sleep(5)
print("Device status 1: %s" % xyDevice.get_device_status_information(0))
print("Device status 2: %s" % xyDevice.get_device_status_information(1))
print("Output 1: %0.2f V , %0.2f A" % (xyDevice.voltage1, xyDevice.current1))
print("Output 2: %0.2f V , %0.2f A" % (xyDevice.voltage2, xyDevice.current2))
time.sleep(5)
xyDevice.disable_output(0)
xyDevice.disable_output(1)
print("...and disabling remote control again.")
xyDevice.disable_remote_control(0)
xyDevice.disable_remote_control(1)
print("Device status 1: %s" % xyDevice.get_device_status_information(0))
print("Device status 2: %s" % xyDevice.get_device_status_information(1))