CNC From the Absolute Basics

by Jon Freeman

Part 8 - Engineering in Miniature - Apr 2014

Quick Links to - Sep13 Oct13 Nov13 Dec13 Jan14 Feb14 Mar14 Apr14 May14 JunJul14

Some of the ideas behind CNC can be applied to intermediate methods of working where computers inform humans in controlling manual machines – HNC, a 'Hybrid', or 'Human', Numeric Control, if you like. Using a computer spreadsheet programme such as 'Microsoft Excel', or 'Open Office Calc', arithmetic useful in plotting points around a PCD, and plotting linear and arc machine trajectories in three dimensions is shown. This is useful in 'HNC' machining. CNC machines may work quicker but maybe this doesn't always matter too much, so let's explore some ways of applying new thinking to older methods.

Over a century ago a young 'Curly' Lawrence took up a hobby of making miniature, working models of some of the steam locomotives of the day. From the 1920s until his death in 1967 he established himself as a prolific author using the pen-name “LBSC”, writing up many detailed construction article series'. His straightforward and lucid style doubtless encouraged many into model engineering, and by following his no-nonsense methods, generations of model engineers were helped to become successful builders of miniature locomotives. Looking back at his style, in “Simple Model Locomotive Building … introducing LBSC's Tich”, a book published after his death but based on his series of construction articles of 1948, on the first page of chapter one we reach a section “How to Mark Out the Frames”. It describes a perfectly logical sequence of measuring, scribing lines and making 'centre-pops', the only tools being a steel rule, scriber, try square and centre punch. The final sentence of this section reads; “You can do it as quickly as I wrote the instructions”. While these methods are as good today as they ever were, using modern tools and ideas to refine them can help us work to far greater accuracy so making a better job of things in a shorter time overall.

LBSC completed most of his early engineering projects using not much more than a simple lathe, a zero to one inch micrometer and a selection of hand tools, and his write-ups assume the reader has similarly limited resources. Following his frame marking instructions, making marks measured from one corner, and then making further marks at distances measured from previously made marks, cumulative errors inevitably build up so that when the whole is assembled, items that should align might not do so, shafts that should turn freely may bind, and so on.

Eliminating Cumulative Measurement Errors

Fig 23 - pc-dro-1

We could still follow LBSC's frame marking method to the letter but marking positions using a 2D CAD programme instead of marking directly to metal. This at least provides a quick and easy way of translating all the dimensions from a number of different datum points into coordinates related to one common datum. At its simplest, a better more accurate job of marking the metal could then be done using a try square, scriber and digital calliper by reading coordinates directly from the CAD screen.

Bypassing marking-out, the next step towards more efficient and accurate working would be to mount the job on a mill-drill or vertical milling machine. From the CAD, positions are read from the screen and the X and Y axis handles are wound to set to position for each hole to be drilled. One problem here is in keeping track of how many whole turns of each axis lead-screw have been made since the start, missing the count by just one will put all subsequent settings in error by a distance equal to the pitch of the lead-screw. Backlash is another potential source of errors, one avoidance strategy might be to approach each set position by turning lead-screw handles the same way – always approaching set positions from the same direction.

