Showing posts with label drilling. Show all posts
Showing posts with label drilling. Show all posts

Friday, September 21, 2012

CNC drilling machine - FINISHED!

With the new path finding routines in our CNC drilling software, and changes to the firmware to allow the user to manually jog the drill head up and down to get more precise alignment during initial set-up, we're finally happy to say that our cheapo CNC drilling machine is finally complete.
Or at least, complete to a state that we're happy to release for anyone else to have a go at making their own.

The last little part of the test was making sure that the machine could drill a PCB even when placed on the cutting bed at an angle. Here's a video showing exactly that:


The drilling is accurate enough for us now (there's still a little bit of play in the x-axis, but we seem to have done enough to remove/reduce any play in the y axis, even when the bed still needs to travel up-and-down in order to correct for the board being at an angle)

Here's the final board, as drilled in the video:


The holes on the bottom-right-hand edge may not be absolutely bang on, but they're good enough to make the board usable, and are about as accurate as you could get by drilling the board by hand. The photo seems to emphasise the amount of drift - it's probably less than 0.5mm away from the centre of the hole.

Having successfully completed a cnc drill test, we put the machine away!


We reckon our machine fulfills all the criteria set in the CNC drill challenge.

  • You can load NC compatible drill files to operate the machine
  • It cost less than �50 to build, completely from scratch with new (no salvaged) parts
  • It's accurate to within 0.5mm (despite the dodgy cheapo stepper motors)
  • The footprint is less than a sheet of A4 (in storage mode, it's about 210mm x 160mm)


It's been a long (and sometimes painful) journey, but it feels great to finally complete a project, not just to a point where it's working, but to be able to compare it to a list of criteria drawn up at the start, and to be able to tick every one off the list!

Along the way we were introduced to brushless motors and their servo-protocol control boards, created our own stepper motor control boards and our own USB-based protocol for moving them, and proved that rack-and-pinion gearing can be used just as successfully for CNCs as belt drives and leadscrews.

If we were to do the whole thing again?
Probably it'd look pretty similar. Maybe instead of a travelled bed-on-wheels we might use rails (similar to the x-axis) because there is a lot of play in the y-axis. But then again maybe not?

Any improvements?
Of course. Better stepper motors would be a great start. When energised, a stepper motor should have no movement in it at all - our steppers have 1mm-2mm of play because of the internal gearing. But then again, this does give us simple movement commands - no messing about with micro-stepping or any of that tricky stuff! We love the simplicity of the rack-and-pinion approach: belt-drives and leadscrews may be more popular, but we reckon we'd stick with ours.

The custom software is enough to make the device usable, but the protocol for sending x- and y- axis values is so simple that allow anyone else can write their own controller software. The latest firmware not only allows you to set a the number of steps to move in both x- and y- axes, but you can also now provide a "ratio" (for every three steps in x, move one in y for example). This means that if a vector line is broken down into enough parts, the machine could be modified to do simple milling - an idea that Justin from BuildBrighton is already working on!

Saturday, September 15, 2012

CNC software update

One of the main problems with getting absolute accuracy with our CNC drilling machine is overcoming backlash. We've loads of it. Not only between the cogs and the gears on our gantries, but inside the cheap little stepper motors too. Because the motors themselves are geared down inside, there's loads of backlash/slack on the actual motor spindle - and that's before any slack we introduce with our plastic push-fit rack-and-pinion arrangement to drive the axes.

All that said, we're still getting pretty good results, by compensating for backlash whenever we change direction in each axis (for example, whenever the x-axis gantry is travelling left-to-right, and we need to reverse it, to move right-to-left, we add in an extra number of steps to the move command, to take up any slack in the system).

Looking over our software, the "move-to-nearest-point" may make pretty efficient use of time, but because of the number of times we change direction over the course of drilling a board, there are plenty of opportunities for backlash/slack to affect our accuracy.

We've changed our driver software to use calculate different paths now.
Previously, it started at one point and simply picked the nearest undrilled point to the current location:


Now, we're going to move the head to the top-left-most point on the board, and drill them in a strict left-to-right, top-to-bottom sequence:


Although not shown on the screenshot, we're also planning on "overshooting" any point when moving the gantry from right-to-left, before moving to the correct location. The reason?

Doing things this way, we should help reduce (if not eliminate) backlash/slack in the y-axis, since the bed will only ever be travelling in the top-to-bottom direction. By overshooting each point when travelling from right-to-left, we're also ensuring that every hole is approached from the top-left corner so the system should be tight when travelling from top-left to bottom-right.

Hopefully this will help reduce the amount of backlash in the system, and produce a more accurate drilling action.

That's the theory taken care of.
The software is almost ready for testing.
There's only one thing left to do - and that's try it out!

Friday, September 14, 2012

CNC drill - more testing

Another Thursday, another post-Midnight testing session at BuildBrighton - this time we're trying to handle play in our cnc drilling machine which is still causing some of our boards to be drilling slightly off.
We managed to get the drill head spinning the right way, and slow down the servo movement (rather than just ram the drill bit into the cutting board at full speed) and it's certainly helped.

Here's the latest test board fresh off the cnc:


We started in the top right hand corner. Around the centre of the board, the drill isn't quite 100% bang on, but is about as accurate as we usually get when drilling these things by hand, with a little Dremel and snake-head attachment, so it should be good enough.

The three holes at the bottom left of the board were totally way out with the printed PCB, but did actually marry up with the on-screen display


So either the PCB layout has changed between printing our test boards onto paper (not impossible) or the software is reading the dxf/nc drill file incorrectly and putting the holes for the transistor at the bottom-right corner in the wrong place!
It shouldn't take a massive amount of work to find out what went wrong and why, and maybe even tighten up some of the inaccuracies around some of the holes.

At the minute, our path-finding is still doing "nearest-non-drilled-hole"


Given that we start in the top-right hand corner, the y-axis travels "downwards" for a total of nine holes, while the x-axis moves left to hit hole 5 and then right onto hole 6 (the x-axis doesn't change in order to then drill holes 7,8 and 9). At hole 10 the y-axis moves in the opposite direction (upwards) and it's around the centre holes that there's a lot of backwards and forwards movements. It's also around these centre holes that we're seeing most inaccuracies.

The next plan is to alter the path-finding in the software so that it starts at the top of the board, and only ever travels in one direction on the y-axis. This should eliminate any backlash in at least one axis and hopefully give us a level of accuracy that we'd be happy to live with, and then we can get on with the exciting stuff like publishing it all online for everyone else to have a go with!

EDIT: Do'h. We were indeed using two different boards for testing! Here's a screenshot of the PCB layout used to load the holes into our CNC. Note how the transistor in the bottom right hand corner has moved down in relation to the rest of the board. If we had printed this board and drilled it, it's looking quite likely that we'd have had a successful test much earlier on!


Sunday, September 9, 2012

CNC drill actually drilling!

Another late night on Thursday at BuildBrighton and another leap forward in progress with our mini CNC drilling machine. This time we actually got a drill bit attached to the RC brushless motor and set it spinning. Because the RC motor requires 12v and we're running our (so-called) 5v motors at 7.5v (at 5v they have no torque at all and stall very easily) we've got a couple of different power supplies running - and a dedicated Arduino board cobbled together to give the RC controller a few commands at boot up to get it spinning.
You can see in the video below that the start-up sequence is quite convoluted!


The laser dot is far too bright to be of any use, so we might just lose that in future development. But we managed to load an nc drill file (and a dxf output from ExpressPCB) into our software and get the machine to drill the pads.

The ultimate test is, of course, to place a printed PCB onto the drill and have it drill out the pre-printed pads. We did this with a printed sheet of paper and the results were pretty encouraging (though not 100% accurate)


Starting in the top-right hand corner, things progressed well for the first few holes. As we got towards the centre of the board, there's a bit of drift which is recovered during the last few holes in the bottom left corner.
Despite these holes looking massively out-of-place on the photo, they're still within about 1mm of the target point - a pretty impressive resolution, considering the hardware used!

There are a few possible explanations for this drift, although it's probably due to a combination of:


  • The servo rams the drilling bit into the board at full speed. This can sometimes cause the bed to move slightly at the start or the end of a drilling stroke. We need to slow down the speed of the servo descent.
  • The anti-backlash routine in software contains some values we just made up that seemed to work! We may need to calculate these values a little more accurately than typing some random numbers and checking the results by eye
  • The drift in the holes is difficult to explain in terms of x- or y- axis since the drilling head travels in all directions (up, down, left, right). We could alter the software so that the bed only every travels in one direction (we could split the board up into rows, and drill each row one at a time, moving the bed in one direction only, while the gantry is allowed to move both left and right). This would make the drilling action less efficient, but would eliminate (or drastically reduce) any backlash in at least one axis.


With these changes in mind, it can't be long before we've a working CNC drilling machine and can post all the files and diagrams online for others to share!


EDIT: At the Mini MakerFaire the following Saturday, one passer-by pointed out that our drill bit was actually spinning the wrong way! We reversed the spin direciton, and the drilling action was much smoother, caused fewer jumps on the travelling y-axis and created lovely little piles of sawdust around each hole drilled. It seems that previously we were just burning our way through the board!

Sunday, September 2, 2012

Repeatability - the holy grail of CNC

After getting our CNC running, we've spent a bit of time trying to work out the auto-calibration on our machine. The idea is that you select two opposite corners on the board, and the software works out the scaling and rotation (given that you may have plonked the PCB down at any old angle).

The rotation part of this works really well, but scaling has been a bit of a problem.
It seems that unless you are absolutely accurate with placing the drill head in the dead centre of each dot at the start, the scaling quickly goes to pot! Any tiny slight mis-alignment during the set-up stage is magnified and repeated many times over when the CNC tries to draw/drill the board.

Also, we struggled quite a bit with consistency.
Whether or not the scaling was correct, it should at least have been consistent - but this is something we had trouble with for a while. Until Robot Steve pointed out that the backlash in our stepper motors was massive! Because the motors themselves are geared down, there's quite a bit of play in the motor assembly. Although 2mm-3mm doesn't sound like a great distance, when you're working to keep a cumulative error over thousands of steps to less than 1mm, it's a massive amount of play.

The answer we came up with is as quick and dirty as it is cheap. Simply put, software compensation for backlash (or play or slop or whatever you call it) means keeping track of which direction each motor is spinning and when it changes direction, adding in a few extra steps to take up the slack first.

How we determine the number of steps required could involve some serious calculations about gear pitch, tooth count, complex trigonometry and more. So we used the SteveCode approach and just tried different numbers until it looked about right.


To reduce any error introduced by badly calibrating the machine, we also added in a fixed constant value for "scaling" - so for testing, where we're not concerned about rotation, we can have the machine plot a series of points from an NC drill file, without having to go through the calibration process every time.

All this seemed to work pretty well.
The last addition to the software is the ability to parse DXF files for hole placement - allowing us to draw a PCB in ExpressPCB and export to dxf, then import the dxf directly into our software as if they were NC drill files.


In ExpressPCB we drew a grid of holes, starting at 10,10, each 5mm apart then exported the layout as a dxf mecahnical drawing


The final dxf file is ready to load into our CNC software which it converts into an NC drill file during import. The NC drill file is then loaded just like any other and drawn on screen


This time we don't bother with calibration (we've already set the backlash and scaling values on the settings screen earlier) and set the machine drawing/drilling:



The key to getting a working CNC is repeatability. And in this case, we've got a brilliant, working, repeatable output! And here's our (second run) drawing being measured up for accuracy:


The input file (ExpressPCB exported dxf) had a grid of 4x4 holes, placed 5mm apart.
The centre points of each hole drawn with our felt-tipped pen are consistently within about 0.3mm which means we've met just about all of the criteria for the BuildBrighton CNC drilling machine challenge:

Less than �50 total build cost? Check (will publish full parts list shortly)
When put away, the total footprint does not exceed an A4 sheet (297mm x 210mm)
Ability to drill up to 80mm x 100m half-eurocard sized boards? Tick
All components are easily accessible from a variety of sources, such as eBay or Amazon marketplace.

The only part we've not actually proved yet is the drilling a 1mm hole inside a 2mm pad.
This is the same as drilling to within 1mm accuracy, and we've proved we can do that, with our cardboard printed output. So all that's left to do is make a collet for the brushless motor and connect a 1mm drill bit - then actually drill some boards!






Saturday, September 1, 2012

CNC drawing and drilling

Tonight we got the z-axis (drill up/down) servo working and managed a full test using a felt-tipped pen in place of a drilling head. The test was almost a complete success!
Ok, not entirely, but pretty much there, except for a bit of tweaking...


There's still the small issue of backlash to compensate for (the motors have a massive amount of "slop" in them, meaning they get less accurate each time you change direction with them).

Instead of a "traditional" cnc controller, we built our own PIC-based board, which doesn't use g-code but rather accepts an x- and y- co-ordinate (distance to travel in each axis, counted in steps) and a "go" command, then moves from point-to-point. At the end of travel, when the machine sends back a "arrived at point" signal to the PC, we send a "peck" command to perform the drilling action (this will be modified with an actual cutting head).

The results were pretty impressive, even in this rough-and-ready form. Here's the input file:


And the actual output drawn on the cnc machine:


You can see the output is pretty similar. Where some of the dots don't line up exactly, we can see how this relates to one (or either) axis changing direction - this is where the backlash compensation needs to be implemented, to keep these turns as tight as possible.

Hopefully we just need to do a little bit of tweaking to get a 100% accurate output from an NC drill file. But for a first-run test, it's very encouraging. Obviously replacing the steppers (with better/more expensive ones) and introducing a belt rather than rack-and-pinion should give us a bit more accuracy - but this flies in the face of the original design brief, to make the machine as simple (and as cheaply) as possible. So we'll do a little more work on this design to see how tight we can get it before exploring alternatives....

Friday, August 31, 2012

CNC drilling machine - testing everything

This is one of the most exciting blog posts for a while. After working on the CNC drilling machine as part of the BuildBrighton �50 CNC challenge for a few weeks, we're actually at the point of putting software, hardware, nc drill parsing and motor controller all together and actually trying to cut a PCB.

Actually, we don't have the drill part running yet - but this test shows actual movement, and we've used a laser dot in place of a drill head. But it shows a (sort-of) working CNC machine....


Instead of jumping in at the deep end and trying to draw a complex PCB (the printed pattern on the paper) we started off with a simple square. But as you can see from the video, we deliberately drew (and mounted) the square on an angle, to simulate mounting a PCB on the cutting bed on a wonky angle.

The software takes care of the rotation and follows the dots.
The first few seconds of the video show the machine being calibrated - the software prompts you to place the cutting head over a hole, record this location, then move the head to a second hole. This is what you see as the head travels diagonally across the board at the start (and the slight delay in the finer movement is us changing some parameters on the PC to reduce the jog step size).

The software then works out the cutting path (in this case, a simple down-across-up type pattern) and sets the motors spinning!

It's interesting to note that the cutting head doesn't necessarily follow the "lines" between the dots (if the dots were on the corners of a square for example), since it is a point-to-point machine, rather than a line follower. We'll try to demonstrate this more clearly in a later post.
But for now, sit back and enjoy our first CNC test.

It's not bad. It's not perfect - we need to take out any backlash in the gears (the motors themselves have quite a bit of "slop" on the spindle because of the internal gearing) to get greater accuracy but as an initial test - and particularly the handling of skewed boards - we're quite pleased with progress so far!

Next time we hope to actually cut (or maybe just draw felt-pen dots on) something.....

Wednesday, August 29, 2012

CNC motor testing via USB

There's an often held belief that you can't do CNCs without a parallel port on your PC and cleverly timed move instructions. That may have been the case back in the day, but we've had the nineties guys, USB is all the rage!

So we're building a USB CNC controller board.
We're quite lucky that these cheap little 5V 28BYJ48 steppers have already been stepped down. They're supposed to be 1/64 but inside they're geared down again. There are loads of places all over the internet which say that they're stepped down again by 1/32 - meaning you need 64 * 32 = 2048 steps for one complete revolution.

If that's the case, we should be able to get pretty precise movement, even with a massive gear/cog riding on the shaft, and without having to bother with the complexities of micro-stepping. There's only one way to be sure - and that's spin one around and count the steps!

In-keeping with our NC drill software, we're looking to build a USB controller which we can give a number of steps and have the motor(s) play out those steps. We've no idea at the minute how many steps we may need to move up to (depending on how many steps per revolution these motors actually need) so we've allowed for a 4-byte value to be sent to our trusty 18F2455 PIC microcontroller.

We're using (as ever) a generic HID device interface and sending data in 8 byte packets.
  • The first byte (byte zero) is our "command byte".
  • If the value is one, it's a command to set the x motor step count
  • If the value is two, it's a command to set the y motor step count
  • The second, third, fourth and fifth bytes make up our 4-byte value (0-2,147,483,647)
  • The sixth byte (byte 5) is a direction - one is anit-clockwise, zero (or any other value) clockwise.

After sending the x-axis step count (or the y) the controller board stops all motor activity (since if the motors are spinning when new values come in, the x- and y- axis will go out of alignment with each other, as the earlier axis will be ahead of the later one).

Only once the command byte 254 is sent do the motors actually spin up.
For as long as the x/y step count has a value greater than zero, the motor(s) are given a signal to move them onto the next step. The step-count value is decreased by one each time one of the axis motors steps. Once both motors have a step-count value of zero, a flag is set to tell the PC that the motors have stopped spinning and the head is now in it's correct position.

Here's a video of some early testing:


What's happening here? Thanks to the autofocus on our camera-phone it's not too clear - but if you squint and stand back from the monitor you might see:

Firstly, the command byte (7th byte) is given the value 1 (set x motor step count), along with the second byte (from the right) set to 16. Since our x count is a 4-byte value, we're setting it to 16*256 = 4096.
We repeat these values with the command byte set to value 2 (set y motor step count) then clear the buffer and send the command value 254 to get the motors spinning.

Giving our control board a value of 4096 makes the motor complete one full rotation.
So there we have it. Our stepper motor has a 1/64 step angle, geared down, not by 1/32 as some other forums suggest, but a full 1/64 again. 64 * 64 = 4096 so this is the number of steps required for a full rotation.

The video then skips back to a blurry laptop screen, where we enter the same values, but this time setting byte 4 to 1. This is the direction byte. When this is set to one, the motor spins in the opposite direction.

All in all, we've had quite a successful evening - we've got both axis motors spinning from a custom-built PIC-based USB (HID device) board and some software which we can talk to the board with and get predictable results. Now we just need to remember how to work with Timer1 to create a 20m/s interrupt on the PIC and we can use this to send servo commands for the z-axis (drill up, drill down and motor speed).

Tomorrow is another BuildBrighton open evening.
There's even a slim chance that after the beers and pizza, we might actually get something working......

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!


Tuesday, August 28, 2012

CNC drilling software development

Ever used Mach3 for your CNC machine? Or RouteOut? Or one of those other CNC applications with a myriad of settings so that it can support any type of CNC machine?

If you've ever bought a second-hand CNC machine off eBay or tried to build one from salvaged parts, you know how difficult it is to work out (or guess at) the settings to make it work. Sometimes you end up shoving numbers in and keep tweaking until the actual output sort-of matches the drawing files you give it.

Well not any more....

Not only has Robot Steve redefined simple CNC design, with his awesome push-fit chassis, but this custom-written software is designed to do away with CNC-hardware-related headaches. Simply load a file, manually move to head to a start position (origin), move the head to a second position, then hit go.

At the minute the software can read NC drill files.
Here's the app reading a drill file generated from an Eagle PCB


After calculating the scale and rotation for each point (at the minute we're just working on scale, having just read in an nc drill file) the software runs through each point, creating a "cutting path"


At first, something appears to have gone wrong down the left-hand side. But on further inspection, the software is actually following the simple rule "move to the nearest hole that hasn't been drilled yet".
Because we set the origin to the top-left-most hole then travel to the bottom-right-most hole, the cutting head  should be at the bottom right of our PCB.
From here, it starts with the rule "move to the nearest point" then marks it as "drilled" when it gets there.
Repeating for only holes that haven't been drilled creates the cutting path above.


Monday, August 27, 2012

CNC drilling machine first test (x- and z- axis)

After a successful couple of hours at the nerd cupboard, we managed to get Steve's CNC design working in two axes. The test board simply uses buttons to turn a connected stepper motor clockwise and anticlockwise (we've yet to finish our controller software) but proves the concept of moving a drilling head across a gantry and performing a plunge-and-drill operation.



Exhilarating stuff!
We're particularly pleased with the dual-servo control: the first servo is actually an RC motor controller and sets the drilling spindle spinning. Then the z-axis servo plunges the drill head, pauses, and retracts the head, before stopping the drill spindle. (In code we "detach" the z-axis servo so that it is only powered for as long as is required.)

Surely it's only a matter of time before the y-axis (cutting bed) is in place and we're ready to try out some custom software to drill our first board!

CNC drilling software (open source?)

We're still not 100% au fait with the requirements for open source, GNU licences and all that kind of stuff - does everything in the chain have to be open source? Can we use our preferred PIC microcontrollers to make a USB device when the Microchip software and USB libraries are not open source? Does it really matter?

We're blundering ahead with our software, but have hit upon two potential problems - and hopefully workable answers to them:

The first is converting the NC drill file units (mm or inches) into steps on our CNC machine.
Since a big part of our design process is to make the machine easily repeated and built from spare parts (salvaged printers are a great place to get hold of cheap steppers) we're trying to work from the assumption that the end user knows nothing (or very little) about their hardware.

Rather than have the user enter all kinds of values to describe their hardware (or worse still, guess at them) we thought we'd have a simple manual calibration routine at the start of the software. Simply put, the user loads their pre-printed/etched PCB onto the cutting bed and moves the drill head above the top-left-most hole (the software will highlight one if there are multiple possibilities). This will form the origin (co-ordinate point 0,0) for our cutting routine(s).

The software will then find the bottom-right-most hole (furthest away from the origin) in the drill file, highlight it and prompt the user to move the drill head (maybe using the computer keyboard's arrow keys or similar) above this second hole. Using these two co-ordinates we can calculate two vitally important things: scale and rotation.

In the NC drill file we have co-ordinates for every point on the board. Using pythagoras theorum (a^2 = b^2 + c^2) we can calculate the distance R1 between the top-left and bottom-right points. On our actual PCB, this represents the same distances between the same two points. The only difference is the units used to measure this distance.

In the same way the same distance can be described in imperial (inches) and metric (millimetres) by multiplying one set of values by a constant, we can do the same to convert inches or millimetres in the NC drill files into steps on the CNC machine. Let's pretend both images (above) are exactly the same size. Let's say the distance R1 is measured in millimetres, but we want the same distance R2 in inches. We know that 1 inch = 2.54cm and 1cm=10mm. So we can easily compare R1 (mm) with R2 (inches) by multiplying R2 by 25.4 (or dividing R1 by 2.54 to get R2, the same distance in inches).

We don't know what this constant value is to convert our NC drill measurements (mm/inches) into number of steps, but we can calculate R2, the distance the drill head travelled between two points, in terms of steps. Knowing the value of R1 (in, say, mm) and the distance of R2 in steps allows us to calculate the scale between the two. Scale = R2/R1

The great thing about using the first hole as our origin point is that it doesn't actually matter at this stage whether or not the PCB board on the CNC machine is dead square. If the PCB board were not aligned exactly squarely, the difference between these two distances would be exactly the same, since they both describe the radius of a circle with it's centre point at the origin

 So now we've worked out the scale (the constant to multiply our NC drill hole positions by to convert distances in mm/inches into number of stepper motor steps) we now need to work out the rotation of the PCB on the cutting bed

Even if the PCB on the cutting bed were badly skewed, the ratio (scaling) between R1 and R2 would be the same. We know the location of the bottom-right-most hole from the origin according to our NC drill file, and we know the distance of the same hole on the actual PCB in terms of number of steps travelled in both the x and y axis. What we need to do is calculate by how much the PCB has been rotated.

One way to do this is to calculate the angle (from the origin) of the diagonal in the NC drill file (the larger of the three angles above) then calculate the angle from the origin of the current position of the drilling head.
Since we know the position of the cutting head from the origin in terms of steps (we count the number of steps moved in both the x- and y- axes) we can calculate this angle (the green diagonal) quite easily.

Using simple trigonometry:



If we rotate the bottom triangle 90 degrees clockwise, we can see that we've described a right angled triangle, where the adjacent side is the number of steps travelled in the y axis, the opposite side is the number of steps travelled in the x-axis, so tanA = stepsY / stepsX

From here we can calculate the angle of the position of the drilling head from the origin.
Using the same principles, and with the values from the NC drill files, we can calculate the angle between the bottom-right-most hole and the origin (top-right-most hole). The opposite side of this triangle is the difference between the x co-ordinates of the two holes and the adjacent side is the difference between the y co-ordinates of the two holes, so tanA = (y1-y2) / (x1-x2)

Knowing these two angles, we can subtract one from the other to calculate by how much the PCB has been rotated on the cutting bed. Now we know the scaling AND rotation, we can simply apply these to every point in the NC drill file, to get the number of steps needed to move in both the x- and y- directions to reach in point on the actual PCB on the cutting bed.

Apply rotation to a co-ordinate point can be acheived by using a rotation matrix:



What this scary looking equation boils down to is - the coordinates (x',y') of the point (x,y) after rotation are:
x' = (x * cosA) - (y * sinA)
y' = (x * sinA) + (y * cosA)

Given that we know x and y (from the NC drill file) and we've calculated the rotation of the PCB on the cutting bed, we can work out:

xSteps = ( (x * cosA) - (y * sinA) ) * scaling
ySteps = ( (x * sinA) + (y * cosA) ) * scaling

where x and y are the co-ordinates given in the NC drill file.
And all without knowing how many teeth are on the CNC belt, how many steps the motors turn per full revolution or any of that other junk, nor without any headaches lining up the PCB to get it absolutely square and accurate on the cutting bed.

In theory, this provides a really nice and easy to use - if not entirely easy to understand for everyone - way of drilling every hole on the PCB, from an NC drill file, given the user has manually located two holes on the board.

Software design requirements for CNC drill machine

Robot Steve's late entry into the BuildBrighton CNC Drilling Machine competition has in some ways spurred us on and in others caused things to grind to a halt. In some ways, seeing such a simple, usable design has us wondering whether it's worth continuing with our little laser-cut caddy. The main difference between our approach and Matt's CNC monster was simply scale and cost:

Matt came up with a solid (though possibly over-engineered) design using linear bearings, rods and bolts by the bucketload, expensive steppers and belts - basically blowing the budget to create the best CNC type machine he could manage.
We stuck to the cheap-as-possible, easy to replicate route, but possibly at the cost of accuracy (we still don't know if our design will actually create a working, functional CNC machine!)

Steve's design fits nicely in the middle.
With 3d printed parts, built from a 3d CAD-based design, he can see his prototype working (virtually) before cutting or casting a single piece of plastic! Yet with minimum part count and easy push-fit construction, there's no need to worry about bolting plastics edge-to-edge and trying to get everything square. It's a great design.

So is it worth continuing with a slightly shonky design, knowing that eventually we'll probably adopt another in the near future? We'll leave that question, and spend our time constructively on the one aspect that no-one seems to have addressed just yet: software.

The budget allows for the complete build - including driver board/electronics and controlling software.
The easiest approach would be to get a MACH3 compatible driver board, hook up the steppers and run everything through some milling software like MACH3. But this is an expensive way of going about things, so we reckon custom software is the way to go.

Also, we're not drilling or milling blank material. Our PCBs with either already be etched, or have tracks and traces already marked on them, ready for etching. So before we start any drilling, we have to make sure our boards are perfectly lined up to begin with.

In something like mach3 we could do this by moving the drill head to a known position and placing the board underneath it, then moving the head to a second (known) position and rotating the board until this second point fits under the head. With the board in place, we could lock it down and start the cnc running.
MACH3 also has a myriad of settings, belt-tooth size, leadscrew adjustment values - all things which make it quite complicated and daunting to the untrained user. For our software we want:


  • Minimum settings screens - we don't care how big your stepper motor is, the tooth pitch, degrees per step and so on. The software should work with a wide range of machines without any complicated maths/physics calculations!


  • Auto-alignment - placing a PCB exactly squarely on the cutting bed is going to be difficult enough. Cutting the sides square is hard - knowing that you've placed one edge exactly squarely can be hit-and-miss, and if your edges aren't exactly true and straight, getting the whole thing to line up is almost impossible!


  • Auto-scaling for different measurement units - NC drill files are commonly described in imperial (inches) but there is software that uses (and an NC drill command for using) metric (millimetres). The software should be able to handle mm and inches without the need to re-calculate the drill position data in the NC drill file.

We're not worried about making everything open source, complying with GNU licences and all that - we're just looking to create some software that just works (in Windows at least) using whichever tools do the job. Of course, details of how the software is created will be explained, should anyone wish to re-create their own, but we're not ruling out any specific technologies just because it's not "open source" or GNU-a-like or anything like that!

Sunday, August 26, 2012

Late entry to the BuildBrighton CNC drill machine challenge

It's a bit late - though not as late as our actual machines are for being ready (they should have been drilling PCBs in time for last August's BuildBrighton Guitar Stompbox Workshop) - but we've had an exciting last-minute entry from Robot Steve.


Steve's taken the simplicity of our design but coupled it with the super-low cost option (and ease of construction) of a 3D printed solution. We think it looks amazing.


Using a servo for the drill plunge, this design keeps things about as simple as they possibly can be. The rails are structural as well as functional (carrying the carriage for the x/z axes) and the tiny steppers are mounted directly onto the moving parts. Rather than mess about with linear bearings, Steve has gone for the simpler (and cheaper) design used in many inkjet printers - greased rails and precision cut nylon blocks sliding along them!


We think the best thing about this design is the relatively low part count. Once you take away the cutting bed (a piece of cheap acrylic or some mdf) and the rails, you're left with a handful of cheaply produced 3d printed parts.


Steve sent over some early prototype photos. It actually looks better in real life!


Tuesday, August 21, 2012

Miniature CNC drilling machine x-axis carriage

We've had a bit of mixed success at Nerd Towers tonight.
Firstly, we wanted to get our x-axis working on the miniature drilling CNC machine. The y-axis (bed) is easy enough - it's just a plastic bed set on top of an Ikea drawer runner. The x-axis is altogether more difficult, as it's a gantry-based axis (to keep the size/footprint down).

In the spirit of making everything as cheaply and as repeatable as possible, we're using the same rack-and-pinion approach for our x-axis as we have done on the y.
Simply put, a long toothed edge will run along the top of the gantry, and the stepper motor mounted on top of the moving carriage will pull the carriage along by rotating a cog/pulley along the tooth-edged strip.

We've decided on this approach as once the parts are designed and proven to work, anyone with access to a laser cutter should be able to make the same thing from our drawings.
The only thing is, we've drawn most of the CNC by eye - so have no idea how far away from the rails or toothed edge our carriage is going to be. So the first thought was to make an adjustable carriage:


At the bottom of the picture you can see the side section of our carriage. By adjusting the bolts. the stepper motor (mounted on the top of the carriage section) could be moved closer to and further away from the toothed edge running along the top.
After bolting all this together, we found that not one single piece of this carriage had been designed properly so we started the whole thing again, this time with a slightly different approach - "guesstioneering"

It's a term coined one night at BuildBrighton and fits this approach perfectly.
Basically we make something based on a best guess, then whittle things down until they fit.....


This second carriage (in blue) was designed entirely by eye and with no reference to our frame! (if the frame doesn't fit, we can always tweak that, and the carriage together, until they line up and mesh together nicely!)
In this instance, the small cog on top of the stepper motor is neither high enough, nor close enough (laterally) to the toothed edge running along the top.
Instead of messing about measuring and re-measuring and cutting and re-cutting, we just decided to make our toothed edge have a bit more play in it. The idea being that we line it up with the carriage in place and just fix it down!

As we were cutting a new toothed section, we decided to go for a double-sided piece, with the cog on the stepper motor sitting between two rails. Hopefully, this will stop the motor from pushing away from the toothed edge and skipping steps....


The only thing now, of course, is that we need to make our gantry stands about 3mm higher and a little wider on one side (so they're asymmetrical) so that this new piece doesn't look like it's been cobbled together and just shoved on as an afterthought. (it has, but there's no need to advertise the fact!)


This new carriage moves along the rails quite nicely.
There's not much play and hopefully this double-rail approach will eliminate this altogether. Here's a quick photo to show the actual size of the gantry. It's really quite small -


So there we have it. A nice sliding gantry with a stepper motor mounted onto it. It's not quite working under it's own steam just yet, but we can't help but feel that we're getting a little bit closer!
Here's how the final thing will sort-of look in place over the y-axis bed. We may even go crazy and lose the lump of scrap wood for a nice piece of red acrylic. That's the kind of colour scheme that would make Robot Steve have a fit



Sunday, August 12, 2012

ExpressPCB to NC Drill files

As part of the CNC drilling machine challenge, one of the things we have to be able to do is parse NC drill files. The idea being that using an industry standard file format makes the machine compatible with a much wider range of PCB layout software.

One of the problems we have is that Eagle sucks.
Yes, that's quite an inflammatory comment but, compared to ExpressPCB, we've seen loads of people have trouble with Eagle-drawn circuit boards.

The first thing is those stupid lozenge shaped pads. And the default hole size seems to be too small. And the pads are ridiculously small. And when you've finally etched your board and drilled it, it's all too easy to ruin a pad because your 1mm drill bit has ripped up all but the tiniest thread of copper left around the pad (right-most-pad, below). One slight wobble with the drill or mis-aligned pad and the whole board can be ruined!


Over at Nerd Towers, we defy convention and refuse to get drawn in to the everyone-uses-Eagle-so-we-must argument. Although it's less of an ideological standpoint and more to do with the fact that it's just so complicated to use when no-one has ever shown you how!

Our tool of choice is ExpressPCB. It's not only free but it's simple to use.
For the hardcore gerber-loving geek crowd, the very things we laud it for may well be it's Achilles Heel too - but it is very simple to use and you can get a PCB thrown together very quickly, all with 2mm pads with 1mm holes (ok, the default is 0.89mm but what's a tenth of a millimetre between friends?). No worring about mirroring, or not mirroring, or which-do-I-mirror before printing for toner transfer - just draw on the top (red) layer and print it out!

To produce PCBs for etching, we usually print to a virtual printer, such as CutePDF and make a PDF file for editing in Inkscape but one thing we recently discovered was the "export to DXF" option


This is quite exciting, as it allows us to generate a file which can be parsed and turned into a drill file. The export to dxf option in ExpressPCB can send just the pad data to a single drawing. Simply loop through the text-based dxf file, find all instances of CIRCLE and write the co-ordinates out to a NC Drill compatible file format!

After a cursory glance at the generated dxf file we can see all our pad data quite easily:


Every pad is a circle entity so we fiddled with a few values and loaded the resulting dxf into Inkscape until we found which entries corresponded to the X and Y co-ordinates. Ultimately it is these values that we'll be interested in to create our own NC drill file.

(comments in the above image were added one we'd identified which values did what, they were not present in the original, generated dxf)

To try out our idea, we picked a circle and set the X/Y to zero and the radius to 4
Interestingly, Inkscape does not position circles from their centrepoint, but from the bottom left corner of the shape. So we expected to see our shape at -4,-4


Inkscape seems to include the stroke (shape outline) width in the X/Y co-ordinates for each shape. So we reduced the stroke width and indeed the X/Y co-ordinates updated accordingly.


We can only assume that with a stroke width of zero, the shape would indeed line up to -4,-4 and thus prove that the values we changed in our dxf file were indeed the correct x,y and radius values.
With this in mind, we're off to write a simple script to convert metric x/y value pairs into an NC Drill file.....


Friday, August 10, 2012

CNC drill machine challenge rules

A few people have been asked about the CNC drill machine challenge and it seems that not everyone has access to the BuildBrighton Google Groups page. So here's the preliminary post, outlining the basic rules for the challenge:


After making what felt like millions of boards for the midi workshop, we've decided to make a cheap, little drilling machine for making homebrew boards.
As the discussion went along, we decided to see if we could make the smallest, cheapest machine we could. Almost immediately we couldn't agree about a single thing for our machine, so we've decided to make one each and compare them.

Matt gets loads of stuff cheap off ebay by buying in bulk. 
Chris gets stuff cheap by extracting it from old hardware using hammers.
Matt uses Eagle and could create NC Drill files directly from it to drive the machine
Chris uses ExpressPCB and a convoluted print-to-pdf-then-convert-to- svg method of generating drilling data

Matt wants to make a machine that can drill large, panellised pcbs - double eurocard size (200x160). 
Chris wants as small a machine as possible to fit on a shelf when not in use, and rarely makes boards bigger than a 50 pence piece.
Chris doesn't get the whole open hardware movement and still prefers PIC microcontrollers over AVR. 
Matt thinks an Arduino-based machine would be much more open to hacking if other people used our plans to make their own boards.
Matt can get cheap linear bearings and has experience of making a gantry-based cnc device
Chris thinks he can cobble something together out of ball-bearings and sellotape
The list goes on and on....

So, we've come up with our own hacker challenge. Hopefully this could be the first of many - little projects that we can work on in small groups or individually, then present back to the group.
It would be really cool if other people joined in (or maybe even joined forces) to come up with alternative ideas for this first challenge.

We'd love to see some alternative ideas to make a drilling machine - we've come up with some parameters (it's not really a contest, so it's not fair to call them rules) but here's what we've eventually agreed to work towards. Because it's a machine that we're hoping others will want to try and make (assuming either design eventually works) our first rule is about cost and availability of parts.
It's easy to hit ebay and Rapid and Farnell and blow a small fortune, but that puts it out of reach for a lot of people. Similarly, it's possible to smash open some old hardware and salvage some cool stuff but no-one else might be able to get hold of the same equipment, and would need to find alternatives. So the rules are


  • If buying all new components, not more than �50 on the entire build (just think about it, a cnc based device for under �50!)
  • If using salvaged hardware (stepper motors from old printers, for example) not more than �20 total build cost
  • As we're building a small machine, the footprint of the device, when put away, should not exceed A4 size (210x297mm)
  • But it'd be useless if it could only drill tiny pcbs, so it has to be able to drill up to half eurocard sized boards (100x80mm)
  • Any bought components should be accessible to everyone and you should reasonably expect to be able to purchase the same components from the same, or alternative suppliers 12 months from now (so you can't win a job lot of motors from some bloke off ebay and put cost of materials down as 50p)
  • Overseas suppliers can be used to keep costs down, as their price per unit is often much less than UK suppliers.
  • The device is to be platform independent - it can use any microcontroller and any software can be used to control the machine, including homemade software/drivers. 
  • It has only to work on any one platform, not all
  • For accuracy, the drilling machine should be able to drill a 1mm hole in a max-sized 2mm pad and leave a complete copper ring intact around the hole
  • For building materials, assume a price for acrylic sheets as �1 per mm thickness, per A4 sheet
  • Cheaper alternatives (such as mdf or laser ply) can be used instead of acrylic for the chassis if required
  • Trivial components and the cost of pcb etching, running a laser cutter etc and consumables will not be used to calculate total build cost
  • The price for delivery of all components bought online will be included in the final cost

More rules may be added as the build goes on, but only to clarify any points that may arise, not to act as a restrictive force to deter alternative ideas.

So there we have it. Another stupid challenge that probably won't get finished (or much beyond the planning stages) But there's nothing like seeing someone making more progress on a project than you, to act as a catalyst and get things moving along. So who else fancies joining in?

The prize? We'll use the "best" design for a "proper version" of the machine for use in the hackspace for all members making their own pcbs. Better than money or other tangible goods, you get to win kudos!

CNC drill challenge update

At an epic BuildBrighton session last night, there was loads going on. Including a new design for our CNC drilling machine challenge.

One of the things we're keen to stick to is repeat-ability (the other is, of course, a shoestring budget). So instead of expensive (and as a few people have pointed out, extremely accurate, precision-made) pulleys and belts, we're going all out with laser-cut acrylic and little, cheap stepper motors.

The previous platform we built was nice and sturdy, but during it's construction we came across a little problem. It's not a major problem, and can surely be remedied easily by anyone with the proper tools and a bit of time and effort, but it does stand in the way of repeat-ability. Basically, getting the two runners exactly parallel is a little bit difficult.


If the runners are not exactly equi-distant, along their entire length, the platform "binds" as it reaches the end of its travel in both directions. This isn't really a major project if the length of travel is kept to about half the total length of the bed (in fact, this is about the maximum we're expecting our bed to travel) but there's just something about the fact that it's so easy to mess this part up that we're not happy with.
So we're going with a much easier (and some would say, slightly shonky) design:


It's a single runner with the platform bolted along the centre-line. The single runner can be mounted onto a scrap of wood (exactly what we used here!) and it's not really important how square this mounting is (we mounted it along a centre-line along the wood for neatness, but it's not critical).

The only bit that's really important is getting the gantry mounts on the sides square with the runner.
BUT - having mounted the runner onto the board, the runner is fixed nice and securely. Using a set-square the gantry mount can be placed and fitted from the same side of the board. In our previous design, having to bolt everything together meant lifting the whole assembly up, and this is where things slipped out of alignment.
With this design, it's quite easy to get the runner and gantry at 90 degrees.


With the two gantry supports fitted, the top/cross piece just clips into place.
In theory, everything should be nice and square. Next we need to fit the stepper motors and actually get something moving to see if this design actually works ;-)

One thing that isn't immediately obvious from these photos is just how teeny tiny this little machine is. It's almost comical. In fact, a few BuildBrighton regulars have decided that it's not only comical but unusable - and have already started a book on how long before this design is abandoned and v3.0 started. We'll show 'em....

Sunday, July 1, 2012

CNC drilling maching platforms

After the problems we'd had with our laser cutter, we weren't sure if we'd manage to get these done tonight. But after finding (and solving) the problem, we were up and cutting again in no time.

We couldn't decide whether to use a smaller gear for our stepper motor (for precision) or a larger one (for speed). Since our steppers are 1/64 (64 steps per full revolution) we went for 16 teeth on our gears. The smaller gear has a tooth size of 2mm, the larger one is 4mm.



Here's the platform for our cnc drilling machine.
Note that the mounting holes for the rails are slightly off. This is because we accidentally moved the sheet when trying to find out why the laser cutter wasn't behaving properly. For the final version, we'll cut this again, but it'll do for a first-trial-run. 



The platform has a rack-style gear along the long edge. On one edge we made the tooth size 4mm, on the other 2mm. This means we can try our larger/smaller gears by simply fitting the appropriate head on the stepper and flipping this platform over.

At these tiny sizes, the slight "kerf" along the cut edge of the acrylic becomes noticable. Whichever way the kerf on the geared head is, we try to mount the platform the other way up, so that the gears mesh as closely as possible.

One full revolution of the stepper takes 64 steps. One full revolution causes 16 teeth to pass along the rack gear. By our calculations, this means that with a head with 16 teeth of 4mm, 4 steps are needed to travel 4mm - or one step is one mm. This should make moving the platform nice and quick, but whether or not this gives us the level of precision we require is still yet to be seen. If we need more precision, we can always fit the 2mm-tooth head, and this should get our precision to 0.5mm (one revolution = 64 steps = 16 teeth at 2mm = 32mm travel so one step = 0.5mm)

If it turns out we need more precision that this, we'll have to consider some kind of belt or threaded-rod type drive.

In the meantime, here's how the 2mm head and rack line up


While flipping the black piece over and replacing the small gear with a larger, 4mm-toothed head looks like this 


The rails will simply bolt onto the base piece of acrylic. We measured the spacing between the mounting holes on the rails and transferred these onto the plastic. We'll take a trip down to The Nut & Bolt Store in Hove tomorrow, and reinforce the join with plenty of hot glue

(note the slots cut into the base, running at ninety degrees to the rails. These are for a base "plinth" to be added, so allow the height of the base and sliding platform to be raised, so ensure a good mesh between the edge of the moving platform and the gear mounted on top of the stepper motor)

Here's how the final assembly would look when all glued and bolted together: