{"id":11,"date":"2013-02-14T09:15:15","date_gmt":"2013-02-14T09:15:15","guid":{"rendered":"http:\/\/bech.in\/?p=11"},"modified":"2021-10-22T16:02:50","modified_gmt":"2021-10-22T16:02:50","slug":"lesson-1-nxt-programming","status":"publish","type":"post","link":"https:\/\/bech.in\/?p=11","title":{"rendered":"Lesson 1"},"content":{"rendered":"<p><strong>Exercise 1<\/strong><br \/>\n<em>Goal<\/em><br \/>\nThe goal with this exercise is to record the values that the light sensor module outputs when used on different colors. Also we will observe what values are displayed when the sensor is used on black and white and discuss why these values can be used as the threshold values.<\/p>\n<p><em>Plan<\/em><br \/>\nThe plan for this exercise is simple: We will place the light sensor above different colors while keeping the distance constant so this does not interfere with the recorded values.<\/p>\n<p><em>Results<\/em><br \/>\nFollowing the approach described above we got the results listed in the table below:<\/p>\n<table>\n<tbody>\n<tr>\n<td>Color<\/td>\n<td>Displayed percentage<\/td>\n<\/tr>\n<tr>\n<td>Green<\/td>\n<td>39<\/td>\n<\/tr>\n<tr>\n<td>Yellow<\/td>\n<td>49<\/td>\n<\/tr>\n<tr>\n<td>Red<\/td>\n<td>47<\/td>\n<\/tr>\n<tr>\n<td>Blue<\/td>\n<td>43<\/td>\n<\/tr>\n<tr>\n<td>Black<\/td>\n<td>35<\/td>\n<\/tr>\n<tr>\n<td>White<\/td>\n<td>49<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>As can be seen in the table the black and white serve as threshold values and this can be attributed to the light sensor that only measures in black and white. This means that the colors are only seen in grayscale and therefore they will be somewhere inbetween the black and white nuances.<\/p>\n<p><strong>Exercise 2<\/strong><br \/>\n<em>Goal<\/em><br \/>\nThe goal for this exercise is the same as exercise 1 with one change: The floodlight on the light sensor is turned off.<\/p>\n<p><em>Plan<\/em><br \/>\nWe will use the same procedure as in exercise 1.<\/p>\n<p><em>Results<\/em><br \/>\nThe results following the plan are listed in the table below:<\/p>\n<table>\n<tbody>\n<tr>\n<td>Color<\/td>\n<td>Displayed percentage<\/td>\n<\/tr>\n<tr>\n<td>Green<\/td>\n<td>39<\/td>\n<\/tr>\n<tr>\n<td>Yellow<\/td>\n<td>47<\/td>\n<\/tr>\n<tr>\n<td>Red<\/td>\n<td>48<\/td>\n<\/tr>\n<tr>\n<td>Blue<\/td>\n<td>44<\/td>\n<\/tr>\n<tr>\n<td>Black<\/td>\n<td>35<\/td>\n<\/tr>\n<tr>\n<td>White<\/td>\n<td>50<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>As can be seen from the values in the table, the black and white measurements serve as the threshold values again. The values are almost the same as with the floodlight turned on, but this is most likely because we placed the light sensor too far away, about 3-5 cms.<\/p>\n<p><strong>Exercise 3<\/strong><br \/>\n<em>Goal<\/em><br \/>\nTo see what happens when the sample interval between readings with the light sensor is increased.<\/p>\n<p><em>Plan<\/em><br \/>\nTry running the program with four different sample intervals: 10 ms, 100 ms, 500 ms and 1000 ms.<\/p>\n<p><em>Results<\/em><br \/>\nIncreasing the interval between readings decreases the reliability of the robot. Since the robot keeps moving according to the last reading, a longer interval can cause it to easily veer off course.<\/p>\n<p><strong>Exercise 4<\/strong><br \/>\n<em>Goal<\/em><br \/>\nTo observe, from gathered data, what influence a change in the sample interval has on the oscillations of the robot.<\/p>\n<p><em>Plan<\/em><br \/>\nUsing the DataLogger class we will record the values measured by the light sensor and plot them in a graph to see the oscillations and compare them.<\/p>\n<p><em>Results<\/em><br \/>\nThe oscillations have recorded and plotted in the following graphs, the interval used is given in the legend:<\/p>\n<p><a href=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/02\/5ms.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-17\" alt=\"5ms\" src=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/02\/5ms.png\" width=\"481\" height=\"289\" srcset=\"https:\/\/bech.in\/wp-content\/uploads\/2013\/02\/5ms.png 481w, https:\/\/bech.in\/wp-content\/uploads\/2013\/02\/5ms-300x180.png 300w\" sizes=\"auto, (max-width: 481px) 100vw, 481px\" \/><\/a> <a href=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/02\/10ms.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-18\" alt=\"10ms\" src=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/02\/10ms.png\" width=\"481\" height=\"289\" srcset=\"https:\/\/bech.in\/wp-content\/uploads\/2013\/02\/10ms.png 481w, https:\/\/bech.in\/wp-content\/uploads\/2013\/02\/10ms-300x180.png 300w\" sizes=\"auto, (max-width: 481px) 100vw, 481px\" \/><\/a> <a href=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/02\/20ms.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-19\" alt=\"20ms\" src=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/02\/20ms.png\" width=\"481\" height=\"289\" srcset=\"https:\/\/bech.in\/wp-content\/uploads\/2013\/02\/20ms.png 481w, https:\/\/bech.in\/wp-content\/uploads\/2013\/02\/20ms-300x180.png 300w\" sizes=\"auto, (max-width: 481px) 100vw, 481px\" \/><\/a> <a href=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/02\/30ms.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-20\" alt=\"30ms\" src=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/02\/30ms.png\" width=\"481\" height=\"289\" srcset=\"https:\/\/bech.in\/wp-content\/uploads\/2013\/02\/30ms.png 481w, https:\/\/bech.in\/wp-content\/uploads\/2013\/02\/30ms-300x180.png 300w\" sizes=\"auto, (max-width: 481px) 100vw, 481px\" \/><\/a> <a href=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/02\/40ms.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-21\" alt=\"40ms\" src=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/02\/40ms.png\" width=\"481\" height=\"289\" srcset=\"https:\/\/bech.in\/wp-content\/uploads\/2013\/02\/40ms.png 481w, https:\/\/bech.in\/wp-content\/uploads\/2013\/02\/40ms-300x180.png 300w\" sizes=\"auto, (max-width: 481px) 100vw, 481px\" \/><\/a> <a href=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/02\/50ms.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-22\" alt=\"50ms\" src=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/02\/50ms.png\" width=\"481\" height=\"289\" srcset=\"https:\/\/bech.in\/wp-content\/uploads\/2013\/02\/50ms.png 481w, https:\/\/bech.in\/wp-content\/uploads\/2013\/02\/50ms-300x180.png 300w\" sizes=\"auto, (max-width: 481px) 100vw, 481px\" \/><\/a><br \/>\nAs can be seen from the graphs, the longer the interval, the longer the oscillation.<\/p>\n<p><strong>Exercise 5<\/strong><br \/>\n<em>Goal<\/em><br \/>\nTo observe what influence using strings directly in the calls to LCD.drawString() has on the free memory, during execution of the program, compared to using variables.<\/p>\n<p><em>Plan<\/em><br \/>\nRun the program with strings directly and with variables. Use the DataLogger class to record the free memory and plot it in a graph to compare the two executions.<\/p>\n<p><em>Results<\/em><br \/>\nThe recorded free memory during the execution has been plotted in the graph below:<\/p>\n<p><a href=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/02\/memory.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-16\" alt=\"memory\" src=\"http:\/\/bech.in\/wp-content\/uploads\/2013\/02\/memory.png\" width=\"481\" height=\"289\" srcset=\"https:\/\/bech.in\/wp-content\/uploads\/2013\/02\/memory.png 481w, https:\/\/bech.in\/wp-content\/uploads\/2013\/02\/memory-300x180.png 300w\" sizes=\"auto, (max-width: 481px) 100vw, 481px\" \/><\/a><\/p>\n<p>The results seem to show that allocation of space for the variable is slower than for the value, however we haven&#8217;t tried with the variable being a constant &#8211; update will be available soon.<\/p>\n<p><em>Conclusion<\/em><br \/>\nThe results given from the first two exercises are most likely not very accurate &#8211; the gathered data indicates that there\u2019s not much difference between having the floodlight on or off. This is probably caused by the fact that we chose to place light sensor at a distance, about 3-5 centimeters, from the colored Lego plates. Therefore the ambient light has probably had a larger influence on the exercise with the floodlight than we thought it would, causing the observed values to be similar.<br \/>\nWe discovered that using a high value for the interval caused our controlled artifact to not be able to follow a black line very reliably whilst using a low value gave the opposite result.<\/p>\n<p><strong>References<\/strong><br \/>\nhttp:\/\/legolab.cs.au.dk\/DigitalControl.dir\/NXT\/Lesson1.dir\/Lesson.html<br \/>Martin, Fred G. Robotic Explorations &#8211; A Hands-On Introduction to Engineering<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Exercise 1 Goal The goal with this exercise is to record the values that the light sensor module outputs when used on different colors. Also we will observe what values are displayed when the sensor is used on black and &hellip; <a href=\"https:\/\/bech.in\/?p=11\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-11","post","type-post","status-publish","format-standard","hentry","category-digicon"],"_links":{"self":[{"href":"https:\/\/bech.in\/index.php?rest_route=\/wp\/v2\/posts\/11","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bech.in\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bech.in\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bech.in\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bech.in\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11"}],"version-history":[{"count":13,"href":"https:\/\/bech.in\/index.php?rest_route=\/wp\/v2\/posts\/11\/revisions"}],"predecessor-version":[{"id":792,"href":"https:\/\/bech.in\/index.php?rest_route=\/wp\/v2\/posts\/11\/revisions\/792"}],"wp:attachment":[{"href":"https:\/\/bech.in\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bech.in\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bech.in\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}