Have both ENC1000_0 and 1047_2B encoders attached, how to distinguish?

Supporting 2.7 and 3.2+
Post Reply
stepheneb
Phidgetly
Posts: 19
Joined: Tue Oct 10, 2023 3:46 pm
Contact:

Have both ENC1000_0 and 1047_2B encoders attached, how to distinguish?

Post by stepheneb »

I have an ENC1000_0 encoder attached via a VINt hub and a 1047_2B high-speed 4-channel encoder attached directly via usb. How can I choose to open a connection to one or the other?

Right now the ENC1000_0 is opened with this code when both are connected.

Code: Select all

>>> en = Encoder()
>>> en.openWaitForAttachment(5000)
>>> en.getDeviceClassName()
'PhidgetVINT'
stepheneb
Phidgetly
Posts: 19
Joined: Tue Oct 10, 2023 3:46 pm
Contact:

Re: Have both ENC1000_0 and 1047_2B encoders attached, how to distinguish?

Post by stepheneb »

There's a somewhat hacky workaround if I set the Channel to 1:

Code: Select all

>> from Phidget22.Phidget import *
>>> from Phidget22.Devices.Encoder import *
>>> en = Encoder()
>>> en.setChannel(1)
>>> en.openWaitForAttachment(5000)
>>> en.getDeviceClassName()
'PhidgetEncoder'
>>> en.getMaxDataRate()
125.0
That doesn't work if I set the Channel to 0:

Code: Select all

>>> from Phidget22.Phidget import *
>>> from Phidget22.Devices.Encoder import *
>>> en = Encoder()
>>> en.setChannel(0)
>>> en.openWaitForAttachment(5000)
>>> en.getDeviceClassName()
'PhidgetVINT'
>>> en.getMaxDataRate()
50.0
Seems like there should be a better way.
fraser
Engineering
Posts: 138
Joined: Thu Nov 19, 2009 4:41 pm
Contact:

Re: Have both ENC1000_0 and 1047_2B encoders attached, how to distinguish?

Post by fraser »

The best way to do this is by Serial Number. All USB Phidgets have a serial number, so your VINT Hub will have one, and the 1047_2B will have one.
These numbers are always printed on a sticker on the device itself, but can also be found by opening the Phidget Control Panel - the serial number will be one of the columns in the list of attached phidgets.

If you call en.openWaitForAttachment() without specifying the serial number first, the computer will open whichever encoder object it happens to identify first.

So you can choose which encoder you are opening by setting the serial number before calling open, with:

Code: Select all

en.setDeviceSerialNumber(SerialNumberGoesHere)
en.openWaitForAttachment(5000)
More specific addressing will be required if you start introducing multiple ENC1000's on your VINT Hub, but given your setup just setting the serial number of the encoder you want to open should be enough.

And an additional note:
The reason that setting the Channel to 1 works is because the 1047_2B has multiple encoder channels and the ENC1000 does not, so the only available encoder device for it to open is the 1047 encoder on channel 1.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests