Forums > MaxMSP

### detect when the sensor is not sensing

Oct 01 2009 | 9:24 am

Hello,

I am reading an accelerometer that gives me number on the 3 axis (X, Y, Z).

I want to detect when my piece is stopped, however when it is stopped the number that I get from the sensor in all the axis is not "0" and always change.

What I want to do is:

When the number coming from the sensor does not change during 3 seconds I want to receive a bang

Any of you have some idea about how to do that?

Oct 01 2009 | 10:05 am
 Quote: I want to detect when my piece is stopped, however when it is stopped the number that I get from the sensor in all the axis is not "0" and always change.

Not sure that I understand your problem correctly, but you might want to look at the amount of change in the sensor readings, or the delta values (subtracting the current from the previous and take the absolut value). If for 3 seconds (delay object) they stay below a certain threshold (trial and error), then light the applaus sign. The best sensor however to detect if your piece is finished is you, of course.

Oct 01 2009 | 10:14 am

The idea is something like that but my problem is that the number stops always in different values. What I want is to have a bang when the number does not change, independent of the threshold.

if the number stops for 3 second in 89 I want a bang

if the number stops for 3 second in 5 I want a bang

and so on…

Oct 01 2009 | 11:24 am

Inn that case, all you need is a delay object.

Oct 01 2009 | 11:49 am

Oct 01 2009 | 11:53 am

Hmm… sorry but i do not understand.

a delay just give me a "delay" in a bang.

I want to detect if the number does not change in 3 seconds. What is the relation?

I tried to make a list and store the last 30 numbers. After I compare the first with the last. If they are the same it means that the sensors have sent the same value. But it is quite unstable.

I know that it might be simple.

Oct 01 2009 | 12:16 pm

When a number comes in, trigger a [delay 3000] object. If another number comes in, send a ‘stop’ message to the delay object, handle the number, and retrigger the delay. Etc.

When the delay object finally fires, you know you haven’t had a new input for 3 seconds.

Oct 01 2009 | 12:58 pm

[change] before [trigger] may also be useful to filter out repeated values…

Oct 01 2009 | 1:06 pm

Thank you guys! It is working fine now. I used the delay as explained here.

Oct 01 2009 | 4:04 pm

I know you got it working, that’s great. However you might want to search for "smoothing sensor values", which may be helpful in the future. There are a number of good example patches for this problem, which comes up using many different sensors… the values coming in are jittery by nature, so there are a bunch of ways to smooth them out and make them more useful.

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

Forums > MaxMSP