I am trying to create a switching system with 4 solid state Phidget relays(link : https://www.phidgets.com/?prodid=1120 ) and Phidget VINT Hub( https://www.phidgets.com/?tier=3&catid= ... prodid=643) by controlling them using the Python API and I am running into a state persistency problem.
I need the relays to keep their state once I close the channels and quit the script.
I saw on this topic : viewtopic.php?t=8471 that using a Phidget may help with this problem but still can't make it work
I am now troubleshooting the problem using one of the Phidget code sample which I modified slightly to control the Phidget remotely.
The way I'm using them is the following :
1: creating 4 DigitalOutput objects and initializing them.
2: Setting the state of the desired relay to True.
3: waiting for a keyboard interruption
4: closing the DigitalOutputs and exiting the script.
Code: Select all
def main():
	#instanciantes 4 DigitalOutput Objects
	digitalOutput0 = DigitalOutput()
	digitalOutput1 = DigitalOutput()
	digitalOutput2 = DigitalOutput()
	digitalOutput3 = DigitalOutput()
	
	#ininitialize the outputs and enabling remote option
	digitalOutput0.setIsHubPortDevice(True)
	digitalOutput0.setHubPort(0)
	digitalOutput0.setIsRemote(1)
	digitalOutput1.setIsHubPortDevice(True)
	digitalOutput1.setHubPort(1)
	digitalOutput1.setIsRemote(1)
	digitalOutput2.setIsHubPortDevice(True)
	digitalOutput2.setHubPort(2)
	digitalOutput2.setIsRemote(1)
	digitalOutput3.setIsHubPortDevice(True)
	digitalOutput3.setHubPort(3)
	digitalOutput3.setIsRemote(1)
	#Search and connect to the server								 
   Net.enableServerDiscovery
     (PhidgetServerType.PHIDGETSERVER_DEVICEREMOTE)
	digitalOutput0.openWaitForAttachment(5000)
	digitalOutput1.openWaitForAttachment(5000)
	digitalOutput2.openWaitForAttachment(5000)
	digitalOutput3.openWaitForAttachment(5000)
	
	#switching ON digitalOutput2
	digitalOutput2.setState(True)
	
	time.sleep(1)
	
	#waiting for a user action to stop the script
	try:
		input("Press Enter to Stop\n")
	except (Exception, KeyboardInterrupt):
		pass
	#closing the channels 
	digitalOutput0.close()
	digitalOutput1.close()
	digitalOutput2.close()
	digitalOutput3.close()
main()