programare cnc

42
NCT ® Milling Machine and Machining Center Controls Collection of Part Program Examples

Transcript of programare cnc

Page 1: programare cnc

NCT®

Milling Machine and Machining Center Controls

Collection of Part Program Examples

Page 2: programare cnc

Produced and developed by NCT Ipari Elektronikai kft.H1148 Budapest Fogarasi út 7 : B.O. Box: H1631 Bp. pf.: 26F Phone: (+36 1) 467 63 00 F Fax:(+36 1) 363 6605

E-mail: [email protected] page: www.nct.hu

Page 3: programare cnc

3

© Copyright NCT 06.07.19

The Publisher reserves all rights for thecontents of this Manual. No reprinting, evenin extracts, is permissible unless our writtenconsent is obtained. The text of this Manualhas been compiled and checked with utmostcare, yet we assume no liability for possibleerrors or spurious data and for consequentiallosses or damages.

Page 4: programare cnc

4

Table of Contents

1 Programming Circular Interpolation with Positioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 Programming Circular Interpolation with Contour Tracking . . . . . . . . . . . . . . . . . . . . . . . . 63 Programming Circular Interpolation with Positioning in Tangential Direction . . . . . . . . . . 74 Programming Circular Interpolation with Contour Tracking . . . . . . . . . . . . . . . . . . . . . . . . 85 Circular Interpolation on Internal Contour . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 Inner Circular Interpolation with Contour Tracking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 Programming Inner Circular Interpolation with Positioning in Tangential Direction . . . . 118 Programming Straight Contour . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 Programming Straight Contour with Contour Tracking . . . . . . . . . . . . . . . . . . . . . . . . . . . 1310 Programming Zero Circles in Case of Contour Tracking . . . . . . . . . . . . . . . . . . . . . . . . . 1411 Contour Tracking with Rounding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1512 Rectangle with Inner Contour Tracking and with Positioning in Tangential Direction . . 1613 Programming Optional Contour with Contour Tracking . . . . . . . . . . . . . . . . . . . . . . . . . 1714 Definition of Optional Contour with Inner Contour Tracking . . . . . . . . . . . . . . . . . . . . . 1815 Optional Inner Contour (Subprogram) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1916 Subprogram Technique with Zero Position Offset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2017 Use of Increment with Subprogram Call . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2118 Programming Increment around Optional Position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2219 Programming a Series of Bores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2320 Programming Bore Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2421 Programming Center Circle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2522 Programming Center Circle Part . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2623 Programming Center Circle to Optional Position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2724 Programming a Series of Bores as Subprogram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2725 Programming Bore Net with the Help of Subprogram . . . . . . . . . . . . . . . . . . . . . . . . . . . 2826 Programming Bore Net with Cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2927 Programming Bore Net with Two Cycles Embedded in Each Other . . . . . . . . . . . . . . . . 3028 Automatic Geometric Calculation between Circle Arcs (Inner Contour) . . . . . . . . . . . . . 3129 Automatic Geometric Calculation between Circle Arcs (Outer Contour) . . . . . . . . . . . . 3230 Automatic Geometric Calculation between Circle Arcs (Inner Contour) . . . . . . . . . . . . . 3331 Programming Cogging - Subprogram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3432 Programming Cogging - Main Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3533 Programming Cogging with a Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3634 Programming Center Circle with Mirroring - Subprogram . . . . . . . . . . . . . . . . . . . . . . . 3735 Programming Center Circle with Mirroring - Subprogram . . . . . . . . . . . . . . . . . . . . . . . 3736 Programming Macro - Sinusoidal Curve . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3837 Programming Macro - Circular Milling, Cylindrical Interpolation . . . . . . . . . . . . . . . . . 3938 Programming Macro - Hemisphere . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4039 Programming Macro - Hemisphere Creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

06.07.19

Page 5: programare cnc

Collection of Part Program Examples

5

Y

XO100

Diagram 1

1 Programming Circular Interpolation with Positioning

%O7011(1.1)N100 T1N110 G54 G0 X0 Y-100N120 G43 Z50 H1N130 S1000 M3 M8N140 G0 Z5N150 G1 Z-10 F20N160 G1 X0 Y-50 F50N170 G3 J50N180 G1 X0 Y-100N190 G0 Z100N200 M30%

The first block contains the selection of toolneeded. The second block includesorientation in plane X-Y in the appropriatecoordinate system. The third block isresponsible for taking tool lengthcompensation into account. Other programexamples of the collection is shown withsimilar program start, therefore they are notdiscussed further on. The program start alsocontains a percent symbol as well as fourdigits after letter O, which is the programidentifier. The program is finished also witha percent symbol. These characters are to beindicated only when programming onexternal device, otherwise the control createsthem automatically. Tool path definition isstarted from the fourth block. Programmingof the whole circle is done with the help ofaddress J, which is the incremental definitionof circle center according to circle startposition. Program is closed with code M30.

Page 6: programare cnc

Collection of Part Program Examples

6

Y

XO100

Diagram 2

2 Programming Circular Interpolation with Contour Tracking

%O7012(1.2)N100 T1N110 G54 G0 X0 Y-100N120 G43 Z50 H1N130 S1000 M3 M8N140 G0 Z5N150 G1 Z-10 F20N160 G1 G42 X0 F50 D1N170 G3 J-50N180 G1 G40 Y-100N190 G0 Z100N200 M30%

The difference from previous example is thecontour tracking. Tracking is to be activatedin block N160. In this case the controlmodifies the block end position so that thenext block is moved by the referred tooldiameter at start. Stop functions similarly, inthis case compensation is 0 at the endposition of block (N180).

Page 7: programare cnc

Collection of Part Program Examples

7

Y

O100 X

Diagram 3

3 Programming Circular Interpolation with Positioning in TangentialDirection

%O7013(1.3)N100 T1N110 G54 G0 X-50 Y-50N120 G43 Z50 H1N130 S1000 M3 M8N140 G0 Z5N150 G1 Z-10 F20N160 G1 X0 F50N170 G3 J50N180 G1 X50N190 G0 Z100N200 M30%

The difference from previous example is thepositioning Since axes reach their desiredposition by the use of acceleration-deceleration, thus in the previous example thetool leaves a trace at circle start position. Thecontour is to be approached in tangentialdirection in all cases in order to avoid this.

Page 8: programare cnc

Collection of Part Program Examples

8

Y

XO100

Diagram 4

4 Programming Circular Interpolation with Contour Tracking

%O7014(1.4)N100 T1N110 G54 G0 X-70 Y-70N120 G43 Z50 H1N130 S1000 M3 M8N140 G0 Z5N150 G1 Z-10 F20N160 G42 X-50 Y-50 D1 F50N170 G1 X0N180 G3 J50N190 G1 X50N200 G1 G40 X70 Y-70N210 G0 Z100N220 M30%

The difference from previous example is thestart position as well as the positioning onand off the contour. Coordinates ofpositioning on and off must be programmedso that movement without compensation islarger than tool radius.

Page 9: programare cnc

Collection of Part Program Examples

9

Y

XO100 X

Diagram 5

5 Circular Interpolation on Internal Contour

%O7021(2.1)N100 T1N110 G54 G0 X0 Y0N120 G43 Z0 H1N130 S1000 M3 M8N140 G0 Z5N150 G1 Z-10 F20N160 G1 X0 Y50 F50N170 G3 J-50N180 G1 X0 Y0N190 G0 Z100N200 M30%

In this case, as in example 1.1, the problemarises from rectangular positioning.

Page 10: programare cnc

Collection of Part Program Examples

10

Y

XO100

Diagram 6

6 Inner Circular Interpolation with Contour Tracking

%O7022(2.2)N100 T1N110 G54 G0 X0 Y0N120 G43 Z0 H1N130 S1000 M3 M8N140 G0 Z5N150 G1 Z-10 F20N160 G1 G41 X0 Y50 F50 D1N170 G3 J-50N180 G1 G40 X0 Y0N190 G0 Z100N200 M30%

Only G41-G42 change in relation to externalcontour tracking. G41-G42 replacementcould also have been substituted by thereplacement of G2-G3. Neither can thisprocess eliminate movement over circle startposition.

Page 11: programare cnc

Collection of Part Program Examples

11

Y

X

R40

O100 X

Diagram 7

7 Programming Inner Circular Interpolation with Positioning in TangentialDirection

%O7023(2.3)N100 T1N110 G54 G0 X0 Y0N120 G43 Z50 H1N130 S1000 M3 M8N140 G0 Z5N150 G1 Z-10 F20N160 G41 X40 Y10 D1 F50N170 G3 X0 Y50 R40N180 G3 J-50N190 G3 X-40 Y10 R40N200 G1 G40 X0 Y0N210 G0 Z100N220 M30%

In order to avoid surface errors, positioning toinner arc is executed in tangential directionby the use of circular interpolation, as in caseof external contour Tangential circle radius isoptional, however larger than tool radius andsmaller than circle radius. Its center is movedaccording to original circle center in directionY with the difference between contour radiusand circle radius.

Page 12: programare cnc

Collection of Part Program Examples

12

Y

X

100

200

Diagram 8

8 Programming Straight Contour

%O7031(3.1)N100 T1N110 G54 G0 X-120 Y-70N120 G43 Z50 H1N130 S1000 M3 M8N140 G0 Z5N150 G1 Z-10 F20N160 G1 X-100 Y-50 F50N170 G1 X100N180 G1 Y50N190 G1 X-100N200 G1 Y-50N210 G1 X-120 Y-70N220 G0 Z100N230 M30%

Round-milling of a rectangle is the simplestexample. G1 codes are repeated only foreasier interpretation, the repeated codes areunnecessary in view of the control

Page 13: programare cnc

Collection of Part Program Examples

13

Y

X

100

200

Diagram 9

9 Programming Straight Contour with Contour Tracking

%O7032(3.2)N100 T1N110 G54 G0 X-120 Y-70N120 G43 Z50 H1N130 S1000 M3 M8N140 G0 Z5N150 G1 Z-10 F20N160 G1 G42 X-100 Y-50 F50 D1N170 G1 X100 N180 G1 Y50N190 G1 X-100N200 G1 Y-50N210 G1 G40 X-120 Y-70N220 G0 Z100N230 M30%

The measure of positioning is to be defined,so that is it larger than tool radius, as inexample 1.4. In the case drafted on thediagram burr may stay on start positioncorner, thus it is recommended to overset theprogram a few mm before the corner whenpositioning on and after the corner whenpositioning off.

Page 14: programare cnc

Collection of Part Program Examples

14

Y

X

100

200

Diagram 10

10 Programming Zero Circles in Case of Contour Tracking

%O7033(3.3)N100 T1N110 G54 G0 X-120 Y-70N120 G43 Z50 H1N130 S1000 M3 M8N140 G0 Z5N150 G1 Z-10 F20N160 G1 G42 X-100 Y-50 F50 D1N170 G1 X100 ,R0N180 G1 Y50 ,R0N190 G1 X-100 ,R0N200 G1 Y-50N210 G1 G40 X-120 Y-70N220 G0 Z100N230 M30%

,R0 is interpreted by the control as circle arcwith zero radius, thus this part is executed asif circle arc during contour tracking. Toolpath radius equals to tool radius, while sharpcorner remains on contour. This version helpsin balanced loading of tool in case of a largerroughing allowance.

Page 15: programare cnc

Collection of Part Program Examples

15

Y

X

100

200

11. ábra

11 Contour Tracking with Rounding

%O7034(3.4)N100 T1N110 G54 G0 X-120 Y-70N120 G43 Z50 H1N130 S1000 M3 M8N140 G0 Z5N150 G1 Z-10 F20N160 G1 G42 X-100 Y-50 F50 D1N170 G1 X100 ,R10N180 G1 Y50 ,R10N190 G1 X-100 ,R10N200 G1 Y-50 ,R10N210 G1 X-70N220 G1 G40 X-50 Y-70N230 G0 Z100N240 M30%

In order to round the fourth corner the toolmust return to the first edge or at least to apart of it. This distance must be larger thanthe sum of rounding and tool radius. In caseof rounding the tool path radius correspondsto the sum of rounding and tool radius.

Page 16: programare cnc

Collection of Part Program Examples

16

R40Y

X

100

20012. ábra

12 Rectangle with Inner Contour Tracking and with Positioning in TangentialDirection

%O7041(4.1)N100 T1N110 G54 G0 X0 Y0N120 G43 Z50 H1N130 S1000 M3 M8N140 G0 Z5N150 G1 Z-10 F20N160 G1 G41 X80 Y10 F50 D1N170 G3 X40 Y50 R40N180 G1 X-100 N190 G1 Y-50N200 G1 X100N210 G1 Y50N220 G1 X-40N230 G3 X-80 Y10 R40N240 G1 G40 X0 Y0N250 G0 Z100N260 M30%

As in example 3.2, positioning is done roundcircle arc, the radius of which is larger thantool radius, but smaller than half of the holesize in direction Y.

Page 17: programare cnc

Collection of Part Program Examples

17

Y

X

100

200

Diagram 13

13 Programming Optional Contour with Contour Tracking

%O7051(5.1)N100 T1N110 G54 G0 X-40 Y-40N120 G43 Z50 H1N130 S1000 M3 M8N140 G0 Z5N150 G1 Z-10 F20N160 G1 G42 X0 Y0 F50 D1N170 G1 X50 N180 G1 Y30N190 G2 X100 R25N200 G1 Y0N210 G1 X200 ,C10N220 G1 Y50N230 G1 X150 Y100N240 G1 X0 ,R20N250 G1 Y0N260 G1 G40 X-30 Y-30N270 G0 Z100N280 M30%

An optional contour is shown in thisexample. Line 210 contains break, while line240 includes rounding. Break is indicated by,C in line 210, where the control measures thespecified distances to straights defined byprevious and following lines and these pointsare linked as resulting contour.

Page 18: programare cnc

Collection of Part Program Examples

18

Y

X

100

200

50

50

Diagram 14

14 Definition of Optional Contour with Inner Contour Tracking

%O7052(5.2)N100 T1N110 G54 G0 X160 Y50N120 G43 Z50 H1N130 S1000 M3 M8N140 G0 Z5N150 G1 Z-10 F20N160 G1 G41 X150 Y100 I-1 J1 F50 D1N170 G1 X0 ,R20N180 G1 Y0N190 G1 X50 N200 G1 Y30N210 G2 X100 R25N220 G1 Y0N230 G1 X200 ,C10N240 G1 Y50N250 G1 X150 Y100N260 G1 G40 XI-20 YI-20 I-1N270 G0 Z100N280 M30%

Positioning to inner contour is done ataddress G41 I_ J_ in block N160. Thedirection vector of previous block can bespecified at addresses. I and J, in this case thecontrol positions to contour so that it is notthe straight defined by the positioning blockbut that of the specified direction vector thatis taken into account when calculatingcoordinates. This method works similarly incase of stop. Only direction tangents can bespecified at addresses I and J, therefore it isonly the sign and ratio that count, not theabsolute value.

Page 19: programare cnc

Collection of Part Program Examples

19

Y

X

20

30

R6

Diagram 15

15 Optional Inner Contour (Subprogram)

%O7053(5.3)N100 T1N110 G54 G0 X0 Y0N120 G43 Z50 H1N130 S1000 M3 M8N140 G0 Z5N150 G1 Z-10 F20N160 G1 G41 X-6 F50 D1N170 G3 X0 Y-6 R6N180 G1 X9N190 G3 Y6 R6 N200 G1 X6N210 G1 Y14N220 G3 X-6 R6N230 G1 Y6N240 G1 X-9N250 G3 Y-6 R6N260 G1 X0 N270 G3 X6 Y0 R6N280 G1 G40 X0 Y0N290 G0 Z100N300 M99%

The program is written as subprogram, this issignaled by M99 instead of M30 at programend. If it is started as main program, it runs asendless cycle. This program is used later onas subprogram.

Page 20: programare cnc

Collection of Part Program Examples

20

Y

X 100

3030

40

Diagram 16

16 Subprogram Technique with Zero Position Offset

%O7061(6.1)N100 T1N110 G54 N120 G43 Z50 H1N130 S1000 M3 M8N140 G52 X30 Y10N150 M98 P7053N160 G52 X70 Y10N170 M98 P7053N180 G52 X30 Y40N190 M98 P7053N200 G52 X70 Y40N210 M98 P7053N220 G52 X30 Y70N230 M98 P7053N240 G52 X70 Y70N250 M98 P7053N260 G52 X0 Y0N270 G0 Z100N280 M30%

The subprogram is prepared with absolutesize specification with zero position draftedon the diagram. The subprogram is detailed inexample 5.3. A local coordinate-system offsetand a subprogram call are included by pairsin the main program. Subprogram is closedwith command M99.

Page 21: programare cnc

Collection of Part Program Examples

21

Y

X 100

Diagram 17

17 Use of Increment with Subprogram Call

%O7062(6.2)N100 T1N110 G54 N120 G43 Z50 H1N130 S1000 M3 M8N140 G52 X50 Y50N150 G51 X0 Y0 P2N160 M98 P7053N170 G50 X0 Y0N180 G52 X0 Y0N190 G0 Z100N200 M30%

G52 is responsible for activating localcoordinate-system, while G51 is responsiblefor activating increment. The control enlargesthe following movements with the valuegiven at address P around coordinatesspecified in block G51 as center. Contourdefinition is also executed in subprogram.

Page 22: programare cnc

Collection of Part Program Examples

22

Y

X 100

Diagram 18

18 Programming Increment around Optional Position

%O7063(6.3)N100 T1N110 G54 N120 G43 Z50 H1N130 S1000 M3 M8N140 G52 X50 Y50N150 G51 X0 Y-40 P2N160 M98 P7053N170 G50 X0 Y0N180 G52 X0 Y0N190 G0 Z100N200 M30%

The specified coordinates must be given inblock G51 according to G52 zero positionoffset, this is why -40 is at address Y. In thiscase zero position is also offset in relation tothe position specified in block G51 as centralenlarging position.

Page 23: programare cnc

Collection of Part Program Examples

23

Y

X 100

10

Diagram 19

19 Programming a Series of Bores

%O7071(7.1)N100 T1N110 G54 G0 X0 Y50N120 G43 Z50 H1N130 S1000 M3 M8N140 G81 XI10 Y50 R2 Z-10 L9N150 G80N160 G0 Z100N170 M30%

