Controlling PSU1000_0 using Python
Posted: Tue Mar 16, 2021 7:33 pm
I'm trying to turn PSU1000_0 on and off programmatically using Python. Here's the setup I have:
Python script on macOS -> USB -> HUB0000_0 -> PSU1000_0.
PSU1000_0 is connected to port 0 on HUB0000_0.
The following code (from examples provided) works fine.
The problem here is that after 3 seconds PSU1000_0 gets turned off. If I try...:
...in an effort to keep the PSU1000_0 on, it does not work. The code completes without any errors and no effect.
What am I doing wrong? It is my understanding that setting duty cycle to 1 should turn PSU1000_0 on. Then I could do stuff with a device connected and powered by it. Once I'm done, I should be able to set the duty cycle to 0 thus turning PSU1000_0 off.
I tested this from Phidget Control Panel and clicking on duty cycle slider turns connected PSU1000_0 on and off as expected.
Python script on macOS -> USB -> HUB0000_0 -> PSU1000_0.
PSU1000_0 is connected to port 0 on HUB0000_0.
The following code (from examples provided) works fine.
Code: Select all
def turn_on(port):
digitalOutput = DigitalOutput()
digitalOutput.setIsHubPortDevice(True)
digitalOutput.setHubPort(port)
digitalOutput.openWaitForAttachment(5000)
digitalOutput.setDutyCycle(1)
time.sleep(3)
digitalOutput.close()
turn_on(0)
Code: Select all
def turn_on(port):
digitalOutput = DigitalOutput()
digitalOutput.setIsHubPortDevice(True)
digitalOutput.setHubPort(port)
digitalOutput.openWaitForAttachment(5000)
digitalOutput.setDutyCycle(1)
turn_on(0)
What am I doing wrong? It is my understanding that setting duty cycle to 1 should turn PSU1000_0 on. Then I could do stuff with a device connected and powered by it. Once I'm done, I should be able to set the duty cycle to 0 thus turning PSU1000_0 off.
I tested this from Phidget Control Panel and clicking on duty cycle slider turns connected PSU1000_0 on and off as expected.