{"id":1027,"date":"2017-11-13T04:52:42","date_gmt":"2017-11-12T19:52:42","guid":{"rendered":"http:\/\/blog.hi-farm.net\/?p=1027"},"modified":"2017-11-13T04:52:42","modified_gmt":"2017-11-12T19:52:42","slug":"arduino-servo-trouble","status":"publish","type":"post","link":"http:\/\/blog.hi-farm.net\/en\/2017\/11\/13\/arduino-servo-trouble\/","title":{"rendered":"Troubles what did not go well in controlling servo by Arduino"},"content":{"rendered":"<div class='wp_social_bookmarking_light'>\n            <div class=\"wsbl_hatena_button\"><a href=\"\/\/b.hatena.ne.jp\/entry\/http:\/\/blog.hi-farm.net\/en\/2017\/11\/13\/arduino-servo-trouble\/\" class=\"hatena-bookmark-button\" data-hatena-bookmark-title=\"Troubles what did not go well in controlling servo by Arduino\" data-hatena-bookmark-layout=\"standard\" title=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\"> <img src=\"\/\/b.hatena.ne.jp\/images\/entry-button\/button-only@2x.png\" alt=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\" width=\"20\" height=\"20\" style=\"border: none;\" \/><\/a><script type=\"text\/javascript\" src=\"\/\/b.hatena.ne.jp\/js\/bookmark_button.js\" charset=\"utf-8\" async=\"async\"><\/script><\/div>\n            <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"http:\/\/blog.hi-farm.net\/en\/2017\/11\/13\/arduino-servo-trouble\/\" data-text=\"Troubles what did not go well in controlling servo by Arduino\" data-via=\"mmlemon\" data-lang=\"ja\">Tweet<\/a><\/div>\n            <div class=\"wsbl_facebook_like\"><div id=\"fb-root\"><\/div><fb:like href=\"http:\/\/blog.hi-farm.net\/en\/2017\/11\/13\/arduino-servo-trouble\/\" layout=\"button_count\" action=\"like\" width=\"100\" share=\"false\" show_faces=\"false\" ><\/fb:like><\/div>\n            <div class=\"wsbl_facebook_send\"><div id=\"fb-root\"><\/div><fb:send href=\"http:\/\/blog.hi-farm.net\/en\/2017\/11\/13\/arduino-servo-trouble\/\" colorscheme=\"light\" ><\/fb:send><\/div>\n            <div class=\"wsbl_tumblr\"><a href=\"\/\/www.tumblr.com\/share?v=3&u=http%3A%2F%2Fblog.hi-farm.net%2Fen%2F2017%2F11%2F13%2Farduino-servo-trouble%2F&t=Troubles%20what%20did%20not%20go%20well%20in%20controlling%20servo%20by%20Arduino\" title=\"Share on Tumblr\" style=\"display:inline-block; text-indent:-9999px; overflow:hidden; width:81px; height:20px; background:url('\/\/platform.tumblr.com\/v1\/share_1.png') top left no-repeat transparent;\">Share on Tumblr<\/a><\/div>\n            <div class=\"wsbl_google_plus_one\"><g:plusone size=\"medium\" annotation=\"inline\" href=\"http:\/\/blog.hi-farm.net\/en\/2017\/11\/13\/arduino-servo-trouble\/\" width=\"250\"><\/g:plusone><\/div>\n            <div class=\"wsbl_evernote\">[`evernote` not found]<\/div>\n            <div class=\"wsbl_line\"><a href='http:\/\/line.me\/R\/msg\/text\/?Troubles%20what%20did%20not%20go%20well%20in%20controlling%20servo%20by%20Arduino%0D%0Ahttp%3A%2F%2Fblog.hi-farm.net%2Fen%2F2017%2F11%2F13%2Farduino-servo-trouble%2F' title='LINE\u3067\u9001\u308b' rel=nofollow class='wp_social_bookmarking_light_a' ><img src='http:\/\/blog.hi-farm.net\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/line88x20.png' alt='LINE\u3067\u9001\u308b' title='LINE\u3067\u9001\u308b' width='88' height='20' class='wp_social_bookmarking_light_img' \/><\/a><\/div>\n            <div class=\"wsbl_pocket\"><a href=\"https:\/\/getpocket.com\/save\" class=\"pocket-btn\" data-lang=\"en\" data-save-url=\"http:\/\/blog.hi-farm.net\/en\/2017\/11\/13\/arduino-servo-trouble\/\" data-pocket-count=\"none\" data-pocket-align=\"left\" >Pocket<\/a><script type=\"text\/javascript\">!function(d,i){if(!d.getElementById(i)){var j=d.createElement(\"script\");j.id=i;j.src=\"https:\/\/widgets.getpocket.com\/v1\/j\/btn.js?v=1\";var w=d.getElementById(i);d.body.appendChild(j);}}(document,\"pocket-btn-js\");<\/script><\/div>\n    <\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n<div style=\"float: right; margin-left: 10px;\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-count=\"vertical\" data-url=\"http:\/\/blog.hi-farm.net\/en\/2017\/11\/13\/arduino-servo-trouble\/\">Tweet<\/a><\/div>\nI will blog a different topic than the laser because I wrote about laser a lot.<\/p>\n<p>I will write down the topic because I had troubles of controlling servo by Arduino, though I used to handling LEDs by Arduino.<\/p>\n<h3>To smooth servo movement more detail &#8211; basic<\/h3>\n<p>If you control servo, normally you will write arduino program below:<\/p>\n<pre>\r\n#include &lt;Servo.h&gt;\r\nServo servo;\r\n\r\nvoid setup(){\r\n    servo.attach([pin number for controlling servo]);\r\n    angle = 120; \/\/ 0-180 degree\r\n    servo.write(angle);\r\n}\r\nvoid loop(){}\r\n\r\n<\/pre>\n<p>Normally it is good you can write code easily because of using degree, but if you want to control more smoothly and detail, you can control by<\/p>\n<pre>\r\nwriteMicroseconds();\r\n<\/pre>\n<p>However, it becomes little difficult how to specify angle; thus unit is different from write() and writeMicroseconds().<\/p>\n<p>In reference, writeMicroseconds takes argument from 1000 to 2000 normally, but some servos take from 700 to 2,300.You need to test the range.<br \/>\nIn fact, the servo I used takes the range more wider. <\/p>\n<p>Arduino reference(Servo#writeMicroseconds() ):<br \/>\n<a href=\"https:\/\/www.arduino.cc\/en\/Reference\/ServoWriteMicroseconds\" rel=\"noopener\" target=\"_blank\">https:\/\/www.arduino.cc\/en\/Reference\/ServoWriteMicroseconds<\/a><\/p>\n<p>Therefore, writeMicroseconds() has a merit that moves servo smooth though this function takes time and complex.<\/p>\n<h3>Unable to move continuously<\/h3>\n<p>Although I cannot search deeply, servo cannot move without using delay() when I move servo continuously in loop().I think there is a time lag that run this code and arriving at the position though I don&#8217;t know the reason completely.<br \/>\nThis is related to servo types and other implementation, but I need delay(15);.<\/p>\n<h3>jittering &#8211; controlling from external<\/h3>\n<p>I wrote a code that continuosly receive and parse values from serial, and control servo by using that values.<br \/>\nI think it goes well, but servo happened to move jittering when connecting serial device and move smooth when disconnecting serial device.It may be overloaded.<\/p>\n<p>The reason why I use &#8220;SoftwareSerial&#8221; code. Actually, I should use &#8220;Hardware&#8221; Serial(using tx, rx pins), but I used SoftwareSerial because I want to debug by retrieving values via USB, in PC.<br \/>\nHowever, SoftwareSerial is heavier than &#8220;hardware&#8221; Serial, and I found the article not to use standard SoftwareSerial.<br \/>\n(<a href=\"https:\/\/arduino.stackexchange.com\/questions\/34126\/whats-the-difference-between-all-the-software-serial-libraries-which-one-is-ar\" rel=\"noopener\" target=\"_blank\">https:\/\/arduino.stackexchange.com\/questions\/34126\/whats-the-difference-between-all-the-software-serial-libraries-which-one-is-ar<\/a>)<\/p>\n<p>In this article, there are alternative recommendations below:<br \/>\n<a href=\"https:\/\/www.pjrc.com\/teensy\/td_libs_AltSoftSerial.html\" rel=\"noopener\" target=\"_blank\">AltSoftSerial<\/a>,<br \/>\n<a href=\"https:\/\/github.com\/SlashDevin\/NeoSWSerial\" rel=\"noopener\" target=\"_blank\">NeoSWSerial<\/a>.<\/p>\n<p>In my situation, I cannot improve the problem when using these alternatives..<br \/>\nSo I improved by using hardware Serial.<\/p>\n<p>Although, I think this depends on Arduino&#8217;s specs(I use <a href=\"http:\/\/akizukidenshi.com\/catalog\/g\/gK-10347\/\" rel=\"noopener\" target=\"_blank\">this Arduino Pro mini 5v<\/a>).So the problem will appear when I use more servo.<\/p>\n<hr \/>\n<p>And, I used 6 servos in my situation and I have other problems I got values via wireless,,,I will write down this other time.<br \/>","protected":false},"excerpt":{"rendered":"<p>Tweet I will blog a different topic than the laser because I wrote about laser a lot. I will write down the to &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[170],"tags":[261,222,223,224],"_links":{"self":[{"href":"http:\/\/blog.hi-farm.net\/en\/wp-json\/wp\/v2\/posts\/1027"}],"collection":[{"href":"http:\/\/blog.hi-farm.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.hi-farm.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.hi-farm.net\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.hi-farm.net\/en\/wp-json\/wp\/v2\/comments?post=1027"}],"version-history":[{"count":28,"href":"http:\/\/blog.hi-farm.net\/en\/wp-json\/wp\/v2\/posts\/1027\/revisions"}],"predecessor-version":[{"id":1055,"href":"http:\/\/blog.hi-farm.net\/en\/wp-json\/wp\/v2\/posts\/1027\/revisions\/1055"}],"wp:attachment":[{"href":"http:\/\/blog.hi-farm.net\/en\/wp-json\/wp\/v2\/media?parent=1027"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.hi-farm.net\/en\/wp-json\/wp\/v2\/categories?post=1027"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.hi-farm.net\/en\/wp-json\/wp\/v2\/tags?post=1027"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}