Thursday, January 16, 2014

3D Editing the Hard Way

Last spring I was digging around Thingiverse, looking for cool things to print, and came across Dizingof's version of a Klein bottle. It was good timing; a week later he decided to remove all his models from the site, but it was also at a point in my 3D printing experience where such a complex print seemed far too difficult.

In the intervening months, the file sat on my hard drive, up until this week when I finally decided that we'd done enough printing, tuning and fixing to attempt it. I fired up Slic3r, tweaked the config a little to drop down to 0.2 mm layers for all the fine details, and exported the file. This took some time. The result was a 34.5 MB file; I uploaded it to the OctoPrint instance controlling the printer, crossed my fingers, and pressed Print.

The initial result was disappointing. I watched the printer make something that looked very much like this:


The solid line is a double skirt, which simply gives the extruder time to start extruding (double because this printer has a Bowden tube, so it tends to drool a bit while heating up). The little blue dots are the beginning of the print, but they're very small, and oddly asymmetric. And then the Z axis went up a step, and printed this - or tried to:


That looks a bit thin but more like what I expected, albeit with a serious problem: most of those dots didn't have anything underneath them, and the printer was dutifully trying to print them in mid-air. That doesn't generally work. I killed the print, and set about figuring out how to fix it.

The simulated print pictures are from Repetier-host, which lets you step through a print layer by layer. The next two layers were loops and circles but I found a nice solid ring at layer five:


That's what I wanted to have for my first layer, but it was already a millimeter in the air.

Keeping in mind that this is a piece of sculpture rather than a machine part, I didn't have any qualms about modifying it a little to make it print better. I'm sure there are ways to slice off the bottom millimeter of the STL in Meshlab or Netfabb or some other program that I don't know how to use, but I was looking for something I knew, and it would be nice to avoid having to re-slice. Did I mention that the slicing process was slow? I actually left it running overnight, so I'm not sure how slow, but I really wanted to avoid reslicing. So I opened up the .gcode file in my favorite editor, vi, to see what I could do.

I should stop here and point out that there's no need to use vi for this task. Use anything that can edit a text file without adding formatting and font changes and paragraph styles; something that advertises itself as a "programmer's editor" or "text editor" will likely work. The biggest advantage of vi for this task is the ability to repeat a command a specified number of times, which comes in handy a little later.

The first few lines of the file are comments, laying out how Slic3r was configured. The next few are a kind of preamble, with calibration, temperature settings for the heated bed and hotend, etc. I was looking for the first lines that commanded the printer to move, using the G1 command:

G1 F1200.000 E-3.00000
G92 E0
G1 Z0.200 F7800.000
G1 X78.016 Y84.757 F7800.000
G1 E3.00000 F1200.000
G1 X78.736 Y84.197 E3.03034 F1200.000

The "G1 Z0.200" is key, that's where the printing actually begins. The first layer consists of everything between that line and the next move command for the Z axis:

G1 F1200.000 E0.04300
G92 E0
G1 Z0.400 F7800.000
G1 X89.870 Y115.575 F7800.000
G1 E3.00000 F1200.000

This print is using 0.2 mm layers, so every time a new layer starts the Z height jumps by that much. I can keep searching through the file for "G1 Z" and find the start of each layer; since I want the print to begin at layer five, I"ll look for when the height reaches 1 mm:

G1 F1200.000 E2.72067
G92 E0
G1 Z1.000 F7800.000
G1 X96.349 Y83.331 F7800.000
G1 X93.815 Y86.897 F7800.000

It happens to be line 4328. Jumping back to the beginning of the first layer, I note that it's on line 38, so I use vi's delete line command to get rid of 4289 lines between them. That gives me back-to-back Z moves, but I don't want the printer going up to 1 mm; I need it to stay at 0.2 mm and print the old fifth layer as the new first. So I have to fool it with another G-code command, one that Slic3r uses all the time for the extruder but never for the XYZ axes:

G1 Z0.200 F7800.000
G92 Z1.000 ; fool the printer into thinking that it's at 1 mm already
G1 Z1.000 F7800.000
G1 X96.349 Y83.331 F7800.000
G1 X93.815 Y86.897 F7800.000

This makes the second Z move command do nothing, but I've left it there as a place marker. Now I can upload the modified file, and watch as the print gets a nice, solid foundation.




For some reason the first layer is slightly different color, but that made it easier to photograph so I won't complain. I'm quite pleased with the finished product, too!


