output value only if it differs from last one ("flickering" output)

personal_username's icon

Hi all,

i'm having issues with the use of an accelerometer which reports me some "flickering" values.
In every position (even still ones!) it will output very quickly two different values (e.g. 0.1, 0.3, 0.1, 0.3 0.1, 0.3).
This is the reason why I can't use [change] object, for it will "always" give me a change!
do you know a way to solve this out?
thanks much!

Julien Bayle's icon

why 2 values?
does it provide x & y ?

what do you need to detect? an x or y change?

I could do something for you but I'd need some infos..

Julien Bayle's icon
Max Patch
Copy patch and select New From Clipboard in Max.

I did that:

I hope it could be a solution for you.
if one of the two values change, it fires the 2 current values.

Luke Hall's icon

You could use [bucket] to compare the current value with the prious one using an [if]. There's a simple example below. The [lbyl] object from CNMAT might be useful too. For data smoothing have a look towards the bottom of this thread for a number of different approaches.

Max Patch
Copy patch and select New From Clipboard in Max.

lh

personal_username's icon

thanks much guys.
Luke solution was what I was looking for! danke!
for julien: from an accelerometer i can have x, y and z values "isolated" and use them for different things.
sensor's output, being analogic, can be very irregular and give you a stream of values you don't really need: that's the reason why it's useful to "filter" the output and use it only if a difference threshold is obtained: that is exactly what luke patch is doing. again: thanks all!

Julien Bayle's icon

ok great !
I misunderstood the question.
The important thing: you found your solution :)