{"id":150,"date":"2019-04-13T11:56:55","date_gmt":"2019-04-13T15:56:55","guid":{"rendered":"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/?p=150"},"modified":"2019-04-17T12:25:12","modified_gmt":"2019-04-17T16:25:12","slug":"irene-motor-drivers","status":"publish","type":"post","link":"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/2019\/04\/13\/irene-motor-drivers\/","title":{"rendered":"[Irene] Motor Drivers"},"content":{"rendered":"<p>I used a waveform generator to output a square wave with T = 2.0ms, Ampl = 3.3Vpp, HiLevel = 3.3Vpp, Offset=1.65Vdc, LoLevel=0V, and Duty Cycle between 20% and 80%. The servo seems to work fine, with a few glitches when the duty cycle was low.<\/p>\n<p><a href=\"https:\/\/gph.is\/g\/4obOm1Z\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/media.giphy.com\/media\/fTtOvJBsEwVOk5mD8a\/giphy.gif\" alt=\"Animated GIF - Find &amp; Share on GIPHY\" width=\"480\" height=\"270\" \/><\/a><\/p>\n<p>However, using the servo library on the Arduino, the pwm output from pin 9 looks funny. Here is a comparison on the oscilloscope:<br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-151 size-large\" src=\"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-content\/uploads\/sites\/22\/2019\/04\/IMG-1113-1024x768.jpg\" alt=\"\" width=\"525\" height=\"394\" srcset=\"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-content\/uploads\/sites\/22\/2019\/04\/IMG-1113-1024x768.jpg 1024w, http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-content\/uploads\/sites\/22\/2019\/04\/IMG-1113-300x225.jpg 300w, http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-content\/uploads\/sites\/22\/2019\/04\/IMG-1113-768x576.jpg 768w\" sizes=\"(max-width: 525px) 100vw, 525px\" \/><\/p>\n<p>Yellow is the square wave from the waveform generator, and green is the output from the Arduino using the servo.h library and the sample code provided by adafruit here <a href=\"https:\/\/learn.adafruit.com\/adafruit-arduino-lesson-14-servo-motors\/arduino-code-for-sweep\">https:\/\/learn.adafruit.com\/adafruit-arduino-lesson-14-servo-motors\/arduino-code-for-sweep<\/a>. Upon inspection of the Arduino servo library, it looks like the servo.write() function sets an interrupt. When I set my own pwm using the following code:<\/p>\n<pre>void loop()\r\n{\r\n\u00a0 digitalWrite(servoPin,HIGH);\r\n\u00a0 delayMicroseconds(active_us);\r\n\u00a0 digitalWrite(servoPin,LOW);\r\n\u00a0 delayMicroseconds(period_us - active_us);\r\n}<\/pre>\n<p>Hallelujah, the Arduino output has the correct duty cycle and period, but the amplitude voltage is lower. Here is what the output from the oscilloscope looked like:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-152 size-large\" src=\"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-content\/uploads\/sites\/22\/2019\/04\/IMG-1114-1024x768.jpg\" alt=\"\" width=\"525\" height=\"394\" srcset=\"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-content\/uploads\/sites\/22\/2019\/04\/IMG-1114-1024x768.jpg 1024w, http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-content\/uploads\/sites\/22\/2019\/04\/IMG-1114-300x225.jpg 300w, http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-content\/uploads\/sites\/22\/2019\/04\/IMG-1114-768x576.jpg 768w\" sizes=\"(max-width: 525px) 100vw, 525px\" \/><\/p>\n<p>In the context of the system, I would need to use interrupts to manage the PWM when integrated with the sensors.<\/p>\n<p>I ordered parts for five alternatives because I don&#8217;t think we have time for ordering parts for a Plan B. In order of potential, my options are:<\/p>\n<ol>\n<li>NEMA 17 &amp;\u00a0<span style=\"font-size: 1rem\">L298 hbridge (cheap from amazon): There are many resources out there using these two parts together and I (almost) had it working with the same type of hbridge last week.\u00a0<\/span><\/li>\n<li>NEMA 17 &amp; L298 hbridge (expensive from sparkfun): I&#8217;ve learned from Build18 that cheap parts are not reliable, so here&#8217;s an alternative. The hbridge is the same model, but the breakout board looks more enhanced. The heat sink is larger.<\/li>\n<li>NEMA 17 &amp; TB6600 motor driver (as recommended by Nathan Serafin). This driver is very heavy duty and reliable, but there are not many resources out there for how to use it.<\/li>\n<li>Continuous rotation servo: I feed this a time interval and it spins for that amount of time, but is very imprecise.<\/li>\n<li>The original servo: I believe I could hack something together to make this work, but it wouldn&#8217;t be pretty. I have better options, and this is only a backup on backups.<\/li>\n<\/ol>\n<p>If the option that I go with does not have enough torque (which is unlikely), I can use a counterweight to require less torque.<\/p>\n<p>I got through trying options 1-3. Here are my results.<\/p>\n<ol>\n<li>NEMA 17 &amp;\u00a0L298 hbridge (cheap from amazon):<a href=\"https:\/\/gph.is\/g\/ZPle0rZ\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/media.giphy.com\/media\/cMWjijfYCGfCgCcZgX\/giphy.gif\" alt=\"Animated GIF - Find &amp; Share on GIPHY\" width=\"270\" height=\"480\" \/><\/a>\n<p>The motor stutters, but is drawing much less current than the imposter NEMA 17.<\/li>\n<li>NEMA 17 &amp; L298 hbridge (expensive from sparkfun): I wired everything, but there is no current flowing. I looked at the <a href=\"https:\/\/www.canakit.com\/Media\/Manuals\/UK1122.pdf\">user manual<\/a> and found operating instructions that include the use of ENA and ENB, which I haven&#8217;t needed to use before when following other tutorials. I will try more wiring configurations<img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-167 size-large\" src=\"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-content\/uploads\/sites\/22\/2019\/04\/IMG-1122-e1555279178143-768x1024.jpg\" alt=\"\" width=\"525\" height=\"700\" srcset=\"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-content\/uploads\/sites\/22\/2019\/04\/IMG-1122-e1555279178143-768x1024.jpg 768w, http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-content\/uploads\/sites\/22\/2019\/04\/IMG-1122-e1555279178143-225x300.jpg 225w\" sizes=\"(max-width: 525px) 100vw, 525px\" \/><\/li>\n<li>NEMA 17 &amp; TB6600 motor driver: This I have no clue how to wire up (LOL). I will meet with Nathan to figure it out.<\/li>\n<\/ol>\n<p><span style=\"font-size: 1rem\">In other news, I have mounted the camera and LED to the door. They are both taped on so we can remove or adjust them.<\/span><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-165 size-large\" style=\"font-size: 1rem\" src=\"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-content\/uploads\/sites\/22\/2019\/04\/IMG-1125-e1555279514531-768x1024.jpg\" alt=\"\" width=\"525\" height=\"700\" srcset=\"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-content\/uploads\/sites\/22\/2019\/04\/IMG-1125-e1555279514531-768x1024.jpg 768w, http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-content\/uploads\/sites\/22\/2019\/04\/IMG-1125-e1555279514531-225x300.jpg 225w\" sizes=\"(max-width: 525px) 100vw, 525px\" \/><\/p>\n<p>Here is what the camera output looks like:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-169 size-medium\" src=\"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-content\/uploads\/sites\/22\/2019\/04\/WIN_20190414_15_58_56_Pro-300x169.jpg\" alt=\"\" width=\"300\" height=\"169\" srcset=\"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-content\/uploads\/sites\/22\/2019\/04\/WIN_20190414_15_58_56_Pro-300x169.jpg 300w, http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-content\/uploads\/sites\/22\/2019\/04\/WIN_20190414_15_58_56_Pro-768x432.jpg 768w, http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-content\/uploads\/sites\/22\/2019\/04\/WIN_20190414_15_58_56_Pro-1024x576.jpg 1024w, http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-content\/uploads\/sites\/22\/2019\/04\/WIN_20190414_15_58_56_Pro.jpg 1280w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>And with the lights off and LED on:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"size-medium wp-image-168 alignnone\" style=\"font-size: 1rem\" src=\"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-content\/uploads\/sites\/22\/2019\/04\/WIN_20190414_16_00_22_Pro-300x169.jpg\" alt=\"\" width=\"300\" height=\"169\" srcset=\"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-content\/uploads\/sites\/22\/2019\/04\/WIN_20190414_16_00_22_Pro-300x169.jpg 300w, http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-content\/uploads\/sites\/22\/2019\/04\/WIN_20190414_16_00_22_Pro-768x432.jpg 768w, http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-content\/uploads\/sites\/22\/2019\/04\/WIN_20190414_16_00_22_Pro-1024x576.jpg 1024w, http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-content\/uploads\/sites\/22\/2019\/04\/WIN_20190414_16_00_22_Pro.jpg 1280w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>And I was standing about two feet away:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-166 size-medium\" src=\"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-content\/uploads\/sites\/22\/2019\/04\/IMG-1123-e1555279679498-225x300.jpg\" alt=\"\" width=\"225\" height=\"300\" srcset=\"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-content\/uploads\/sites\/22\/2019\/04\/IMG-1123-e1555279679498-225x300.jpg 225w, http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-content\/uploads\/sites\/22\/2019\/04\/IMG-1123-e1555279679498-768x1024.jpg 768w\" sizes=\"(max-width: 225px) 100vw, 225px\" \/><\/p>\n<p>I&#8217;m behind and still working to solve the same problems as last time.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I used a waveform generator to output a square wave with T = 2.0ms, Ampl = 3.3Vpp, HiLevel = 3.3Vpp, Offset=1.65Vdc, LoLevel=0V, and Duty Cycle between 20% and 80%. The servo seems to work fine, with a few glitches when the duty cycle was low. However, using the servo library on the Arduino, the pwm &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/2019\/04\/13\/irene-motor-drivers\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;[Irene] Motor Drivers&#8221;<\/span><\/a><\/p>\n","protected":false},"author":62,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[5],"_links":{"self":[{"href":"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-json\/wp\/v2\/posts\/150"}],"collection":[{"href":"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-json\/wp\/v2\/users\/62"}],"replies":[{"embeddable":true,"href":"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-json\/wp\/v2\/comments?post=150"}],"version-history":[{"count":8,"href":"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-json\/wp\/v2\/posts\/150\/revisions"}],"predecessor-version":[{"id":175,"href":"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-json\/wp\/v2\/posts\/150\/revisions\/175"}],"wp:attachment":[{"href":"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-json\/wp\/v2\/media?parent=150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-json\/wp\/v2\/categories?post=150"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s19-teama7\/wp-json\/wp\/v2\/tags?post=150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}