Lines and Arcs

When I started reading up on G-Code I noticed that, as well as straight lines, it could also define arcs and circles. I also noticed that the G-Code produced by Easel only contained short line segment, and no arcs at all.

My assumption was that this was an arbitrary limitation of Easel, and I wondered if there was any way to fix this.

I found a very clever python script called g1tog23.py written by Frank, which takes a G-Code file containing line segments, and where appropriate converts lots of contiguous line segments into an arc or circle. I tried this on a test design of five interlinked circles. It seemed to work, so I then tried sending it to the X-Carve.

The first problem was that the python script had inserted lots of A0.0000 commands. I couldn’t find this command on my g-code cheat sheet, so I have no idea what it’s supposed to do. Neither did the g-code interpreter on the X-Carve, which rejected it as an ‘Unknown Command’. So I simply stripped them out.

The next problem was that instead of drawing arcs, the X-Carve was drawing straight lines from the start and end position of the arcs. This was unhelpful.

Reading up some more on g-code, I learned about G64. This command is used to specify how accuratly arcs should be drawn. Without it, when you ask the interpreter to draw an arc, it draws a straight line and says “that’s close enough”. G64 is used to say “That’s not good enough, I want no more than n units of deviation from the arc”.

The interpreter does not support the G64 command.

But it does support G61! G61 means “No compromises! I want my arcs as accurataly as possible”. So once I manually issued that command before running the g-code, I got beautiful arcs and circles.

I discovered later that it’s actually quite common for G64 not to be supported, especially on single board computers, because the calculations involved are to intensive. It’s more common for the g-code generator itself to do the calculations to convert from arcs to line segments. That is clearly the reason why Easel is producing the g-code that it is.

It was disappointing that the result took just as long as carving without arcs. Disappointing, but obvious in hindsight. The bottleneck isn’t sending commands, or interpreting them, but doing the physical carving.

But using this script does mean that the size of the g-code file is drastically reduced, typically by about half. It could be worth using just for that reason.

And at least I’ve learned a lot more about g-code.

 

Universal G-Code Sender

Easel worked pretty well with our new X-Carve, but it only runs on OS X or Windows, not on Linux. We didn’t want to keep our nice Mac laptop in the workshop, and I don’t have anything running Windows, so I looked around for a Linux solution.

I found the Universal G-Code Sender. This is a simple (ish) Open Source program written in Java that supports, amongst other things, Linux, and will send G-Code commands to the X-Carve.

Easel has the option to export G-Code to a file instead of sending directly to the X-Carve.

So our workflow is now:

  • Design using Easel on the desktop Mac in the office
  • Export G-Code
  • Load G-Code into UGS running on a cheap Linux box in the workshop
  • Use UGS to send the code to the X-Carve.

There were a few minor problems to overcome. The G-Code that Easel generates does not include a “Set Home” command, nor does it start the spindle. It also generates absolute rather than relative paths. These problems were easy to solve by manually sending the relevant G-Code commands with UGS before loading and sending the G-Code file to the X-Carve.

The commands are:

G10 L20 P0 X0 Y0 Z0        to set the home position

M3 S12915                              to start the spindle

 

X-Carve

So, we took delivery of an X-Carve a couple of weeks ago, and since then I’ve been learning all about CNC machines, g-code, CAM/CAD packages, USG and GRBL. It’s been a fairly steep learning curve.

It arrived in kit form while I was away for the weekend, but by the time I got home, Jenny had already put it together and got it working, leaving me to play with software.

The software that comes with it, and is recommended and supported, it Easel. It’s a fairly straightforward browser-based program that is pretty intuitive, and does everything. It lets you do the design (CAD), specify bit size, depth of cut, speed of cutting, and so on (CAM), and then generates g-code and sends it to the X-Carve. It’s not bad, and it works. For fairly simple designs.

It runs on Windows and OS X. Linux is not supported.

IMG_0077The first thing I tried to create, after the demo and test designs, was a big circular sign. In hindsight, this was clearly running before I could walk. Still, it worked pretty well. I used MDF for the first attempt, because that was all I had available. Lessons learnt: don’t try detailed carving with MDF, it doesn’t work. But as a proof of concept it was a success.

I tried the same design on hard plywood, and the results were better with clearer and crisper edges. The design could still do with some tweaking, but Easel and the X-Carve worked well, if slowly. The design covered about 600 x 600 mm and took around 18 hours.

The next problem I hit was file size and Linux compatibility. But that’s for another post….

Python

I’ve spent the last ten years writing mostly in Perl, but I’ve just recently started using Python (yes, I’m late, I know)

I like it. So far at least, it seems cleaner and neater than Perl, easier to read, and there seems to be at least as many libraries available as there are for Perl.

Installing WordPress

Well, that was more effort than I expected.

At first, it seemed to go well. The installation went very smoothly and very quickly, and I had a multi site WordPress using subdomains up and running in no time.

Then I tried to use it.

The first problem was when I tried to write a post, and discovered that the text colour was set to white text on a white background. Some googling and some poking around with the Safari debugger showed me how to fix that by hacking the editor.min.css file.

The next problem was trying to change the header image. When I uploaded a file it went to one directory. When I tried to use a file it looked in a different directory. So uploading an image “worked”, but I wasn’t able to use it.

I finally fixed that problem with a lot of experimentation and some clever symbolic links.

It seems to be working now (so far at least). But dammit – I thought WordPress was solid, reliable, tried-and-tested software? Why does it seem so buggy? And how on earth do non-programmer who don’t know how to hack css and create symbolic links manage to use it?