Controlling PSU1000_0 using Python

Supporting 2.7 and 3.2+
Post Reply
ZeeGee
Fresh meat
Posts: 1
Joined: Tue Mar 16, 2021 7:24 pm
Contact:

Controlling PSU1000_0 using Python

Post 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.
User avatar
Patrick
Lead Developer
Posts: 634
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Controlling PSU1000_0 using Python

Post by Patrick »

You need to leave the digital output open to keep it enabled.

-Patrick
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests