Sinumerik 840D C-Axis Cam Milling Polar Interpolation Subroutine

David Krause14 min read
Motion ControlSiemensTechnical Reference
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Overview: Why C-Axis Interpolation for Cam Profiles

Milling a non-circular cam lobe with a CNC mill requires simultaneous coordination of a rotary contouring axis (the C-axis, typically the workpiece spindle in turning-mill configurations or a 4th-axis rotary table in a machining centre) and a linear contouring axis (X or Y). When the cutter must trace a closed profile that is described as a function of the angular position of the workpiece, the controller is asked to interpolate two axes where the path is parameterised by an angle rather than by an arc length. Standard linear (G01) and circular (G02/G03) interpolation cannot follow an arbitrary closed curve at constant angular velocity without error, so an explicit kinematic model of the cam must be supplied to the control.

This reference describes the workflow for generating a cam-lobe roughing subroutine on a Siemens SINUMERIK 840D sl / SINUMERIK Operate controller (and the closely related 810D platform), using polar coordinate interpolation. The same principles apply to the Emco WinNC Sinumerik 810D/840D retrofit package, where the underlying NCK kernel is the same as the production Siemens control. The article covers the mathematical model, the NC commands required, a complete parametric subroutine, derivative-based quality checks, and a troubleshooting matrix.

Mathematical Foundation of a Cam Profile

A cam profile is described by a polar coordinate function r(θ), or equivalently by a radius-of-curvature envelope ρ(θ) where the contact point on the follower defines the cutter centre path. The ith derivative of position defines the kinematic smoothness of the cam, and these derivatives dictate what NC interpolation strategy is acceptable.

Derivative of position r(θ) Physical meaning Machining implication
1st: dr/dθ Slope (tangent direction) Determines cutter feed-rate modulation along the lobe
2nd: d²r/dθ² Curvature Limits step-over for fixed cutter diameter; required for tangential arc segments
3rd: d³r/dθ³ Jerk (rate of change of acceleration) Discontinuities create audible knock and follower liftoff; must be C¹-continuous
4th: Snap Rate of change of jerk High-performance cams for high-rpm engines
5th: Crackle Rate of change of snap Rare, racing only
6th: Pop Rate of change of crackle Reserved for theoretical cam design papers

A correctly designed cam must be -continuous at minimum: position, slope, and curvature must be continuous across lobe-to-dwell transitions. If the subroutine you write produces a profile that is only C&sup0-continuous (i.e. the curve is closed but the tangent has a kink), the follower will lift off at that kink and the cam will be functionally scrap, regardless of surface finish. Always check the first and second derivative continuity before sending the program to the machine.

Sinumerik 840D C-Axis Configuration

Before any cam program is generated, the C-axis must be released as a contouring axis. On the 840D sl the configuration is performed in Start-up > Axis Configuration and involves the following machine data:

  • MD30100 $MA_CTRLOUT_MODULE_NR – setpoint output for the C-axis
  • MD30200 $MA_NUM_ENCS – encoder assignment
  • MD30300 $MA_IS_ROT_AX = 1 – declares the axis as rotary
  • MD30310 $MA_ROT_IS_MODULO = 1 – enables modulo (0…360°) wrap
  • MD30320 $MA_DISPLAY_IS_MODULO = 1 – displays as 0…360° in the HMI
  • MD32010 $MA_JOG_VELO_RAPID – rapid traverse in JOG
  • MD32020 $MA_JOG_VELO – jog feed

For turning-mill configurations where the C-axis is the workpiece spindle acting as a rotary axis, additional settings are required under Start-up > Spindles:

  • MD35000 $MA_SPIND_ASSIGN_TO_MACHAX – assign spindle to channel axis
  • MD35400 $MA_SPIND_OSCILL_DES_VELO – oscillation speed (used during C-axis mode reversal)

The complete machine data list for converting a spindle to a C-axis is published in the SINUMERIK 840D sl Commissioning Manual and the List Manual (FB1, FB2, FB3).

Polar Coordinate Interpolation Commands

Polar coordinate interpolation causes the control to interpret a linear axis command as a radial command while the C-axis provides the angular coordinate. The cutter is then driven so that its tip traces the polar curve r(θ) directly.

Siemens (SINUMERIK) syntax

Siemens does not use the Fanuc-style G112/G113 G-codes natively. The 840D sl provides the equivalent through the TRACYL (transparent cylinder) and TRANSMIT (transparent transmission) transformations for peripheral milling and face turning respectively. For pure polar coordinate interpolation where a single linear axis and a rotary axis are coupled, the relevant construct is:

ROT Z ; orient the polar frame, Z is now the radial axis
AROT Z ; absolute rotation of frame
G111 ; activate polar coordinate interpolation (SINUMERIK 840D)
G112/R,<radius>,<angle> ; move to polar point
G113 ; cancel polar coordinate interpolation

The Emco WinNC Sinumerik builds accept both the native Siemens syntax and the Fanuc-compatible dialect. The Fanuc dialect uses:

G112 X_ Y_ ; activate polar interpolation, origin at workpiece
G01 C_ F_ ; linear axis (X or Y) becomes radial, C is angle
G113 ; cancel polar coordinate interpolation

In the Fanuc dialect, the linear axis declared in the G112 block becomes the radial feed axis, and C provides the angular position. Feedrate F is interpreted as mm/min along the radial axis (or mm/rev with G95 active). The control internally converts the radial command and the angular command into simultaneous X-C or Y-C motion such that the tool tip traces a polar path. This is the simplest way to drive a parametric cam curve r(θ) when the curve is described in polar form.

Cam Profile Subroutine: Polar Form

The following subroutine demonstrates a working polar-interpolation roughing pass for a symmetric cam with two lobes. The radial function is supplied as a discrete table R[i] and C[i] (angle in degrees), and the subroutine linearly interpolates between samples. For final roughing on a heat-treated blank before profile grinding, this is sufficient.

;============================================================
; CAM_ROUGH.SPF - 2-lobe cam roughing subroutine
; SINUMERIK 840D sl / Emco WinNC Sinumerik 810D/840D
; Calls: CAM_ROUGH(<base_radius>, <lift>, <start_angle>, <step_deg>)
;============================================================
PROC CAM_ROUGH(REAL R_BASE, REAL LIFT, REAL A_START, REAL STEP)
DEF REAL ANG, RAD, RAD_OLD, D_RAD, PATH
DEF INT N, I

; Select C-axis as contouring axis (turn spindle into C-axis)
SETMS(0)        ; master spindle = spindle 0
M70             ; spindle becomes active rotary axis on 840D

; Switch to polar interpolation, X is radial
G111            ; Siemens polar interpolation ON
G94 G97 F120    ; mm/min, constant spindle speed (irrelevant in C-mode)

; Compute number of steps for 360 degrees
N = 360 / STEP

; Initial position
ANG = A_START
RAD = R_BASE + LIFT * SIN(ANG * 3.14159265 / 180)
G0 X=RAD C=ANG   ; rapid to start

; Roughing pass with tangential continuity
RAD_OLD = RAD
FOR I=1 TO N
  ANG = A_START + I * STEP
  RAD = R_BASE + LIFT * SIN(2 * ANG * 3.14159265 / 180)
  D_RAD = RAD - RAD_OLD
  PATH = SQRT(D_RAD*D_RAD + (RAD * STEP * 3.14159265/180)^2)
  G1 X=RAD C=ANG F=120
  RAD_OLD = RAD
ENDFOR

G113            ; cancel polar interpolation
M71             ; restore spindle mode
RET
ENDPROC

The lift term LIFT * SIN(2*ANG) produces a symmetric two-lobe cam with base circle R_BASE. Each lobe rise and fall is described by a half-sine, which is C-infinity continuous and trivially parameterised. The radial command X=RAD and the angular command C=ANG are interpolated simultaneously by the NCK so the cutter tip moves on the desired polar curve. For a single-lobe cam, replace SIN(2*ANG) with SIN(ANG) and extend the angular range to 720°.

Tangential Continuity vs Notching

If you command C-axis motion in 1-degree increments with G01 blocks, the resulting toolpath consists of short straight segments. The cutter traces a polygon that approximates the cam, but the second derivative of position is undefined at every vertex: the curvature is impulsive. This is the "notching" technique. It is acceptable for a roughing pass that will be followed by profile grinding, but it is not acceptable for a finished cam. Two problems arise:

  1. Follower liftoff: A knife-edge follower will jump at every vertex, accelerating wear on the roller bearing.
  2. Cutter load spikes: At each vertex, the cutter must abruptly change direction, producing a chatter mark that profile grinding cannot fully remove on a thin case-hardened layer.

To obtain tangential arc continuity at the sampled points, the subroutine must insert a circular arc segment between each linear sample. This is done by computing the local radius of curvature at each sample point and inserting a G02/G03 arc of that radius between samples. The formula for the radius of curvature in polar coordinates is:

ρ(θ) = (r² + (dr/dθ)²)^(3/2) / |r² + 2(dr/dθ)² - r(d²r/dθ²)|

For the half-sine lobe r = R_BASE + LIFT*SIN(θ), the curvature is well behaved everywhere except at the inflection points. The polar-interpolation subroutine above generates C&sup0-continuous output (the cutter is on the curve) but the velocity vector is not C¹-continuous because of the discrete samples. To upgrade to C¹ continuity, generate an interpolated polyline with chord error less than the desired surface tolerance, and add explicit corner-rounding arcs of radius ρ at every vertex using G1 X.. C..,RND=ρ.

