Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

Macro Programming


Reko
 Share

Recommended Posts

Hi,

 

I have been teaching a CNC course at my local college for about 8 years and the subject of "macro programming" comes up from time to time.

 

Typically, a student will say the shop they work at uses a "macro" for certain operations like slot cutting or pocket milling... this usually comes up when I am demonstrating sub-programming and looping and the projects that go along with that. From what I have seen, custom macro's can be very powerful tools if the person writing them knows their stuff.

 

My standard answer to my students is, not very many shops use "macro" programming, but if yours does, great, don't buck the system, do what your co-workers are teaching you because making friends with the journeymen is the best way to survive. But, also, learn sub-programming too because it is another tool in your toolbox.

 

I also like to say, there really isn't anything that can't be programmed on the shop floor with standard G-code, conversational programming, or a CAD/CAM system... all of which modern shops have... so in general, "macro programming" is not necessary for the today's average CNC machinist.

 

This is just my opinion.

 

I am curious how many of you agree/disagree with me.

 

So, my questions are...

 

-How many of you actively use "macro" programming?

-What do you use it for?

-Why choose a "macro program" over CAM?

-How firm are you in your beliefs on this issue?

Link to comment
Share on other sites

Hi Reko,

 

to answer your question in order

 

no not actively using macro programming, but have used them

ran a few job that had to have seq. serial number in ea part

so use the macro to pull the numbers and count for me..

 

I use cam when every possible..

 

pretty firm unless someone can make since in why to change.. :-)

Link to comment
Share on other sites

My old boss uses them pretty aggressively, and was amazing at finding uses for macros in his programming. He programmed twin spindle/twin turret Mori-Seiki 8 axis machines. He used macros throughout the program, but I can't tell you what they did. I just know it made it impossible for me to see what was going on in the program.

 

On a part I wrote a program for though he used macros to check for tool breakage and use redundant tooling. He also had a custom probing routine that would set 48 fixture offsets. The probe also checked the parts in-process and made offsets if I remember correctly. I didn't understand it at all, but seeing it in action made me wish I did. It was pretty amazing stuff. He took an ordinary horizontal program running 24 parts through two operations on one tombstone and made it a really slick program that ran unmanned for like 20+ hours making tight tolerance Aerospace parts.

 

With the new Probe toolpaths in Mastercam maybe there is less need for these kinds of macros? But I have never used the probe toolpaths since these aren't an option we have so I have no idea.

 

So, I have seen a real use for macro programming and how powerful it is. I wish I knew how to use it. Maybe one of these days I will.

Link to comment
Share on other sites

In my experience if you can use them do. I have seen macros used in a few different ways. In an aerospace shop I worked at they would use the macros to check the part position, rotation, and alignment from datum points or tooling balls (within a set tolerance) in the machine to the variables that were generated with a CMM report. then alarm out if it didn't check out. These parts were very complex and expensive and set up would take hours. being supported by bondo just added to the fun. it would also check for tool breakage and wear and adjust accordingly. I took a ton of human error out it. I have seen it used for parametric programming as well. Bob said he uses a custom macro to auto tool length measure. I depends on your parts I guess.

Link to comment
Share on other sites

You should also let the students know that the machine control is actively using macro's behind the scene's. We use them in our Blohm and Magerle creep feed grinders. In fact that's about the only way to program them. These machines have constant overhead dress that is also macro driven

Link to comment
Share on other sites

I teach macros and their uses, they can do some pretty cool stuff. You can create custom operations, but most of all if you do a lot of manual programming it could greatly reduce the programming time for features like bolt circles...one macro can easily be designed to make any type of bolt circle pattern. In general macros are a very important programming method that is still quite often used in industry where the same type of parts are constantly produced.

Link to comment
Share on other sites
In general macros are a very important programming method that is still quite often used in industry where the same type of parts are constantly produced.

