G-Code importing, and a bit of calibration help. Controller v1.2

I am generally filled with forboding about adding features to the Polargraph Controller. I remember it as being a twisted and unstructured wild-west kind of program. However, whenever I actually get into coding in it again, I always regret my fear, because I get something really useful done, in a really short length of time. Last weekend was no different.

Download the result: Polargraph v1.2 code bundle, or read on… If you dare.

G-Code importing

Polargraph exemplar Kongorilla has made a number of not-so-subtle hints about the impediments he runs into in getting stuff prepared for drawing. There’s a workflow that is sometimes fairly tortuous, even if it is logically straightforward. The controller has only been able to import SVG files, so a run through inkscape has always been the last step for most people.

IMG_20150519_172018910

The load vector dialog now allows .gco and .g files too, so anything that emits g-code files is also now a contender. Now, it’s fairly simplistic, understands only G0 and G1 commands, and the Z-axis implementation is rudimentary, but it does mean that it can swallow the output of wonderful things like Dullbits’ beautiful Death-To-Sharpie sketch.

The Z axis automatically makes a choice about when the pen is up or down. The very first Z axis change is ignored, and the second one is used henceforth as the “down” (drawing) position. Any position other than that second position is considered a travel (non-drawing_ position. This is because dullbits has Z1.0 as it’s drawing position and Z0 for travel, whereas inkscape(‘s gcodetools) seems to have Z-0.125000 as it’s drawing position, and moved to Z5.0 for travel. So opposite directions.

Usually the first Z movement is to shift into travel mode, in order to safely get to the start point, and then the second Z movement is to drop the pen / tool. Scripts that have funky stuff going on in their Z movement might need a bit of manual editing to work.

It’s immediately become obvious that .gco is not a standard enough file extension, so I’ll change it to .gcode as well for the next release. For now, just rename the file.

Preview cord offset

A commonly reported problem is that a drawing is short and fat, or tall and thin, or has a curved top or bottom, or it’s sides diverge.

There is a page about this in the Polargraph wiki, but it’s quite hard to diagnose, and hard to explain in words. I added this extra feature to the queue preview that allows me to simulate common calibration errors.

The way I imagine this being used, is:

  1. Draw a shape. Oh no, it’s all wrong!
  2. View the command queue in the controller app. It looks right here!
  3. Adjust the preview cord offset until it the preview matches what happened on the paper.
  4. Look at the value of preview cord offset. If it is:
    1. Positive: Your home point is further from the sprockets than you’ve told the machine. This might mean your home point is actually further down than you’ve measured, or your machine is wider than you’ve measured.
    2. Negative: Your home point is closer to the sprockets than you’ve told it. The home point might be higher up the machine than you have measured, or your machine is actually narrower than you’ve measured.

Firmwares

Polargraph_server_a1 has been updated to v1.2, and while there is no new functionality for UNO owners, I have merged the old MEGA-only features in, and made them configurable at compile time. So you can use polargraph_server_a1 on a MEGA, and get the SD card reading, norwegian pixel, spiral pixel etc. I actually fully expect this to have broken a load of stuff, so please take care, and report bugs.

In other news, I’ve also been working on porting the Controller to Processing 2, but that’s not borne fruit quite yet.

Download the code: Polargraph v1.2 code bundle