{"id":399,"date":"2016-09-12T00:22:33","date_gmt":"2016-09-12T07:22:33","guid":{"rendered":"http:\/\/www.mjblythe.com\/hacks\/?p=399"},"modified":"2021-12-22T00:01:01","modified_gmt":"2021-12-22T07:01:01","slug":"28byj-48-stepper-motor","status":"publish","type":"post","link":"http:\/\/www.mjblythe.com\/hacks\/2016\/09\/28byj-48-stepper-motor\/","title":{"rendered":"28BYJ-48 stepper motor"},"content":{"rendered":"<p><a href=\"http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/IMG_20160908_214656293.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-large wp-image-518\" src=\"http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/IMG_20160908_214656293-1024x576.jpg\" alt=\"img_20160908_214656293\" width=\"600\" height=\"338\" srcset=\"http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/IMG_20160908_214656293-1024x576.jpg 1024w, http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/IMG_20160908_214656293-300x169.jpg 300w, http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/IMG_20160908_214656293-768x432.jpg 768w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>Based off of <a href=\"http:\/\/hackaday.com\/2016\/07\/21\/simple-clock-is-great-stepper-motor-project\/\">this post on hackaday<\/a> about a simple clock using a cheap stepper motor, I decided on a whim to buy some. I chose <a href=\"https:\/\/www.amazon.com\/gp\/product\/B015RQ97W8\/\">these on Amazon<\/a> because they had the desirable combination of being cheap and prime-eligible.<\/p>\n<p>Before they arrived, I did some reading and found that there were different verdicts on the gearing&#8230;<\/p>\n<p><!--more--><\/p>\n<ul>\n<li><a href=\"https:\/\/www.adafruit.com\/product\/858\">Adafruit<\/a> says 32 steps\/rev and 1\/16.032 gearing (which they round up to 513 steps\/rev).<\/li>\n<li><a href=\"https:\/\/grahamwideman.wikispaces.com\/Motors-+28BYJ-48+Stepper+motor+notes\">Graham Wideman<\/a> disassembled a few. He confirmed Adafruit&#8217;s gearing and also found one with a 1\/63.68395 gearing (= 2308 steps\/rev)<\/li>\n<li><a href=\"http:\/\/42bots.com\/tutorials\/28byj-48-stepper-motor-with-uln2003-driver-and-arduino-uno\/\">42 bots<\/a> didn&#8217;t disassemble anything, but agreed with the 1\/63.68395 gearing<\/li>\n<li><a href=\"http:\/\/www.jangeox.be\/2013\/10\/stepper-motor-28byj-48_25.html\">Jangoex<\/a> found that between 508 and 509 steps resulted in a full revolution (which approximates 1\/16, but is a different ratio than Adafruit)<\/li>\n<li><a href=\"http:\/\/forum.arduino.cc\/index.php?topic=71964.15\">The Arduino forums<\/a> have a lot of discussion (I haven&#8217;t read it all), but sounds like there&#8217;s just a wide variety of gear ratios, and possibly even a true 1\/64 ratio<\/li>\n<\/ul>\n<p>So, when my steppers arrived, I decided to run experiment to determine which gear ratio I had.<\/p>\n<p>I wrote some code <a href=\"https:\/\/github.com\/mblythe86\/stepper_motor_testing\">(linked here)<\/a> to:<\/p>\n<ol>\n<li>move 1 full rotation (2048 steps)<\/li>\n<li>increment counter &amp; print<\/li>\n<li>pause<\/li>\n<li>loop<\/li>\n<\/ol>\n<p>And here&#8217;s the code in action, spinning the motor (with a bit of tape on the motor shaft to make the rotation more visible):<\/p>\n<p><video width=\"600\" height=\"338\" autoplay loop><source src=\"http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/05\/stepper.mp4\" type=\"video\/mp4\" \/><\/video><\/p>\n<p>I should point out that I usually power my breadboard from a 9V wall-wart with a linear regulator to bring it down to 5V.  This stepper draws enough power, though, that I was having problems with brown-out.  So, I switched to using a <a href=\"https:\/\/www.amazon.com\/gp\/product\/B00HR798YS\">4xAA battery pack<\/a>.  The voltage is a bit higher than 5V, but everything seems to tolerate it OK.<\/p>\n<h3>Preliminary result<\/h3>\n<p>After 5000+ revolutions, there was no noticeable change in end position.\u00a0 I think I may have the magical &#8220;true&#8221; 1\/64 gearing!<\/p>\n<p>Just to be sure I didn&#8217;t fool myself, I changed to code to do 513 sequences (i.e. 4 steps), I noticed it drifting quickly.<\/p>\n<p>NOTE: when I tested all 5 steppers that I bought (all seem to have the same gearing), one seemed to get jammed.\u00a0 Running it in the opposite direction, and giving it a bit of manual &#8220;encouragement&#8221; seems to have fixed it, but it&#8217;s probably the one I&#8217;ll disassemble. It may have also been that my battery pack was running low, and didn&#8217;t have enough power to reliably drive the motor.<\/p>\n<h3>Teardown<\/h3>\n<p>At this point, I decided to potentially sacrifice one motor to confirm once and for all that I had a true 1\/64 gearing.<\/p>\n<p>Getting the case apart was surprisingly difficult. I thought that the little tabs would bend out of the way easily, but they were too small to grab easily, and much tougher than I expected.<\/p>\n<p><a href=\"http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/IMG_20160908_214627138.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-large wp-image-519\" src=\"http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/IMG_20160908_214627138-1024x576.jpg\" alt=\"img_20160908_214627138\" width=\"600\" height=\"338\" srcset=\"http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/IMG_20160908_214627138-1024x576.jpg 1024w, http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/IMG_20160908_214627138-300x169.jpg 300w, http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/IMG_20160908_214627138-768x432.jpg 768w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>Once I got it opened, the gear train looked similar to other photos I had seen.<\/p>\n<p><a href=\"http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/IMG_20160908_215610908.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-large wp-image-520\" src=\"http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/IMG_20160908_215610908-1024x1024.jpg\" alt=\"img_20160908_215610908\" width=\"600\" height=\"600\" srcset=\"http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/IMG_20160908_215610908-1024x1024.jpg 1024w, http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/IMG_20160908_215610908-150x150.jpg 150w, http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/IMG_20160908_215610908-300x300.jpg 300w, http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/IMG_20160908_215610908-768x768.jpg 768w, http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/IMG_20160908_215610908.jpg 1916w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>Of course, even though it looks similar, that doesn&#8217;t tell us the gear ratios:<\/p>\n<style type=\"text\/css\" scoped>\n  .wp-caption { margin: 0px;\n                padding: 2px; } \n<\/style>\n<p><div id=\"attachment_527\" style=\"width: 110px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/motor_out.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-527\" class=\"wp-image-527\" src=\"http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/motor_out-150x150.jpg\" alt=\"motor_out\" width=\"100\" height=\"100\" srcset=\"http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/motor_out-150x150.jpg 150w, http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/motor_out-300x300.jpg 300w, http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/motor_out.jpg 600w\" sizes=\"auto, (max-width: 100px) 100vw, 100px\" \/><\/a><p id=\"caption-attachment-527\" class=\"wp-caption-text\">motor out:<br \/>9 teeth<br \/>(hard to see here)<\/p><\/div><div id=\"attachment_523\" style=\"width: 110px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/gear1.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-523\" class=\"wp-image-523 size-thumbnail\" src=\"http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/gear1-150x150.jpg\" alt=\"gear1\" width=\"100\" height=\"100\" srcset=\"http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/gear1-150x150.jpg 150w, http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/gear1-300x300.jpg 300w, http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/gear1.jpg 600w\" sizes=\"auto, (max-width: 100px) 100vw, 100px\" \/><\/a><p id=\"caption-attachment-523\" class=\"wp-caption-text\">Gear 1:<br \/>32 in, 11 out<\/p><\/div><div id=\"attachment_524\" style=\"width: 110px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/gear2.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-524\" class=\"wp-image-524 size-thumbnail\" src=\"http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/gear2-150x150.jpg\" alt=\"gear2\" width=\"100\" height=\"100\" srcset=\"http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/gear2-150x150.jpg 150w, http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/gear2-300x300.jpg 300w, http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/gear2.jpg 600w\" sizes=\"auto, (max-width: 100px) 100vw, 100px\" \/><\/a><p id=\"caption-attachment-524\" class=\"wp-caption-text\">Gear 2:<br \/>22 in, 9 out<\/p><\/div><div id=\"attachment_525\" style=\"width: 110px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/gear3.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-525\" class=\"wp-image-525 size-thumbnail\" src=\"http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/gear3-150x150.jpg\" alt=\"gear3\" width=\"100\" height=\"100\" srcset=\"http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/gear3-150x150.jpg 150w, http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/gear3-300x300.jpg 300w, http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/gear3.jpg 600w\" sizes=\"auto, (max-width: 100px) 100vw, 100px\" \/><\/a><p id=\"caption-attachment-525\" class=\"wp-caption-text\">Gear 3:<br \/>27 in, 8 out<\/p><\/div><div id=\"attachment_526\" style=\"width: 110px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/gear4.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-526\" class=\"wp-image-526 size-thumbnail\" src=\"http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/gear4-150x150.jpg\" alt=\"gear4\" width=\"100\" height=\"100\" srcset=\"http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/gear4-150x150.jpg 150w, http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/gear4-300x300.jpg 300w, http:\/\/www.mjblythe.com\/hacks\/wp-content\/uploads\/2016\/09\/gear4.jpg 600w\" sizes=\"auto, (max-width: 100px) 100vw, 100px\" \/><\/a><p id=\"caption-attachment-526\" class=\"wp-caption-text\">Output:<br \/>24 teeth<\/p><\/div><br style=\"clear:both\"><\/p>\n<p>And the math reduces like this:<br \/>\n<br \/>\n$${9 \\over 32}\\times{11 \\over 22}\\times{9 \\over 27}\\times{8 \\over 24}$$ $${9 \\over 32}\\times{1 \\over 2}\\times{1 \\over 3}\\times{1 \\over 3}$$ $${3 \\over 32}\\times{1 \\over 2}\\times{1 \\over 3}$$ $${1 \\over 32}\\times{1 \\over 2}$$ $${1 \\over 64}$$<\/p>\n<p>So, I do truly have a stepper motor with a 1\/64 gearing.  This will make any projects in the future much easier, not having to compensate for an odd gearing!<\/p>\n<p>Unfortunately, putting the stepper back together was also difficult.  The magnets pull the motor output shaft off-center, so the plate doesn&#8217;t really want to click back in place.  Additionally, I don&#8217;t have a good tool to bend the tabs back in place&#8230;so it&#8217;s being held together with masking tape for now.  Good thing I have four others to use!<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>Based off of this post on hackaday about a simple clock using a cheap stepper motor, I decided on a whim to buy some. I chose these on Amazon because they had the desirable combination of being cheap and prime-eligible. Before they arrived, I did some reading and found that there were different verdicts on [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[14],"tags":[],"class_list":["post-399","post","type-post","status-publish","format-standard","hentry","category-reverse-engineering"],"_links":{"self":[{"href":"http:\/\/www.mjblythe.com\/hacks\/wp-json\/wp\/v2\/posts\/399","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.mjblythe.com\/hacks\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.mjblythe.com\/hacks\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.mjblythe.com\/hacks\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.mjblythe.com\/hacks\/wp-json\/wp\/v2\/comments?post=399"}],"version-history":[{"count":28,"href":"http:\/\/www.mjblythe.com\/hacks\/wp-json\/wp\/v2\/posts\/399\/revisions"}],"predecessor-version":[{"id":576,"href":"http:\/\/www.mjblythe.com\/hacks\/wp-json\/wp\/v2\/posts\/399\/revisions\/576"}],"wp:attachment":[{"href":"http:\/\/www.mjblythe.com\/hacks\/wp-json\/wp\/v2\/media?parent=399"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.mjblythe.com\/hacks\/wp-json\/wp\/v2\/categories?post=399"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.mjblythe.com\/hacks\/wp-json\/wp\/v2\/tags?post=399"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}