Vision 3D Printer – First Print

So you have the printer built and the software installed, now for the leap into printing with it.

Turning It On

Before you turn on the printer, double check the wiring one more time. Make sure the colors of the cables all line up (I had an endstop with a plug that was backwards and shorting the board). Here is the RAMPS wiring diagram again.

Ok, time to turn it on. You should see lights turn on flash on the arduino and RAMPS boards. If you don’t (or they instantly turn back off), unplug the power immediately. Your wiring could still be wrong and you might have either a short or a disconnect.

Debugging Wiring Problems

Debugging these problems can be painful if your not an electronics wiz. My best advice is to use a volt meter with a conductivity function (it beeps if the two probes touch). In this mode can you touch the different pins on the board and make sure that they are connected if they are supposed to be and not if they shouldn’t. Starting from basic things like power and then moving on to the peripherals is they way I normally work through the board.

If the problem isn’t obvious from above, you can also try unplugging everything and then one by one start adding the components back until either you find the problem component or until you have everything plugged in and working (remember to turn off the power each time you add something).

Making It Move

The board may power on, but you are still a ways off from being able to print. I recommend testing out your firmware configuration by using pronterface. Open pronterface, select the usb connection, an click connect. Once you have a connection, be prepared to turn off the power. Click the auto-home button, and if the motors start moving the wrong way, kill the power quick. You’ll want to make sure you leave enough room on all 3 axis so that you have time kill the switch before the motors start driving the axis too far one way.

Some common problems you may encounter at this stage are:

  1. Axis moves the wrong way (invert the direction in the firmware’s Configuration.h)
  2. Axis doesn’t move, but motor makes noise (turn up the gain on stepper driver)
  3. Motors don’t stop after hitting the end stop (invert the endstop in the firmware’s Configuration.h)
    1. Also, it is good to test the endstops by hand. Center the axis, push the endstop switch by hand, and then tell pronterface to move the axis towards the endstop. Make sure it moves when the endstop is open and doesn’t when it is closed.

Another useful trick is to loosen the pinion gears on the stepper motors so that you can test their movement with out actually moving the axis.

First Print

Turn on the heated bed and extruder heater in pronterface. The extruder should heat up quickly, but it may take several minutes for the bed to fully warm up. Once the extruder is at temp, move the z-axis up a few cm, and extrude some plastic via pronterface. It may take several cm worth of extrusion length before anything comes out. Make sure the filament is also moving the right way ūüôā

Assuming you have a model in gcode (see slic3r below), load it in pronterface and click print. If you make it through the first layer, consider yourself lucky. Also, try printing something really simple like a cube first. This will make it easier to see what is going wrong. There are many problems that you are likely to encounter at this stage:

  1. Nothing comes out of the extruder
    1. Sometimes, it just takes a little extra extruding before anything comes out (even after you just finished getting it to work). This is because extruders tend to ooze a little while they are idle. (Try adding a 1 layer skirt in slic3r.)
    2. Your temp sensor might be reporting incorrectly. (Make sure your temp sensor is correctly set in the firmware’s Configuration.h)
  2. The filament is too thick on the plate (Your z-axis 0 is too low. You can move the endstop or adjust the Z offset in slic3r)
  3. The filament instantly curls up off the plate. (Your Z-axis 0 is likely too high. Same solution as above)
  4. The filament height and thickness look right, but your part doesn’t stick, or starts to peel after a few layers. (Assuming you are using ABS, Try the ABS juice from Matt’s video. You really can’t add to much to the plate. I haven’t printed with PLA yet)
  5. The nozzle tears the tape on the printer plate. (Your z=axis 0 is too low. See above)

Got another problem? Let me know and I can add it ūüėČ

Slicing Your Model

You can spend a lot of time tweaking slic3r settings. In fact this topic alone is too long for me to write about. Try starting off with a tutorial like this one. I’m also a firm believer in using the latest version of slic3r. Some people advise that older versions work better, but I have not seen that to be true. In fact, with every new version there are many bug fixes and enhancements. Slic3r is only getting better and better.


Python: os.walk vs linux find

AKA: Why Python needs a find module

I found myself needing to scan and modify a bunch of files (300k) for a really large project. The modifications were too complex for a perl or sed one-liner, and I thought Python would be good for quickly coding all the logic. But as I started iterating on my script, I found it to be very slow when traversing through the project’s files. I was using find on the command line to look up which files I expected to see changes in, and I noticed it was pretty fast, almost 10x faster than python, so of course I was like WTF? Long story short, find¬†is very fast, and well, os.walk is not. Below are some performance comparisons I made of different ways of scanning the files in python vs find.

Test Setup

