{"id":9342,"date":"2014-11-18T17:39:30","date_gmt":"2014-11-18T06:39:30","guid":{"rendered":"http:\/\/legoeng.local\/?p=9342"},"modified":"2019-06-27T12:29:13","modified_gmt":"2019-06-27T02:29:13","slug":"exploring-thresholds","status":"publish","type":"post","link":"http:\/\/legoeng.local\/exploring-thresholds\/","title":{"rendered":"Exploring Thresholds"},"content":{"rendered":"

\"BOGATECH\"<\/a>This unit introduces an extremely simple exercise that allows students to think more deeply about the concept of a threshold and how to use it to make a robot react to its environment.<\/p>\n

It is based on my Teachers Introduction Course to LEGO\u00ae MINDSTORMS NXT & EV3<\/a> at BOGATECH<\/a>\u2019s website. Here the programming examples are based on the LEGO MINDSTORMS EV3 Software, but at BOGATECH’s website you can find the NXT version and the differences between the two platforms, if you are interested.<\/p>\n

The following exercises can even be done by students without any programming experience, with the goal of introducing the concept of a threshold and programming with logical structures. It is very interesting to observe that in this practical exercise, the challenge is not to program the Wait and Switch blocks, it is to determine the thresholds to be used in each block to make the robot detect the lines and their color correctly. Students could, for example, be given the program already written. Students typically understand these blocks very intuitively and with little explanation.<\/p>\n

At the end the unit, an experiment is proposed to generate a graph based on the color sensor\u2019s measurements. This graph perfectly illustrates the sensor behavior. This approach can be extrapolated to other sensors.<\/p>\n

A little bit of theory<\/h2>\n

To better understand how a sensor works and how the EV3 makes decisions based on sensor values, we need to explain the concept of a threshold.<\/p>\n

A very simple example is to use the classroom doorway to illustrate that depending on where we stand, we will either be inside or outside the classroom. But if we stand just in the middle of the doorway, where will we be? We will be at the door\u2019s threshold<\/em> which separates the inside from the outside.<\/p>\n

For another example, let\u2019s imagine that we want to classify the students by separating the short from the tall ones. One way to do it is to take the tallest student and the shortest one, draw two lines on the blackboard at their heights and ask the class where to draw the line that will separate the short from the tall students? In other words, how can we calculate the threshold that will state the difference between a short and a tall person? Perhaps the easiest approach would be to find the mean of the two extremes, that is to simply add the two measurements and divide the result by 2, that is, (A+B) \/ 2.<\/p>\n

We can also calculate the arithmetic mean of the whole class, by adding all the students\u2019 heights and dividing the result by the number of students. That will typically give us a different result, but why? When should we apply this concept? We could also add different weights to the different measurements, but how and when should we do this?<\/p>\n

To calculate the threshold required to differentiate between a pair of sensor measurements is very similar, but first we need to find out the values of the sensors we want to differentiate. As outlined below, we can use the View menu on the EV3 brick to read the value of the Color sensor when we place it on top of different colors. Similarly, we could read the volume level on a Sound sensor or the distance to an object in front of the Ultrasonic sensor.<\/p>\n

Exercise overview<\/h2>\n

\"SchematicsAs shown in this image, the exercise consists of finding the right thresholds to make the robot…<\/p>\n

    \n
  1. Go forward and stop when it finds the black line, using only a Wait block.<\/li>\n
  2. Do the same exercise but stopping at the green line.<\/li>\n
  3. Go over or \u201cjump\u201d the green line and stop at the black line.<\/li>\n
  4. Stop at any line (green or black) and, using a Switch based on the value of Reflected Light Intensity of the Color sensor, it has to say the color of the line using a Sound block.<\/li>\n<\/ol>\n

    Preparation<\/h2>\n

    We need to tape a black line onto a white background. We also need another color line (e.g. green or blue) that will give a\u00a0reflected light intensity higher than black and lower than white. In the following exercises we will use several thresholds, but always between pairs of measurements corresponding to two different colors.<\/p>\n

    \"EV3<\/a>Each team will need a simple two-wheeled robot with a Color sensor (to be used as a light sensor) attached to the front of the robot, as shown in the image (e.g.\u00a0LEGO MINDSTORMS Education EV3 Software >\u00a0Robot Educator > Driving Base + Color Sensor Down).<\/p>\n

    Next, every student or group of students will need to fill in a table with their robot\u2019s sensor readings on top of the white, the green, and the black colors (the readings might differ for each sensor) \u2013 by using the \u201cView\u201d option of the EV3 brick, selecting \u201cReflected Light\u201d and choosing the corresponding port of the color sensor \u2013 and calculating the thresholds between each pair of colors. At this point it is important that the students make some tests and realize that the reading of the Color sensor\u2019s reflected light intensity on the same color or point can vary depending on differences in lighting in the room or the position of the robot.<\/p>\n\n\n\n\n\n\n
    Black<\/strong><\/td>\nThreshold Black-Green<\/td>\nGreen<\/strong><\/td>\nThreshold Green-White<\/td>\nWhite<\/strong><\/td>\n<\/tr>\n
    6%<\/td>\n7%<\/strong><\/td>\n9%<\/td>\n42%<\/strong><\/td>\n75%<\/td>\n<\/tr>\n
    <\/td>\n\u00a0<\/strong><\/td>\nThreshold Black-White<\/td>\n\u00a0<\/strong><\/td>\n<\/td>\n<\/tr>\n
    <\/td>\n<\/td>\n40%<\/strong><\/td>\n<\/td>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

    Exercise 1: Stop at black<\/h2>\n

    The first three exercises deal with varying the light intensity threshold of the Wait block to stop the robot at the desired lines.<\/p>\n

    Create a new program and add…<\/p>\n