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 ?
Calibration
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: Calibration
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).
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: Calibration
that's the problem; they're not linear and like you say math is pretty hard to do in NXT-G.
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: Calibration
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:
So to put actual numbers in for your case, it would be something like this:
Or to simplify it:
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.
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;
}
Code: Select all
(100-0)*(sensor - 500)/(1000-500)+0 //for sensor 1
(100-0)*(sensor - 550)/(900-550)+0 //for sensor 2
Code: Select all
100 * (sensor - 500) / (1000 - 500) //for sensor 1
100 * (sensor - 550) / (900 - 550) //for sensor 2
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Who is online
Users browsing this forum: Semrush [Bot] and 0 guests