|
|
# Group 4
|
|
|
|
|
|
## Lab Notebook 1
|
|
|
|
|
|
**Date:** 12/02 2015
|
|
|
|
|
|
**Group members participating:** Tine Hansen, Daniel Moltzen, Mads Eriksen, Lars Høeg
|
|
|
|
|
|
**Activity duration:** 4 hours
|
|
|
|
|
|
## Goal
|
|
|
What is the goal?
|
|
|
|
|
|
The goal for this activity is to build a LEGO car equipped with a light sensor and test different light levels according to different colors and get the LEGO car to follow a black line. Furthermore, our goal is to test different code to see how it affects the movement of the LEGO car when it has to follow a black line.
|
|
|
|
|
|
## Plan
|
|
|
What is your plan to reach the goal?
|
|
|
Implement different code, make changes, test values
|
|
|
|
|
|
## Results
|
|
|
|
|
|
### Exercise 1 - table of light values according to different colors
|
|
|
|
|
|
By using the program LineFollower.java, we have measured the different percentage of light levels with both the LED on and off. Beneath is a table of colors and their corresponding measurements:
|
|
|
|
|
|
![table light levels](http://gitlab.au.dk/uploads/u4099/legolabtimadala/3817451f0b/table_light_levels.PNG)
|
|
|
|
|
|
The threshold for black and white is obtained by meassuring light percentage levels. The threshold for white is then 56 and black 36 with the LED turned on.
|
|
|
|
|
|
### Exercise 2 -
|
|
|
|
|
|
Changed - light.setFloodlight(false);
|
|
|
|
|
|
Observation: When the LED is turned Off, the percentage shown changes with the surrounding light and shadows even though the material stays the same
|
|
|
|
|
|
Explain - The shadows and light reflected in the surface changes the measurement that is compared to the WhiteAndBlackThreshold, thus a color with shadows will appear darker than it really is.
|
|
|
|
|
|
### Exercise 3
|
|
|
In exercise three we change the sample interval to 10ms, 100ms, 500ms and 1000ms to see how this affects the LEGO car's movements across a squared line pattern and a circle pattern.
|
|
|
|
|
|
LightSensor light = new LightSensor(SensorPort.S3);
|
|
|
final int blackWhiteThreshold = 45;
|
|
|
final int sampleInterval = 10; // ms
|
|
|
|
|
|
A: 10 ms is changed to 100ms
|
|
|
|
|
|
Straight line course - Sample rate is too long, so it mostly drives to the right because white is the biggest area.
|
|
|
|
|
|
Circle course - The robot turns to the right if it does not see any black lines and therefore it turns more right than left, it works better than with the straight lines, because the black line turns right
|
|
|
|
|
|
B: is changed to 500 ms
|
|
|
|
|
|
Straight line course - The robot keeps turning right because it can barely see the black line, because it updates too slow.
|
|
|
|
|
|
Circle course - Again, it does not very often see a black line and therefore just turns around most of the time since it only changes direction when an update happens where the robot is just above the black line.
|
|
|
|
|
|
C: is changed to 1000 ms
|
|
|
|
|
|
Straight line course - Keeps turning right! It only see “white”. Again sample rate is too slow.
|
|
|
|
|
|
Circle course - Same as with the straight lines.
|
|
|
|
|
|
|
|
|
### Exercise 4
|
|
|
In this exercise, we use datalogger.java and Slinefollower.java to collect measurements in different sample intervals. These samples are then plotted in a graph to be able to see the difference.
|
|
|
|
|
|
Sample Interval 10 ms:
|
|
|
![data table 10 ms lab 1](http://gitlab.au.dk/uploads/u4099/legolabtimadala/f50cd1c69e/data_table_10_ms_lab_1.PNG)
|
|
|
|
|
|
Sample interval 100 ms:
|
|
|
![data table 100 ms lab 1](http://gitlab.au.dk/uploads/u4099/legolabtimadala/16f4ef751b/data_table_100_ms_lab_1.PNG)
|
|
|
|
|
|
Sample interval 1000:
|
|
|
![data table 1000 ms lab 1](http://gitlab.au.dk/uploads/u4099/legolabtimadala/9095671640/data_table_1000_ms_lab_1.PNG)
|
|
|
|
|
|
### Exercise 5
|
|
|
In this exercise we use SensorPorttest.java. We change the code to experiment with the formula that describes the relationship between the light percent and the raw values.
|
|
|
|
|
|
Looking at the previous percentage values from exercise 1 and compares them too the RAW values, we see that that the formula always rounds down the percentage, even though it should be rounded up. However, the values is still within an acceptable area.
|
|
|
|
|
|
Black: raw vlaue: 683 calculated: 0,3323558162 in percent: 33,23558162% Før 36%
|
|
|
|
|
|
White: raw value: 490 calculated: 0,5210166178 in percent: 52,10166178% Før 56%
|
|
|
|
|
|
Could there be a reason for using the raw values instead of the light percent?
|
|
|
By using the light percent formula you lose a lot of decimals, so one could say that the RAW values would give you a more precise feedback eg. differ colors from each other. So if you only have to differ from black and white it is enough to only use the light percentage formula.
|
|
|
|
|
|
### Exercise 6
|
|
|
In this exercise we try to use text strings in the calls to LCD.drawString instead of the variables right and left and use Runtime.getRuntime().freeMemory() to display the amount of free memory on the heap during the execution.
|
|
|
|
|
|
Blue: Sending via variable
|
|
|
Red: Sending with string
|
|
|
|
|
|
![Screen Shot 2015-02-17 at 12.45.50](http://gitlab.au.dk/uploads/u4099/legolabtimadala/f89bbd6649/Screen_Shot_2015-02-17_at_12.45.50.png)
|
|
|
|
|
|
The graph indicates that running with variable results in slower allocation than running with with a string.
|
|
|
|
|
|
## Conclusion
|
|
|
|
|
|
In the first two exercises we discovered that having the floodlight set off impacted the measurements extensively. It was harder to differ the different colors and it was more responsive to natural light which had an impact on the measurements.
|
|
|
The results from changing the sample interval showed that a greater time span between measurements, caused the LEGO car to not be able to follow the black line as accurately as if we used a shorter period of time between measurements.
|
|
|
In regards to the formula for the relation between the light percentage and the raw values we saw that the formula always round the decimals down, so the accuracy was lower than the raw values, however they were still within an acceptable area. In the last exercise we saw that the allocation were slower running with a variable.
|
|
|
|
|
|
## References
|
|
|
http://legolab.cs.au.dk/DigitalControl.dir/NXT/Lesson1.dir/Lesson.html |
|
|
\ No newline at end of file |
|
|
## See the different lessons under the pages tab |
|
|
\ No newline at end of file |