Forums > MaxMSP

Hi Acceleration Rate

April 24, 2006 | 9:40 pm

Can anyone point me in the right direction on a way in which to measure the rate of acceleration(?), speed of increase/decrease of one of the analogue sticks on a ps2 controller? I am working on using it as a backward/forward motion controller for scratching and would like to be able to make the "return to normal" time of a line object acceleration/velocity (not sure what best describes it) dependant.


April 25, 2006 | 1:19 am

Are you trying to measure the speed that stick moves?

this is something i came up with (very quickly – hence it’s a bit rough) – it polls the position of the controller and calculates the distance moved between each measurement – I’m not sure if this is what you want, but i’m sure my patch can be improved – it’s late and time for bed…

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 202 116 212 196617 lets pretend this is one axis of the controller;
#P newex 62 343 37 196617 abs 0.;
#P number 114 89 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P user multiSlider 220 199 151 145 0. 80. 1 3433 15 0 0 2 0 0 0;
#M frgb 0 0 0;
#M brgb 255 255 255;
#M rgb2 127 127 127;
#M rgb3 0 0 0;
#M rgb4 37 52 91;
#M rgb5 74 105 182;
#M rgb6 112 158 18;
#M rgb7 149 211 110;
#M rgb8 187 9 201;
#M rgb9 224 62 37;
#M rgb10 7 114 128;
#P toggle 62 232 15 0;
#P newex 88 181 27 196617 i;
#P newex 62 304 53 196617 bondo 2;
#P newex 62 324 53 196617 – 0.;
#P newex 62 252 27 196617 + 1;
#P newex 88 205 27 196617 t b f;
#P newex 62 284 53 196617 gate 2 1;
#P user hslider 169 133 20 252 128 1 0 0;
#P toggle 72 86 15 0;
#P newex 72 123 52 196617 metro 25;
#P comment 105 75 54 196617 poll speed;
#P fasten 5 0 10 0 93 229 67 229;
#P connect 10 0 6 0;
#P connect 6 0 4 0;
#P connect 4 0 8 0;
#P connect 8 0 7 0;
#P connect 7 0 13 0;
#P connect 2 0 1 0;
#P fasten 1 0 9 0 77 168 93 168;
#P connect 9 0 5 0;
#P fasten 3 0 9 1 174 169 110 169;
#P connect 5 1 4 1;
#P connect 4 1 8 1;
#P connect 8 1 7 1;
#P connect 12 0 1 1;
#P fasten 13 0 11 0 67 366 162 366 162 185 225 185;
#P window clipboard copycount 15;


April 25, 2006 | 9:26 am

Yes I am trying to calculate the speed the stick moves up or down and then using that acceleration to judge how fast, when released the value should return to 1 (original playing speed).
One problem I can see is that the analog stick goes from 0 65535 in the vertical direction but also gives values in the horizontal so that changes the data. Not that it matter much as it is just scratching so wouldnt be too noticable.

I was messing about with your patch and using poll 50 as thats what my hi object is set to which controls the other buttons and right analog stick. When you say on one axis do you just mean the postive vertical axis ? So upward motion on stick? Or was it just relating to vertical or horizontal motion in general?


April 25, 2006 | 9:56 am

The output of the 2 different axis will be separate – each will be prepended by an id – if you look at hi’s output (using print) you will see this. If you use route with the appropriate axis id’s you can separate all the different controller numbers. There are lot’s of examples of this if you search the archives.


April 25, 2006 | 10:08 am

Yes I am aware of the seperate id’s etc but the left analog seems to have id’s 4 and 0. I am guessing the id for vertical motion is 0 but it isnt clear because it is pretty hard just to move along a straight hoziontal line to check if that is id 4. Id 4 only seems to show up when you hit full right/left in horizontal axis.

So what I have set up is a route 0 from hi’s output but this still seems to output values whether your moving left/right or up/down, same goes for routing 4. So it seems quite hard to seperate the two.


Viewing 5 posts - 1 through 5 (of 5 total)