Macro Programming for Arbitrary Curves

SINUMERIK 840D supports arithmetic in NC programs through the DEF statement, the built-in functions SIN, COS, TAN, SQRT, EXP, LN, and the conditional IF-ENDIF, FOR-ENDFOR, and WHILE-ENDWHILE constructs. This makes the control capable of generating any curve that can be expressed as a closed-form function of θ, including:

  • Trochoidal cams (used in automatic watch movements): r = R_BASE + A*SIN(kθ) + B*SIN(2kθ)
  • Polynomial cams (7th-degree polynomials give smooth jerk): r = a0 + a1θ + a2θ² + ... + a7θ&sup7
  • Fourier-series cams: r = a0 + Σ[a_n*COS(nωθ) + b_n*SIN(nωθ)]
  • Harmonic-drive cycloidal cams: r = R_PRIM - R_GEN*SIN(θ)

For very large point counts (more than about 10000 samples), the loop overhead in the NCK becomes significant. In that case, pre-compute the points off-line in a CAM system and write them as a flat NC file. The CAM System for Scroll Profile with Three CNC Interpolations research paper describes the linear-interpolation approximation strategy used in commercial CAM packages when generating non-circular profiles that exceed the NC's block-buffer size.

Roughing and Finishing Strategy

Because the C-axis polar-interpolation path is roughed out before heat treatment and then finish-ground, the recommended workflow is:

  1. Rough turn/turn-mill the blank to within 0.5 mm of the final lobe profile. Stock allowance for grinding is typically 0.2–0.4 mm per side.
  2. Pre-heat-treat stress relieve at 650°C to stabilise geometry.
  3. Rough mill the cam using the polar-interpolation subroutine above, with a ball-nose or torus cutter leaving 0.1–0.2 mm stock for grinding.
  4. Heat treat (case harden or through harden as required).
  5. Deflection straighten after heat treatment.
  6. Profile grind on a cam grinder using the same polar curve, but interpreted at sub-micrometre resolution.
  7. Lap or super-finish the contact surface.

The NC roughing pass must therefore leave a uniform stock allowance, regardless of cutter geometry. Use the cutter-radius compensation (G41/G42 with CUT2D or the 5-axis equivalent CUT3DFS) to offset the toolpath by the cutter radius, plus the grinding stock.

Cutter Selection and Compensation

For cam milling, the cutter must produce a concave fillet at the base circle that matches the smallest follower radius. The standard choices are:

Cutter type Geometry Best for CUT2D offset
Ball-nose Hemispherical tip General cam roughing, free-form cams Yes, G41/G42 + CUT2D
Torus (bull-nose) Tip radius + cylindrical land High-feed roughing on convex lobes Yes, G41/G42 + CUT2D
Conical (tapered ball) Cone + spherical tip Steep-sided cams with small base radius Yes, G41/G42 + CUT3DFS
Plain end-mill Flat bottom Only for prismatic features, not lobes Not suitable

Activate cutter-radius compensation outside the polar-interpolation region (use G111/G113 or G112/G113 to bracket it), because some NCKs do not allow CRC inside a transformation. Issue the compensation cancel before G113 to avoid Alarm 10753 "Cutter radius compensation cannot be used together with polar coordinate interpolation".

Feedrate and Spindle Considerations

During C-axis mode, the spindle is acting as a contouring rotary axis, so any commanded S value is irrelevant. The effective cutting speed (m/min) varies around the cam because the radius changes. To keep chip load constant, use the feed-per-tooth value with a virtual teeth count and a virtual spindle speed:

fz_eff = fz * z_eff
v_cutter = fz_eff * z_eff * RPM / 1000   ; m/min, varies with r(θ)
; Constrain fz so that v_cutter never exceeds the cutter rating
IF fz_eff * z_eff * RPM / 1000 > V_MAX
  F = V_MAX * 1000 / (z_eff * RPM)        ; re-compute feed
ENDIF

On SINUMERIK 840D sl, the F word in G1 inside the polar block is interpreted as the velocity along the radial axis unless G95 (feed per revolution) is active. With G95 active and a virtual C-axis spindle speed, the feed is automatically modulated by the radius, which is usually what the operator wants.

Verification Procedure