The programming of bores 10mm apart fromeach other is defined incrementally withrepetition. In this case positioning has to bedone one orientation block ahead of the firstbore, since the positions were not defined inabsolute value. The cycle is started bymoving the increment distance, which isfollowed by drilling and this is repeated withthe value given at address L. Drilling cycle isclosed with code G80.

Page 24: programare cnc

Collection of Part Program Examples

24

Y

X 100

10

10

Diagram 20

20 Programming Bore Series

%O7072(7.2)N100 T1N110 G54 G0 X0 Y50N120 G43 Z50 H1N130 S1000 M3 M8N140 G81 XI10 Y50 R2 Z-10 L9N150 G80N160 G0 X50 Y0N170 G81 X50 YI10 R2 Z-10 L4 N180 G80N190 G0 X50 Y50N200 G81 X50 YI10 R2 Z-10 L4N210 G80N220 G0 Z100N230 M30%

The second series of bores is programmed asa new drilling cycle, where size is again to bespecified in increment. Since both cycleswould include the middle bore, the secondseries must be split into lower and upper part.

Page 25: programare cnc

Collection of Part Program Examples

25

Y

XR50

10°

Diagram 21

21 Programming Center Circle

%O7073(7.3)N100 T1N110 G54 G0 X0 Y0N120 G43 Z50 H1N130 S1000 M3 M8N140 G16 G0 X50 Y-10N150 G81 X50 YI10 R2 Z-10 L36N160 G80 G15N170 G0 Z100N180 M30%

Programming center circle differs from boreseries in the use of polar coordinate datainput. Orientation is also executed ahead ofthe first bore, however this has nosignificance in case of whole circle.

Page 26: programare cnc

Collection of Part Program Examples

26

Y

XR50

10°

Diagram 22

22 Programming Center Circle Part

%O7074(7.4)N100 T1N110 G54 G0 X0 Y0N120 G43 Z50 H1N130 S1000 M3 M8N140 G16 G0 X50 Y-10N150 G81 X50 YI10 R2 Z-10 L10N160 G80 G15N170 G0 Z100N180 M30%

Programming center circle part differs fromprogramming center circle in that themultiplication of repetition number and angledifference does not result in 360 degrees.Orientation is also executed ahead of the firstbore.

Page 27: programare cnc

Collection of Part Program Examples

27

Y

XR50

10°

Y

XDiagram 23

23 Programming Center Circle to Optional Position

%O7075(7.5)N100 T1N110 G54 G0 X0 Y0N120 G43 Z50 H1N130 S1000 M3 M8N140 G52 X60 Y60N150 G16 G0 X50 Y-10N160 G81 X50 YI10 R2 Z-10 L36N170 G80 G15 N180 G52 X0 Y0N190 G0 Z100N200 M30%

In this case work zero position is not locatedin the middle of work but on a corner. In suchcase local coordinate system (G52) must beprogrammed, while the further program partcorresponds to the previous one. Localcoordinate system must be inactivated at theend of cycle, otherwise further coordinatesgiven in absolute values will be calculatedfrom this zero position.

24 Programming a Series of Bores as Subprogram

%O7076(7.6)N100 G81 YI10 R2 Z-10 L9N110 G80N120 G0 XI10 Y0N130 M99%

The programming of the series of bores issimilar to the previous example, thedifference is that it also contains Xpositioning at the end of series. Thus a borenet is resulted from the call with a givennumber from the main program.

Page 28: programare cnc

Collection of Part Program Examples

28

Y

X 100

10

24. ábra

25 Programming Bore Net with the Help of Subprogram

%O7077(7.7)N100 T1N110 G54 G0 X10 Y0N120 G43 Z50 H1N130 S1000 M3 M8N140 M98 P7076 L9N150 G0 Z100N160 M30%

This task can be accomplished in moredifferent ways. The simplest method is toprogram horizontal bore series as subprogramand the subprogram is called more times.There is a zero position offset in subprogramwhich must be inactivated at the end of mainprogram. Percent symbol as well as numberand name of program is shown at the startand end of program for the sake of easierseparation of program parts.

Page 29: programare cnc

Collection of Part Program Examples

29

Y

X 100

10

Diagram 26

26 Programming Bore Net with Cycle

%O7078(7.8)N100 T1N110 G54 G0 X10 Y0N120 G43 Z50 H1N130 S1000 M3 M8N140 #1=1N150 WHILE[#1LE9] DO1N160 G0 X10 Y0N170 G81 YI10 R2 Z-10 L9N180 G80N190 G52 XI10 Y0N200 #1=#1+1N210 END1N220 G52 X0 Y0 N230 G0 Z100N240 M30%

The second method is to organize verticalbore series into an internal cycle. In this casesubprogram is not needed but so called macrovariables must be adopted. These macrovariables must be defined with value inputand can be used optionally. The cycle ischaracterized by command WHILE. Cyclestart is signaled with DO1, its end is signaledwith END1, where numbers indicateinherence.

Page 30: programare cnc

Collection of Part Program Examples

30

Y

X 100

10

Diagram 27

27 Programming Bore Net with Two Cycles Embedded in Each Other

%O7079(7.9)N100 T1N110 G54 G0 X10 Y0N120 G43 Z50 H1N130 S1000 M3 M8N140 #1=10N150 WHILE[#1LE90] DO1N140 #2=10N150 WHILE[#2LE90] DO2N170 G81 X#1 Y#2 R2 Z-10N200 #2=#2+10N210 END2N200 #1=#1+10N210 END1N220 G80 N230 G0 Z100N240 M30%

In the third case when there are two cyclesembedded in each other, macro variables arerelated to X and Y coordinates of bores. Thusthe initial value of macro variable is set to thefirst coordinate, while the end value is set tothe last coordinate. Increase in macrovariables is executed with the differencebetween coordinates.

Page 31: programare cnc

Collection of Part Program Examples

31

Y

X

100

75

R505

R185R14

Diagram 28

28 Automatic Geometric Calculation between Circle Arcs (Inner Contour)

%O7081(8.1)N100 G54 G90 G17 G0N110 T1N120 G43 Z50 H1N130 S1000 M3N140 G0 X0 Y0N150 G0 Z2N160 G1 Z-19N170 G0 X0 Y0N180 G41 G1 X17.5 Y-20 D1N190 G3 X37.5 Y0 R20N200 G3 XI-505 YI505 R505 ,R14N210 G3 I0 J-135 R185 Q-1 ,R14N220 G3 I467.5 J0 R505 Q-1 ,R14N230 G3 I0 J135 R185 Q-1 ,R14N240 G3 X37.5 Y0 I-467.5 J0 R505 Q-1N250 G3 X17.5 Y20 R20N260 G1 G40 X0 Y0 N270 Z50N280 M30%

Page 32: programare cnc

Collection of Part Program Examples

32

Y

X

R460

200

80

R18R200

Diagram 29

29 Automatic Geometric Calculation between Circle Arcs (Outer Contour)

%O7082(8.2)N100 G54 G90 G17 G0N110 T1N120 G43 Z50 H1N130 S1000 M3N140 G0 X0 Y0N150 G0 Z2N160 G1 Z-19N170 G0 X90 Y-70N180 G42 G1 X40 Y-50 D1N190 G1 Y0N200 G3 XI-460 YI460 R460 ,R18N210 G3 I0 J-100 R200 Q-1 ,R18N220G3 I420 J0 R40 Q-1 ,R18N230 G3 I0 J100 R200 Q-1 ,R18N240 G3 X40 Y0 I-420 J0 R460 Q-1,R18N260 G1 X40 Y50 N270 G1 G40 X90 Y70N280 Z50N290 M30%

Page 33: programare cnc

Collection of Part Program Examples

33

Y

X

R5R31

R9

262

R11

22 22R11

57

Diagram 30

30 Automatic Geometric Calculation between Circle Arcs (Inner Contour)

%O7083(8.3)N100 G17 G0 G90 G94N110 T1N120 G0 X0 Y0N130 G43 Z50 H1N140 S1000 M3N150 G0 Z-50N160 G0 X0 Y-35N170 G1 G41 Y-46 D1N180 G3 X11 Y-35 R11N190 G1 Y-11 ,R9N200 G1 X120N210 G3 X120 Y11 R11N220 G1 X20N230 G3 X-11 Y-20 R31 ,R5N240 G3 X-20 Y11 I-20 J-20 R31 Q1N250 G1 X-120N260 G3 Y-11 R11N270 G1 X-11 ,R9N280 G1 Y-35N290 G3 X0 Y-46 R11N300 G1 G40 Y-35N310 G0 X0 Y0N320 Z50N330 M30%

In case end milling cutter 22 is used, radiuses11 are embodied by the milling cutter, thusthe two-direction milling path coincide. Inthis case tangential approach is disregardedwhen positioning.

Page 34: programare cnc

Collection of Part Program Examples

34

40°

80°

Diagram 31

31 Programming Cogging - Subprogram

%O7091(9.1)N100 G1 X0 Y50N110 G3 X-4.587 Y49.789 R50 N120 G3 X-8.846 Y46.468 R5N130 G2 X-12.206 Y43.313 R5N140 G3 X-15.391 Y42.286 R45N150 G3 X-18.490 Y41.026 R45N160 G2 X-23.093 Y41.282 R5N170 G3 X-28.490 Y41.090 R5N180 G3 X-32.139 Y38.302 R50N190 G68 X0 Y0 RI40N190 M99%

In this example coordinates of a cog isdefined in subprogram. Unfortunately asgenerally in case of cogging, the cog formcannot be defined with simple geometriccalculations, therefore the form coordinateshave to be calculated with a CAD/(CAM)system. The incremental rotating ofcoordinate system is realized in line G68.

Page 35: programare cnc

Collection of Part Program Examples

35

Y

XR50

R5

R45

R5

Diagram 32

32 Programming Cogging - Main Program

%O7092(9.2)N100 T1N110 G54 G0 X40 Y70N120 G43 Z50 H1N130 S1000 M3 M8N140 G0 G42 X30 Y50 D1N150 G1 X0 Y50 N180 M98 P7091 L9N220 G69N230 G1 X-30 Y50N240 G0 G40 X-40 Y70N250 G0 Z100N260 M30%

In this program the subprogram is called asmany times as is the number of cogs. At theend of program the inactivating of coordinatesystem rotation as well as the leaving ofcontour is needed.

Page 36: programare cnc

Collection of Part Program Examples

36

Y

XR50

R5

R45

R5

Diagram 33

33 Programming Cogging with a Program

%O7093(9.3)N100 T1N110 G54 G0 X40 Y70N120 G43 Z50 H1N130 S1000 M3 M8N140 G0 G42 X30 Y50 D1N150 G1 X0 Y50 N160 #1=0N170 WHILE[#1LT9] DO1N180 G68 X0 Y0 R[#1*40]N190 G1 X0 Y50N200 G3 X-4.587 Y49.789 R50 N210 G3 X-8.846 Y46.468 R5N220 G2 X-12.206 Y43.313 R5N230 G3 X-15.391 Y42.286 R45N240 G3 X-18.490 Y41.026 R45N250 G2 X-23.093 Y41.282 R5N260 G3 X-28.490 Y41.090 R5N270 G3 X-32.139 Y38.302 R50N280 #1=#1+1N290 END1N300 G69N310 G1 X-30 Y50N320 G40 X-40 Y70N330 G0 Z100N340 M30%

Cog from can be embedded in the programwith the help of macro variables and by theuse of an internal cycle, as it is also possibleto define rotation in absolute value. Theready contour corresponds to the previousexample in every aspect.

Page 37: programare cnc

Collection of Part Program Examples

37

Diagram 34

34 Programming Center Circle with Mirroring - Subprogram

%O7101(10.1)N100 T1N110 G54 G0 X0 Y0N120 G43 Z50 H1N130 S1000 M3 M8N140 G52 X10 Y10N150 M98 P7102N160 G51.1 Y0N170 M98 P7102N180 G51.1 X0N190 M98 P7102N200 G50.1 Y0N210 M98 P7102N220 G50.1 X0N230 G52 X0 Y0N240 G0 Z100N250 M30%

In this case work zero position is not in themiddle of work but on a corner. In this caselocal coordinate system (G52) must beprogrammed, afterwards the programcorresponds to the previous example with thedifference, that the offset is programmed infour cycles. The local coordinate system mustbe inactivated at the end of cycles, otherwisefurther coordinates given in absolute valueare also calculated from this zero position.

35 Programming Center Circle with Mirroring - Subprogram

%O7102(10.2)N140 G16 G0 X40 Y-10N150 G81 X50 YI10 R2 Z-10 L5N160 G80 G15N170 G0 Z100N180 M99%

The main program shown in the previousexample needs this subprogram for thecorrect operation. By the way this programalmost completely corresponds to theexample discussed in chapter 22. on page 26.

Page 38: programare cnc

Collection of Part Program Examples

38

Diagram 35

36 Programming Macro - Sinusoidal Curve

%O7111(11.1)N100 T1N110 G0 G90 X0 Y0N120 G43 Z50 H1N130 S1000 M3 M8N140 G1 Z-10N150 #1=0N160 WHILE[#1LE360] DO1N170 #2=SIN#1N180 G1 X#1 Y#2 F100N190 #1=#1+0.1N200 END1N210 G0 Z50N220 M30%

In this example programming of a simplesinusoidal curve is shown with the help ofmacro variables. The circle is started at theorigin, its longitudinal axis is parallel to axisX. To make it simple, tool compensation isdisregarded. #1 is the so called runningvariable, which is 0<#1<360. (Since NCcontrol belongs to the world of engineering,not that of mathematics, naturally degrees aremeasured in angle not in radian.) Variable #2can be calculated from this with the help ofthe sinus function. Afterwards assignment of#1 to coordinate X and of #2 to coordinate Yis simple. This, linked in a cycle, results inthe sinusoidal curve.

In case the start position of the needed curve is not the origin or if its amplitude is not 1 unit orits length is not 360 mm, line N180 can be modified as follows:

