{"id":832,"date":"2016-05-10T00:07:16","date_gmt":"2016-05-09T14:37:16","guid":{"rendered":"http:\/\/www.l8ter.com\/?p=832"},"modified":"2016-05-10T00:13:57","modified_gmt":"2016-05-09T14:43:57","slug":"quick-hack-printrboard-working-with-arduino-ide-and-using-stepper-motors-in-own-sketch","status":"publish","type":"post","link":"http:\/\/www.l8ter.com\/?p=832","title":{"rendered":"Quick hack, Printrboard working with Arduino IDE and using stepper motors in own sketch."},"content":{"rendered":"            <script type=\"text\/javascript\" src=\"http:\/\/www.l8ter.com\/wp-content\/plugins\/wordpress-code-snippet\/scripts\/shBrushCpp.js\"><\/script>\n<p>This is a quick hack and slash to capture what i did and used to get this printrboard motor controllers working with the Arduino IDE<\/p>\n<p><a href=\"http:\/\/www.l8ter.com\/wp-content\/uploads\/2016\/05\/IMG_20160509_231511.jpg\"><img loading=\"lazy\" class=\"aligncenter size-large wp-image-843\" title=\"IMG_20160509_231511\" src=\"http:\/\/www.l8ter.com\/wp-content\/uploads\/2016\/05\/IMG_20160509_231511-494x370.jpg\" alt=\"\" width=\"494\" height=\"370\" srcset=\"http:\/\/www.l8ter.com\/wp-content\/uploads\/2016\/05\/IMG_20160509_231511-494x370.jpg 494w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2016\/05\/IMG_20160509_231511-288x216.jpg 288w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2016\/05\/IMG_20160509_231511-800x600.jpg 800w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2016\/05\/IMG_20160509_231511.jpg 857w\" sizes=\"(max-width: 494px) 100vw, 494px\" \/><\/a><\/p>\n<p>Things you need to get started, Printrboard, USBTinyISP (or use an arduino to program (<a href=\"http:\/\/www.instructables.com\/id\/Turn-Your-Arduino-Into-an-ISP\/\">http:\/\/www.instructables.com\/id\/Turn-Your-Arduino-Into-an-ISP\/<\/a>), one motor to test i guess.<\/p>\n<p>Download and install winavr (<a href=\"https:\/\/sourceforge.net\/projects\/winavr\/?source=typ_redirect\">https:\/\/sourceforge.net\/projects\/winavr\/?source=typ_redirect<\/a>) I used 20100110.<\/p>\n<p><span style=\"font-size: 12px;\">Download and install Arduino I successfully use version 1.6.8 (<a href=\"http:\/\/arduino.cc\">arduino.cc<\/a>)<\/span><\/p>\n<p>Download Arduino HID support pack ( \u00a0 \u00a0<a href=\"https:\/\/github.com\/scwimbush\/Printrboard-HID-Arduino-IDE-Support\">https:\/\/github.com\/scwimbush\/Printrboard-HID-Arduino-IDE-Support<\/a>) extract to hardware folder in arduino (cached copy <a href=\"http:\/\/www.l8ter.com\/wp-content\/uploads\/2016\/05\/Printrboard-HID-Arduino-IDE-Support-master.zip\">Printrboard-HID-Arduino-IDE-Support-master<\/a>\u00a0)<\/p>\n<p>Download Stepper driver library (<a href=\"https:\/\/github.com\/laurb9\/StepperDriver\">https:\/\/github.com\/laurb9\/StepperDriver<\/a>) extract to the libraries folder in the Arduino folder. Chached copy here\u00a0<a href=\"http:\/\/www.l8ter.com\/wp-content\/uploads\/2016\/05\/StepperDriver-master.zip\">StepperDriver-master<\/a><\/p>\n<p>Hookup your USBtinyISP to your printrboard ISP 6pin header *RED line on ribbon cable towards the sd card slot*<\/p>\n<p>Dont hook any power to the printrboard (no usb no 12V)<\/p>\n<p>Plug USBtinyISP to the pc, wait for driver to install if you cant find (x64 etc) it here it is\u00a0<a href=\"http:\/\/www.l8ter.com\/wp-content\/uploads\/2016\/05\/usbtiny_signed_8.zip\">usbtiny_signed_8<\/a><\/p>\n<p>Open command prompt, navigate to the arduino hardware directory as follows (C:\\Program Files (x86)\\Arduino\\hardware\\printrboard\\avr\\bootloaders)<\/p>\n<p>run &#8220;avrdude -c usbtiny -p at90usb1286 -U lfuse:w:0xde:m -U hfuse:w:0xdb:m -U efuse:w:0xf0:m&#8221; Wait for completion<\/p>\n<p>run &#8220;avrdude -c usbtiny -p at90usb1286 -U flash:w:BootloaderHID.hex:i &#8211; See more at: http:\/\/blog.lincomatic.com\/?p=548#sthash.rAaaAdym.dpuf&#8221; It may error at the end but this should work.<\/p>\n<p><a href=\"http:\/\/www.l8ter.com\/wp-content\/uploads\/2016\/05\/avrdude.png\"><img loading=\"lazy\" class=\"aligncenter size-large wp-image-837\" title=\"avrdude\" src=\"http:\/\/www.l8ter.com\/wp-content\/uploads\/2016\/05\/avrdude-494x416.png\" alt=\"\" width=\"494\" height=\"416\" srcset=\"http:\/\/www.l8ter.com\/wp-content\/uploads\/2016\/05\/avrdude-494x416.png 494w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2016\/05\/avrdude-288x242.png 288w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2016\/05\/avrdude.png 677w\" sizes=\"(max-width: 494px) 100vw, 494px\" \/><\/a><\/p>\n<p>Unplug USBTinyISP, Plug printrboard to the pc, ensure boot jumper is on the board, plug in 12v to board. Turn it on it shouldnt require any drivers. plug a stepper motor into the Z-Motor header.<\/p>\n<p><a href=\"http:\/\/www.l8ter.com\/wp-content\/uploads\/2016\/05\/arduino-example.jpg\"><img loading=\"lazy\" class=\"aligncenter size-large wp-image-836\" title=\"arduino example\" src=\"http:\/\/www.l8ter.com\/wp-content\/uploads\/2016\/05\/arduino-example-408x494.jpg\" alt=\"\" width=\"408\" height=\"494\" srcset=\"http:\/\/www.l8ter.com\/wp-content\/uploads\/2016\/05\/arduino-example-408x494.jpg 408w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2016\/05\/arduino-example-238x288.jpg 238w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2016\/05\/arduino-example-496x600.jpg 496w, http:\/\/www.l8ter.com\/wp-content\/uploads\/2016\/05\/arduino-example.jpg 562w\" sizes=\"(max-width: 408px) 100vw, 408px\" \/><\/a><\/p>\n<p><span style=\"font-size: 12px;\">Open Ardunio, Load up the Examples -&gt; Stepper Driver -&gt; Basic Stepper Driver sketch (if you dont have it you didnt install the library correctly earlier)<\/span><\/p>\n<p><span style=\"font-size: 12px;\">The following modifications are using only Z motor however here is the entire list of pins that the marlin system (<a href=\"https:\/\/github.com\/lincomatic\/Marlin\/blob\/Marlin_v1\/Marlin\/pins.h\">https:\/\/github.com\/lincomatic\/Marlin\/blob\/Marlin_v1\/Marlin\/pins.h<\/a>)\u00a0uses;<\/span><\/p>\n<p><pre class=\"brush: cpp\">\/****************************************************************************************\r\n* Printrboard Rev. B pin assingments (ATMEGA90USB1286)\r\n* Requires the Teensyduino software with Teensy2.0++ selected in arduino IDE!\r\n* See http:\/\/reprap.org\/wiki\/Printrboard for more info\r\n****************************************************************************************\/\r\n#if MOTHERBOARD == 81\r\n#define MOTHERBOARD 81\r\n#define KNOWN_BOARD 1\r\n\r\n#define X_STEP_PIN         28\r\n#define X_DIR_PIN          29\r\n#define X_ENABLE_PIN       19\r\n#define X_MIN_PIN          47\r\n#define X_MAX_PIN          -1\r\n\r\n#define Y_STEP_PIN         30\r\n#define Y_DIR_PIN          31\r\n#define Y_ENABLE_PIN       18\r\n#define Y_MIN_PIN           20\r\n#define Y_MAX_PIN          -1\r\n\r\n#define Z_STEP_PIN         32\r\n#define Z_DIR_PIN          33\r\n#define Z_ENABLE_PIN       17\r\n#define Z_MIN_PIN          36\r\n#define Z_MAX_PIN          -1\r\n\r\n#define E0_STEP_PIN         34\r\n#define E0_DIR_PIN          35\r\n#define E0_ENABLE_PIN       13\r\n\r\n#define HEATER_0_PIN       15  \/\/ Extruder\r\n#define HEATER_1_PIN       -1\r\n#define HEATER_2_PIN       -1\r\n#define HEATER_BED_PIN     14  \/\/ Bed\r\n#define FAN_PIN            16  \/\/ Fan\r\n\r\n#define TEMP_0_PIN          1  \/\/ Extruder - ANALOG PIN NUMBERING\r\n#define TEMP_1_PIN         -1\r\n#define TEMP_2_PIN         -1\r\n#define TEMP_BED_PIN        0  \/\/ Bed - ANALOG PIN NUMBERING\r\n\r\n#define SDPOWER            -1\r\n#define SDSS                26\r\n#define LED_PIN            -1\r\n#define PS_ON_PIN          -1\r\n#define KILL_PIN           -1\r\n\r\n#ifndef SDSUPPORT\r\n\/\/ these pins are defined in the SD library if building with SD support\r\n  #define SCK_PIN          21\r\n  #define MISO_PIN         22\r\n  #define MOSI_PIN         23\r\n#endif\r\n\r\n#ifdef ULTRA_LCD\r\n\r\n  #ifdef NEWPANEL\r\n  \/\/arduino pin which triggers an piezzo beeper\r\n    #define BEEPER 33\t\t\t\/\/ Beeper on AUX-4\r\n\r\n#ifndef MCP28017_LCD\r\n    #define LCD_PINS_RS 16 \r\n    #define LCD_PINS_ENABLE 17\r\n    #define LCD_PINS_D4 23\r\n    #define LCD_PINS_D5 25 \r\n    #define LCD_PINS_D6 27\r\n    #define LCD_PINS_D7 29\r\n#endif \/\/ MCP28017_LCD\r\n    \r\n    \/\/buttons are directly attached using AUX-2\r\n    #define BTN_EN1 11 \/\/ PC1\r\n    #define BTN_EN2 12 \/\/ PC2\r\n#ifndef PANUCATT_VIKI\r\n    #define BTN_ENC 31  \/\/the click\r\n#endif\r\n    \r\n    #define BLEN_C 2\r\n    #define BLEN_B 1\r\n    #define BLEN_A 0\r\n    \r\n    #define SDCARDDETECT -1\t\t\/\/ Ramps does not use this port\r\n    \r\n      \/\/encoder rotation values\r\n    #define encrot0 0\r\n    #define encrot1 2\r\n    #define encrot2 3\r\n    #define encrot3 1\r\n\r\n  #else \/\/old style panel with shift register\r\n    \/\/arduino pin witch triggers an piezzo beeper\r\n    #define BEEPER 33\t\tNo Beeper added\r\n\r\n    \/\/buttons are attached to a shift register\r\n\t\/\/ Not wired this yet\r\n    \/\/#define SHIFT_CLK 38\r\n    \/\/#define SHIFT_LD 42\r\n    \/\/#define SHIFT_OUT 40\r\n    \/\/#define SHIFT_EN 17\r\n    \r\n    #define LCD_PINS_RS 16 \r\n    #define LCD_PINS_ENABLE 17\r\n    #define LCD_PINS_D4 23\r\n    #define LCD_PINS_D5 25 \r\n    #define LCD_PINS_D6 27\r\n    #define LCD_PINS_D7 29\r\n    \r\n    \/\/encoder rotation values\r\n    #define encrot0 0\r\n    #define encrot1 2\r\n    #define encrot2 3\r\n    #define encrot3 1\r\n\r\n    \r\n    \/\/bits in the shift register that carry the buttons for:\r\n    \/\/ left up center down right red\r\n    #define BL_LE 7\r\n    #define BL_UP 6\r\n    #define BL_MI 5\r\n    #define BL_DW 4\r\n    #define BL_RI 3\r\n    #define BL_ST 2\r\n\r\n    #define BLEN_B 1\r\n    #define BLEN_A 0\r\n  #endif \r\n#endif \/\/ULTRA_LCD\r\n\r\n#endif\r\n<\/pre><\/p>\n<p>Set the following (16 steps because the drivers do 1\/16);<br \/>\n<pre class=\"brush: cpp\">\/\/ All the wires needed for full functionality\r\n#define DIR 33\r\n#define STEP 32\r\n\r\n\/\/ Since microstepping is set externally, make sure this matches the selected mode\r\n\/\/ 1=full step, 2=half step etc.\r\n#define MICROSTEPS 16\r\n<\/pre><\/p>\n<p>And once you have done that we make a small modification to set that motor driver to enabled by going low on the enable pin.<br \/>\n<pre class=\"brush: cpp\">void setup() {\r\n    \/*\r\n     * Set target motor RPM.\r\n     * These motors can do up to about 200rpm.\r\n     * Too high will result in a high pitched whine and the motor does not move.\r\n     *\/\r\n      pinMode(17,OUTPUT); \/\/ Enable\r\n       digitalWrite(17,LOW); \/\/ Set Enable low\r\n    stepper.setRPM(120);\r\n}<\/pre><\/p>\n<p>Now remove the boot pin on the printrboard, press the reset button, you should hear the usb connection sound in windows. Ensure the Arduino software is set to install via Printrboard board. Then click upload in the Arduino software, when it is complete it will reset the board. Power the board off replace the jumper and turn it back on. The motor should now be woorking.<\/p>\n<p>This concludes this quick getting the printrboard working. Hopefully it is clear as mud,\u00a0\u00a0you should be able to figure it out from here \ud83d\ude42<\/p>\n<p>Here are a few links i used here:<\/p>\n<p><a href=\"https:\/\/github.com\/scwimbush\/Printrboard-HID-Arduino-IDE-Support\">https:\/\/github.com\/scwimbush\/Printrboard-HID-Arduino-IDE-Support<\/a><br \/>\n<a href=\"http:\/\/reprap.org\/wiki\/File:F4_Schematic.png\">http:\/\/reprap.org\/wiki\/File:F4_Schematic.png<\/a><br \/>\n<a href=\"http:\/\/reprap.org\/mediawiki\/images\/2\/26\/Printrboard_RevF_Board300.png\">http:\/\/reprap.org\/mediawiki\/images\/2\/26\/Printrboard_RevF_Board300.png<\/a><br \/>\n<a href=\"http:\/\/blog.lincomatic.com\/?p=548\">http:\/\/blog.lincomatic.com\/?p=548<\/a><br \/>\n<a href=\"http:\/\/reprap.org\/wiki\/Printrboard\">http:\/\/reprap.org\/wiki\/Printrboard<\/a><br \/>\n<a href=\"http:\/\/fritzing.org\/projects\/a4988-single-stepper-test\/\">http:\/\/fritzing.org\/projects\/a4988-single-stepper-test\/<\/a><br \/>\n<a href=\"https:\/\/github.com\/laurb9\/StepperDriver\">https:\/\/github.com\/laurb9\/StepperDriver<\/a><br \/>\n<a href=\"https:\/\/github.com\/lincomatic\/Marlin\/blob\/Marlin_v1\/Marlin\/pins.h\">https:\/\/github.com\/lincomatic\/Marlin\/blob\/Marlin_v1\/Marlin\/pins.h<\/a><br \/>\n<a href=\"http:\/\/reprap.org\/wiki\/Printrboard\">http:\/\/reprap.org\/wiki\/Printrboard<\/a><br \/>\n<a href=\"https:\/\/bitbucket.org\/makible\/5dprint-firmware\/wiki\/EEPROM%20Settings\">https:\/\/bitbucket.org\/makible\/5dprint-firmware\/wiki\/EEPROM%20Settings<\/a><br \/>\n<a href=\"https:\/\/github.com\/scwimbush\/Printrboard-HID-Arduino-IDE-Support\">https:\/\/github.com\/scwimbush\/Printrboard-HID-Arduino-IDE-Support<\/a><br \/>\n<a href=\"http:\/\/printrbot.com\/wp-content\/uploads\/2013\/01\/HelpFileForUsingPrintrboardElectronics-.pdf\">http:\/\/printrbot.com\/wp-content\/uploads\/2013\/01\/HelpFileForUsingPrintrboardElectronics-.pdf<\/a><br \/>\n<a href=\"http:\/\/blog.lincomatic.com\/?p=502\">http:\/\/blog.lincomatic.com\/?p=502<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a quick hack and slash to capture what i did and used to get this printrboard motor controllers working with the Arduino IDE Things you need to get started, Printrboard, USBTinyISP (or use an arduino to program (http:\/\/www.instructables.com\/id\/Turn-Your-Arduino-Into-an-ISP\/),&#8230; <a class=\"more-link\" href=\"http:\/\/www.l8ter.com\/?p=832\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":843,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[46,16],"tags":[47,145,144,146,143],"_links":{"self":[{"href":"http:\/\/www.l8ter.com\/index.php?rest_route=\/wp\/v2\/posts\/832"}],"collection":[{"href":"http:\/\/www.l8ter.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.l8ter.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.l8ter.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.l8ter.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=832"}],"version-history":[{"count":9,"href":"http:\/\/www.l8ter.com\/index.php?rest_route=\/wp\/v2\/posts\/832\/revisions"}],"predecessor-version":[{"id":847,"href":"http:\/\/www.l8ter.com\/index.php?rest_route=\/wp\/v2\/posts\/832\/revisions\/847"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.l8ter.com\/index.php?rest_route=\/wp\/v2\/media\/843"}],"wp:attachment":[{"href":"http:\/\/www.l8ter.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=832"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.l8ter.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=832"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.l8ter.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=832"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}