forked from zietzm/Helmholtz_Test_Bench
c8e131c8e2
- Removed default value for channel - formatting to make pycharm happy - added comments
57 lines
2.0 KiB
Python
57 lines
2.0 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)
|
|
device = PS2000B.PS2000B(DEVICE) # create Object of class PS2000B, pass COM-port to functions inside
|
|
|
|
# static device information can be read
|
|
print("Connection open: %s" % device.is_open())
|
|
print("Device: %s" % device.get_device_information())
|
|
|
|
# dynamic device status information can be read
|
|
device_status_info1 = device.get_device_status_information(0)
|
|
device_status_info2 = device.get_device_status_information(1)
|
|
print("Device status 1: %s" % device_status_info1)
|
|
print("Device status 2: %s" % device_status_info2)
|
|
|
|
print("Current output: %0.2f V , %0.2f A" % (device.get_voltage(), device.get_current()))
|
|
|
|
# device can be controlled
|
|
if not device_status_info.remote_control_active:
|
|
print("...will enable remote control...")
|
|
device.enable_remote_control()
|
|
|
|
print("...set voltage to 12V and max current to 1A...")
|
|
device.voltage1 = 12
|
|
device.current1 = 1
|
|
time.sleep(10)
|
|
print("...now enabling the power output control...")
|
|
device.enable_output(0)
|
|
time.sleep(2)
|
|
device_status_info1 = device.get_device_status_information(0)
|
|
device_status_info2 = device.get_device_status_information(1)
|
|
print("Device status 1: %s" % device_status_info1)
|
|
print("Device status 2: %s" % device_status_info2)
|
|
print("Current output: %0.2f V , %0.2f A" % (device.voltage1, device.current1))
|
|
time.sleep(10)
|
|
print("...set voltage to 5.1V...")
|
|
device.voltage1 = 5.1
|
|
time.sleep(10)
|
|
print("Current output: %0.2f V , %0.2f A" % (device.get_voltage(), device.get_current()))
|
|
print("...after 5 seconds power output will be disabled again ...")
|
|
time.sleep(5)
|
|
device.disable_output()
|
|
print("...and disabling remote control again.")
|
|
device.disable_remote_control()
|
|
|
|
print("Device status 1: %s" % device.get_device_status_information(0))
|
|
print("Device status 2: %s" % device.get_device_status_information(1))
|