Home > Advanced Projects > CNC Drill

Modified: 23:19, 26 October 2013

  • Reads .drl gerber format files
  • 0.001" resolution
  • 0.002" accuracy
  • 265mm x 280mm table
  • Manual feeds
  • LCD display
  • Serial connection.

This project has a lot to it so has been split into the following pages:


My eyesight is not what it used to be and there are occasions where we have lots of PCB drilling to do for the KS3 projects. I have always been intrigued by the operation of CNC equipment, the way it pruposefully and faithfully reporduces things time and time again. Looking at some Gerber files, the format of the information was simple 5 digit co-ordinates so I decided I would try to build a CNC PCB drill....using mechano and printer parts

...and you know what...it actually works and very accurate, to 0.005"!.

This project has a lot to it so has been split into the following pages:
Download different videos:

The drill is connected to the PC via the rapidly disappearing RS232 serial Com port. Tine to update to a USB driver I think.

The heart of the system is a PIC16F876 PIC which controls communication to the PC, monitoring the opto-switches and provides thre PWM outputs to control the X,Y and Z axis motors. It also controls the LCD 16x4 display. The PC runs a good old VB6 program that reads .drl files, and graphically represents them on the screen. It can manage up to 6 different hole sizes and sort them to optimise the quickest drilling path.

When Running, the PC sends drill co-ordinates to the drill and the unit replies when the position has been reached. The command to drill is then sent and a confirmation is returned when the hole has been drilled. This process is repeated until all the holes have been drilled.

The whole drilling operation is controlled by the PC running a Visual basic program. The program loads in a Gerber file of the hole positions which is created by the PCB software when the board was designed.

Gerber hole files have a series of G, M and T codes that select certain functions on the CNC equipment and hole co-ordinates in the format of:


where X is the x cordinate followed by 5 digits showing relative position in 1/1000" followed by Y coordinate in the same format.
The VB program reads these values and stores them as co-ordinates to send to the Drill. The only other codes the VB program uses are the T codes.

T1Cn.nnn = where n is the drill size in inches
Tn = select drill n size for following holes.

These settings can be altered by the PCB software - for example metric instead of imperial and relative movements instead of absolute position. I used imperial units and absolute position with 3 decimal places.


The drill has to be "Homed" first. This means moving the drill to the bottom left of the table, just clear of the minimum limit sensors. The drill is moved until the sensors are hit in each direction then just nudges clear of them. The 3rd button on the top of the keypad accomplishes this and sets this position as the origin - 0,0.

Next the drill is moved to the nearest hole where the PCB is adjusted so that the hole to be drilled is directly under the drill. The hole is drilled and a pin put into the hole to keep the position. Then the drill is sent to the furthest hole and again the PCB adjusted while fixed by the first to the correct position. Then the PCB is secured down, the pin removed and it is ready to go - a bit of a fuss but it's the simplest way for accuracy.

The first hole in the list is selected and the RUN is pressed. The following cycle is then repeated until there are no more holes left in the list:

  1. The PC sends the co-ordicates of the hole to the Drill via the serial port
  2. The Drill moves to that position and sends confirmation back to the PC
  3. The PC instructs the Drill to activate the Z motor, drilling the hole
  4. The Drill confirms to the PC when the hole is drilled
  5. The software selects the next hole in the list.

The x and y motors are controlled using PWM. The motors accelerate rapidly until they come with a certain proximity of the hole then reduce to minimum speed. If they move too far past the hole, they slowly reverse until they are within 0.003". This effect can be seen clearly in the videos. When the motors are stopped, the connections are electrically connected together to apply a braking effect caused by emf, resulting in very little run-on at low speeds.

The program interface is shown below:
Explanation of the software controls:
Load File - open a .drl gerber file

Com1/Open - selects/opens a com port for serial connection

Drill Sizes - A list of differernt hole sizes in this file, up to 6 can be shown

Hole List - Contains all holes of selected Drill Sizes, displayed in 4 columns, hole number, x and y coordinates and drill number. This will be the order and list of hole co-ordinates that will be sent to the Drill when Run is selected.

Min. hole space - the minimum acceptable distance between 2 holes.

Optimise - This puts all the holes in the Hole List into an order that requires the least amount of movement of x and y. It also checks the hole spacing set in Min hole space

Scale/Rescale - The entire screen can be scaled to allow for errors when the PCB was reproduced through printer errors both on x and y axis. It has a resolution of 0.05% being about 1/1000" per 2" and the image is redisplayed on screen (tested but never used)

Mirror - Flips all hole positions horizontally

Trace - When selected shows on screen the path the drill will take when drilling all the holes. (This should be next to Optimise)

Cursor/Set - Shows the position of the yellow cross hairs on screen. These can be altered and Set pressed to force the Drill to accept the new co-ordicates as its current location (tested but never used)

Selection - If the user draws a box on screen, only the holes within that box will be shown and the Selection option as pressed. Release this option to unselect holes

Grid Offset - Can move all holes in any direction - effectively moving the entire PCB (tested but never used)

The following controls produce data and confirmation text to appear in the text box underneath them:

Send Cursor - Sends instructions for drill to move to cursor coordinates

Drill - Sends instruction to the Drill to activate a drill down/up sequence.

Home - Moves drill to position 0,0. This does not calibrate the drill the same as the Home button on the keyboard does

On/Off - Instructs the Drill to switch the drill motor on or off.

Clear - Clears all text in the text box

Get Position - Sends instruction to the Drill to return the current position it has for the drill

Run - Starts drilling the holes in the Hole List starting with the selected entry.

System Settings - This reveals the settings window which allows the user to change certain speed settings. The default ones shown tend to work the best, until wear and dust begin to affect it!

Motor Speed Settings - the minimum and maximum speeds for the x and y motors can be set and the Drilling speed for the z motor (not the drill itself). The maximum speed is set by Frame Steps. This sets the number of interrupts per on/off cycle and thus the number of different speeds effectively. high values reduce the frquency of the PWM which will reduce motor efficiency.

Stopping Distances - These set the number of slots or 1/1000" prior to a hole positon that the motors will be braked. Too low a value will not give the motors time to reach a stop causing the motors to repeatedly change direction in an attempt to locate the hole.

More details on operation and construction can be found on the following pages:

by Phil Townshend 2012

www.edutek.ltd.uk - Working Electronics For Students & Teachers