CNC Programming and Computer-Aided Manufacturing/Design

cnc programmingCNC programming, computer-aided manufacturing, and large-scale control systems such as SCADA — the hardware side of industrial programming is at least as important to industry as its more glamorous sibling, computer-aided design. CNC programming is what makes machine tools actually perform the complex tasks that are required of them; without it, much of today’s technology would not be possible. Software and Web design trends may come and go, but CNC and CAM skills are always in demand.

CNC: What Is It?

CNC stands for Computer Numeric Control. CNC, CAD (Computer-Aided Design), and CAM (Computer-Aided Manufacturing), together form the basis of modern-day software-controlled industrial manufacturing systems. CNC machines are software-controlled machine tools, such as lathes, mills, and cutters. They are used to perform the same tasks as traditional machine tools and mechanically-automated tools; CNC machines, however, are controlled entirely by software. CNC machines include extremely precise multi-axis milling tools and high-powered, high-precision laser and electron-beam devices which could not be operated accurately using strictly mechanical controls.

What About 3D Printing?

“Lathes and mills? I thought that 3D printers were going to replace them!”

3D printing is a rapidly-growing field, and 3D printers are already among the most important CNC tools. But they do have some built-in limitations. 3D printers are excellent with plastics and other materials which can harden by thermal or chemical processes after being formed. 3D printing with metals generally requires the metal to be sintered or melted at some point in the process, resulting in mechanical properties which may be very different from those of a piece machined from a rolled or heat-tempered alloy. And at this point, the 3D printing process simply can not match the precise tolerances of high-precision machining. For the time being, at least, the fully-automated factory floor is likely to have 3D printers working side-by-side with more traditional CNC machines, rather than replacing them entirely.

Trace It Back

Most descriptions of computer-controlled manufacturing systems focus on CAD and CAM — design and high-level programming — and treat factory-floor machine-tool control almost as an afterthought. But since we’ve been talking about CNC, let’s start with the CNC machine tools themselves, then trace the process backward to computer-aided manufacturing and design systems. After all, without the CNC machines on the factory floor, there wouldn’t be any computer-aided manufacturing. And as we’ll see, there are likely to continue to be significant opportunities for skilled machinists with a good working knowledge of low-level CNC programming, as well as high-end CAD/CAM software.

How They Work

Mechanically, many CNC machines work like traditional machine tools, with the workpiece, the cutting tool, or both rotating rapidly, and with the overall motion of the workpiece or the cutting tool precisely controlled by mechanical means. In a CNC machine, however, these mechanical actions are controlled by stepper motors or other servo-type mechanisms, which are themselves controlled by software. Besides mechanical cutting, milling, grinding, or drilling action, CNC machines can use flame, plasma, laser, electric discharge, or water-jet cutting, punches, knives, or even such specialized tools as embroidery needles.

For all of these systems, however, the actions of the tool and the workpiece are controlled by means of commands written in a CNC programming language.

CNC Programming Languages

While there is no single programming language for all CNC tools (many of which have strictly proprietary languages), G-code (or the G programming language) is the most widely used CNC programming languages, available in a variety of largely proprietary implementations. Of these, the FANUC implementation became at least a partial standard in the CNC industry in the 1990s. Initially, G-code resembled a low-level programming language, such as assembly language; later versions, however, include control structures and other features more typical of a high-level language. Current CAD/CAM software makes it possible to create machine instructions at the design level, then automatically convert them into G-code for the individual tools.

G and M

G-code largely consists of two types of command: G codes and M codes. G codes consist of the letter G (designating the memory address where the command will be stored) followed by a control number (from 0 through 99). G codes are traditionally called preparatory codes, because they tell the machine how it should move. G01 is a typical G code; it tells the machine to move the cutting tool (or workpiece) in a line at a specific feed rate or distance. It will be followed by codes indicating the axis of motion and increment.

M codes are called often miscellaneous codes; they control more general machine operations (motor on/motor off, coolant on/coolant off, spindle motion, etc.), and like G codes, consist of the M prefix followed by a one to three digit numeric code. Other codes (represented by letters of the alphabet followed by integer or decimal numbers) control such things as the axis, speed, or geometry of the cut. While other, strictly proprietary CNC languages may have different commands, they generally operate on similar principles.

Higher-Level Control

As you can imagine, writing G-code directly can be a time-consuming task, and the chances of introducing serious errors into the code are fairly high. Manual G-code programming is a bit like the days of MS-DOS, when programmers had to write their own printer drivers, sending low-level escape codes directly to the printer. And just as contemporary operating systems supply their own printer drivers, relieving the programmer of the need to send commands directly to the printer, contemporary CAD/CAM systems allow manufacturing designers and programmers to create control programs in a higher-level language (or wizard-style development environment) which the CAM software then converts to G-code. (Note, however, that in many situations, programmers still need to write their own low-level G code, since CNC programming is not yet as fully standardized as desktop or mobile OS programming.)

CAD

Now let’s look at the higher end. Computer-aided design (CAD) software is used to design items to be manufactured, ranging from a fairly simple stand-alone object to a complex, high-precision system made of a large number of individual parts. Design in CAD is primarily engineering design, rather than simple graphic design, and CAD output typically includes precise dimensions, tolerances, and even material requirements; CAD is frequently integrated with computer-aided engineering (CAE). The best CAD software is extremely sophisticated (and often very expensive), and skilled CAD designers are in high demand. There are very definitely good opportunities for anyone with a good knowledge of CAD software and the ability to produce technically complex designs that meet the precise engineering requirements of today’s technology.

CAM

CAD systems may be integrated with an entire suite of software, including project management and scheduling systems, product lifecycle management software, and computer-aided manufacturing (CAM) systems. When integrated with a CAD system, CAM software can take CAD output (essentially the design and specifications for a manufactured piece) and convert it directly or indirectly into CNC programming code.

In an ideal world, this design-to-manufacturing cycle would be seamless and easy: the designer would create the design in a CAD module and send it to a fully integrated CAM module, which would then automatically convert it perfect CNC code and send it to the appropriate factory-floor machines. In the actual world of here-and-now, of course, it isn’t that easy.

Human Skills Are in Demand

In practice, the G codes generated by CAM software are still, like most machine-generated code, often not as efficient or as well-tailored to the specific situation as the hands-on product of a first-rate programmer. Generated code may be much less prone to errors, but its design is based on generalized assumptions, rather than the specific requirements of the situation. In the case of CAM-generated codes, this may mean that the output must be checked and edited by hand before it can be run, in order to take into account the particular requirements of the machinery, or of the production run.

Seeing With a Machinist’s Eyes

A CAM program can’t see the factory floor through the eyes of an experienced machinist. Actual manufacturing conditions may require some tasks to be done by hand, even if they could theoretically be done as part of the CNC manufacturing process. And it isn’t unusual at all for workplaces to include improvised processes and steps, often in order to compensate for problems that were not anticipated in the original design phase. it’s not really surprising, since manufacturing processes go on in the physical world, where things are rarely as simple as they are in the idealized world of computer design.

Some Adjustment Required

What does this mean to anyone interested in pursuing a career in machine control or operation? Basically, it means that there will probably continue to be a need for skilled, knowledgeable machinists who understands both low-level CNC programming and practical factory-floor problems. Designers may be able to produce complete, sophisticated designs in high-end CAD software, then convert them into machine control codes with the click of a mouse, but they will still need skilled machinists at the factory-floor level to make that code work (and make it work efficiently) under real-world conditions.