Stabilize data from IR Distance Measuring Sensor
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!
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…
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
On Tue, Jul 22, 2008 at 6:26 AM, ray
> 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?
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:
#N vpatcher 314 296 717 666;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 65 22 53 196617 raw input;
#P comment 22 316 69 196617 filtered input;
#P number 73 37 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 73 62 47 196617 t i i i;
#P number 36 294 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 36 224 47 196617 gate 2 2;
#P newex 73 257 79 196617 slide 100. 100.;
#P number 91 174 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 173 91 39 196617 bucket;
#P newex 91 117 92 196617 expr abs($i1-$i2);
#P newex 91 146 113 196617 if $i1 > 8 then 1 else 2;
#P window linecount 2;
#P comment 156 253 192 196617 or simply dont’ pass changes of 8 or less if that gives you the desired results;
#P connect 4 0 6 0;
#P connect 5 0 7 0;
#P connect 6 0 7 0;
#P connect 9 0 8 0;
#P connect 8 0 6 1;
#P connect 6 1 5 0;
#P connect 8 1 2 0;
#P connect 2 0 1 0;
#P connect 1 0 4 0;
#P fasten 8 2 3 0 114 85 178 85;
#P connect 3 0 2 1;
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!
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.
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
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:
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,
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: