Programming Examples

This section contains NC programming examples. The first one uses basic BNC programming features while the second example uses the NCPP programming features. The third example illustrates Polar Coordinates in a subprogram.

NC Part Program Example

Following the simple drawing below, of a part program, is a sample NC part program that may be used to test the BNC programming features.

NCPartProgramDrawingExample.PNG

 

Here is one way the part shown on the previous page may be programmed using the NC system:

BNC Part Program   1   Inch

PART.HNC

%

N10 G0 G90 x0. Y0. S500 T1 M6

N12 X0.5 Y0.5 Z0.5 M3

N15 G81 X0.5 Y0.5 Z0.75 F5.

N20 X0.5 Y7.5

N25 X9.5 Y7.5

N30 X9.5 Y0.5

N35 G0 X0. Y0. S1000 T2 M6

N40 G0 X5. Y6.5 Z0.5

N50 G0 G42 X5. Y6.5 M3

N55 G1 Z-0.25 F5.

N65 G2 X5. Y1.5 I5. J4. F10.

N70 X5. Y6.5 I5. J4.

N71 G0 Z0.5

N72 G0 G40 X5. Y6.5

N75 G0 Y10.5 Z3. M2

E

NCPP Example—Bolt NCPP Example—Bolt Hole Circle

The Bolt Hole Circle program uses subprograms to produce five different Bolt Hole patterns, as shown below, and specifies which canned cycle to use, how many holes to skip, and on which hole to begin the skip.

NCBoltHoleCircleExample.PNG

 

ISNC Part Program   1   Inch

BOLT_ABS.FNC

%

O4000

T1 M06

M03 G00 G90 X0 Y0 Z0 S1800

#500 = 99

G65 P5080 A30.0 B10 C2.5 S4 T3 H81 I-9 J-3.5 K0 Z-1 R-.7

G65 P5080 A30.0 B12 C2.6 S2 T4 H81 I9  J-3.5 K0 Z-1 R-.2

G65 P5080 A0.0  B8  C2.3 S6 T2 H81 I9  J3.5  K0 Z-1 R-.4

G65 P5080 A30.0 B9  C2.5 S2 T1 H81 I-9 J3.5 K0  Z-1 R-.1

#1 = 0

WHILE [#1LT5] DO 100

#500 = 98

G65 P5080 A90.0 B5 C[1.5+#1] S0 T0 H81 I0 J0 K.5 Z-2 R-.7

#1 = #1+1

N1000 END 100

M02

ISNC Part Program   2   Inch

BOLT_ABS.FNC

 

O5080

(#1 IS THE START ANGLE)

(#2 IS THE NUMBER OF HOLES)

(#3 IS THE RADIUS)

(#4 IS THE BOLT CIRCLE CENTER PT X COORD)

(#5 IS THE BOLT CIRCLE CENTER PT Y COORD)

(#6 IS THE BOLT CIRCLE CENTER PT Z COORD)

(#18 IS THE RETURN LEVEL)

(#19 IS THE HOLE TO SKIP)

(#11 IS THE CANNED CYCLE NUMBER)

(#26 IS THE HOLE DEPTH)

#30 = [360.0/#2]

#31 = 0

#32 = 0

#33 = 0

WHILE [#31LT#2] DO 250

#7 = [#1+[#31*#30]]

IF [[#19-1]EQ#31] GOTO 200

IF[#32EQ1] GOTO 200

#33 = 1

G00 Z#6

G#500 G#11 Z#26 X[#4+[#3*COS[#7]]] Y[#5+[#3*SIN[#7]]] R[#18] F20.

N200 #31 = #31+1

IF [#33EQ1] GOTO 300

IF [#20EQ0] GOTO 300

#20 = #20-1

#32 = 1

GOTO 310

N300 #32 = 0

N310 #33 = 0

N400 END 250

M99

NCPP Example—Gear Pattern

The program below uses Polar Coordinates in a subprogram to generate a Gear pattern:

NCGearPatternExample.PNG

 

NC Part Program   1   Inch

GEAR_ABS.HNC

 

%

M03 G00 G21 G90 X0 Y0 Z0 S1800

(VARIABLE #4006 - INCHES/METRIC)

IF [#4006 EQ 20] GOTO 10

IF [#4006 EQ 21] GOTO 15

N10 #850 = 25.4

GOTO 20

N15 #850 = 1.0

N20

G65 P5085 A30.0 B8 C2.5 S0 H2. I1 J1 K1 R.45 T.2

G65 P5085 A0.0 B5  C1.5 S0 H1.2 I5 J3   K1 R.3 T.2

G65 P5085 A15. B20 C1.8 S0 H1.5 I5 J-3. K1 R.6 T.1

M02

/

NC Part Program   2   Inch

GEAR_ABS.HNC

 

O5085

(#1 IS THE START ANGLE)

(#2 IS THE NUMBER OF GEAR TEETH)

(#3 IS THE OUTSIDE RADIUS)

(#11 IS THE INSIDE RADIUS)

(#4 IS THE GEAR CENTER PT X COORD)

(#5 IS THE GEAR CENTER PT Y COORD)

(#6 IS THE GEAR CENTER PT Z COORD)

(#19 IS THE TOOTH TO SKIP)

(#18 IS THE TOOTH RATIO)

/

#30 = [360.0/#2]

#31 = 0

#22 = [#30*#18]

#23 = #30-#22

#24 = #11*#850

#25 = #3*#850

#26 = #20*#23

G52 X#4 Y#5 Z#6

G90 G00 G16 X#25 Y#1

G01 Z-.25 F20.

WHILE [#31LT#2] DO 250

#1 = [#1+[#22]]

G03 G16 X#25 Y[#1] R#3

G01 X#24 Y[#1+#26]

#1 = [#1+[#23]]

G03 X#24 Y[#1-#26] R#11

G01 X#25 Y[#1]

G15

N200 #31 = #31+1

N400 END 250

M99

E

 

NCPP Example—Tool Variable Index

Variables 30000 - 30600 are reserved for NC tool setup. Some of these variables are read/write while others are read-only. See NC Tool Setup Variables for detailed descriptions. The code example below demonstrates how these variables can be used to specify individual tool numbers and to assign attributes of those tool numbers (such as cutting time) to other variables.

 

#30000 = 2000 (Sets tool setup variable read/write to target tool 2000)

#501 = #30004 (Stores cutting time for tool 2000 in variable 501)

#30000 = 3000 (Switches tool setup variable read/write to target tool 3000)

#502 = #30004 (Stores cutting time for tool 3000 in variable 502)