PhidgetSBC4 with MOT2002 issues
Posted: Fri Jan 28, 2022 9:36 am
Hi,
I am trying to connect PhidgetSBC4 with MOT2002 and receive data via VoltageInput.
I can see the sensor via the control panel and via another script (digital input) I can also reach it. But when I try to reach it via Voltage input I get:
my code looks like this:
I am trying to connect PhidgetSBC4 with MOT2002 and receive data via VoltageInput.
I can see the sensor via the control panel and via another script (digital input) I can also reach it. But when I try to reach it via Voltage input I get:
Code: Select all
Opening channel... 622855 hub: 0 chan: 0
Traceback (most recent call last):
File "/Ksa/relay_phidget/parexec1", line 14, in onPulse
File "/Ksa/relay_phidget/CL", line 54, in OpenChannel
Phidget22.PhidgetException.PhidgetException: PhidgetException 0x03 (Timed Out)
Code: Select all
import sys
import time
import threading
from Phidget22.Devices.DigitalInput import *
from Phidget22.Devices.DigitalOutput import *
from Phidget22.PhidgetException import *
from Phidget22.Phidget import *
from Phidget22.Devices.VoltageInput import *
def onSensorChange(self, sensorValue, sensorUnit):
print("SensorValue: " + str(sensorValue))
print("SensorUnit: " + str(sensorUnit.symbol))
class CL:
"""
CL description
"""
def __init__(self, ownerComp):
self.ownerComp = ownerComp
self.serial = parent().par.Serialnumber
self.remote = parent().par.Remotedevice
self.hubport = parent().par.Hubport
self.hubportdevice = parent().par.Hubportdevice
self.channelnumber = parent().par.Channel
self.ownerComp.store("is_open", False)
self.ownerComp.store("state", None)
#self.OpenChannel()
def OpenChannel(self):
print(
"Opening channel...",
self.serial,
"hub:",
self.hubport,
"chan:",
self.channelnumber,
)
self.phidget = VoltageInput()
self.phidget.setDeviceSerialNumber(int(self.serial))
self.phidget.setHubPort(self.hubport)
self.phidget.setIsHubPortDevice(self.hubportdevice)
self.phidget.setChannel(self.channelnumber)
self.phidget.setOnSensorChangeHandler(onSensorChange)
self.phidget.openWaitForAttachment(1000)
# Which mode to operate
#Other valid sensor types for this sensor include: SENSOR_TYPE_MOT2002_MED, SENSOR_TYPE_MOT2002_HIGH
#Uncomment these lines if you want to operate in other mode
#self.phidget.setSensorType(VoltageSensorType.SENSOR_TYPE_MOT2002_LOW)
#self.phidget.setSensorType(VoltageSensorType.SENSOR_TYPE_MOT2002_LOW)
self.phidget.setSensorType(VoltageSensorType.SENSOR_TYPE_MOT2002_LOW)
if self.remote:
self.phidget.setIsRemote(True)
Net.enableServerDiscovery(PhidgetServerType.PHIDGETSERVER_DEVICEREMOTE)
try:
self.phidget.openWaitForAttachment(1000)
print("Phidget channel attached")
self.ownerComp.store("is_open", True)
#self.GetState()
except PhidgetException as e:
print("Open failed.")
print("Phidget Exception:", e.details)
self.phidget.close()
return
def CloseChannel(self):
print("Closing channel...")
c = self.phidget.close()
print("Channel closed.", c)
self.ownerComp.store("is_open", False)
def SetState(self, state):
self.phidget.setState(state)
self.GetState()
return
def GetState(self):
try:
state = self.phidget.getState()
self.ownerComp.store("state", state)
except PhidgetException as e:
print(e, e.details)
return state
def onStateChangeHandler(state):
print("State:", str(state))