|
# Group 13
|
|
# Group 13 - LEGO lab |
|
|
|
\ No newline at end of file |
|
## Lab Notebook Lession 1
|
|
|
|
|
|
|
|
**Date:** 13/02 2015
|
|
|
|
|
|
|
|
**Group members participating:** Lars, Thomas, Nikolaj, Jesper
|
|
|
|
|
|
|
|
**Activity duration:** 5 hours
|
|
|
|
|
|
|
|
## Goal
|
|
|
|
In this lesson we build a LEGO car and equip it with a light sensor. We then seek to complete 6 exercises, that each explore a certain aspect of the sensor and nxt.
|
|
|
|
|
|
|
|
## Plan
|
|
|
|
Follow the instructions at[1]
|
|
|
|
|
|
|
|
## Results
|
|
|
|
|
|
|
|
### Exercise 1
|
|
|
|
|
|
|
|
| Color | White | Black | Green | Grey |
|
|
|
|
|------------|-------|-------|-------|------|
|
|
|
|
| Light vale | 58-59 | 36-37 | 46-47 | 56 |
|
|
|
|
|
|
|
|
The threshold value signifies a reference light percentage (the desired state) for which the program can determine whether it is above a white or black area on the ground. A light value below the threshold leads to the conclusion that the machine is above a black area, while for a value above the threshold, a white area. As such, we would like to use the mean value of black and white as the threshold.
|
|
|
|
|
|
|
|
threshold = (58+36)/2 = 47
|
|
|
|
|
|
|
|
Depending on the lighting in the room, the timeday and so on, the threshold will change.
|
|
|
|
|
|
|
|
### Exercise 2
|
|
|
|
| Color | White | Black | Green | Grey |
|
|
|
|
|------------|-------|-------|-------|------|
|
|
|
|
| Light vale | 39-42 | 29 | 35 | 36-42 |
|
|
|
|
|
|
|
|
Here we turned off the red LED light, which made the sensor more exposed to the environmental light. As such the light values became lower overall, since only the reflection of the environmental light is used.
|
|
|
|
This point also became apparent when we recorded the light value for 'Grey', which was closer to the loft lamp - the value should naturally not be as high as white.
|
|
|
|
|
|
|
|
### Exercise 3
|
|
|
|
|
|
|
|
The sample interval indicates how often the robot should react to its environment. A large sample interval leads to a slow reaction to color shifts between black and white and therefore rough movement, while a small sample interval makes the robot follow the line more precisely.
|
|
|
|
|
|
|
|
### Exercise 4
|
|
|
|
The following four graphs show the data collected from using 10ms, 50ms, 100ms and 500ms sample intervals respectively. A short sample interval is expected to update the direction of the robot often, while a slow sample interval might allow the robot to drive further away from the black line before its direction is corrected. The graph, which we have created using the DataLogger, illustrate this point well. We see for a 10ms sample rate that we first of all have a lot of data samples, but also that the curve resembles a sinus curve, which oscillates with a fairly high frequency. The same points can be made for 50ms and 100ms, although they oscillate with a lower frequency as expected. The final graph, which modulates 500ms is a special case in that the robot is not able to follow the black line for such a high sample interval. As a result it runs in circles causing the graph to be somewhat chaotic, but still with a low frequency as expected.
|
|
|
|
|
|
|
|
|
|
|
|
![Alt Text](http://oi57.tinypic.com/29qntwz.jpg)
|
|
|
|
|
|
|
|
![Alt Text](http://oi58.tinypic.com/10yl6cy.jpg)
|
|
|
|
|
|
|
|
![Alt attribute text Here](images/ex4_100ms.png)
|
|
|
|
|
|
|
|
![Alt attribute text Here](images/ex4_500ms.png)
|
|
|
|
|
|
|
|
|
|
|
|
### Exercise 5
|
|
|
|
| Color | White | Black | Green | Grey |
|
|
|
|
|------------|-------|-------|-------|------|
|
|
|
|
| Raw Light vale | 450 | 640 | 530 | 443 |
|
|
|
|
|
|
|
|
![Alt attribute text Here](images/ex5_lp_white.png)
|
|
|
|
|
|
|
|
![Alt attribute text Here](images/ex5_lp_black.png)
|
|
|
|
|
|
|
|
![Alt attribute text Here](images/ex5_lp_green.png)
|
|
|
|
|
|
|
|
![Alt attribute text Here](images/ex5_lp_grey.png)
|
|
|
|
|
|
|
|
From these 4 colors, it becomes apparent that the light percentages calculated using the given formula matches the measured values from exercise 1 very well. However, while the formula is hereby verified, the light percent is not as accurate as possible. The reason for this is that the calculated light percent from the sensor is stored as an integer, which does not take decimal numbers into account. This problem can be alleviated either by using 32-bit floating point numbers, or simply by using the raw values directly.
|
|
|
|
Note: once again, grey was affected by environmental light, and naturally should not be as high as white.
|
|
|
|
|
|
|
|
### Exercise 6
|
|
|
|
We tried to use text strings directly in the calls to ```LCD.drawString``` instead of the variables right and left. We used ```Runtime.getRuntime().freeMemory()``` to store the amount of free memory on the heap during the execution using the variables and during the execution using strings directly. This gave us the following two graphs.
|
|
|
|
|
|
|
|
![Alt attribute text Here](images/ex6_mem_var.png)
|
|
|
|
|
|
|
|
![Alt attribute text Here](images/ex6_mem.png)
|
|
|
|
|
|
|
|
Here we see how the heap gets filled during the executions and is cleared when the amout of free memory is less than 40,000.
|
|
|
|
We see how the heap is filled faster when executing the program using strings directly, compared to the program that uses variables. This indicates that the program does not have a direct reference to the strings if not stored in a variable, and therefore allocates space on the heap for the strings each time they are used.
|
|
|
|
|
|
|
|
## Conclusion
|
|
|
|
In conclusion, we have solved the 6 exercies we set out to do. Overall, we have gained knowledge of our first proportional-control program, and have gained insight in how the light sensor module for the nxt works.
|
|
|
|
|
|
|
|
## References
|
|
|
|
[1] http://legolab.cs.au.dk/DigitalControl.dir/NXT/Lesson1.dir/Lesson.html |
|
|
|
\ No newline at end of file |
|
|