These problems are solved with the next incremental help, the DRO – digital readouts. CAD programmes can be found to run on any old PC, and with a computer in the workshop, a new low-cost product from M-DRO (Fig 23) makes fitting and using a DRO both relatively easy and affordable. Up to four position encoding 'scales' may be connected to the interface unit which connects to the PC which is used as the display. The basic software is available as a free download from their website ( so that you can try before you buy (other DRO systems are available).

Computer Aided Marking-Out ? PCD Example

Fig 24 - PCD Spreadsheet

How would you go about marking out hole positions around a circle? We could use protractors, compasses and scribers, but once equipped with an XY table or mill drill, a simple computer spreadsheet may be used to calculate all the hole coordinates for us. We can then set the machine one hole at a time by reading coordinates from the computer and setting the machine accordingly – this task is so much easier and less error-prone with a DRO! A spreadsheet for working out PCD points is shown in Fig 24. It uses equations similar to those used in a previous CNC G code example. These spreadsheets may be downloaded from the companion website Using it is simplicity itself, the user is invited to enter five numeric values in the five shaded cells. These numbers are; the PCD diameter, the centre X and Y coordinates, the number of points or holes, and the angle of the first one. No sooner entered, the required number of XY coordinate pairs are shown in the lines below. It is smart enough to display the correct number of results. Equipped with this spreadsheet and a mill-drill fitted with DRO, you can drill holes around a pitch circle diameter almost as quickly as a CNC machine could do. If you consider the time taken to write a CNC programme, it may well be quicker to do without CNC!

Other Spreadsheets Useful for 'HNC'

Fig 25 - Linear Spreadsheet

Fig 25 shows another very simple but useful spreadsheet. Whereas a CNC machine can zip along a straight line in any direction, the limits to human manual dexterity invariably lead to us carving lumpy lines when we try twiddling any more than one axis at a time. This spreadsheet could be used for 'HNC' straight line machining at strange angles, or as close to a straight line as we have the patience to cut. Having entered the coordinates of the start and end points, it works out the coordinates of any practical number of intermediate points – these can then be set on the machine by hand, the more points used the better the fit. This spreadsheet is also useful for working out hole positions where you might need to drill a number of screw holes across the width of some item, for example.

Both of these spreadsheets are quite simple, taking little time to design and create. In keeping with our whole ethos of trying to offload as much of the work as possible, the calculation method was worked out once with equations being written once in the first row of output cells. Once satisfied with the equations they were then copied and pasted into the next couple of hundred rows below. This might reveal the odd problem or two, in which case, the error can be corrected in the top row and the copy / paste operation repeated, over-writing previous erroneous efforts. You will recognise similarity with the method of using subroutines in G code – the equations are written once for the programme to 'loop' through many times.

Fig 26 - Helical Spreadsheet

To complete our tool-kit of CNC trajectory emulators, the spreadsheet of Fig 26 performs the same calculations as Mach3 software for cutting arcs. In fact CNC machines do not really cut arcs at all, being capable only of straight lines (but how straight exactly, is a topic for another time!). We accept machined arcs when sufficient short straights are cut to give a close enough approximation. This spreadsheet is rather more complex than the previous two. Again, as a matter of style, users are invited to enter data only in the cells shaded turquoise, but unlike the others, it is easy to put in information that makes no sense. The arc centre is required, and as with the 'Centre Format Arc' in Mach3 G code, this may be expressed as absolute X,Y coordinates or as offsets from the 'Start' position. This choice is selected by entering either the letters 'A' or 'R' (or 'a' or 'r') for 'Absolute' or 'Relative' in cell B7. The equations check that a valid character has been entered in cell B7 before it will allow any calculations. Likewise, as G code uses G2 and G3 codes respectively for clockwise and counter clockwise arcs, the figure '2' or '3' must be entered into cell B8 to enable further calculation. Once these are checked, there are two ways of finding the radius – from the centre to either the start point or end point. Clearly if these are not (at least very nearly) the same then some data error exists. If no 'radius error' is found, next the difference between start and end angles is found. This result may be positive or negative, but we know that for counter clockwise arcs the angle step must be positive to fit the convention of angle becoming more positive in this direction, and likewise opposite for clockwise. Upon this, a whole turns worth of angle may get added to or subtracted from the angle difference – as said, this is more complex than the previous examples, and goes to explain the 'Intermediate Workings out'.

The spreadsheets were created using 'Open Office Calc', a part of the free, 'Open Source' Open Office software, downloadable freely from the internet. They will also work with Microsoft Office Excel spreadsheet, and may work with others.

Profile-Hugging Boiler Bush Without CNC

Fig 27 - Machining a Boiler Bush on a Conventional Mill

Fig 28 - Boiler Bush skirt machining finished

Figures 27 and 28 show another spreadsheet being used to calculate machine settings to make a boiler bush. The spreadsheet was designed to lists pairs of position coordinates in terms of cut depth at angle around. The rotary table is rotated to the next angle, the tool is then set to the depth indicated for that angle, the sequence is repeated for the umber of angle steps to complete the circle. The spreadsheet allows easy setting of the three input values required. These are the radius of the boiler to be 'hugged', the radius of the hole into which the bush will fit, and the 'number of arcs or steps'. This gives the user an easy choice between taking longer machining a finer finish or roughing out in fewer steps. The undulations in the finish are clearly visible having used 72 steps, giving an angle step of 5 degrees in this example. The picture also demonstrates one way of preparing a lap-top computer for the 'Workshop Floor Bounce Test'! Balancing things on the milling machine table is probably never a good idea, particularly as the font size had been set to 'large' to enable easy reading from the bench some short distance away. A slightly better job might have been possible by mounting the rotary table on edge making the work piece horizontal, but the way shown was chosen to be similar to the CNC examples run on the KX3. This spreadsheet is also to be found on

Computer – a Versatile Multi-Tool

Hopefully you will now be convinced that computer, DRO, CAD and spreadsheets can be incredibly useful in the engineering workshop. Downloading these spreadsheets and running them on your own PC will allow you to see all the inner-workings. Please feel free to use, copy or modify them for your own use. To make changes you will first need to 'un-protect' them. This is found under the menu. Protection was applied to help prevent accidental obliteration of equations, no password used.

Why Equals “ = ” Sometimes Doesn't Work !

We make the “ = ” symbol work quite hard for us in our use of spreadsheets and other scientific and engineering software. In writing Mach3 G code, the use we find for it is in statements such as:

#21 = cos[#22]

In this context, “ = ” is the assignment operator, that is to say the result of the cosine calculation is assigned to, or placed into, the memory cell labelled #21. There isn't much to go wrong here, unless an attempt is made to shove a number somewhere it cannot be shoved!

With spreadsheets, any cell may be left empty, used to contain a number or text, or may be used to display the result of some formula or function written into that cell. Using the '=' symbol as the first character of the cell content indicates the cell contains some formula or function. To see how this works, if you enter the text

2 + 2

into a cell, it will appear in the cell as '2 + 2' as the spreadsheet interprets this as a piece of text. If instead you enter

=2 + 2

this is interpreted as a formula and the cell content reads as '4'. As an example of the second use of an equals sign in one line, the cell G9 of the spreadsheet of Fig 04 contains:

=IF(RadStart = RadEnd; "Radii Same"; "Radii Different")

The general form of this, the spreadsheet 'IF' function being:

=IF(expression true; do this if true; do this otherwise )

In this second use, the expression 'RadStart = RadEnd' compares the results of calculations in cells i16 and i17 (cells which have been renamed 'RadStart' and RadEnd' to help make equations more readable), the comparison evaluating to 'TRUE' or 'FALSE'. This is a test, not an assignment. As explained above, the radius at the start and end of an arc must be the same (or very nearly so), but this check doesn't seem satisfactory. Cell G9 shows “Radii Different” when all the other information looks correct. The problem with this very simple test is that it does not take into account any of the possible rounding or truncation errors in either the calculations or the figures entered for use. The cells only display figures to two or three decimal places because the cell formats have been set like this to give a tidy display. The underlying maths is performed to greater but not absolute accuracy with a number of 'decimal places' remaining unseen. For these reasons it seems more sensible to look for a “Close Enough” test, rather than an “Equals” test. As for what constitutes “Close Enough”, there is nothing to be gained chasing sub-micron accuracy when we can't machine or measure to this resolution. In this spreadsheet the proper test is conducted in cell i18 where the test used is:

IF( ((RadStart-RadEnd < 0.01) AND (RadStart-RadEnd > -0.01)) ; ; )

This allows for a little wiggle-room by evaluating 'TRUE' so long as the two radii agree to within 0.01 units (whether inches, mm or what is not specified).

Another Spreadsheet Saves the Day

Fig 29 - Challenger Lathe Thread Chart Plate and Controls

Fig 30 - Lathe Thread Chart Spreadsheet

A workshop true story as a further example of the usefulness of the humble spreadsheet, although not related to CNC.

A message arrived at Jon's workshop from a local full-size locomotive restoration team. The tatty sketch showed a plumbing part with a one inch 11TPI thread on one end and a three eighths BSP thread on the other, and the message read; “can we have one by tomorrow please?” Having a suitable piece of bronze to hand, Jon replied; “No problem, I'll drop it round first thing.” Looking up the BSP thread – 19 TPI. Looking at the screw-cutting plate on the lathe (Fig 29), no problem cutting 11 TPI but – ah! 18, 20, but no 19 TPI.

Not about to give up, looking at the chart, there are lots of possible settings not listed. Looking at the number of change wheels and the various ratios set by all combinations of the knobs and levers comes to over 2000 possible ways of setting up for screw cutting, rather more than the 67 shown! Could there be a way of setting up for 19 TPI not shown on the chart? How long would it take to work out all those possible combinations? It took maybe a couple of hours to knock-up a spreadsheet (Fig 30) capable of showing all possibilities, it revealed no ways of cutting an exact 19 TPI but there were three settings offering 19.05 TPI, strictly speaking a metric thread of pitch one and a third mm, close enough to get out of trouble this time.

Continued in Part Nine