{"id":281,"date":"2014-06-06T15:34:04","date_gmt":"2014-06-06T15:34:04","guid":{"rendered":"http:\/\/www.thinkering.de\/cms\/?p=281"},"modified":"2017-02-20T08:20:17","modified_gmt":"2017-02-20T08:20:17","slug":"tracked-robotic-vehicle","status":"publish","type":"post","link":"http:\/\/www.thinkering.de\/cms\/?p=281","title":{"rendered":"Tracked Robotic Vehicle"},"content":{"rendered":"<p>Specs:<br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\nTamya dual motor gear box<br \/>\ndual homebrew relay-based H-Bridge<br \/>\ncontrolled by a Atmega328p with Arduino UNO Bootloader.<br \/>\nSharp GP2D120XJ00F distance sensor (range: 10-80cm)<br \/>\nel-cheapo Bluetooth module (HC-06)\/Xbee Series 2 modules<br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\n<a href=\"http:\/\/www.thinkering.de\/cms\/wp-content\/uploads\/2014\/06\/20121029_123835.jpg\"><img loading=\"lazy\" class=\"alignnone size-medium wp-image-282\" src=\"http:\/\/www.thinkering.de\/cms\/wp-content\/uploads\/2014\/06\/20121029_123835-300x225.jpg\" alt=\"20121029_123835\" width=\"300\" height=\"225\" srcset=\"http:\/\/www.thinkering.de\/cms\/wp-content\/uploads\/2014\/06\/20121029_123835-300x225.jpg 300w, http:\/\/www.thinkering.de\/cms\/wp-content\/uploads\/2014\/06\/20121029_123835-1024x768.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\n<a href=\"http:\/\/www.thinkering.de\/cms\/wp-content\/uploads\/2014\/06\/20120803_000750.jpg\"><img loading=\"lazy\" class=\"alignnone size-medium wp-image-283\" src=\"http:\/\/www.thinkering.de\/cms\/wp-content\/uploads\/2014\/06\/20120803_000750-300x225.jpg\" alt=\"20120803_000750\" width=\"300\" height=\"225\" srcset=\"http:\/\/www.thinkering.de\/cms\/wp-content\/uploads\/2014\/06\/20120803_000750-300x225.jpg 300w, http:\/\/www.thinkering.de\/cms\/wp-content\/uploads\/2014\/06\/20120803_000750-1024x768.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\nThis little project just continues growing. All circuits are built on perfboards, mostly using discrete components. The Arduino components are really bearbones and make a great base for further development, as the basic functions such as movement and obstacle detection are already worky nicely.<br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\nI&#8217;ve added a &#8220;ceiling&#8221; on top, which is a blank perfboard for now. Anything can be mounted\/soldered to it, for example a 2.4 GHz wireless camera with moving mechanics+electronics. For programming you have to connect an FTDI breakout board\/cable.<br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\nThe H-Bridge is a quite simple design. Only 2 MCU pins are needed for speed control and reverse in direction. As for now, the device is working with 2 separate power supplies: 4 AA cells for the motors and a 9V battery for the &#8220;brain&#8221;\/wireless camera. This is not really elegant, but it was the simplest way of eliminating the noise caused by the DC motors.<br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\n<a href=\"http:\/\/www.thinkering.de\/cms\/wp-content\/uploads\/2014\/06\/RelaisundFet.jpg\"><img loading=\"lazy\" class=\"alignnone size-medium wp-image-284\" src=\"http:\/\/www.thinkering.de\/cms\/wp-content\/uploads\/2014\/06\/RelaisundFet-300x252.jpg\" alt=\"RelaisundFet\" width=\"300\" height=\"252\" srcset=\"http:\/\/www.thinkering.de\/cms\/wp-content\/uploads\/2014\/06\/RelaisundFet-300x252.jpg 300w, http:\/\/www.thinkering.de\/cms\/wp-content\/uploads\/2014\/06\/RelaisundFet.jpg 400w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\nHere&#8217;s the dude in motion. Pretty fast and stable &#8230;<br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\n<iframe width=\"420\" height=\"315\" src=\"\/\/www.youtube.com\/embed\/UNRcQgSHM0o?rel=0\" frameborder=\"0\" allowfullscreen><\/iframe><br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\nThis is the stationary mode (if you just turn it on, but don&#8217;t send it any commands yet): it has got a character of its own \ud83d\ude09 It rotates for a random time period, which makes its behaviour quite unpredictable, yet wirelessly controllable with the current firmware.<br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\n<iframe width=\"560\" height=\"315\" src=\"\/\/www.youtube.com\/embed\/tEl54CFH6m4?rel=0\" frameborder=\"0\" allowfullscreen><\/iframe><br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\nThe Arduino code and the corresponding Android app (created with the MIT App Inventor) can be found under the download link below. The app is somewhat universal, since it sends ASCII characters when a button is pressed, but its most useful feature is its bluetooth management functions, which supports pretty much all baud rates.<br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\n<a href=\"http:\/\/www.thinkering.de\/cms\/wp-content\/uploads\/2014\/06\/Tamya-Robot.rar\">Tamya Robot<\/a><br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\nAnother modification I&#8217;ve done on this robot is adding a thumb-joystick-controlled X-Bee-based remote control. Since this mod was only a temporary breadboard hack, I don&#8217;t remember the connection details but they were pretty simple and can be read out of the code.<br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\nTransmitter code:<\/p>\n<pre class=\"brush: cpp; collapse: true; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\n\/\/Robot controller TX part: analog joystick on A4 and A5\r\n\/\/Xbee module connected to TX and RX of the Arduino\r\nint left_PWM, right_PWM, dir = 0;\r\nint fb = 0;\r\nint lr = 0;\r\n\r\nvoid setup(){\r\n  Serial.begin(57600);\r\n}\r\n\r\nvoid loop(){\r\n  fb = analogRead(A4);\r\n  lr = analogRead(A5);\r\n  right_PWM = 0;\r\n  left_PWM = 0;\r\n  \r\nif(fb &gt; 530){      \/\/back\r\n    dir = 1;\r\n    fb=map(fb,1023,530,255,0);\r\n      \r\n    if(lr &lt; 480){\r\n      lr = map(lr,480,0,0,255);\r\n      left_PWM = fb - lr;\r\n      right_PWM = fb;\r\n      \r\n    } else if(lr &gt; 520){\r\n      lr = map(lr,520,1023,0,255);\r\n      \r\n      left_PWM = fb;\r\n      right_PWM = fb - lr;\r\n    } else {\r\n      left_PWM = fb;\r\n      right_PWM = fb;\r\n    }\r\n}else if(fb &lt; 490){    \/\/forward\r\n    dir=0;\r\n    fb=map(fb,0,490,255,0); \r\n    \r\n    if(lr &lt; 480){\r\n      lr = map(lr,480,0,0,255);\r\n      left_PWM = fb - lr;\r\n      right_PWM = fb;\r\n    }else if(lr &gt; 520){\r\n      lr = map(lr,520,1023,0,255);\r\n      left_PWM = fb ;\r\n      right_PWM = fb- lr;\r\n    }else{\r\n      left_PWM = fb;\r\n      right_PWM = fb;\r\n    }\r\n} else if(lr &lt; 480){    \/\/only left track activated \r\n    lr = map(lr,480,0,0,255);\r\n    left_PWM = 0;\r\n    right_PWM = lr;\r\n    dir = 0;\r\n }else if(lr &gt; 520){    \/\/only right track activated\r\n    lr = map(lr,520,1023,0,255);\r\n    left_PWM = lr ;\r\n    right_PWM = 0;\r\n    dir = 0;\r\n  }else {\r\n    left_PWM = 0;\r\n    right_PWM = 0;\r\n    dir = 0;\r\n}\r\n\r\n\/\/create string and send\r\nString dataString = String(dir);\r\ndataString += ',';\r\ndataString += left_PWM;\r\ndataString += ',';\r\ndataString += right_PWM;\r\ndataString += '\\n';\r\nSerial.print(dataString);\r\n\r\n\/\/delay to recover\r\ndelay(100);\r\n}\r\n<\/pre>\n<p><br style=\u201dclear:both;\u201d \/><br \/>\n<br style=\u201dclear:both;\u201d \/><br \/>\nRobot code:<\/p>\n<pre class=\"brush: cpp; collapse: true; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\n\/\/Robot Thumb Joystick Remote Control Sketch\r\n\/\/X-Bee module connected to TX and RX of the Atmega328\r\n\/\/Vehicle code: receives the strings via serial from the Xbee module and controls the \r\n\/\/power mosfets on left\/right c_pins via PWM to drive the tracks\r\n\r\nconst int sensorPin = A0;       \/\/ SHARP Sensor\r\n\r\nconst int left_dir_pin = 4;     \/\/ all the motor pins\r\nconst int left_c_pin = 5;\r\nconst int right_dir_pin = 7;\r\nconst int right_c_pin = 6;\r\n\r\nconst int led = 13;              \/\/green LED on SCK (digital pin 13)\r\n\r\nint sensorValue = 0;    \/\/ variable to store the value coming from the sensor\r\n\r\nunsigned int sensor_threshold = 200;\r\nString inString = &quot;&quot;;    \/\/ string to hold input\r\nint currentNumber = 0;  \/\/counter for value indices\r\nint dir, left_PWM, right_PWM = 0;  \/\/values read from the received String\r\n\/\/---------------------------------------------------------------------------\r\nvoid setup() \r\n{\r\n  \/\/ declare the motor pins and led-pin as an OUTPUT:\r\n  pinMode(left_dir_pin, OUTPUT);\r\n  pinMode(left_c_pin, OUTPUT);\r\n  pinMode(right_dir_pin, OUTPUT);\r\n  pinMode(right_c_pin, OUTPUT);\r\n  pinMode(led, OUTPUT);\r\n  \/\/zigbee-modem-baud rate\r\n  Serial.begin(57600);\r\n}\r\n\/\/----------------------------------------------------------------------------\r\nvoid loop() \r\n{\r\n   int inChar;\r\n  \r\n  \/\/ Read serial input:\r\n  if (Serial.available() &gt; 0) {\r\n    inChar = Serial.read();\r\n  }\r\n\r\n  if (isDigit(inChar)) {\r\n    \/\/ convert the incoming byte to a char \r\n    \/\/ and add it to the string:\r\n    inString += (char)inChar; \r\n  }\r\n\r\n  \/\/ if you get a comma, convert to a number,\r\n  \/\/ set the appropriate value, and increment\r\n  \/\/ the counter:\r\n  if (inChar == ',') {\r\n    \/\/ do something different for each value of currentNumber:\r\n    switch (currentNumber) {\r\n    case 0:    \/\/ 0 = direction \r\n      dir = inString.toInt();\r\n      \/\/ clear the string for new input:\r\n      inString = &quot;&quot;; \r\n      break;\r\n    case 1:    \/\/ 1 = left:\r\n      left_PWM = inString.toInt();\r\n      \/\/ clear the string for new input:\r\n      inString = &quot;&quot;; \r\n      break;\r\n    }\r\n    currentNumber++;\r\n  }\r\n  if (inChar == '\\n') {\r\n    right_PWM = inString.toInt();\r\n\r\n  digitalWrite(left_dir_pin, dir);  \/\/if 0, tank goes forward\r\n  digitalWrite(right_dir_pin, dir);\r\n  analogWrite(left_c_pin, left_PWM);   \/\/PWM \r\n  analogWrite(right_c_pin, right_PWM);\r\n  \/\/ clear the string for new input:\r\n    inString = &quot;&quot;; \r\n    \/\/ reset the color counter:\r\n    currentNumber = 0;\r\n  }\r\n\r\n}\r\n\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Specs: Tamya dual motor gear box dual homebrew relay-based H-Bridge controlled by a Atmega328p with Arduino UNO Bootloader. Sharp GP2D120XJ00F distance sensor (range: 10-80cm) el-cheapo Bluetooth module (HC-06)\/Xbee Series 2 modules This little project just continues growing. All circuits are built on perfboards, mostly using discrete components. The Arduino components are really bearbones and make &hellip; <a href=\"http:\/\/www.thinkering.de\/cms\/?p=281\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Tracked Robotic Vehicle<\/span> <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":{"ngg_post_thumbnail":0},"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/www.thinkering.de\/cms\/index.php?rest_route=\/wp\/v2\/posts\/281"}],"collection":[{"href":"http:\/\/www.thinkering.de\/cms\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.thinkering.de\/cms\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.thinkering.de\/cms\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.thinkering.de\/cms\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=281"}],"version-history":[{"count":4,"href":"http:\/\/www.thinkering.de\/cms\/index.php?rest_route=\/wp\/v2\/posts\/281\/revisions"}],"predecessor-version":[{"id":288,"href":"http:\/\/www.thinkering.de\/cms\/index.php?rest_route=\/wp\/v2\/posts\/281\/revisions\/288"}],"wp:attachment":[{"href":"http:\/\/www.thinkering.de\/cms\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.thinkering.de\/cms\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=281"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.thinkering.de\/cms\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}