Part Program Structure
Part program structure is the anatomy of a CNC program — the way its blocks are ordered, its work sequenced and its sections organised — and it matters as much as the codes themselves. A program block tells the machine one small thing; the structure of the whole program decides whether those blocks run a job safely, cleanly and predictably from beginning to end. A well-structured program opens by setting every assumption to a known value, runs each tool’s work in a logical order, retracts and changes tools at safe moments, and ends decisively; a badly structured one runs on assumptions, changes tools in the middle of a feature, and surprises the operator halfway through the job. This entry, the first structure of the programming group’s sequence, sets out how a part program is put together.
What a part program is
A part program is the complete set of instructions for one job or one operation: the tool to use, the position to cut, the speed and feed to run at, and when to stop. It is stored under a program number (the O word on most controls), and it is executed from the first block to the last, each block a line that the control reads and acts on in order. Within that running list, the blocks play different parts — some position the tool, some cut, some switch the machine’s auxiliaries on and off, some end the program — and the structure is the deliberate arrangement of those parts. Most programs also carry sequence numbers (the N word), which number the blocks so that a specific line can be found, started from or edited; the numbers are the program’s street addresses, and a program that numbers its blocks in steps keeps room to insert new ones. The codes themselves are the vocabulary, and the structure is the grammar that turns vocabulary into a job.
The opening: setting the state
A part program opens with a header, and the header’s business is to remove assumption. Because the meaning of every later block depends on the modal state left active — as the reading a program block entry explains — a program must not begin with a line of cutting and hope that the control is in the right mode. The opening blocks therefore force the critical modes to known, safe values: absolute rather than incremental position, the correct unit system, the active work offset selected, tool length compensation in the state the program expects, and the tool, spindle and coolant as the job needs them. The header also carries the program’s identity for the human reader — a comment naming the part, the operation, the material and the tool list — so that anyone who opens the program knows what it is for. A program that begins by declaring its state is a program that can be read, proved and trusted; a program that begins by hoping is a program that will one day surprise someone.
The run: from safe start to finished feature
After the header, the program runs the job, and the run follows a disciplined order that protects both the part and the machine. A tool is brought to the spindle — loaded at the tool-change position — and its length offset is made active so that the control knows where the tool tip is. The tool then moves at a safe clearance height to a point above the start of its work, and only there does it move down to the cut: no rapid move is ever allowed to pass through the part or the workholding, and the structure keeps every positioning move above the highest obstacle. The spindle is started and the coolant turned on, and the machining blocks run the feature — the offsets and compensations doing their work as the earlier entries describe — until the tool retracts to clearance, the coolant stops, and the tool returns to the change position to make way for the next. The discipline of the run is the discipline of height and order: down to cut, up to clear, across at height, down again — repeated feature by feature, tool by tool, until the last tool finishes the part and the program ends.
Organising the work
The order of the cuts within a program is a decision, and good structure makes it deliberately. The commonest and soundest rule is to group the work by tool: every feature that one tool can cut is cut while that tool is in the spindle, before it is changed for the next, so that the part is not re-set and the machine is not slowed by needless tool changes. Within a tool’s work, the cuts are ordered by the needs of the part — roughing before finishing, so that the finishing cut runs on a part already relieved of most of its metal and its stress; the heavy and the rough work first, the delicate features last; and features that share a datum or a setup together, so the part is not disturbed between them. Where the part is thin or easily distorted, the structure also balances the metal removal so that one side is not emptied before another. These are the decisions of a machinist as much as a programmer, and the program’s structure is where they are written down.
Structure for the person, not only the machine
The program is read by the control, but it is proved, edited and maintained by a person, and a well-structured program is written to be read. Sequence numbers step in tens so that a block can be inserted between existing ones; comments in parentheses mark each section — the tool, the operation, the intent of a tricky move — so that the operator can follow the job and find the line to change; and the conventions of the shop are kept consistent from one program to the next, so that every program reads like every other. This is the structure that pays at the machine, because a readable program is a provable one: the operator can step it block by block, check each move against the part, and run it with confidence. The part program structure is the skeleton on which the codes hang — the blocks give it its sentences, the offsets and compensations its accuracy — and the skeleton is what makes a list of blocks into a job that runs, first time, from a safe opening to a finished part.