i believe there is a piston Mfg'er here on the left coast that uses Macro programming on a large scale. i would imagine they could plug in diameters and linears into variables in the beginning of one program and make just about any piston.

Link to comment
Share on other sites

Since end user training is part of my job, I figured I would weigh in on this issue. Almost every customer asks about them. The usual questions run the gamut from what exactly is Custom MACRO B, to why would/should I use MACRO programming instead of standard G-COde programming. In order to give the "right" answer, I always as them about how they currently process their parts. Do they have a CAM system, how is the skill level of the shop floor folks, do you currently probe your parts or your setup? Do(es) your machine(s) have probing, etc...

 

I'll hit your questions one at a time from the perspective of someone that trains customers how to use it, when to use it, and sometimes when not to use it.

 

-How many of you actively use "macro" programming?
:D :waving:

 

-What do you use it for?
I use it for tool measurement, part measurement, tool changes, part counters, SPC, DPRNT, remachining condition evaluation, machine tool condition evaluation, in position checks, the list in vast.

 

-Why choose a "macro program" over CAM?
MACRO programming should not be thought of as an "instead of", rather MACRO Programming should be though of as "in conjunction with". FANUC Custom MACRO B it a tool's who's limitation is your imagination.

 

-How firm are you in your beliefs on this issue?
Dogmatic.
Link to comment
Share on other sites
  • 1 month later...

We use a custom macro at work to write tool offsets and index to the next tool, for machines that don't have decent tool setting functions. Set the tool via the handwheel call up "G14" and it writes the offset, brings the head up, and changes to the next tool. Other machines I run with tool setters and probes all use macros to calibrate the devices and make measurements.

Link to comment
Share on other sites
  • 3 weeks later...
Guest MTB Technical Services

This is a Macro I wrote about 10 years ago for a FANUC 15M as a custom G-Code Cycle for 5-axis drilling.

The Macro was written for a 5-Axis Profiler with the B-Axis as the Primary/Master

and the A-Axis as the Secondary/Slave.

G68 was the code for the 3D Coordinate Conversion then.

It's now G68.1

 

%

O9013 (G183 5-AXIS DRILL CYCLE)

(THIS MACRO SUPPORTS A FANUC 15M SERIES CONTROL)

(SET PARAMETER 7053=183)

 

(PROPER PROGRAMMING SYNTAX)

(G183 EXAMPLE)

(G183 X0 Y0 Z0 A10.0 B20.0 D83 H1.0 Q0.1 R0.1 F15.0)

(X0 Y0 Z0 - HOLE LOCATION COORDINATES - REQUIRED)

(A10.0 B20.0 - ROTARY AXIS COORDINATES - REQUIRED)

(D83 - SELECTS G83 DRILL CYCLE-VALID VALUES 73,81,82,83,84,85,86,87 - REQUIRED)

(H1.0 - INCREMENTAL HOLE DEPTH - ALWAYS POSITIVE - REQUIRED)

(P0 - DWELL IN MILLISECONDS W/O DECIMAL POINT - OPTIONAL FOR G82 CYCLE)

(Q0.1 - INCREMENTAL PECK DEPTH - ALWAYS POSITIVE - REQUIRED FOR G73/G83 CYCLES)

(R0.1 - INCREMENTAL CLEARANCE PLANE - ALWAYS POSITIVE - REQUIRED)

(F15.0 - UPM OR UPR FEEDRATE - REQUIRED)

 

(VERIFY ALL REQUIRED VARIABLES ARE SPECIFIED)