Before running any cam program on a workpiece, verify it using the following checklist:

  1. Dry-run in graphics simulation. Use SINUMERIK Operate's 3D simulation view with the workpiece blank defined. Verify that the cutter does not gouge the base circle or exceed the lobe tip.
  2. Check the curve closure. The end position must match the start position to within one block-lookahead distance. If it does not, add an explicit final G1 X=R_BASE+A_START C=A_START block.
  3. Check the first derivative (slope). Plot dr/dθ at the sample points in a spreadsheet and verify that there are no impulsive jumps.
  4. Check the second derivative (curvature). Plot d²r/dθ². A cam with continuous curvature must have no sign reversals except at the intended inflection points.
  5. Single-block first cut. Run with Single Block enabled and rapid override at 25% for the first execution. Watch the load meter on the spindle drive and stop immediately if the load exceeds the rated continuous value.
  6. Probe the lobe tip and base circle. Use a touch probe (SINUMERIK 840D supports the standard probe cycles CYCLE971, CYCLE972, CYCLE973, CYCLE974) to verify the actual radius at 0°, 90°, 180°, and 270°. Tolerance should be within 0.05 mm for a roughing pass.

Troubleshooting Matrix

Symptom Probable cause Resolution
Alarm 10753 "CRC not allowed with polar interpolation" Cutter-radius compensation active inside G111/G112 block Cancel CRC (G40) before G111, reactivate after G113
Alarm 16720 "C-axis not released" Spindle-to-C-axis switching not configured in MD35000 Set MD35000 $MA_SPIND_ASSIGN_TO_MACHAX and issue M70 before polar interpolation
Alarm 21612 "Axis change disabled during transformation" C-axis commanded outside the modal G111/G112 range Keep all C-axis commands inside the polar block; avoid resetting C mid-curve
Profile is closed but has visible chatter marks every 1° Subroutine using 1° notching without RND corner rounding Reduce step to 0.1° or add RND=ρ corner-rounding arcs
Lobe tip is undersize by 0.1 mm Compensation not engaged, or cutter-wear offset stale Verify G41/G42 with CUT2D is active; reset cutter geometry per $TC_DP1
Path velocity is not constant F word interpreted as linear feed, not tangential Use G95 feed-per-revolution with a virtual C-axis speed
Alarm 14011 "Programmed and computed end point differ" Polar interpolation block truncated by block-limit Increase look-ahead (MD20150 $MC_GCODE_RESET_VALUES, block 20 default 50)
Cutter plunges into base circle at transition RND corner radius larger than local curvature radius Compute local ρ and clamp RND to 0.8 * ρ_min

Safety and Operator Notes

Warning: When the spindle is acting as a C-axis, the spindle-drive brake must be engaged via MD36933 $MA_SAFE_DES_VELO_LIMIT in safety-integrated mode. If the brake is not engaged, the workpiece can rotate under gravity when the drive enable is removed, causing a crush hazard.
Caution: Never command an M-code that switches the spindle back to spindle mode (M3/M4/M5) while inside a G111/G112 polar block. This will produce undefined NCK behaviour and may trigger Alarm 16720. Always issue G113 first.
Notice: For sub-spindle configurations with a counter-spindle on a turning-mill, both spindles can be C-axes simultaneously if configured, but polar interpolation only applies to the active master spindle (SETMS). The second spindle must be parked or in C-axis mode but not in polar interpolation.

FAQ

What is the difference between G112/G113 polar interpolation and a TRACYL transformation on the 840D sl?

Polar interpolation (G112/G113) couples one linear axis and one rotary axis in the workpiece plane, with the linear axis acting as the radial coordinate. TRACYL couples two linear axes to a rotary axis to drive a peripheral-milling toolpath on a cylindrical surface (e.g., a scroll profile). For a flat cam, G112/G113 is the simpler and more direct choice; TRACYL is for wrap-around surfaces.

Can I use polar interpolation on a 4-axis machining centre that has a rotary table as the C-axis?

Yes, provided the rotary table is declared as a contouring axis (MD30300 = 1) and modulo (MD30310 = 1). The X or Y axis of the table becomes the radial axis in the polar block, and the table rotates as the C-axis. No spindle-to-C-axis switching (M70) is required because the rotary table is already a true NC axis.

What is the maximum number of polar-interpolation blocks that the 840D sl can execute per second?

On a standard NCU 710.3 the block-processing rate is approximately 200 blocks/s for short polar blocks. With look-ahead (MD20150) set to the default of 50, the actual path velocity is limited by the controller's ability to process the block buffer. For point counts above 5000, switch from inline parametric generation to a flat pre-computed NC file.

Why does my cam have a visible seam at the start angle even though the math is closed?

The seam is almost always a tolerance mismatch between the end position of the last block and the start position of the first block. Because the polar block is computed in single-precision floating point inside the NCK, the last block may end at 359.99° instead of 360°. Add a final explicit G1 X=R_BASE C=A_START block to force closure, or use SETMS with modulo wrap to suppress the offset.

Can cutter-radius compensation be active inside the polar block?

On the 840D sl, cutter-radius compensation (G41/G42) is not permitted inside G112/G113 polar interpolation; the control raises Alarm 10753. Cancel CRC with G40 before entering the polar region, and reactivate it after G113. The polar block must therefore already be offset for the cutter radius, which is the responsibility of the subroutine author.

Back to blog