Wednesday, 29 August 2012

NC drill file format - origin is bottom left

So far we've been working with screen co-ordinates, with the origin (0,0) at the top left. But when reading/parsing NC drill files, the origin seems to follow cartesian co-ordinates with the origin in the bottom left (like you get when drawing a graph on a piece of paper).

So a quick hack later and our software now starts with the dot nearest the bottom-left-hand corner of the board


It then prompts to move the drilling head to the top-right-hand corner hole


And calculates a cutting path from the current hole (the top-right) back, not necessarily to the origin, but in a way that passes through each hole.


When the cutting head reaches point A, the general rule to follow is "move to the nearest undrilled dot". If we were doing this job manually, we'd probably go from point A to point E, continue working up the board, then move to the left and work our way back down again.

But that doesn't actually follow the "move to the nearest dot" rule. From point A, the nearest dot is point B, so that's the path that's taken. Now at point B, point E is still further away than one of the other, non-drilled, points. So the head moves to point C instead. When it gets to point D, however, the nearest undrilled hole is point E, so the cutting head moves there and continues in a more predictable pattern.

We could probably "iron out" these peculiar movement patterns by looking ahead more than one hole at a time, but that's an awful lot of work for something that we've not even tested yet! For now, we'll live with a few quirks until we've seen it actually drill a PCB board!