{"id":152,"date":"2014-09-27T01:31:42","date_gmt":"2014-09-27T01:31:42","guid":{"rendered":"http:\/\/itp.fromjia.com\/?p=152"},"modified":"2014-09-27T01:31:42","modified_gmt":"2014-09-27T01:31:42","slug":"lab-sensor-change-detection","status":"publish","type":"post","link":"http:\/\/itp.fromjia.com\/?p=152","title":{"rendered":"Lab: Sensor change detection"},"content":{"rendered":"<p>Benedetta had recommended that we do this lab. Truthfully, I&#8217;m not sure why detecting the change in voltage output overtime is very useful. \u00a0Here are a few other questions I have:<\/p>\n<ul>\n<li>How long should the detection time be?<\/li>\n<li>How to detect the noise value of an analog sensor?<\/li>\n<\/ul>\n<p><strong>Digital sensor<\/strong><\/p>\n<p>Since digital sensors can only sense two states, what&#8217;s important\u00a0for detecting digital sensor change are the rising and falling edges.<\/p>\n<p><a href=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-26-at-8.59.37-PM.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-153\" src=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-26-at-8.59.37-PM-300x165.png\" alt=\"Screen Shot 2014-09-26 at 8.59.37 PM\" width=\"300\" height=\"165\" srcset=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-26-at-8.59.37-PM-300x165.png 300w, http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-26-at-8.59.37-PM.png 966w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<div id=\"attachment_154\" style=\"width: 740px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-26-at-9.05.32-PM.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-154\" class=\"size-large wp-image-154\" src=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-26-at-9.05.32-PM-1024x439.png\" alt=\"Circuitry for detecting digital sensor change. \" width=\"730\" height=\"312\" srcset=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-26-at-9.05.32-PM-1024x439.png 1024w, http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-26-at-9.05.32-PM-300x128.png 300w\" sizes=\"auto, (max-width: 730px) 100vw, 730px\" \/><\/a><p id=\"caption-attachment-154\" class=\"wp-caption-text\">Circuitry for detecting digital sensor change.<\/p><\/div>\n<div id=\"attachment_157\" style=\"width: 510px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/digitalsensor.gif\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-157\" class=\"size-full wp-image-157\" src=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/digitalsensor.gif\" alt=\"Digital sensor reading.\" width=\"500\" height=\"281\" \/><\/a><p id=\"caption-attachment-157\" class=\"wp-caption-text\">Digital sensor reading.<\/p><\/div>\n<p>To detect the state change, we need to store the current state of a button as well as the previous state:<\/p>\n<p><script src=\"https:\/\/gist.github.com\/OhJia\/655bd4068d0a164d8abc.js\"><\/script><\/p>\n<p><strong>Analog sensor<\/strong><\/p>\n<p>It&#8217;s more complicated with analog sensor detection. We need to detect the peak value from the sensor. Like with the digital sensor, both the current and the previous states are tracked. To find the peak, we pick a threshold that would be below the peak. Each time the sensor value rises above the peak, the sensor value is stores as the peak. This happens continuously until the peak value is always above the sensor value.<\/p>\n<div id=\"attachment_159\" style=\"width: 310px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-26-at-9.22.12-PM.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-159\" class=\"size-medium wp-image-159\" src=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-26-at-9.22.12-PM-300x160.png\" alt=\"Analog sensor change.\" width=\"300\" height=\"160\" srcset=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-26-at-9.22.12-PM-300x160.png 300w, http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-26-at-9.22.12-PM.png 980w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-159\" class=\"wp-caption-text\">Analog sensor change.<\/p><\/div>\n<div id=\"attachment_160\" style=\"width: 740px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-26-at-9.23.23-PM.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-160\" class=\"size-large wp-image-160\" src=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-26-at-9.23.23-PM-1024x497.png\" alt=\"Circuitry for analog sensor change detection.\" width=\"730\" height=\"354\" srcset=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-26-at-9.23.23-PM-1024x497.png 1024w, http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-26-at-9.23.23-PM-300x145.png 300w, http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-26-at-9.23.23-PM-1200x582.png 1200w, http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/Screen-Shot-2014-09-26-at-9.23.23-PM.png 1380w\" sizes=\"auto, (max-width: 730px) 100vw, 730px\" \/><\/a><p id=\"caption-attachment-160\" class=\"wp-caption-text\">Circuitry for analog sensor change detection.<\/p><\/div>\n<div id=\"attachment_162\" style=\"width: 510px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/analogsensor.gif\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-162\" class=\"size-full wp-image-162\" src=\"http:\/\/itp.fromjia.com\/wp-content\/uploads\/2014\/09\/analogsensor.gif\" alt=\"Reading analog sensor change. The LED light up every AFTER the sensor has peaked. \" width=\"500\" height=\"281\" \/><\/a><p id=\"caption-attachment-162\" class=\"wp-caption-text\">Reading analog sensor change. The LED light up every AFTER the sensor has peaked.<\/p><\/div>\n<p>With analog sensors there are often noise in the sensor reading that interfere with peak readings. To remove the noise, the code is modified as such:<\/p>\n<p><script src=\"https:\/\/gist.github.com\/OhJia\/11c0150c49abd2eeb6d5.js\"><\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Benedetta had recommended that we do this lab. Truthfully, I&#8217;m not sure why detecting the change in voltage output overtime is very useful. \u00a0Here are a few other questions I have: How long should the detection time be? How to detect the noise value of an analog sensor? Digital sensor Since digital sensors can only [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-152","post","type-post","status-publish","format-standard","hentry","category-physical-computing"],"_links":{"self":[{"href":"http:\/\/itp.fromjia.com\/index.php?rest_route=\/wp\/v2\/posts\/152","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/itp.fromjia.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/itp.fromjia.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/itp.fromjia.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/itp.fromjia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=152"}],"version-history":[{"count":4,"href":"http:\/\/itp.fromjia.com\/index.php?rest_route=\/wp\/v2\/posts\/152\/revisions"}],"predecessor-version":[{"id":163,"href":"http:\/\/itp.fromjia.com\/index.php?rest_route=\/wp\/v2\/posts\/152\/revisions\/163"}],"wp:attachment":[{"href":"http:\/\/itp.fromjia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=152"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/itp.fromjia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=152"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/itp.fromjia.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=152"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}