N180 G1 X[A+[#1*B]] Y[C+[#2*D]] F100,where A and C are the offset values (X;Y), B is the length and D is the amplitude.

Page 39: programare cnc

Collection of Part Program Examples

39

37 Programming Macro - Circular Milling, Cylindrical Interpolation

%O7112(11.2)N100 T1N110 G43 Z50 H1N120 S1000 M3 M8N130 G0 X50 Y0N140 #1=0N150 WHILE[#1LE360] DO1N160 #2=50*SIN[#1]N170 #3=50*SIN[#1]N180 G1 X#2 Y#3 Z[50-#1]N190 #1=#1+1N200 END1N210 G0 Z50N220 M30%

In this example the task is to program aspacial ellipse, plane XY of which is a circle.In this case actually a circle is programmed,but meanwhile position Z is calculated fromcurrent position X. In order to do this thecircle programming must be parametric.Circle can simplest be defined with relationX=R*cos" and Y=R*sin". Coordinate Z canbe calculated easily therefrom. The runningvariable is the central angle.

Page 40: programare cnc

Collection of Part Program Examples

40

Diagram 36

38 Programming Macro - Hemisphere

%O7118(11.8)N100 T1N110 G54 G0 X0 Y0N120 G43 Z50 H1N130 S1000 M3 M8N140 G0 X-50 Y-50 Z0N150 #1=-50N160 WHILE[#1LE50] DO1N170 #2=-50N180 WHILE[#2LE50] DO2N190 #3=0N200 IF[[[#1*#1]+[#2*#2]]GT1600] GOTO220N210 #3=SQRT[1600-[#1*#1]-[#2*#2]]N220 G1 X#1 Y#2 Z#3 F1000N230 #2=#2+1N240 END2N250 #1=#1+1N260 IF[#1GE50]GOTO370N270 #2=50N280 WHILE[#2GE-50] DO2N295 #3=0N300 IF[[[#1*#1]+[#2*#2]]GT1600] GOTO320N310 #3=SQRT[1600-[#1*#1]-[#2*#2]]N320 G1 X#1 Y#2 Z#3N330 #2=#2-1N340 END2N350 #1=#1+1N360 END1N370 M30%

On the diagram an R40 hemispherecan be seen on a 100x100 plane. Itstool path defined with macrovariables is shown in the followingprogram. Programs written with suchtechnique have the disadvantage thatthe real feed cannot be effectivebecause of the extremely manycalculations, but the processor time isdecisive. This can be recognized,since the tool stops “to think”between movements. The speed canbe accelerated/decelerated with thefining/roughing of resolution - linesN230, N250, N330 and N350.

Page 41: programare cnc

Collection of Part Program Examples

41

Diagram 37

39 Programming Macro - Hemisphere Creation

%O7119(11.9)N100 POPEN31N110 DPRNT[O7120(FELGOMB)]N120 DPRNT[T1]N130 DPRNT[G54 G0 X-50 Y-50]N140 DPRNT[G43 Z50 H1]N150 DPRNT[G90 G01 S1000 M3 M8 F1000]N160 #1=-50N170 WHILE[#1LE50] DO1N180 #2=-50N190 WHILE[#2LE50] DO2N200 #3=0N210 IF[[[#1*#1]+[#2*#2]]GT1600] GOTO230N220 #3=SQRT[1600-[#1*#1]-[#2*#2]]N230 DPRNT[G1 X#1[53]Y#2[53]Z#3[53]]N240 #2=#2+1N250 END2N260 #1=#1+1N270 IF[#1GE50]GOTO370N280 #2=50N290 WHILE[#2GE-50] DO2N300 #3=0N310 IF[[[#1*#1]+[#2*#2]]GT1600] GOTO330N320 #3=SQRT[1600-[#1*#1]-[#2*#2]]N330 DPRNT[G1 X#1[53]Y#2[53]Z#3[53]]N340 #2=#2-1N350 END2N360 #1=#1+1N370 END1N380 PCLOS31N390 M30%

On the diagram, as in the previousexample, an R40 hemisphere can beseen on a 100x100 plane Thisexample shows how to create atechnological program withoutmacro variables, capable of quickrun. Such technological program hasthe advantage that the extremelymany calculations are skipped underrun and the real feed is effective andit is not the processor time thatdecides. The program creation speedchanges with the fining/roughing ofresolution - lines N240, N260, N340and N360 -,while the machiningspeed remains unchanged. Asignificant difference to the previousexample is the periphery handling.Opening and closing of periphery isimportant, otherwise the programwritten in backing storage can bedamaged. It is hard to estimate thesize of prepared program, thereforeit is recommended to avoid directstorage writing and to use serialperiphery instead.

Page 42: programare cnc