After a hiatus of a couple of years, I’m finally starting to get back into 3D printing. One of my Printrboards got messed up when some wires on my hot end shorted. The hot end temperature was no longer reading correctly. Since my other Printrboards all work correctly, I knew that the problem was not a bad thermistor or wiring. Instead of throwing out the Printrboard, I decided to try to fix it. The first step was to have a look @ the Printrboard schematic. Here’s what the temperature sensing circuit looks like:
I got out my ohmmeter, and R9 was OK, but E-THERM to GND was reading as a dead short, so I assumed that C10 was bad. This was a good opportunity to play with my AOYUE INT 2702 hot air rework station, which I’d never used. I removed C10, and much to my chagrin, the reading from the hot end ADC pin was stuck at 1024. Furthermore, shorting E-THERM to ground was causing my Printrboard to reboot! This led me to conclude that something was fried inside the AT90USB1286 on the ADC pin connected to E-THERM (PF1_ADC1). Conveniently, 2 other ADC pins, ADC2 and ADC3, are broken out into an expansion header on the Printrboard. I first soldered C10 back into place. The trace connecting ADC1 to E-THERM was inaccessible, so I couldn’t cut it. Instead, I disconnected it by lifting the pin on the MCU off the PCB. Next, I connected a piece of 40AWG wire wrap wire between the A2 header pin and the E-THERM trace.
Success, the ADC2 pin is working perfectly! The only caveat is that I have to remember to run modified firmware when using this board, reassigning the hot end thermistor pin from ADC1 to ADC2. In Marlin firmware, it’s as simple as finding the Printrboard section of pins.h, and reassigning TEMP_0_PIN from 1 to 2.
It’s been a few years since I hacked together the copy of Arduino-0022 that’s been floating around the web, which lets you compile and automatically upload Arduino code to an AT90USB1286. This made it a lot easier to develop Arduino code for the AT90USB1286, and in particular to easily modify the Marlin firmware for the Printrboard.
Yesterday, I figured it was high time to add AT90USB1286 support to Arduino 1.0.5-r2. The basic procedure for the modification was to first install Teensyduino, which adds the AT90USB1286 compilation support to Arduino, but only uploads to a Teensy++ 2.0, running PJRC’s proprietary halfkay bootloader. I modified the Teensyduino configuration to also support uploads to targets running the LUFA CDC Bootloader, or via USBtinyISP or USBasp ICSP programmers.
The only difference between the Printrboard and AT90USB1286 entries is that the extraneous USB Type, CPU Speed, and Keyboard Layout submenus are grayed out from the Tools menu.
To load Marlin firmware onto a Printrboard, you will most likely want to use [BootloaderCDC]Printrboard.
Note that unlike my Arduino-0022 hack, the pinMode()/digitalRead()/digitalWrite() functions in version currently only support the pins that are exposed on the Teensy++ 2.0. This is because I haven’t yet had the time to figure out how to add in the remaining AT90USB1286. However, this limitation doesn’t affect Marlin firmware on the Printrboard, because Marlin uses its own fastio functions, rather than using Arduino digital pin numbers and pinMode()/digitalRead()/digitalWrite(). See pinmap.txt for the currently supported Arduino digital pin numbers.
Thanks again to PJRC for Teensyduino. Teensys are a great alternative to Arduino boards.
I just synced my Marlin branch for Printrboard with the latest code from ErikZalm’s branch. I noticed that there were a lot of changes in the planner, temperature control, etc. Hopefully, it will be an improvement, rather than breaking anything. Please report here or on github if you find any anolmalies with the new code.
My Printrbot from the Printrbot’s Kickstarter Campaign was supposed to arrive in February. Unfortunately, due to the huge number of supporters they received, the schedule has been pushed back, and I doubt I’ll receive mine until late May. In the meantime, I’ve been getting antsy waiting for mine to arrive, so I decided to go ahead and build one from scratch. The Printrbot that I ordered is actually the laser-cut model. John Seaber of JDS Labs was kind enough to send me the printed bits and a complete extruder for the RepRap version of Printrbot.
I already had most of the other parts needed to build a Printrbot, except for the threaded rods and miscellaneous nuts and bolts. I had 4 used steppers gutted from laser printers (which I bought from Wildseyed), and a stepper for the extruder plus smooth rods from Epson Stylus Color 600 ink jet printer that has been gathering dust for more than 10 years. There is a decent Printrbot BOM on printrbottalk’s wiki; a few bits here and there are missing, but it still saved me a lot of time. The nuts & bolts were all easy to find at a local hardware store, except for the M3 screws. The M3 screws were the only parts I had to buy for which an SAE equivalent simply wouldn’t do, since they had to mate into threaded holes in the motors. I ended up wasting a whole afternoon going to several hardware stores, and almost gave up, before finally finding them at Ace Hardware. It’s amazing how difficult it is to buy metric parts in the US.
Since I had already been experimenting with my own variations on Wildseyed’s Hot End, I already had a hot end built and ready to go. My modifications on Wildseyed’s design are 1) it can be completely dissassembled for cleaning 2) the brass barrel is shorter, has less mass, and screws on 3) I’m using a radial resistor embedded in the aluminum block, rather than attaching an aluminum-cased resistor to the outside.
Unfortunately, the extruder I received was set up for a different mount, so I had to adapt it. A trip to the hardware store yielded a PVC pipe elbow, that, as luck would have it, had the exact inside and outside diameters to form an adapter for my hot end. I cut out a small ring, and attached the hot end with M3 grub screws.
One thing I learned while assembling this printer is that LM8UU bearings need precise alignment, or they will bind very badly. The bearings in the Printrbot’s x-carriage are press fit, which is great for simplicity, but can cause headaches if the parts aren’t printed perfectly. Initially, my carriage was binding very badly, and would barely move. Even worse, the LM8UU’s were gouging deep grooves into my smooth rods. This is because of two factors 1) the spacing of the x-carriage smooth rods was slightly different between the left and right sides of the carriage, due to imperfections in the printed rod holders and 2) the holes in the plastic x-carriage piece I received were not perfectly parallel. After some cleanup of the holes with a rasp in my drill press, I got everything to line up, and the carriage now moves smoothly.
I had a similar problem with the smooth rods of my z-axis. The rods on the y-axis ride on 2 LM8UU’s which are stacked on top of each other, and press fit into a printed plastic block. Again, due to minor imperfections in the print, the stacked bearings didn’t line up perfectly, and my z-axis bearings were binding quite badly against my smooth rod. I was lucky that I was able to pry them out, because they were a very tight fit. Again cleaning up the holes with a rasp on my drill press fixed the problem.
All in all, there was a maddening amount of tweaking and coaxing involved in getting my Printrbot assembled and calibrated. My x-motor’s shaft was a bit to short so I had to cut down its mount a bit. This in turn, caused problems with the alignment of the belt and idler bearing. The z-motor mount dimensions were a bit off, so the threaded rods were tilted inwards, rather than parallel to the z-axis smooth rods. I had to re-drill the holes to achieve the proper alignment. The couplers between the z motors and threaded rods didn’t quite fit right, and caused the rods to wobble. I solved this by switching to aluminum couplers. The crimp on pins that I bought from Ultimachine didn’t fit into the Molex hoods I bought, so I had to improvise the connections to my Printrboard.
I decided to use CAT-5 for wiring my Printrbot. It’s cheap and has a jacket, so cabling is tidy. Since the cable has more conductors than I need, and the gauge of the wires in CAT5 is relatively small, I used one twisted pair for each connection.
I still need to attach end stops, build the hot bed, and get a 12V power supply with higher output to power the hot bed. In the meantime, I was itching to crank out some test prints. The problem is that it’s very difficult to get the molten ABS to stick to any cold surface. I finally decided to try something crazy … print ABS on ABS. I printed on a piece of the Epson Stylus Color 600 printer from which I salvaged the motor that I’m using for the extruder. The first object that I printed was a replacement foot for my Vitamix.
My Printrbot is running Marlin firmware, which I adapted to run on Printrboard, and I’m using either Pronterface and Repetier host software, depending on my mood. Currently, I’m using Slic3r to convert STL’s to GCODE. While calibrating the printer, I found that the carriage and build plate vibrate quite a bit, and the motion is not completely smooth. This wobbling can be seen in my test prints. Hopefully, the excessive vibration is due to a modification that I made to the design, as opposed to an intrinsic problem in the Printrbot. Because my rods came in 3′ lengths, I extended all of the rods from 10″ to 12″ long.
Here is my first print, the Vitamix foot:
I was just happy that it came out well enough to use. At this stage, there was still a lot of tweaking to do … refining the calibration, adjusting the temperature, tweaking the parameters for Slic3r. After a lot of experimentation and failures
I am finally able to get some decent prints. In a future article, I will discuss my current printer settings. I made the mistake of selecting a very challenging object as my second print, Surveyor’s Cat Toy.
Here is my best attempt so far:
I am now in the process of printing an extruder for a friend. My best print to date is the small gear on the left:
Both of the gears are printed with .2mm layer height. The only difference is that I slowed down the perimeters from 30mm/s to 15mm/s in order to get rid of the vibration. Here is my Printrbot attempting to print the large extruder gear:
The print actually failed because 1) my extruder jammed, due to a stray piece of plastic which fell into it and 2) my ABS printing surface started warping too much. I need to get my heated bed working before I can print large parts.
While the AT90USB1286 MCU in the Teensylu/Printrboard can be programmed with an ICSP or JTAG programmer, you can also install a bootloader, which will allow you to program it via a USB connection alone. Besides the convenience of not having to attach a hardware programmer, uploading firmware via a USB bootloader is blazingly fast. Also, it allows you to write host software to do end user firmware upgrades without a hardware programmer.
I am currently aware of 3 bootloader options for the AT90USB128x MCU’s:
DFU – USB Device Firmware Upgrade Class
This is the bootloader officially supported by Atmel.
PRO: can integrate into Arduino IDE; works with avrude via avr109 protocol.
CON: requires user to know which virtual serial port it’s associated with; in Windows, uses native Windows driver, but requires INF file install, needs upgrade of avrdude to newer version for Arduino < 1.0.
HID – USB Human Interface Device Class
PRO: Trouble free – doesn’t require any device drivers – just plug and play
CON: doesn’t integrate into Arduino IDE
Before you can install a bootloader on your MCU, you must set the fuses correctly to allocate space for it. We need 4K bytes (2K words) of space, so using the Engbedded Atmel Fuse Calculator, we see that we need Boot Flash Size BOOTSZ=01, which is in the high fuse. Here are the fuse settings that I use on mine:
BE CAREFUL IF YOU WANT TO FIDDLE WITH FUSE SETTINGS YOURSELF. It’s not hard to “brick” your AVR with the wrong settings. In fact, when I was first working with my Printrboard, I managed to brick it by messing up the CKSEL bits, thinking I was supposed to set it for an external oscillator. Luckily, all I had to do was connect an external oscillator (I used the signal generator function of my DSO Quad mini scope) to XTAL1 and then use avrdude to fix the offending fuse. If you do something worse, like disabling SPIEN by accident, you might have to resort to HV programming. Here is some info on recovering a bricked AVR: http://www.larsen-b.com/Article/260.html
Note that I have set hfuse = 0xdb, which disables the JTAG interface. This makes more I/O pins available (in particular, some of the pins exposed on the I/O headers of Printrboard). If you want to use a JTAG programmer, you should instead set hfuse = 0x9b.
Once your fuses are set correctly, use avrdude with your programmer to upload the bootloader. After your bootloader is installed, you don’t need to use the programmer anymore – just a USB connection is enough.
Booting into Bootloader
Once a bootloader is installed (see instructions below), the bootloader must be activated when you want to upload firmware. To boot the AVR into the bootloader instead of normal program code, you must tie the HWB pin to ground during a RESET pulse. To to this on Teensylu or Printrboard, simply remove the 2-pin jumper that’s next to the AT90USB1286 chip, then press and release the reset button. You can then replace the HWB jumper.
NOTE: If you have a Printrboard RevD, the jumper has been reversed, and needs to be INSTALLED to get into the bootloader, and REMOVED to run your firmware.
Below, I describe how to install and use each of the bootloaders. For Arduino IDE integration, use BootloaderCDC. I also like BootloaderHID, because it doesn’t need drivers, and doesn’t require selecting a virtual serial port.
Download and install FLIP. FLIP will also install the device driver.
Install with avrdude: avrdude -c usbtiny -p at90usb1286 -U flash:w:BootloaderCDC.hex:i (note if using a usbtiny and avrdude complains of a verification error at byte 0x1f000, ignore it)
To flash hex files, you’ll need a newer version of avrdude than the one included with Arduino < v1.0. The version I use is 5.10. After Booting into Bootloader (the first time, Windows might want a driver … point it to the INF file that I included) , type: avrdude -c avr109 -P port -p at90usb1286 -U flash:w:firmware.hex:i, substituting your Printrboard’s CDC serial port for port, and the name of your hex file for firmware.hex.
If you want to flash directly from the Arduino IDE, follow my instructions for installing my at90usb1286txt.zip files into Arduino. Then, after restarting Arduino and Booting into Bootloader, select [BootloaderCDC]Teensylu/Printrboard from the Arduino Tools->Board menu. Then select the serial port associated with your board. Hit the Upload button in the Arduino IDE to compile and upload your sketch.
Install with avrdude: avrdude -c usbtiny -p at90usb1286 -U flash:w:BootloaderHID.hex:i (note if using a usbtiny and avrdude complains of a verification error at byte 0x1f000, ignore it)
To flash hex files, after Booting into Bootloader, type: hid_bootloader_cli -mmcu=at90usb1286 -w -v firmware.hex, substituting the name of your hex file for firmware.hex. I’ve included the Windows binary. For Linux or OSX, you can build hid_bootloader_cli yourself from the LUFA sources.
NOTE: When uploading a bootloader to the AT90USB1286 using a USBtinyISP, you will get a verify error from avrdude. You can safely ignore it. The problem is that the USBtinyISP has a bug with reading flash memory above the 64K (10000h) boundary. However, it can write it without problems.
If you want to use your RepRap for CNC use, such as milling PCB’s, regular 3D printing firmwares might not be ideal. For instance, Marlin is not able to handle the slow step rates used for CNC work.
I have ported grbl, a firmware specifically for CNC use (from which Marlin derived its acceleration routines), to Printrboard and Teensylu. You can download it from my fork at: https://github.com/lincomatic/grbl.
I spent this past weekend porting Repetier-Firmware to Printrboard and Teensyduino. It took me a while to get it working properly, because the code intermixes calls to fastio and Arduino, and the pin definitions in fastio.h were different from the Teensyduino Arduino library. It is now working pretty well, so Printrboard and Teensylu users now have yet another option for RepRap firmware. I’ve already submitted my changes to Repetier, and he’s merged them into his code. Download it here: https://github.com/repetier/Repetier-Firmware.
In case you haven’t tried it, Repetier also has an interesting host program, Repetier-Host, which works with other firmwares as well as Repetier-Firmware.
As of this writing, the official version of Marlin firmware from github does not yet work with Printrboard. Printrboard is a fork of Teensylu, designed by the folks at Printrbot. Printrboard isn’t yet available for purchase, but since the design is open source, anyone can download it and get the PCB’s manufactured themselves. Sprinter is currently the only RepRap firmware works with Teensylu and Printrboard out of the box. I am now successfuly running Marlin on my Printrboard. Below is a video of Printrboard virtually printing a Printrbot with Marlin:
Last month, I submitted an issue with ErikZalm to get the compile errors fixed when compiling Marlin for Teensylu. The main branch of Marlin now compiles for Teensylu by setting MOTHERBOARD = 8. Unfortunately, this build setting won’t work with Printrboard, because some of the pins are different. Also, there is a kill function that Marlin calls if it detects certain things like a shorted thermistor, etc… but it’s not able to send the error messages back to the host, so it looks like your board is just dead.
I think Erik is too busy right now getting V1 out the door to deal with making fixes for a couple of not so popular boards, so I’ve forked Marlin on github with my fixes for making it behave nicely with Teensylu and Printrboard. You can download it here: lincomatic/Marlin.
For Firmware Hackers Only
For those who want to know what’s special about my branch of Marlin, it has to do with the mappings of the I/O pins. The code in Marlin has two different ways to access digital I/O pins: 1) the Arduino digitalRead/Write() functions 2) fastio – there are macros and pin assignments in fastio.h. In ErikZalm’s Marlin branch, the pin numbers are different between Arduino and fastio functions, which leads to confusion and bugs. What I have done is use the digital pin definitions in Teensyduino’s core_pins.h and updated the pins in fastio.h to match them. This way, a call to digitalRead(28) is equivalent to _READ(28).
in pins.h, analog pins use ADC numbering instead of digital pin numbering. Therefore, even though B_THERM -> F0/ADC0 and E_THERM -> F1/ADC1, we are using them as ADC pins, so B_THERM=0 (ADC0) and E_THERM=1 (ADC1).
Printrboard uses some pins that aren’t supported by Teensyduino, since they aren’t exposed in the Teensy hardware. Therefore, those pins aren’t listed in core_pins.h. I have added them to fastio.h, so they are accessible only with fastio macros. They are digital pins 46 and 47 see the “//– Begin not supported by Teensyduino
” section of fastio.h
XSTEP = physical pin 51. Looking at the AT90USB1286 spec sheet, pin 51 = PA0 (AD0)
in core_pins.h, #define PIN_A0 28
X_MIN = AT90USB1286 pin 9 = PE3
core_pins.h doesn’t have a definition for PIN_E3, because the pin isn’t accessible in Teensy++, so we can’t talk to that pin at all with the Arduino functions. However, it’s in fastio.h:
//– Begin not supported by Teensyduino
//– don’t use Arduino functions on these pins pinMode/digitalWrite/etc
#define DIO47_PIN PINE3
#define DIO47_RPORT PINE
#define DIO47_WPORT PORTE
#define DIO47_PWM NULL
#define DIO47_DDR DDRE
My first step in loading Marlin RepRap firmware into the Printrboard is to get Arduino to play nicely with it. The method I am going to describe in this article for programming a Printrboard with Arduino will work with the Teensylu or any other device that uses the AT90USB1286 and has an ICSP connector. The programmer we are going to use is a USBtinyISP or compatible. Since the AT90USB1286 isn’t officially supported by Arduino, it takes a bit of setting up to get things working properly.
I first looked at the instructions on Teensylu’s page in the RepRap wiki, but found them very confusing, and I didn’t like the idea of having to send the HEX file to the MCU using an external utility instead of doing everything within the Arduino IDE. So, I set out to streamline the process and document it as I went. If you follow my method below, you’ll be able to compile and download your firmware all within the Arduino IDE.
Step 1: Download and install Teensyduino
Teensyduino was created by PJRC for their Teensy line of boards. Teensy is a great alternative to Arduino if you want an ultra compact board with built in USB. The Teensy++ happens to also use the AT90USB1286, so it’s compatible w/ Printrboard/Teensylu. Follow PJRC’s instructions for installation from the download link.
If you only plan to program for RepRap, you don’t need to install any of the libraries. On Windows, you will be prompted to install the serial driver. Select yes. You don’t have to worry when Windows complains that the driver is unsigned… it’s just an INF file to tell Windows to use one of its own built-in drivers.
Step 2: Modify Teensyduino Configuration for use with USBtinyISP
Navigate to where your Arduino files are located. On my computer, I have them in d:\arduino-0022. We will call this <arduinofolder>. Now, find the subfolder where the Teensyduino library was installed:
If you are in the correct folder, you should already see a boards.txt and a subfolder called core in there. Drop the files from at90usb1286txt.zip into that folder, overwriting the existing boards.txt. You should see something like this:
If you don’t plan to develop with any of PJRC’s Teensy or Teensy++ boards, you can keep them from showing up in your Arduino menu by copying boards.txt.nopjrc over boards.txt.
Now, when you start Arduino, you should see some new configurations in the Tools->Board menu. The important ones are:
To use a USBtinyISP programmer, select either [usbtinyisp]AT90USB1286 or [usbtinyisp]Teensylu/Printrboard. The only difference between the two configurations is that I took the extra useless options out to make things simpler when programming Teensylu/Printrboard. The Teensylu/Printrboard option is the same as the AT90USB1286 option with USB Type = Serial and CPU Speed = 16MHz.
At this point, you can plug in your USBtinyISP and into your AT90USB1286/Teensylu/Printrboard and start programming!
So what are the [BootloaderCDC] configurations for? They allow you to download sketches into your target board directly through a USB connection to your host, without the USBtinyISP programmer. See my next article for details on how to do that.
Update 20140909: I have uploaded a copy of Arduino 1.0.5-r2 for Windows to github, which is already modified to work with the AT90usb1286, so you don’t have to modify it as above. Simply go to https://github.com/lincomatic/arduino-1.0.5-r2-at90usb1286 and click the Download Zip button, and then extract the contents to your PC. My distribution also supports the USBasp in addition to the USBtinyISP.
I have been somewhat intrigued by the RepRap project, an open source 3D printer movement, for several years. However, wasn’t motivated enough to jump into the fray until late last year, when I saw Brook Drumm’s Printrbot on Kickstarter.
With only about 1 hour left before funding closed, I pledged $500 to get a Printrbot kit. While I could have started from scratch, and built a Prusa Mendel, after reading about how much tweaking is involved in building and setting up a RepRap, I decided to start with a Printrbot – a cute, compact, and simple design, and the most inexpensive RepRap at the time. Printrbot’s Kickstarter was a smashing success. They raised an astonishing $830K. Unfortunately, the gigantic amount of orders they received means that mine will take a little longer to get to me than I originally anticipated. So, I’ve been immersing myself in the intricacies of the electronics, firmware, host software, and mechanical aspects of RepRap for the past couple of months.
There are a variety of popular controller electronics for RepRap, the most popular being RAMPS. The electronics are one of the largest costs of building a RepRap. Although RAMPS is convenient, because it’s based on an Arduino Mega, I like the idea of having a single dedicated board. The Printrbot folks have designed their own controller board, which they call Printrboard. Although Printrbot is not yet selling Printrboards, the design is open source, and thus, I was able to obtain one before their release.
Kang, a fellow RepRapper from Seoul, Korea, built a few Printrboards and sent me one to play with.
Printrboard is a fork of Teensylu, an AT90USB1286/AT90USB1287 based RepRap controller. I like the fact that these boards are based on the AT90USB128x MCU’s because they have built-in full USB support, eliminating the need for an external serial->USB bridge IC; additionally, the native USB support means that communication with the host computer is blazingly fast – 12Mbps rather than 115200kbps.
There are a few notable differences between Printrboard and Teensylu. Printrboard is a single board solution. First, Printrboard adds an integrated SD card reader. This is handy for printing while untethered to a computer. Teensylu has I/O pins which can be used to easily add an SD card reader.
Second, the stepper motor drivers are integrated onto Printrboard’s PCB, while Teensylu uses plug-in Pololu/Stepstick carriers. The advantages of integrating the stepper drivers onto the main PCB are reduced cost and compactness. The downside is that it is not uncommon to blow up a stepper driver IC, so having them soldered in means if one goes bad, the whole board is unusable.
Third, Printrboard uses Allegro A4982’s in a 24-TSSOP package, while Pololu/Stepstick use the Allegro A4988 in a 28QFN package. The TSSOP package is considerably larger, and has a wider pin pitch, which makes reworking the board easier if one of them blows out; the 28QFN is very tiny and not for the faint of heart. The other difference between the A4982 and A4988 is that the A4982 only supports full/half/quarter/sixteenth stepping, while the A4988 also supports one eighth stepping.
Some other minor differences between Printrboard and Teensylu are that while Printrboard only supports a 12V2 ATX power input, Teensylu gives more power options. Also, Teensylu has a large USB-A socket, while Printrboard uses a micro USB-B socket.
I am diving into figuring out how to load Marlin RepRap firmware into Printrboard/Teensylu, to keep my end of the bargain with Kang. A series of articles will follow with my findings.