Page 1 of 1
Calibration
Posted: 11 Jan 2012, 13:03
by cyragia
Hello,
I have a robot which uses 2 light sensors (from lego).
I use NXT-G to program the robot.
The problem is that the 2 sensors don't give the same values (raw) at the same colors.
In NXT-G you can only calibrate 1 sensor and the other one is calibrated with the same scheme.
As my sensors are different the second sensor is wrongly calibrated, so i can't use it properly.
Does someone know a way to calibrate the 2 sensors independent ? Or another solution ?
Re: Calibration
Posted: 11 Jan 2012, 20:23
by mattallen37
One way would be to use offsets from the values. Find the offset to the color with the highest RAW reading, and add that offset to the RAW reading. Do this for both sensors. If they still don't match up (if they aren't linear), you can scale the readings instead, but that would take a lot more math (which isn't all that easy in NXT-G).
Re: Calibration
Posted: 12 Jan 2012, 11:41
by cyragia
that's the problem; they're not linear and like you say math is pretty hard to do in NXT-G.
Re: Calibration
Posted: 12 Jan 2012, 15:20
by mattallen37
Okay then, just for the sake of argument, lets say the ranges are 1000-500 for sensor 1, and 900 - 550 for sensor 2 (highest to lowest readings). You want them to both be on the same scale (eg 100-0).
Here is
my NXC function for scaling numbers:
Code: Select all
//Scales a range of numbers to a new range.
//Input value, lowest possible, highest possible, scale from this, to this. It returns the result.
float ScaleRange(float Value, float ValueMin, float ValueMax, float DesiredMin, float DesiredMax)
{
return (DesiredMax - DesiredMin) * (Value - ValueMin) / (ValueMax - ValueMin) + DesiredMin;
}
So to put actual numbers in for your case, it would be something like this:
Code: Select all
(100-0)*(sensor - 500)/(1000-500)+0 //for sensor 1
(100-0)*(sensor - 550)/(900-550)+0 //for sensor 2
Or to simplify it:
Code: Select all
100 * (sensor - 500) / (1000 - 500) //for sensor 1
100 * (sensor - 550) / (900 - 550) //for sensor 2
This is probably the closest you will get to making the values the same. Due to part tolerance and such, it could take an extreme amount of work to match the values perfectly.
Re: Calibration
Posted: 12 Jan 2012, 16:00
by cyragia
Thanks !