CNCUtil Users Guide

DRAFT STILL UNDER CONSTRUCTION
comments requested

Introduction

The cncutil.org CNCUtil Library allows Machinests to retain the control of the milling machine where it is needed while allowing the computer to do the hard work of producing the GCODE needed for things like circular pockets, Arc pockets, etc. CNCUtil also does most of the math which tends to take up a lot of a GCODE programmer's time.

When using CNC for milling everything ultimately boils down to moving the milling bit up, down left, right, etc. in carefully controlled movements as small as 10,000 of an inch.   This movement is ultimately controlled by a scripting language called GCODE which is conceptually like the LOGO turtle which Apple invented to teach graphics to children only GCODE is harder to read than most modern languages and is missing many features found in most programming languages.

When GCODE is hand written it can allow expert machinists detailed control over the actions of the machine but it can be quite cumbersome, error prone and time consuming. On the other hand it is possible to draw the desired shape in 3D CAD packages and then surrender all control over the movements of the machine which tends to produce inferior parts, use more machine time and consume more materials. &nbps; What quite often happens is that people draw with the CAD convert with CAM system and then end up manually editing the GCODE which is very time consuming because the GCODE is one big long sequence and every time the CAD image changes the CAM conversion has to be redone so the manual editing also has to be redone.

CNC Util provides an alternative solution which works in a way that most programmers find intuitive. You are able to clearly describe what you want the machine to do with a series of high level commands and the library takes care of all the mundane work necessary to generate high quality GCODE. When using CNCUtil productivity is highest when using our high level object such as arc pocketing but at any time you can drop down to detailed level control and you can even merge in existing GCODE snippets without having to manually edit the resulting output.

Getting Started

Download & Install

You will need to download and install both ruby and our library. This process is described in the our guide Running the programs

Getting Started

The way I learn best is with a series of well explained examples that explain how to accomplish increasingly complex things. For that reason this document is organized as a series of examples

The library automatically takes care of a lot of the math needed when using GCODE but sometimes you may want to use the math functionality directly such as when you need to calculate an angle when you know the location of a point.

There are a few basic knowledge items which didn't fit well as indepentant examples which we have grouped in to a separate section. I suggest looking at those after you have reviewed several examples.

Once you have deveoped a basic understanding of the library using the examples here it will be much easier to understand the full fledged projects

Detailed class, method level documentation is available in our Library Class, Method and Attribute documentation This includes comments we added to the source code and can be an invaluable aid in using the library.

CNC Process

This document assumes that you understand the basic CNC process along with the major components of CNC hardware and software. This is described in some detail in the CNC process portion of our overview document This is rather critical knowledge so please review this if you are not already familure with CAD, CAM, CNC Drivers, etc.

Understanding GCODE

When using our library it you are ultimately giving the computer high level instructions that it uses to generate a computer scripting language called GCODE which is ultimately what is read by the CNC driver software which turns the stepper motors that move the milling head. It can be helpful but not essential to understand the basics of GCODE which is described in our Introduction to GCODE document. This one is a pretty quick read. It also provides an overview of the coordinate space used by CNC mills which is essential knowledge when planning milling jobs. GCODE is explained at a higher level in our overview document

Understanding Ruby

When you are writting scripts that use our library you are ultimately writing simple Ruby programs. A basic knowledge of Ruby can be helpful but is not essential. For that matter you can accomplish quite sophisticated parts simply by reviewing our examples and our more complex projects which bring the individual concepts explained in the examples together to mill complex parts. We have published some basic ruby information in our Ruby Notes document.

 

What is a CNCShape

Whenever you see me using a CNCShape type object it is an object which has used more primitive operations and combined them to complete a more complex task. The CNCShapeSpiral object is a good example of such an object. Normally you would never need to see how I approach milling a spiral but if you have a similar task that the built in object is not quite capable of you can take use the ruby source as an example and enhance it.

 

Cutting tool Compensation - Adjusting for Bit sizes

