Page 1 of 1

Controlling PSU1000_0 using Python

Posted: Tue Mar 16, 2021 7:33 pm
by ZeeGee
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.

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)
The problem here is that after 3 seconds PSU1000_0 gets turned off. If I try...:

Code: Select all

def turn_on(port):
	digitalOutput = DigitalOutput()
	digitalOutput.setIsHubPortDevice(True)
	digitalOutput.setHubPort(port)
		
	digitalOutput.openWaitForAttachment(5000)

	digitalOutput.setDutyCycle(1)
	
turn_on(0)
...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.

Re: Controlling PSU1000_0 using Python

Posted: Wed Mar 17, 2021 9:16 am
by Patrick
You need to leave the digital output open to keep it enabled.

-Patrick