PhidgetSBC4 with MOT2002 issues

Supporting 2.7 and 3.2+
Post Reply
xbix
Fresh meat
Posts: 2
Joined: Thu Jan 27, 2022 6:09 am
Contact:

PhidgetSBC4 with MOT2002 issues

Post by xbix »

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:

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)
my code looks like this:

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))
User avatar
mparadis
Site Admin
Posts: 959
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: PhidgetSBC4 with MOT2002 issues

Post by mparadis »

- Dobule check that the addressing parameters are correct (especially IsHubPortDevice = true)
- Ensure that no other script or program has any other ports on the hub open
- Try running a simpler script like the one below, just to rule out anything going wrong in your code.

Code: Select all

from Phidget22.Phidget import *
from Phidget22.Devices.VoltageInput import *
import time

def onVoltageChange(self, voltage):
	print("Voltage: " + str(voltage))

def main():
	voltageInput0 = VoltageInput()

	voltageInput0.setIsHubPortDevice(True)
	voltageInput0.setHubPort(0)

	voltageInput0.setOnVoltageChangeHandler(onVoltageChange)

	voltageInput0.openWaitForAttachment(5000)

	try:
		input("Press Enter to Stop\n")
	except (Exception, KeyboardInterrupt):
		pass

	voltageInput0.close()

main()
xbix
Fresh meat
Posts: 2
Joined: Thu Jan 27, 2022 6:09 am
Contact:

Re: PhidgetSBC4 with MOT2002 issues

Post by xbix »

Thank you for your help.

Unfortunately, I have already tried that. I recently updated the firmware from 110 to 203, but that shouldn't have any effect, should it?
User avatar
mparadis
Site Admin
Posts: 959
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: PhidgetSBC4 with MOT2002 issues

Post by mparadis »

I'm able to remotely open a voltage input on my v203 with the following code, so I don't think that's the issue.

Code: Select all

from Phidget22.Phidget import *
from Phidget22.Net import *
from Phidget22.Devices.VoltageInput import *
import time

def onVoltageChange(self, voltage):
	print("Voltage: " + str(voltage))

def onAttach(self):
	print(self)

def main():
	Net.enableServerDiscovery(PhidgetServerType.PHIDGETSERVER_DEVICEREMOTE)

	voltageInput0 = VoltageInput()

	voltageInput0.setIsHubPortDevice(True)
	voltageInput0.setHubPort(0)
	voltageInput0.setIsRemote(True)

	voltageInput0.setOnVoltageChangeHandler(onVoltageChange)
	voltageInput0.setOnAttachHandler(onAttach)

	voltageInput0.openWaitForAttachment(20000)

	try:
		input("Press Enter to Stop\n")
	except (Exception, KeyboardInterrupt):
		pass

	voltageInput0.close()

main()
If you still suspect the firmware change as the source of the issue you could downgrade the firmware through the control panel by right-clicking on the hub.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests