detect when the sensor is not sensing

Oct 1, 2009 at 9:24am

detect when the sensor is not sensing

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?

#45677
Oct 1, 2009 at 10:05am
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.

#164717
Oct 1, 2009 at 10:14am

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…

#164718
Oct 1, 2009 at 11:24am

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

#164719
Oct 1, 2009 at 11:49am

#164720
Oct 1, 2009 at 11:53am

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.

#164721
Oct 1, 2009 at 12:16pm

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.

#164722
Oct 1, 2009 at 12:58pm

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

#164723
Oct 1, 2009 at 1:06pm

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

#164724
Oct 1, 2009 at 4:04pm

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.

#164725

You must be logged in to reply to this topic.