Setting port and channel - C language

C, C++, and Visual C++
satsriakal
Phidgetsian
Posts: 9
Joined: Sun Nov 12, 2017 3:44 am
Contact:

Setting port and channel - C language

Postby satsriakal » Thu Dec 21, 2017 5:25 am

Hi everybody,

I'm using a VintHub device with this code (C language):

Phidget_setHubPort((PhidgetHandle)x->ch, 2);
Phidget_setIsHubPortDevice((PhidgetHandle)x->ch, 1);
Phidget_setChannel((PhidgetHandle)x->ch, 2);

If I comment the third line, I got the console message with the port and the channel number set (the channel is always set to 0). The device works but for all ports, channel number is 0.
If I uncomment the third line, I don't get any message, and the device doesn't work at all.

What should I change?
Best regards
BB

User avatar
mparadis
Site Admin
Posts: 609
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: Setting port and channel - C language

Postby mparadis » Thu Dec 21, 2017 11:26 am

If you are trying to use the ports of the VINT Hub on their own (i.e. in DigitalInput, DigitalOutput, VoltageInput or VoltageRatioInput mode), you need to use IsHubPortDevice (set to "true" or 1) and setHubPort to choose which VINT Port to use. Calling setChannel with a non-zero argument will cause open to fail in this case, since the VINT Hub ports are considered to each only have one channel themselves.

If you are trying to use a VINT Device (such as the DAQ1500 or TMP1200) connected to one of the ports on the VINT Hub, you'll want to use setHubPort to specify which port of the VINT Hub it's connected to, and setChannel to specify which port on the VINT device you want to open.

Have a look at this video, which shows an example to clarify the difference between these two cases.

satsriakal
Phidgetsian
Posts: 9
Joined: Sun Nov 12, 2017 3:44 am
Contact:

Re: Setting port and channel - C language

Postby satsriakal » Fri Dec 22, 2017 8:51 am

Thanks a lot!


Return to “C/C++”

Who is online

Users browsing this forum: No registered users and 1 guest