All my testing was done with the same directory of files, and I ran each test 4 times (discarding the first run). In other wards, all the filesystem caches were warmed and then I ran each test 3 times. I used the following script to profile the performance:

> cat timeit 
ELAPSED=`echo "$STOP - $START" | bc`
echo "Elapsed Time: $ELAPSED" >&2

And the realtime executable is simply this c program:

> gcc -o realtime realtime.c 
#include <sys/time.h>
int main(void) {
    struct timeval time_now;
    printf ("%ld.%d\n",time_now.tv_sec,time_now.tv_usec);
    return 0;

Matching Files in Python

As I noted above, scanning files is pretty slow in python. Here is a quick performance comparison of the different approaches I tried:

Using the re module:

> cat 
import os
import re
pattern = re.compile(r'.*\.png')
for root, dirs, files in os.walk(os.getcwd()):
    for f in files:
        if pattern.match(f):
            print os.path.join(root,f)

Using the builtin string functions:

 > cat 
import os
for root, dirs, files in os.walk(os.getcwd()):
    for f in files:
        if f.endswith(".png"):
            print os.path.join(root,f)

Using the slice operator:

 > cat 
import os
for root, dirs, files in os.walk(os.getcwd()):
    for f in files:
        if f[-4:] == ".png":
            print os.path.join(root,f)


 command run1 run2 run3
¬†timeit find ./ -name “*.png” > /dev/null ¬†1.58 1.48 1.48
 timeit >/dev/null  21.33 22.10 21.41
 timeit >/dev/null  22.31 21.39 19.87
 timeit >/dev/null  22.15 21.24 20.87

Traversing Files

The previous results weren’t very telling other than python is slow. So this test is simply how many seconds does it take to print all the files in the project.

 command     run1  run2    run3
 timeit find ./ >/dev/null  1.61 0.80  1.26 
 timeit >/dev/null  20.69 20.79  20.85 
> cat 
import os
for root, dirs, files in os.walk(os.getcwd()):
    for f in files:
        print os.path.join(root,f)

Matching strings in Python

Lets do the same comparison, but without os.walk in the mix:

Using the re module:

> cat
import re
import files
pattern = re.compile(r'.*\.png')
for f in files.files:
    if pattern.match(f):
        print f

Using the builtin string functions:

> cat 
import files
for f in files.files:
    if f.endswith(".png"):
        print f

Using the slice operator:

> cat 
import files
for f in files.files:
    if f[-4:] == ".png":
        print f


 command  run1 run2  run3
 timeit >/dev/null  0.390 0.377 0.390
 timeit ends >/dev/null 0.276 0.271 0.277
 timeit >/dev/null  0.234 0.231 0.242

Final Thoughts

We now have a real measurable difference in python’s string matching options, but they are all pretty close. I’m not sure it matters to much which one you use. The real question I have is when are we going to get a “find” module for python. Something like the following would be great:

'''find module'''
def search(path, expression, callback=None):
    searches the given path for the regular expression passed in.
    @param path: path to search
    @param expression: regular expression to search with
    @param callback: (optional) callback to be executed every time a file is found.
    The callback should accept a filename as the only argument
    @return: iterator for all the matched files

# Usage:
import find
for f in"~/Music", ".*\.mp3"):
    print "Mp3:", f

Installing Silhouette Connect for Illustrator on OSX

I have a Silhouette SD (recently replaced by the portrait). Its a great little paper/vinyl cutter, but the software it comes with (Silhouette Studio) isn’t all the great for working on complex designs. I much prefer to work in Adobe Illustrator, and until recently I had a pretty good setup working. Then came OSX Mavericks…

Silhouette SD, Adobe Illustrator, and OSX (pre Mavericks)

While it isn’t advertised, it turns out that the Cutting Master 2 plugin (download here) for Illustrator works with the Silhouette SD. This means you can directly cut from Adobe Illustrator! After a little trial and error, I found that you just have to pretend like you own the CC300-20 cutter.

UPDATE: Oh look, and now they advertise this works. I wish they posted this 2 years ago.

Silhouette SD, Adobe Illustrator, and OSX Mavericks

After upgrading to OSX Mavericks, Cutting Master 2 stopped working. No big deal, this happened with Lion. I’ll just download the latest… Oh, and that doesn’t work either.

In the mean time, Silhouette Connect was released! Its actually a much nicer version of CM2. The interface is great, and it has the same cutting settings that Silhouette Studio offers and the layer and color settings of CM2. Woot! Well worth the money.

Silhouette Connect can’t find Illustrator

I have all my Adobe software installed into a folder called “Adobe” inside of Applications. This is not the standard location and sadly the Silhouette Connect installer can’t be pointed at it directly (lame). No problem I thought, I’ll just create a symlink from where it would normally get installed. No luck ūüė¶

