Using PhidgetVoltageInput with multiple sensors (8/8/8)

Supporting Max/MSP versions 6 and up
Post Reply
davidestevens
Phidgetly
Posts: 20
Joined: Tue May 14, 2013 5:01 am
Contact:

Using PhidgetVoltageInput with multiple sensors (8/8/8)

Post by davidestevens »

So I'm attempting to transition my Max app from Phidgets21 (where I just used the PhidgetsInterfaceKit) to Phidgets22. (OSX & Max)
My primary usage case is 4 Phidget IR sensors and a couple of (floor) pressure sensors.
I have one (IR) sensor working using PhidgetVoltageInput on input 0, but darned if I can figure out how to access the other inputs. I've searched the docs, and tried a few things out, but nothing worked.
Could someone explain to me the way to access multiple analogue inputs on the 8/8/8?
thanks
David
jdecoux
Labview Developer
Posts: 161
Joined: Mon Nov 13, 2017 10:20 am
Contact:

Re: Using PhidgetVoltageInput with multiple sensors (8/8/8)

Post by jdecoux »

In Phidget22 each input uses its own object, as opposed to Phidget21 where there was one object for a whole device.

You will need to set the corresponding "channel" for each.
davidestevens
Phidgetly
Posts: 20
Joined: Tue May 14, 2013 5:01 am
Contact:

Re: Using PhidgetVoltageInput with multiple sensors (8/8/8)

Post by davidestevens »

Thanks. I couldn't get that to work at first (not sure what I did wrong), but I seem to have it working ok now. I notice that one needs to set the channel message (for each [PitchVoltageInput]) every time you reload the Max patch - or can I use @ arguments to set that?
.. just checked - no, that doesn't work.
I found that you need to leave time for the objects to attach to their channels before you change the data interval.
davidestevens
Phidgetly
Posts: 20
Joined: Tue May 14, 2013 5:01 am
Contact:

Re: Using PhidgetVoltageInput with multiple sensors (8/8/8)

Post by davidestevens »

And then - I closed and reopened the test patch I was using to figure this out, and the board had stopped sending. So I closed the patch and opened Phidget Control Panel - and there was no data coming from the sensors there either!I had to disconnect and reconnect the Phidget board to get it working again. What's that about?!
jdecoux
Labview Developer
Posts: 161
Joined: Mon Nov 13, 2017 10:20 am
Contact:

Re: Using PhidgetVoltageInput with multiple sensors (8/8/8)

Post by jdecoux »

Specifying which Phidget channel to connect to is done using the text of the object itself, as outlined in the Specifying a Phidget section of our Max/MSP Language Page.

For example, to specify a channel, you would use:

Code: Select all

PhidgetVoltageInput channel=1

Yes, you need to wait for the channels to become attached in order to set their data interval, or any other properties that affect the channel's operation.
jdecoux
Labview Developer
Posts: 161
Joined: Mon Nov 13, 2017 10:20 am
Contact:

Re: Using PhidgetVoltageInput with multiple sensors (8/8/8)

Post by jdecoux »

You can use the "attach" message from the channel to catch when the channel has been attached, and use that to supply the "bang" for all your initialization parameters that need to be set after the channel is attached.

This will be more reliable than waiting on a timer, and will also catch cases where the channel is unplugged and plugged back in for any reason.
davidestevens
Phidgetly
Posts: 20
Joined: Tue May 14, 2013 5:01 am
Contact:

Re: Using PhidgetVoltageInput with multiple sensors (8/8/8)

Post by davidestevens »

ok, thanks. Including the channel= message seems to have sorted that particular problem.
And using the attach message to trigger the individual data intervals is good idea.
Unfortunately, reloading the patch (even when restarting Max first) seems to cause the connection to the Phidget to drop the connection still. I have to dis/reconnect the Phidget before starting Max. Is there a way around this?
jdecoux
Labview Developer
Posts: 161
Joined: Mon Nov 13, 2017 10:20 am
Contact:

Re: Using PhidgetVoltageInput with multiple sensors (8/8/8)

Post by jdecoux »

Do you have any other programs running at the same time that might be using your Phidgets?

Only one program can attach to a given Phidget at a time, locking out all others. (With the exception of using them over the Network Server).

This includes the control panel examples, etc.
davidestevens
Phidgetly
Posts: 20
Joined: Tue May 14, 2013 5:01 am
Contact:

Re: Using PhidgetVoltageInput with multiple sensors (8/8/8)

Post by davidestevens »

No, just the Max patch. And, it works properly until I do something like closing and reopening the patch after editing.
When the patch reopens Max can see the Phidget board (I can send messages to the PVI objects without error messages coming up), but there seems to be no data. If I quit Max and open Phidget Control Panel, the Phidget board is seen, and I can open the individual windows for the voltage channels, but the data display remains empty. If I unplug/replug the board, once PCP reconnects, data (usually) flows again. If I quit PCP and reopen Max, the patch shows incoming data again.
Tomorrow i’ll try this again with a Phidget that i’ve been using for months with no problems (with v21), in case there’s something up with the new 8/8/8 i’ve been trying v22 with.

A semi related question, in case I don’t sort this out while I have this extra Mac to work with... can I have both v21 and v22 present on the same machine, or is that a bad idea? (Or even doable?) The reason being that if I want to continue trying out v22, I would need to switch back to v21 (which I know works reliably) when i next have some workshops to run (end of August).
davidestevens
Phidgetly
Posts: 20
Joined: Tue May 14, 2013 5:01 am
Contact:

Re: Using PhidgetVoltageInput with multiple sensors (8/8/8)

Post by davidestevens »

ok, so I've tried this out with a different Phidget. It worked straight away when I first opened the input patcher in Max. Hurrah! I made a few tiny tweaks to the patch (added serialnumber= message to the PVIs), saved, closed and reloaded it. Still seeing the Phidget, but no data coming in.
Quit Max and opened Phidget Control - no data coming in.
Quit PControl, dis/reconnected the Phidget. Re-opened PControl, Data showing as arriving.
Quit Control & opened Max. Opened patcher. Connected, but no data. Dis/reconnected Phidget. Single data value appears, but no continuous data.
So the Phidget board isn't faulty. Is there some kind of message that the Phidget objects send to the board when closing a patch, that could cause it to stop sending data (or different data?)

NB. Channels are assigned correctly to all of the PVIs in the patch (getChannel). And there aren't any error messages coming out of the right inlet of the one PVI I have a message box attached to.

Edit: I restarted my Mac, and the Phidget was connected and working in Max. So this time I tried quitting Max (without closing the Phidget patch first) and then started Max up again (which is more or less what will be happening once the system is installed). No data coming from the Phidget board. Does this give you any more idea where the problem might be?
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests