I took the average of the ratios which seems to work much better, also fixed up the function a bit:
(In actionscript now...) You have to watch for divisions by zero when calculating the ratio when the meter has just been sitting and everything is zeros.
If you slow down the samples a bit it can deal with a fair bit of noise, in the worst case it basically averages without as much delay.
The algorithm seems to be most sensitive to certain kinds of noise, mainly when the values seem to be going up except for one. From my experience with a multimeter, that doesn't happen very often on your sensor.
You can play with it here, press simulate to start the graph and hold down the laser button to raise the temperature.
http://www.sharemation.com/691175002/laser/Untitled-1.html
Code:
var floatingRatio:Number = 0;
function seriesSum4(a:Number, b:Number, c:Number, d:Number):Number {
// Find Differences
var da:Number = b - a;
var db:Number = c - b;
var dc:Number = d - c;
// Find Ratio
var ratio:Number = (db / da + dc / db) / 2.0;
if (isNaN(ratio))
ratio = 0;
if (Math.abs(ratio) < 1) {
floatingRatio = (floatingRatio + ratio) / 2.0;
}
trace (floatingRatio + " - " + ratio);
return a + da / (1.0 - floatingRatio);
}
If you slow down the samples a bit it can deal with a fair bit of noise, in the worst case it basically averages without as much delay.
The algorithm seems to be most sensitive to certain kinds of noise, mainly when the values seem to be going up except for one. From my experience with a multimeter, that doesn't happen very often on your sensor.
You can play with it here, press simulate to start the graph and hold down the laser button to raise the temperature.
http://www.sharemation.com/691175002/laser/Untitled-1.html