torsdag den 2. september 2010

NXT Programmering, Lesson 1

Duration of activity: 3 hours Participants: Nick, Allan and Jens Chr.


The goal of this session was to get the leJOS NXT framework to work on our computer, and build our first robot.


We got the framework working on a single computer (maybe two...).


We followed the description of building the robot from the manual and installed the first example program. The program made the robot follow the outer part of a black line, with curves and it was able to turn around at the end of the line and follow the line back to its origins.


With standard program:
The program is sequentially controlled[1], since it follow a procedural series of steps, although there is only one step.


We tried with a black line on white surface, where the robot worked perfectly and we tried it on a black line on a dark blue surface where the program did not work. Here the robot just turned around on it self and were not able to start anywhere.


With the light sensors refresh rate at 10, 100 and 500 ms:
We did not see any significant changes in the way the robot responded to the change in color. We thought the 10 ms would make a difference, and therefor we thought the program was not properly loaded, so we change the refresh rate to 5000 ms and saw the robot turn in circles over the black line until the refresh matched the black line and the robot changed direction.


Light sensor:
We needed to get the percentages returned by the sensor in different lightconditions. We tried with the lights on, as it normally would be, with it turned off and only light from surroundings and thirdly with lights off and light from a Macs screen. The results were the following:

Lightcondition\Color Red Blue Green White Black Yellow
Lights on 62% 50% 51% 64% 45% 63%
Lights off 44% 35% 42% 45% 26% 45%
Lights off, light from Mac 44% 38% 42% 45% 29% 43%


With the lights on, the sensor were able to distinguish between three levels of input. One level would be black, second would be blue and green, and third would be red, white and yellow.


With the light off, the amount of level stayed the same, but the different levels changed. Level one would be black, two would be blue, and the rest would be the third level. Although this seems somewhat promising, as soon as the surroundings change just the slightest (someone walking by etc.) the readings changed, so a program would not be able to distinguish the colors, even of the difference stayed the same.

Memory usage
When printing during execution of the program it is seen that memory is constantly falling when text strings are used directly in method calls. This points at that it is not good practice to insert text strings directly into method calls, since this results in a form of "memory leak". Notice that memory leaks in an embedded system are not desirable, since the amount of available memory typically is small.

Ingen kommentarer:

Send en kommentar