Yup, another win for Silhouette America. Why am I always hacking their products to get them working?

After much debugging, which included modifying dtruss to redirect its output to a file of my choice (wow strace is nicer (ye, yes, ¬†dtrace is even more badass)), compiling a program that maps .vol files to their normal path, and compiling a program to create hard links, I was able to figure out and solve the problem.¬†It turns out that the installer lists all the contents of /Applications/ looking at their filetype and symlinks are only being seems as “symlinks” instead of being resolved to their src directory. So what we really need is a hardlink.

  1. Copy and paste the hardlink code from this stack overflow answer into a file called hardlink.c
  2. Open the Terminal App and inside it run:
  3. > gcc -o hardlink /path/to/hardlink.c
  4. > ./hardlink /Applications/Adobe/Adobe\ Illustrator\ CS5 /Applications/Adobe\ Illustrator\ CS5
  5. Re-run the Silhouette Connect installer. It should find Illustrator this time!

Cracking password protected zip files on OSX


It seems silly to me that someone would give me a zip file but not the password to open it. I have all of the data, just not the ability to easily read it. So why send the file at all?

Regardless of the answer, this was a fun opportunity to learn a little about John The Ripper (JTR or just ‘john’). There are two versions of john. The normal release and the community “jumbo” release. So which do you use? It depends on what you want to do. Each has a different set of non-overlapping features, and the docs are not always clear on which does what. For the rest of this post I will specifically guide you through using john on OSX to crack a zip file.

Where Do I Begin

Zip support currently only exists in the jumbo release of john, so thats the best place to start, but right away you might notice that by default john is single threaded. Is there a mac today that isn’t multi-core? Cracking can take a long time, so we’ll want to use as much of the CPU as possible to make it faster. Luckily for me, the jumbo release supports OpenMP which can make parts of the program run in parallel.

Sadly for me, OSX Mavericks does not support OpenMP out of the box.

Why Sometimes I Hate My Mac

If only I ran linux, this would be so much easier. Of course many other things would be so much harder, but really Apple?

To build john with OpenMP, I need a modern version of gcc which Apple does not provide. In fact, I’m about to spend the next few hours setting up development environment just so I can build john.

  1. Download and Install Xcode via the AppStore (and grab a snickers, cause this is going to take some time)
  2. Once thats working, install the command line tools:
    1. open a terminal & run:
    2. > xcode-select
  3. If you are me, spend the next 1.5hours debugging why xcode-select doesn’t run (my Xcode install was totally messed up. It seems like some previous version didn’t get fully uninstalled and my environment was a mix of the two)
  4. Now download and install macports
  5. In your terminal, install gcc4.8 via macports (this will also take a long time):
    1. >  sudo port install gcc48
    2. >¬†sudo port select –set gcc mp-gcc48
    3. > hash gcc
  6. OMG, 4 hours later, I’m finally ready to start on the actual project!

Setting Up John

UPDATE: As Mems pointed out below in the comments, you can just grab the jumbo version of john from macports as well (I’m assuming it is also built with openmp support):

> sudo ports install john-jumbo


Or you can compile it yourself and fiddle with more optimizations (which is likely unnecessary):

  1. Download and untar john (jumbo)
  2. Back in the terminal go to the john directory:
    1. > cd /path/to/john/
    2. > cd src
  3. Open the Makefile and uncomment this line:  MPFLAGS = -fopenmp -msse2
  4. Now build john:
    1. > make clean macosx-x86-64

Running John

UPDATE: If you installed john from macports, the tools below should already be in your path. See Mem’s comments below…

Before we can start cracking, we first need to setup an input file for john:

  1. > cd ../run/
  2. > ./zip2john /path/to/ > zip_hash.txt

Potentially the fastest way to crack the zip file is to use a dictionary attack. There are a lot of dictionaries/wordlists online, and john can iterate through them and through variations on the words in the list. Skull Security has a nice set to get you started. After you have downloaded one, then you can start running john:

  1. > ./john –wordlist=/path/to/wordlist.txt zip_hash.txt

If this doesn’t work, you can try brute forcing the password:

  1. ./john zip_hash.txt

Other features worth mentioning:

  • John might take several days (or even weeks) to crack the password. You can safely stop it at any time by hitting Ctrl-C. When you are ready to resume again, add the “–restore” option and restart john. It will pickup from where it left off!
  • It may not look like john is doing anything once you start it. Hit enter/return in the terminal and john will print the current status of what it is doing.
  • The activity monitor can show you how much CPU john is using. It should be more than 100% if openMP is enabled.