forked from zietzm/Helmholtz_Test_Bench
Implemented Arduino-based polarity control into main script
This commit is contained in:
+27
-27
@@ -10,55 +10,55 @@ DEVICE = "COM7" if platform.system() == "Windows" else "/dev/ttyACM0"
|
||||
|
||||
# connection to the device is automatically opened
|
||||
print("Connecting to device at %s..." % DEVICE)
|
||||
device1 = PS2000B.PS2000B(DEVICE) # create Object of class PS2000B, pass COM-port and channel to functions inside
|
||||
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" % device1.is_open())
|
||||
print("Device: %s" % device1.get_device_information())
|
||||
print("Connection open: %s" % xyDevice.is_open())
|
||||
print("Device: %s" % xyDevice.get_device_information())
|
||||
|
||||
# dynamic device status information can be read
|
||||
device_status_info1 = device1.get_device_status_information(0)
|
||||
device_status_info2 = device1.get_device_status_information(1)
|
||||
print("Device status 1: %s" % device1.get_device_status_information(0))
|
||||
print("Device status 2: %s" % device1.get_device_status_information(1))
|
||||
print("Current output 1: %0.2f V , %0.2f A" % (device1.voltage1, device1.current1))
|
||||
print("Current output 2: %0.2f V , %0.2f A" % (device1.voltage2, device1.current2))
|
||||
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...")
|
||||
device1.enable_remote_control(0)
|
||||
xyDevice.enable_remote_control(0)
|
||||
if not device_status_info2.remote_control_active:
|
||||
print("...will enable remote control...")
|
||||
device1.enable_remote_control(1)
|
||||
xyDevice.enable_remote_control(1)
|
||||
|
||||
print("...set voltage 1 to 12V and max current to 1A...")
|
||||
device1.voltage1 = 12
|
||||
device1.current1 = 1
|
||||
xyDevice.voltage1 = 12
|
||||
xyDevice.current1 = 1
|
||||
time.sleep(2)
|
||||
print("...now enabling the power output control 1...")
|
||||
device1.enable_output(0)
|
||||
xyDevice.enable_output(0)
|
||||
|
||||
time.sleep(2)
|
||||
print("... set voltage 2 to 5V and max current to 1A...")
|
||||
device1.voltage2 = 5
|
||||
device1.current2 = 1
|
||||
xyDevice.voltage2 = 5
|
||||
xyDevice.current2 = 1
|
||||
time.sleep(2)
|
||||
print("...now enabling the power output control 2...")
|
||||
device1.enable_output(1)
|
||||
xyDevice.enable_output(1)
|
||||
|
||||
time.sleep(5)
|
||||
print("Device status 1: %s" % device1.get_device_status_information(0))
|
||||
print("Device status 2: %s" % device1.get_device_status_information(1))
|
||||
print("Output 1: %0.2f V , %0.2f A" % (device1.voltage1, device1.current1))
|
||||
print("Output 2: %0.2f V , %0.2f A" % (device1.voltage2, device1.current2))
|
||||
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)
|
||||
device1.disable_output(0)
|
||||
device1.disable_output(1)
|
||||
xyDevice.disable_output(0)
|
||||
xyDevice.disable_output(1)
|
||||
print("...and disabling remote control again.")
|
||||
device1.disable_remote_control(0)
|
||||
device1.disable_remote_control(1)
|
||||
xyDevice.disable_remote_control(0)
|
||||
xyDevice.disable_remote_control(1)
|
||||
|
||||
print("Device status 1: %s" % device1.get_device_status_information(0))
|
||||
print("Device status 2: %s" % device1.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))
|
||||
|
||||
Reference in New Issue
Block a user