Incidentally, this trick of editing gcode can also be used to salvage a part that's gone bad, especially if it's mostly finished with just a little more to do, and the remainder is in one piece. You'll need a way to figure out which layer the printer was working on when it failed, probably by measuring the height of the partial print with your calipers. Then find the closest layer to that height by searching for Z moves, delete everything between the beginning of the first layer and that point, and use G92 to reset the Z height as above. With a little luck, and glue, you may save yourself a lot of frustration. . .

Wednesday, January 1, 2014

You Need a Vernier Caliper

... if you're trying to run a 3D printer, that is.

For the last couple of months our two operational printers have been spending most of their time printing parts for other printers; the OB1.4 has been especially busy since it can handle the larger parts, and has been upgraded with a heated bed to prevent warping (highly recommended, even if you only print PLA). But those parts are all done, so they've been looking for work. A couple of weeks ago I saw a jumbo-size geared heart printed by a friend, and decided that it would make a fine Christmas gift; I picked the PLA Heart Gears and put the OB to work. The first part looked great, and the next, but soon things started to go awry. The printer couldn't go more than a few minutes without the extrusion slowing, causing weak layers; sometimes it would stop entirely and ruin the print.

We'd had some similar issues printing the first GUS Simpson prototype, but I replaced the extruder with an improved version and a much better hobbed bolt, and since then had gone through three 2 kg spools of filament with no stoppages. So I started by tweaking the hot end temperature, then lowering the printing speed, trying to use shorter retractions, stopping retraction entirely, and a few other minor tweaks. Nothing really improved the situation, the print had failure after failure. I finally finished the heart late on Christmas Eve by editing the G-code files for two of the parts and printing just the portions after the jams, then gluing the pieces together.

Needless to say, this was very frustrating, not to mention painful - I had been babysitting the printer waiting for it to have a problem and my thumb was sore from trying to push the filament each time it began to jam! I knew that the printer wasn't having hotend issues, because every time I pulled back the jammed filament, cut it off and reloaded, it would extrude with very little pressure. After everything was done, I was determined to find the problem. I went back to the pieces that I'd cut off, the 30 cm or so that was inside the Bowden tube between the extruder and the hotend. It didn't look bad, but when I got out my trusty vernier caliper, here's what I saw. . .




When I first unwrapped this filament I measured it, as usual, and saw that it was elliptical rather than circular; that is, it was significantly thinner measured one way than the other. That isn't a good sign, but it also isn't typically a big problem, as long as the average cross-section is consistent. In this section of the filament however, the measurements at those two points were 1.43x1.55 mm, and 2.03x1.92 mm. Keeping in mind that this is supposed to be 1.75 mm filament, that kind of variation is no good - on several levels.

When an object is sliced, the extruder movement commands are calculated based on an assumption about the volume of plastic that will be extruded for each millimeter of filament pushed forward. I'd told Slic3r to expect a circular cross-section with a diameter of 1.75 mm, so the volume in a linear millimeter is 2.41 mm3. On this filament where it measures 1.43x1.55 mm, the volume is 1.74 mm3 (28% too low) and at the fat section, 2.03x1.92 mm, it's 3.09 mm3 (28% too high). Such wide variation is going to result in weak spots that can allow the print to split apart and blobs that can cause the nozzle to drag through lower layers and pull the part loose from the printbed.

But what was killing my prints was the fat section. Our OB uses a J-Head hotend (a real one, from the designer) and it is drilled out to 2.00 mm diameter. The extra diameter doesn't sound like much, but when I tried pushing that section of filament into a spare J-Head, it wouldn't go in more than a centimeter without a lot of force, and pulled a section of the PTFE liner out when I removed it. It wouldn't fit in an Aluhotend or a Ubis either. The problem is that if you make the inside diameter of the hotend large enough to accommodate these kinds of variations, the filament will kink and jam.

By the way, I'm not going to name the manufacturer of this filament, because I bought it almost six months ago and it's possible they've improved their product. It was purchased on eBay at a very low price, $27.99 with free shipping, so I thought it was worth a try, but I've since discovered that the seller (who is apparently just reselling from an overseas factory) offers no guarantees on the filament diameter, and even goes so far as to claim that if their filament doesn't work it must be the fault of the printer, not the material. So this filament is going in the trash. I will name some of the places where we've bought high quality filament: ProtoParadigm, MakerGeeks, Printed Solid and Printrbot. They're all more expensive than the eBay seller, as much as twice the cost, but the key is that their product works (and won't end up in the garbage can). And even with those sellers I still measure the filament before the first print, just to see. . .