PDA

View Full Version : Phidget Devices



cmmguy
03-04-2008, 06:46 AM
Is there a list of device names that show up in "PHIDGET.DeviceType" so that I can determine the correct type that was connected? Is there a way to decode the serial number?

How can I determine the difference between a 0/0/4, 0/0/8, 8/8/8, or a 0/16/16 when hooked up to my app. I am trying to build some flexibility into the program.
For example: the 0/0/4 returns "PhidgetInterfaceKit" but I think the others do also and the The "NumOutputs" returns 4, but on the 0/0/8 and the 8/8/8 the count would be the same.

Am I overlooking a simple answer to this?


Thanks
J

Alex
03-04-2008, 11:04 AM
Probably the easiest way of finding the Phidget device type that was connected is by using a Phidget.Manager object. Assuming you're using .NET, download any of the example Zip files and look at the ManagerExamples. edit: I also attached the two C# Manager Examples:)

Going through the code, you'll see that the Phidget Manager is basically an object that sits "outside" of the normal Phidget devices in the sense that it is used for the purpose of detecting Attach and Detach events for all Phidgets, not just a particular type. If you look in the Attach event, you'll see the AttachEventArgs object (e) getting passed in. Use this and you can run a test on e.Device.Name to see if it's the device type that you want. You can also run a check at any time on the manager object to return a list of all the connected Phidget devices using the Phidget.Manager.Devices collection.

Is this what you're looking for?

I'm not sure what you mean by "decode" the serial number though...

cmmguy
03-04-2008, 12:03 PM
I am able to get the following:

PHIDGET.DeviceType
PHIDGET.DeviceVersion
PHIDGET.IsAttached
PHIDGET.LibraryVersion
PHIDGET.Open
PHIDGET.SerialNumber
PHIDGET.Tag

But I believe that the DeviceType is not unique to the 0/0/4
I thought that maybe within the serial number may have been "coded" a model number. Some manufacturers will code various info into the serial number such as manufacture date or lot numbers.

Of all the different Phidget devices, what are all the different DeviceType(s) that show up when hooked up?

Thanks
J

Alex
03-04-2008, 01:12 PM
Which programming language are you using?

If you're using .NET, are you sure you're using the Phidget.Manager object? None of these commands are available on the Phidget.Manager object...

cmmguy
03-04-2008, 03:11 PM
I am using VB6.
The PHIDGET is the object I create when the connection is made so it could be named anything.

Code at the top:


Private WithEvents PM As PhidgetManager
Dim WithEvents IFKit As PhidgetInterfaceKit


In the Form load event:


Set PM = New PhidgetManager


the Attach Event:


'An InterfaceKit was found. Start everything up
Private Sub PM_OnAttach(ByVal PHIDGET As PHIDGET.IPhidget)
Dim I As Long
If PHIDGET.DeviceType <> "PhidgetInterfaceKit" Then
bInterfaceActive = False
shapeInterface.FillColor = vbRed
Else
Set IFKit = PHIDGET
iIFPortCount = PHIDGET.NumOutputs
iDeviceSerialNo = PHIDGET.SerialNumber
bInterfaceActive = True
shapeInterface.FillColor = vbGreen
' Save settings
ProfileWrite sINIPath, "misc", "IFPorts", Str(iIFPortCount)
ProfileWrite sINIPath, "misc", "IFSerialNo", Str(iDeviceSerialNo)
End If
End Sub

Alex
03-04-2008, 04:12 PM
What Phidget version are you using? I just downloaded the latest vb6 Example files (http://www.phidgets.com/downloads.php?os_id=1) from Phidgets.com and this is what I found in the OnAttach Event:


Private Sub PM_OnAttach(ByVal deviceType As String, ByVal deviceName As String, ByVal serialNumber As Long, ByVal version As Long, ByVal tag As String)
DisplayDevice deviceName, version, serialNumber, True
End Sub

Make sure you have the latest Phidget MSI installed too:)

cmmguy
03-05-2008, 04:57 PM
I am using the older version because I dont like the .net extensions that I have to install for the newer version to work(examples).

Looking at the example you posted doesnt provide any more info that the code I posted and I am still trying to see if there is an answer to my original question about "which interface is connected".

Thanks
J

Alex
03-05-2008, 07:04 PM
Looking at the example you posted doesnt provide any more info that the code I posted

I didn't paste that code as an example to help you out. I pasted it because I was confused because the code you posted didn't match what I was looking at in the examples.


I am still trying to see if there is an answer to my original question about "which interface is connected".

and I'm trying to help you find that answer;) That's why I needed to know if we were on the same page, which now I know that we're not because you're using the older Phidget.MSI. They're significantly different in functionality and operation.

The older Phidget.MSI I believe will return a different value than the new one when you call the DeviceType method, so it's pretty hard to help you since I only have the new Phidget.MSI. I can't remember for sure though (it's been a while since I used the old Phidget.MSI), so don't download the new one just yet cause I'm at home. When I get to work tomorrow, I'll give Phidgets a call and see what they have to say.

Alex
03-06-2008, 10:09 AM
Hey cmm guy. Before I call Phidgets up, I wanted to check to make sure that I need to. I realized that I was mistaken about something. I was getting the DeviceType method confused with the DeviceName method.

Using the Phidget21.MSI and the vb6 example called PhidgetMonitor, this is the results of the DeviceName method from all the Phidget devices that I just attached:


Phidget Servo Controller 4-motor
Phidget InterfaceKit 8/8/8
Phidget InterfaceKit 0/0/4
Phidget InterfaceKit 0/0/8
Phidget Touch Rotation

and from the TextLCD with 8/8/8 returns two DeviceNames:
Phidget TextLCD
Phidget InterfaceKit 8/8/8Could you test this method in your Phidget20 version? Maybe we get the same results?



Also, I wanted to address your question in your PM publicly because I think it'll help a lot of other people reading this thread:


is there a way to use the new DLL without all the .net overhead? I thought I saw a thread on that very questions but never really understood the final answer.There is no way around having to download the .NET framework with the Phidget 2.1 DLL. However, just because you need to have the .NET framework installed, doesn't mean that you use it in every case. VB6 doesn't use the .NET framework at all. In the case of the Phidgets 2.1 Library and vb6, vb6 uses the COM DLL and talks directly to the C DLL. The .NET framework is only required for the .NET based DLL's used in any of the .NET based languages. You can also read all about the Phidget 2.1 Libraries in their Phidget Library documentation (http://www.phidgets.com/documentation/Tutorials/Library_Information.pdf)

cmmguy
03-06-2008, 08:09 PM
There is no DeviceName method or property. This must be unique to 2.1
And yes, that is exactly what I was looking for.
Thanks for you help with this.

J

Alex
03-06-2008, 09:04 PM
cool! Glad I could help:D