Stabilize data from IR Distance Measuring Sensor

rayon's icon

Hi,

I'm wondering what's the best way to stabilize data from a IR Distance Measuring Sensor connected with Make Controller. I'm using Max/Msp Jitter. Max can read the data but the numbers kept jumping around within 20s up and down. Any ideas? My project is to use distance sensor as a scaling device to scale image/video.

Thank you in advance!

rayon

rayon's icon

Just want to add some details to my last post. I used OSC-route/analogin to get data from the sensor. I've never used any sensors with Max/MSP jitter before, so, this is very new to me.

Is there a reason why the input number changes so frequently even no activity in front of the sensor? And how can I make it stabled?

What I'm trying to do is a interactive installation, something like: corresponding to the distance of the viewer to the sensor, the image resizes itself larger or smaller. The problem now is due to the input data changes so frequently, the image shakes very bad.

I hope this make sense...

Thanks again!

Rob Ramirez's icon
Scott Fitzgerald's icon

Some of the more popular IR distance sensors work on a logarithmic
scale (like this one :
http://itp.nyu.edu/physcomp/sensors/Reports/GP2D120 ). So the numbers
seem to jump all over the place, but are acting as they should. Check
out a datasheet for the sensor, it should tell you what to expect form
it based on distance/voltage.

And, as Robert suggested, search for sensor smoothing in the max
forum/mail archives

On Tue, Jul 22, 2008 at 6:26 AM, ray wrote:
>
> Is there a reason why the input number changes so frequently even no activity in front of the sensor? And how can I make it stabled?

rayon's icon

Thanks for the tips!

I've tried several recommendations from the previous posts. I think the code from Zachary is the closest to get a smoother read from the sensor, however the number still jitters slightly.

here is the code:

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

I'm gonna keep up trying the other ways. During the searching, I found many people are using Arduino and Arduino has far more supports and tutorials than Make Controller has. I just start using Make Controller for several days. Should I be considering using Arduino instead? I'm wondering which one is more popular for artists and easier to use(time saving) overall?

Thank you so much for your help!

Sasha Harris-Cronin's icon

I would say the arduino is more popular, mostly because of the price and ease of programming. There is more of a community built around the arduino at this point, as well.

GhostandtheMachine's icon

I think this is way too late, but I have dealt with similar issues using phidget sensors. I found that a great simple smooth, which I got from someone else's forum post recently, sorry I can't remember who, is; zl stream 20, to zl median. I use this in conjunction with a velocity gate (something similar to, smoothed, current value minus last) which helps with the bouncing values

jon

KK's icon

Hello,
I've been using IR sensor from Sharp, GP2D12 and GP2Y0A2YK0F models;
the best solution I've found is to use some smoothing functions directly in Arduino
to average the last 10-20 readings, like in the example you can find in the Arduino IDE:
Open->Examples->Analog->Smoothing

And if that's not enough, you can linearize the values in MaxMsp,
using the / line / object with a short ramp time or more precise median/gaussian filters.

Depending on the application, you can trade stability VS responsiveness
to adjust the system behaviour to your needs.

And for the hardware side, if you have noise in the analog signal try to place a 10uF electrolytic capacitor between the adc power and ground, to clear the signal. More info here: http://www.societyofrobots.com/robotforum/index.php?topic=2712.0

Hope this helps,
all the best,
gio

mzed's icon

Those sharp IR sensors draw a lot of power in short bursts. This can make your signal dirty.

- try powering the MCK from something other than USB.
- try some noise-reducing capacitors. See:

mz