IF[#24 EQ #0] GOTO 9998

IF[#25 EQ #0] GOTO 9998

IF[#26 EQ #0] GOTO 9998

IF[#1 EQ #0] GOTO 9990

IF[#2 EQ #0] GOTO 9991

IF[#7 EQ #0] GOTO 9992

IF[#11 EQ #0] GOTO 9993

IF[#17 EQ #0] GOTO 9994

IF[#18 EQ #0] GOTO 9995

IF[#9 EQ #0] GOTO 9997

 

(INITIALIZE VALUES TO FORCE ABSOLUTE VALUES)

#7=ABS[#7]

#9=ABS[#9]

#11=ABS[#11]

#16=ABS[#16]

#17=ABS[#17]

#18=ABS[#18]

 

(VALIDATE CYCLE TYPE)

[#10=#7]

IF[#10 LT 73] OR [#10 GT 87] GOTO 9992

IF[#10 EQ 74] GOTO 9992 (NO LEFT-HAND TAPPING)

IF[#10 EQ 84.2] GOTO 9992 (NO RIGHT-HAND RIGID TAPPING)

IF[#10 EQ 84.3] GOTO 9992 (NO LEFT-HAND RIGID TAPPING)

 

(VALIDATE HOLE DEPTH)

IF[#11 EQ 0] GOTO 9993

 

(VALIDATE PECK VALUE)

IF[#10 EQ 73] AND [#17 EQ 0] GOTO 9994

IF[#10 EQ 83] AND [#17 EQ 0] GOTO 9994

 

(VALIDATE CLEARANCE PLANE R)

IF[#18 EQ 0] GOTO 9995

 

(VALIDATE DWELL P TO 2 SECONDS OR LESS)

IF[#10 EQ 82] AND [#16 EQ #0] GOTO 9996

IF[#10 EQ 82] AND [#16 GT 2000] GOTO 9996

 

(CALCULATE UNIT VECTORS FROM ANGLES)

#4=[[COS[#1]]*[sIN[#2]]]

#5=[[sIN[#1]]*[-1]]

#6=[[COS[#1]]*[COS[#2]]]

 

(POSITION TO HOLE W/CLEARANCE BEFORE 3-D COORDINATE CONVERSION)

G00 G90 X[#24+[#4*#18]] Y[#25+[#5*#18]] Z[#26+[#6*#18]] A#1 B#2

 

(SKIP 3-D COORDINATE CONVERSION IF ANGULAR SUM = 0)

IF[[ABS[#1]+ABS[#2]] EQ 0] GOTO 69

 

(SET 3-D COORDINATE CONVERSION)

(B-AXIS ROTATION MUST BE SET FIRST)

 

G68 X#24 Y#25 Z#26 I0 J1 K0 R#2 (B-AXIS PRIMARY/MASTER)

G68 I1 J0 K0 R#1 (A-AXIS SECONDARY/SLAVE)

 

N68

(DRILLING USING 3-D COORDINATE CONVERSION)

(LOCAL WORKPLANE ORIGIN IS HOLE LOCATION)

(X,Y,Z VALUES ARE LOCAL WORKPLANE COORDINATES)

 

[#21=0]

[#22=0]

[#23=0]

GOTO 70

 

N69

(DRILLING WITHOUT 3-D COORDINATE CONVERSION)

 

(X,Y,Z VALUES ARE ORIGINAL COORDINATES)

[#21=#24]

[#22=#25]

[#23=#26]

 

N70

(PERFORM DRILLING CYCLE)

IF[#10 EQ 73] GOTO 73

IF[#10 EQ 81] GOTO 81

IF[#10 EQ 82] GOTO 82

IF[#10 EQ 83] GOTO 83

IF[#10 EQ 84] GOTO 84

IF[#10 EQ 85] GOTO 85

IF[#10 EQ 86] GOTO 86

IF[#10 EQ 87] GOTO 87

 

 

N73 (CHIP BREAK)

G#10 G98 X[#21] Y[#22] Z[#23-#11] Q#17 R[#23+#18] F#9

GOTO 99

 

N81 (STANDARD DRILLING)

G#10 G98 X[#21] Y[#22] Z[#23-#11] R[#23+#18] F#9

GOTO 99

 

N82 (SPOT W/DWELL)

G#10 G98 X[#21] Y[#22] Z[#23-#11] P[#16] R[#23+#18] F#9

GOTO 99

 

N83 (DEEP HOLE PECK)

G#10 G98 X[#21] Y[#22] Z[#23-#11] Q[#17] R[#23+#18] F#9

GOTO 99

 

N84 (TAPPING)

G#10 G98 X[#21] Y[#22] Z[#23-#11] R[#23+#18] F#9

GOTO 99

 

N85 (BORING)

G#10 G98 X[#21] Y[#22] Z[#23-#11] R[#23+#18] F#9

GOTO 99

 

N86 (BORING)

G#10 G98 X[#21] Y[#22] Z[#23-#11] R[#23+#18] F#9

GOTO 99

 

N87 (BORING)

G#10 G98 X[#21] Y[#22] Z[#23-#11] R[#23+#18] F#9

GOTO 99

 

N99

G80

G69 (CANCEL 3-D COORDINATE CONVERSION)

M99

 

(ALARMS)

N9990 G69 #3000=1(INVALID ANGULAR ADDRESS - A )

N9991 G69 #3000=2(INVALID ANGULAR ADDRESS - B )

N9992 G69 #3000=3(UNSUPPORTED DRILLING CYCLE )

N9993 G69 #3000=5(INVALID HOLE DEPTH - H )

N9994 G69 #3000=4(INVALID PECK VALUE - Q )

N9995 G69 #3000=6(INVALID CLEARANCE PLANE - R )

N9996 G69 #3000=7(INVALID DWELL - P )

N9997 G69 #3000=8(INVALID FEEDRATE - F )

N9998 G69 #3000=9(UNSPECIFIED HOLE COORDINATE - X,Y,Z )

M30

%

Link to comment
Share on other sites

I use MACRO programs for Barfeed, Part Transfer and cutoff on twin spindle lathes.

 

For any family of parts I write an Incremental program with variables

 

N5 (SPINDLE-1 CUT SHAPE)

(CUT FORM)

 

M98 P4999 (LF/RF)

 

G28 U0

G28 V0 W0

G54

G00 T1010

G361 B0.0 D0.

G00 T [#543](TOOL PRECALL)

M69

G98 G19 M46

M303

M45

G43 H10.

G97 S5000 M13

M69

G00 C#562 (SET FROM O4999)

M68

G00 X60 Y0 Z0

G52 X0 Y#546 Z0 (BUGGER FACTOR ADJUST Y)

 

(***************************)

M172 (SYNC FOR LOWER SUPPORT)

M175 (SYNC FOR LOWER SUPPORT)

(***************************)

 

IF [#562EQ0 ]GOTO900 (LEFT FACING C0)

 

(RIGHT FACING FROM HERE)

(CUT1 0.3MM STOCK)

G0 Y-20.3 Z [-#520-1.5]M8 (Z-81.5)

X-22.

G1 Y-15.3 F500.

G3 V.5 W.5 R.5

G1 Z-2. (Z-2)

G2 V7.3 W7.3 R7.3

G1 V4.

G2 V7.3 W-7.3 R7.3

G1 Z [-#520+12]

G3 V.7 W-.7 R.7

G1 V6.

G2 V5.3 W-5.3 R5.3

G1 W-7.

G3 V.5 W-.5 R.5

G1 V5.

G0 X40.

(CUT2 0MM STOCK)

G0 Y-20. Z [-#520-1.5](Z-81.5)

X-22.

G1 Y-15.

G3 V.5 W.5 R.5

G1 Z-2. (Z-2)

G2 V7. W7. R7.

G1 V4.

G2 V7. W-7. R7.

G1 Z [-#520+12](Z-68)

G3 V1. W-1. R1.

G1 V6.

G2 V5. W-5. R5.

G1 W-7.

G3 V.5 W-.5 R.5

G1 V5.

G0 X40. M09

GOTO998 (EXIT)

(*******************)

Link to comment
Share on other sites
  • 2 weeks later...

I think that macro programming is an awesome tool. I have been using it for touch probes and parametric programming for about ten years. I think that for most people it is harder to grasp than most cad systems simply because hardly anyone teaches it. It can do more than just bolt circles and holes. I have developed a family of programs that machine 3d features on parts all using custom macro b.

Link to comment
Share on other sites
  • 1 year later...

I think that macro programming is an awesome tool. I have been using it for touch probes and parametric programming for about ten years. I think that for most people it is harder to grasp than most cad systems simply because hardly anyone teaches it. It can do more than just bolt circles and holes. I have developed a family of programs that machine 3d features on parts all using custom macro b.

 

I certainly agree. Here are a few examples of a few 3D parts I have made with parametric programs. 

 

Square Sinewave C Axis Polar

Polar Rectilinear Sinewave

Polar Rectilinear Sinewave B

 

 

Link to comment
Share on other sites

What Leghorn said.

 

We primarily service the die casting industry, but we're running some aerospace parts that have to be cut from aluminum extrusion (customer supplied material).  The extrusion is so warped that there's no way a good part could be made without macro.  I've got the machine probing each part in several places and positioning features accordingly.  I use NCPlot to visualize and check my work, since it'll eat all that macro and work offset assignment for breakfast.

 

It's also good for long runs of families of parts; I'm working on a macro for our primary product line so that when we make a process improvement I'll only have to change things once instead of dozens of times, and so the program can just sit in the machine instead of the operator having to load the right one.

 

Oh, and it makes serial number engraving a piece of cake.

Link to comment
Share on other sites
  • 4 weeks later...

I currently work at a shop where the only thing I do is program in Marcos b ! l might be a little biased because I specialist in Macro programming but I truly believe macros is the most cost efficient way of programming . Marco is as powerful as any computer languish from a simple bolt pattern to complex 5 axis programs it can do it all . Thur macro I created my own custom can cycles and complex code that can be as long as 5 pages which has cut down on programming time from @ 2 hour to literally 2 minutes !! Most people don't understand how powerful macro is but we are currently working on code that will eventuality make most of our programming automated !! It can get really complicated but believe shop should take a closer look !! It could one day be the future way of programming

  • Like 1
Link to comment
Share on other sites
  • 8 months later...

Yes I use macros a lot for auto set of  both Z & W zero offsets on a 2 spindle lathe, offset shifts, part transfers, Swiss style pulls on a non Swiss machine, automatic wear offset adjustments, auto threading cycles with automatic undercuts not included in a lot of solid models, a program that make any simple washer (takes about 5 minutes to program at machine)  runs 5,6,7 etc at a time in each cycle, pulls stock out to make more, counts the total and stops when total of say 150 is reached, custom probing cycles, facing programs on vertical mills,the list of possibilities is endless. Now why you say?  When you work in a shop for 8 years that has no Cam system  you learn to use them effectively. Even now that I work with a Cam system I still find them powerful and very useful in the right situations.

  • Like 1
Link to comment
Share on other sites

Yes I use macros a lot for auto set of  both Z & W zero offsets on a 2 spindle lathe, offset shifts, part transfers, Swiss style pulls on a non Swiss machine, automatic wear offset adjustments, auto threading cycles with automatic undercuts not included in a lot of solid models, a program that make any simple washer (takes about 5 minutes to program at machine)  runs 5,6,7 etc at a time in each cycle, pulls stock out to make more, counts the total and stops when total of say 150 is reached, custom probing cycles, facing programs on vertical mills,the list of possibilities is endless. Now why you say?  When you work in a shop for 8 years that has no Cam system  you learn to use them effectively. Even now that I work with a Cam system I still find them powerful and very useful in the right situations.

If you enjoy macro programming check out my download under the cool macros section under Machining, Tools, Cutting & Probing. I have several that do 3D shapes and basic shapes.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...