{"id":17,"date":"2012-01-24T22:48:11","date_gmt":"2012-01-25T03:48:11","guid":{"rendered":"http:\/\/www.mcgurrin.com\/robots\/?p=17"},"modified":"2012-01-30T19:56:57","modified_gmt":"2012-01-31T00:56:57","slug":"wheel-encoders","status":"publish","type":"post","link":"https:\/\/www.mcgurrin.info\/robots\/17\/","title":{"rendered":"Wheel Encoders"},"content":{"rendered":"<p>In order to estimate position and orientation using dead reckoning, you have to measure the rotation of your wheels (or the motor shaft or gear driving the wheels).\u00a0 \u00a0This means using some sort of shaft or wheel encoder.\u00a0 The RP5 has a gear that rotates 4x for every wheel rotation, and a hole in it which they indicate can be used to count gear rotations using some sort of optical (infrared) encoder.<\/p>\n<p>One can get much more precision by using more holes\/slots or more markings, as discussed in <a href=\"http:\/\/www.arduino.cc\/cgi-bin\/yabb2\/YaBB.pl?num=1257038219\">this thread<\/a> on homemade encoders.\u00a0 Also, having two offset sets of marks allows one to do quadrature encoding and determine the direction of travel as well. For my first robot, I\u2019m just using a rough encoder, with 4 counts per wheel revolution.<\/p>\n<p>In looking in the chassis, there\u2019s not a lot of room. As a result, I decided I\u2019d use a small transmissive sensor, rather than a reflective sensor.\u00a0 Both have an IR emitter and an IR photo detector. \u00a0For reflective units, they both face the same direction, and the detector measure IR reflected back to the sensor.\u00a0 For a transmissive or interrupt sensor, the two units are separated by a gap, and the detector picks up IR passing through the gap. So far, so good.<\/p>\n<p>I ended up using Vishay transmissive optical sensors (model TCST1202) I purchased from DigiKey.\u00a0 I found a ciruch \u00a0and wiring them up based on the circuit posted by Aniss1001 in the &#8220;<a href=\"http:\/\/www.arduino.cc\/cgi-bin\/yabb2\/YaBB.pl?num=1257038219\">Homemade wheel encoder<\/a>&#8221;\u00a0 thread on the Arduino forum.<\/p>\n<div id=\"attachment_18\" style=\"width: 310px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.mcgurrin.com\/robots\/wp-content\/uploads\/2012\/01\/Encoder-circuit.png\"><img aria-describedby=\"caption-attachment-18\" decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-18\" title=\"Encoder circuit\" src=\"http:\/\/www.mcgurrin.com\/robots\/wp-content\/uploads\/2012\/01\/Encoder-circuit-300x207.png\" alt=\"encoder circuit diagram\" width=\"300\" height=\"207\" srcset=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2012\/01\/Encoder-circuit-300x207.png 300w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2012\/01\/Encoder-circuit.png 426w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-18\" class=\"wp-caption-text\">Encoder circuit diagram - for a different encoder, but it worked fine<\/p><\/div>\n<p>I built the circuit on a prototyping breadboard for testing and got a surprise.\u00a0 The circuit worked fine, but the gear is transparent to IR!\u00a0 It turns out that nylon and most plastics used for inexpensive gears are pretty transparent to IR.\u00a0 I first tried creating an opaque section with a black marker, but while that worked on paper, it didn\u2019t adhere well enough to the gear.\u00a0 I ended up using a piece of black tape.\u00a0 Once that worked, I cut some small circuit boards down to size and built the encoders, practicing my soldering skills.<\/p>\n<p>I just used hot glue to mount the encoders.\u00a0 The encoder boards stick up above the chassis base, so I\u2019m using standoffs to raise the plastic plate with the Romeo controller and other devices.\u00a0 Here&#8217;s a picture of one of the encoders before mounting,, and then mounted on the chassis:<\/p>\n<div id=\"attachment_19\" style=\"width: 310px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.mcgurrin.com\/robots\/wp-content\/uploads\/2012\/01\/IMG_0090.jpg\"><img aria-describedby=\"caption-attachment-19\" decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-19\" title=\"IMG_0090\" src=\"http:\/\/www.mcgurrin.com\/robots\/wp-content\/uploads\/2012\/01\/IMG_0090-300x224.jpg\" alt=\"Homemade wheel encoder\" width=\"300\" height=\"224\" srcset=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2012\/01\/IMG_0090-300x224.jpg 300w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2012\/01\/IMG_0090-1024x764.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-19\" class=\"wp-caption-text\">Homemade wheel encoder<\/p><\/div>\n<div id=\"attachment_20\" style=\"width: 234px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.mcgurrin.com\/robots\/wp-content\/uploads\/2012\/01\/IMG_0093.jpg\"><img aria-describedby=\"caption-attachment-20\" decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-20\" title=\"Mounted encoder\" src=\"http:\/\/www.mcgurrin.com\/robots\/wp-content\/uploads\/2012\/01\/IMG_0093-e1327463177346-224x300.jpg\" alt=\"\" width=\"224\" height=\"300\" srcset=\"https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2012\/01\/IMG_0093-e1327463177346-224x300.jpg 224w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2012\/01\/IMG_0093-e1327463177346-764x1024.jpg 764w, https:\/\/www.mcgurrin.info\/robots\/wp-content\/uploads\/2012\/01\/IMG_0093-e1327463177346.jpg 1936w\" sizes=\"(max-width: 224px) 100vw, 224px\" \/><\/a><p id=\"caption-attachment-20\" class=\"wp-caption-text\">Mounted encoder<\/p><\/div>\n<p><strong>UPDATE:<\/strong> If you don&#8217;t want to build your own, I just discovered these <a href=\"http:\/\/arduino-direct.com\/sunshop\/index.php?l=product_detail&amp;p=202\">pre-built transmissive encoder boards<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In order to estimate position and orientation using dead reckoning, you have to measure the rotation of your wheels (or the motor shaft or gear driving the wheels).\u00a0 \u00a0This means using some sort of shaft or wheel encoder.\u00a0 The RP5 &hellip; <a href=\"https:\/\/www.mcgurrin.info\/robots\/17\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[8,7,4,13],"_links":{"self":[{"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/posts\/17"}],"collection":[{"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/comments?post=17"}],"version-history":[{"count":6,"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/posts\/17\/revisions"}],"predecessor-version":[{"id":64,"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/posts\/17\/revisions\/64"}],"wp:attachment":[{"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/media?parent=17"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/categories?post=17"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mcgurrin.info\/robots\/wp-json\/wp\/v2\/tags?post=17"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}