This is a task that many people want to make quite complex but it is almost absurdly simple. Image you are milling out a square pocket that is 4 inches per side and you want it to measure exactly 4 inches across.

 

I like to mill with a 1/2" (0.5") diameter bit. If I pace the exact center of the bit on a line it will mill out one half of it's diameter which is actually it radius of 0.5 or 0.025 inches on each side of the center point.

 

If I want my square to be exactly 4 inches wide and 4 inches tall then I have to move the milling head 1 bit radius to the inside to allow for the amount the bit will cut on both sides. Most of the CNCUtil pocketing and shape commands will automatically deduct the proper amount for the bit size you are using but when you resort to more primitive lines you may have to accomdate this manually.

 

So when using the 0.5" inch bit on a 4 inch square pocket rater than moving from 0,0 to 4,0 to 4,4 to 0,4 to 0,0 I have to move in one bit radius or 0.25 inches for each exterior coordinate. Or if I was milling an outside profile I would have to move out the same amount. The dimensinions adjusted are 0.25, 0.25 to 0.25, 3.75 to 3.75, 3.75 to 0.25, 3.75 to 0.25, 0.25.

 

Obviously adjusting for bit diameters is cumbersome and time consuming so all the CNCUtil pocketing commands automatically take them into account and make the adjustments automatically.

 

 

TODO: Insert picture

 

Climb milling

 

 

 

Examples

Examples are simple jobs that are not complex enough to consider a project and are generally intended to illustrate a single concept. Many examples include a link to a more complete piece of code that you can run as is or modify to suit your needs.

When require statements are shown it indicates that module is a required import for the functionality. A require is only needed once for a program is kept at the top of the file.

Many lines of comments have been added to the example code. These comments start with a "#" and continue to the end of the line. They are intended to explain the code and have no functional purpose. We normally do not comment this much and if you remove these comments most of the programs are 75% shorter.




Built in Math



Basic Things you need

Movement speeds

One of the most important things in milling is ensuring that the mill is moving the work head into the work material at an approapriate speed. If it goes to fast then the cut quality will be low but if it moves too slow it then the work can take much longer to finish which can dramatically lower productivity. CNCUtil addresses this by allowing you to feed in a test case where you measure the time it takes your mill to move 1 on 2 or 3 axises simultaneously. We convert this number to a feet per minute movement at each different speed. This feet per minute movement is used by the software to select a speed for both rough and finish cutting based on the characteristics of the current bit and the current material. In your machine configuration file you supply the following array: @test_speed = [82,44,30,21,19,15,12,11,9,8,7.5,7,6.5,6.4,6.2,5.5,5.4,5.3,4.5,4] by calling the test_speed setter method and the CNCMill class will calculate the feet per minute based on these numbers. The numbers are the time in seconds it took to move 1 inch on all three axis simultaneously starting at F1 working up to F20. # Test result for EMC2 driving Xylotex controller hooked to my Taig 2019Cr mill. (F1FPM=0.0609756097560976 test speed=82) (F2FPM=0.113636363636364 test speed=44) (F3FPM=0.166666666666667 test speed=30) (F4FPM=0.238095238095238 test speed=21) (F5FPM=0.263157894736842 test speed=19) (F6FPM=0.333333333333333 test speed=15) (F7FPM=0.416666666666667 test speed=12) (F8FPM=0.454545454545455 test speed=11) (F9FPM=0.555555555555555 test speed=9) (F10FPM=0.625 test speed=8) (F11FPM=0.666666666666667 test speed=7.5) (F12FPM=0.714285714285714 test speed=7) (F13FPM=0.769230769230769 test speed=6.5) (F14FPM=0.78125 test speed=6.4) (F15FPM=0.806451612903226 test speed=6.2) (F16FPM=0.909090909090909 test speed=5.5) (F17FPM=0.925925925925926 test speed=5.4) (F18FPM=0.943396226415094 test speed=5.3) (F19FPM=1.11111111111111 test speed=4.5) (F20FPM=1.25 test speed=4)

 

 

(c) cncutil.org, Inc - All rights Reserved