To measure the distances i used a big cartboard, foot rule and the stadard NXT ultrasonic Sensor. For each new measurment i replaced the cartboard in a new distance to the sensor. Also i wrote a simple peace of code:
- Code: Select all
public static void main(String[] args)
{
UltrasonicSensor Sens1 = new UltrasonicSensor(SensorPort.S2);
LCD.drawString("US Measuring", 0, 0);
LCD.drawString("press Button", 0, 1);
Button.waitForPress();
RConsole.openUSB(2500);
RConsole.print("srart of measure loop");
float temp;
int a;
while (true)
{
LCD.clear();
temp = Sens1.getRange();
Delay.msDelay(50);
LCD.drawInt(Math.round(temp), 0, 0);
RConsole.println("float: " + Float.toString(temp));
a = Sens1.getDistance();
Delay.msDelay(50);
LCD.drawInt(a, 0, 1);
RConsole.println("int: " + Integer.toString(a));
Delay.msDelay(2000);
}
}
Here are my measurements: (2 from 10 measurmends)
real distance: 24 23 22 21 20 ... 10 ... 5 4 3 2
meas. dist 1: 24 24 23 23 22 ... 12 ... 7 6 5 255
meas. dist 2: 24 24 23 23 22 ... 12 ... 7 6 8 67
You will see that i get a constant variance of 2. This is true for all distances betewwn 21 and 3.
Another Problem is the distance of 3 here i only get every 5th measurmend correct and this only if you calculate the variation of 2 into the measured distance.
Is this a known problem? What causes this beheavior? Can i fix this somehow to get more accurate measurements with low distances?
