{"id":10049,"date":"2015-03-31T13:27:11","date_gmt":"2015-03-31T02:27:11","guid":{"rendered":"http:\/\/legoeng.local\/?p=10049"},"modified":"2019-03-26T18:28:55","modified_gmt":"2019-03-26T07:28:55","slug":"darkness-or-darker","status":"publish","type":"post","link":"http:\/\/legoeng.local\/darkness-or-darker\/","title":{"rendered":"Darkness or darker?"},"content":{"rendered":"
<\/a>In this article, we look at the difference between fixed and relative thresholds in LabVIEW, that is the \u201cdarkness\u201d and the \u201cdarker\u201d settings in the Wait for Light Sensor block.<\/p>\n Note: This article builds on \u201cExploring thresholds<\/a>\u201d by Josep Fargas. It is recommended that you read that article first.<\/p>\n The examples in this article were written in LabVIEW<\/a> with the LabVIEW Module for LEGO MINDSTORMS.<\/p>\n A common exercise in robotics classes consists of having a robot drive on a white surface until it detects a black border and then stop. We might call this \u201cStop at the line\u201d.<\/p>\n To do this, the robot has to first learn what light sensor readings correspond to the white surface and what readings correspond to the black border.<\/p>\n <\/a>In Port View students can verify the light values for white surface and black border respectively as follows:<\/p>\n For example, let\u2019s say that we\u2019ve recorded the following values (remembering that 100% means brightest, and 0% means darkest):<\/p>\n Using these, we can determine an average for the threshold value:<\/p>\n Note: The average (or midpoint) of the two readings isn\u2019t always the best choice. Students can explore the transition between the white surface and the black border with Port View on their robot and find an optimized threshold as distinction between bright (keeping going forward!) and dark (stop!).<\/p>\n Using a \u201cWait for Darkness\u201d with a threshold of 45 gives us this LabVIEW program\u2026 <\/a><\/p>\n But what happens when the lighting changes in the room? E.g. If the Sun goes behind a cloud?<\/p>\n There, however, is an alternative to \u201cWait for Darkness\u201d that means we don\u2019t have to set a fixed threshold at all, that is \u201cWait for Darker\u201d. Using this setting, we choose how much darker the light should be until the Wait block considers the light dark enough to react. But how much darker?<\/p>\n Let\u2019s use the previous example:<\/p>\n The difference between white surface (60%) and the threshold (45%) = 60% – 45% = 15% darker.<\/p>\n Therefore when the robot senses a drop in lighting of more than 15% it will treat this as having found a black border.<\/p>\n\n
\n
\n
\n