Page 1 of 2

setHubPort not working?

Posted: Sun Mar 04, 2018 6:13 pm
by IanBloomfield
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?

Re: setHubPort not working?

Posted: Mon Mar 05, 2018 8:30 am
by mparadis
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.

Re: setHubPort not working?

Posted: Mon Mar 05, 2018 11:44 am
by IanBloomfield
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

Re: setHubPort not working?

Posted: Mon Mar 05, 2018 2:20 pm
by jdecoux
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.

Re: setHubPort not working?

Posted: Mon Mar 05, 2018 4:53 pm
by IanBloomfield
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?

Re: setHubPort not working?

Posted: Tue Mar 06, 2018 10:32 am
by jdecoux
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.

Re: setHubPort not working?

Posted: Tue Mar 06, 2018 6:18 pm
by IanBloomfield
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.


Re: setHubPort not working?

Posted: Wed Mar 07, 2018 5:34 am
by IanBloomfield
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

Re: setHubPort not working?

Posted: Wed Mar 07, 2018 5:43 am
by IanBloomfield
here is link to Onedrive file for my patch for tilt sensor!AmLYZInOd-bVlxk2vQVYhftK6J-Q

Re: setHubPort not working?

Posted: Wed Mar 07, 2018 2:44 pm
by Patrick
When calculating rotation from angular rate data, use the timestamp in the event, not a fixed value matching the data interval.