setHubPort not working?

Supporting Max/MSP versions 6 and up
IanBloomfield
Phidgetly
Posts: 29
Joined: Thu Feb 15, 2018 4:49 am
Contact:

setHubPort not working?

Postby IanBloomfield » Sun Mar 04, 2018 6:13 pm

I have a project with two spatials, I have two spatial objects created and outputting readings, I had set a message with the input setHubPort 0 and the other setHubPort 5.

both Phidget objects are recording but they were back to front. so it seems the setHubPort command is not working with the Spatial? what am I doing wrong here?

also - has anyone made a Max patcher that calculates the angle of tilt from either gyroscope or accelerometer? that they would be willing to share?

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

Re: setHubPort not working?

Postby mparadis » Mon Mar 05, 2018 8:30 am

What do you mean by "back to front"? Are you saying that the object that you're opening as hub port 5 is getting data from the accelerometer on port 0? Are you setting hub port before opening? You won't be able to change any of these matching critera after calling open.

IanBloomfield
Phidgetly
Posts: 29
Joined: Thu Feb 15, 2018 4:49 am
Contact:

Re: setHubPort not working?

Postby IanBloomfield » Mon Mar 05, 2018 11:44 am

How do you call open?

What I did was tool the phidgets spacial example and changed the get message to sethubport so it's a message that inserts to input of phidgetspatial. There is no open close command on the spatial example so I'm not sure how to put these in

jdecoux
Labview Developer
Posts: 66
Joined: Mon Nov 13, 2017 10:20 am
Contact:

Re: setHubPort not working?

Postby jdecoux » Mon Mar 05, 2018 2:20 pm

When using Phidgets with Max/MSP, you do not need to call open. All Phidgets are opened and specified within the object itself. The Phidget is closed once the object ceases to exist.

If you want to connect to a Spatial on hub port 5, then you would create a PhidgetSpatial object as follows:

PhidgetSpatial hubport=5

All other specifiers can be found in the readme.txt file included with the examples.

IanBloomfield
Phidgetly
Posts: 29
Joined: Thu Feb 15, 2018 4:49 am
Contact:

Re: setHubPort not working?

Postby IanBloomfield » Mon Mar 05, 2018 4:53 pm

Thanks I'll look at that, it explains why when U have max open the phidgets doesn't work in any other program.

Can I ask what is the output units from the accelerometer and gyro I'm trying to work in programming to get positional data from the unit. Is there any internal processing done on the readings as I don't seem to get Accel readings higher than 1?

jdecoux
Labview Developer
Posts: 66
Joined: Mon Nov 13, 2017 10:20 am
Contact:

Re: setHubPort not working?

Postby jdecoux » Tue Mar 06, 2018 10:32 am

The units for the accelerometer are g-force (g), and the units for the gyroscope are degrees per second.

To find this information (for those who later come across this post with similar questions), you can go to the API page, and select your Phidget and class from the drop-down menus. You can see the attached screen-shot for details.

How quickly are you moving the accelerometer? The spatial is able to measure up to 8g on all axes. You should see spikes in the reading above 1 if you shake the accelerometer hard enough.
Attachments
Phidget_Units_API.png

IanBloomfield
Phidgetly
Posts: 29
Joined: Thu Feb 15, 2018 4:49 am
Contact:

Re: setHubPort not working?

Postby IanBloomfield » Tue Mar 06, 2018 6:18 pm

yeah I realised I had my sliders max and min values set to low,

I have successfully inputted the maths for calculating tilt from the accelerometer but am struggling with the gyroscope.

it should be

output/sens (I used 0.008 value here as my rotational values are low) then multiply by 0.02 (20ms time interval between readings) to get angle per interval then I need to somehow set a running total

I was using the accum box to tally a running total but my value always resets to zero when gyro stops moving. This is now Max/MSP coding but do you have any idea what would be the best function here? I need to serially add the output values to get the gyro rotation?

I was using the complimentary filter for the final checking.

thanks.

IanBloomfield
Phidgetly
Posts: 29
Joined: Thu Feb 15, 2018 4:49 am
Contact:

Re: setHubPort not working?

Postby IanBloomfield » Wed Mar 07, 2018 5:34 am

Some one from the Max forum gave some advice re: the gyro accumulation.

I noticed the fastest sample rate from the sensors is 20ms.

but the number readouts I'm getting through MAX/MSP are no where near updating at 20ms, maybe 1-1.5/sec.

I can't work out is that just lag in the animation and the number calculations are secretly happening - or does it just mean I am losing data?

someone suggested I should record my outputs as audio then convert that to numbers and process it afterwards?

Can I ask you to look at my attempt at patch and see what u think?

Ultimately what I want to get out is data that will tell me how much rotation the sensor does, how fast it rotates and with the accel - not being able to distinguish gravity from movement - I planned to amalgamate the 3 axis into a vector and essentially look at displacement > than or < 0.98. (ie. how much linear acceleration that is not gravity?)

the two sensors will be attached to the back of my hands and record data for max 3-5 mins at a go whilst performing surgical training exercises. as they are attached to hands the degrees of rotation will be mainly in the roll axis (I think - plan is to attach with sensor wire pointing to the wrist)

thanks for your time

can't uplos my patch - I'll try PM

IanBloomfield
Phidgetly
Posts: 29
Joined: Thu Feb 15, 2018 4:49 am
Contact:

Re: setHubPort not working?

Postby IanBloomfield » Wed Mar 07, 2018 5:43 am

here is link to Onedrive file for my patch for tilt sensor

https://1drv.ms/u/s!AmLYZInOd-bVlxk2vQVYhftK6J-Q

User avatar
Patrick
Lead Developer
Posts: 3044
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: setHubPort not working?

Postby Patrick » Wed Mar 07, 2018 2:44 pm

When calculating rotation from angular rate data, use the timestamp in the event, not a fixed value matching the data interval.

-Patrick


Return to “Max/MSP”

Who is online

Users browsing this forum: No registered users and 1 guest