Programming CNC Macros - Part 1
ฝัง
- เผยแพร่เมื่อ 26 ส.ค. 2024
- Having a look at Fanuc Macro B Programming. We'll go through a very basic program to provide an introduction into what you can do with macro programming. I'm going to focus on the Fanuc Macro B language since it happens to be very common control and the Haas macro language is pretty much exactly the same. In the accompanying video, the software being used is Cimco Edit 8. Another popular software for simulating your macro programs is NCplot. Here are links to both of those softwares...
www.cimco.com/...
www.ncplot.com/
In the example, I start with a very basic gcode program that profiles a rectangle that is 6"x4". From there input those length and width values into variables.
#1=6.0
#2=4.0
Now instead of calling X6.0 in the program, you can call X#1. Same goes for the Y location, instead of Y4.0 we're calling Y#2. So why would you want to do this? Typing X6.0 is pretty much the same as typing X#1. The reason is flexibility.
You can now simply edit the variable values and the program will automatically update to the new sizes. In the example, there is only one callout for variables 1 and 2 so this is not a great example just yet but we can increase the complexity a bit and then maybe show some of the power of fanuc macro b programming.
In the example, I add in a radius at one of the corners and a new variable to hold the size of that radius. In the program, to cut this radius correctly the original command of X#1 needs to be updated to stop short of the end of the part. It needs to stop short by the size of the defined radius. We can use macro math functions for this. When doing math, otherwise referred to as an equation, we need to encase it in square brackets [ ]. Our equation will look like this...
X[#1-#3]
This will set the value for X to whatever #1 - #3 is. Using math inside of your programs will unleash some amazing capabilities for you. Even if you do not completely use macro programming, these equations are still valuable.
Trying to figure out the feedrate for a tap? Lets pretend a mill is used, so inches per minute are needed, using a 1/2-13 tap running at 200 rpm....for the G84 canned cycles F values you can type in F[1/13*200] no need for a calculator!
Keep an eye out for video 2 on Fanuc Macro B Programming!
blog.caminstru...
See other blog posts
blog.caminstru...
Check out our website
caminstructor.com
#Mastercam #LearnCNC
For anyone who wants to dive deeper, Peter smid has probably the best book for fanuc group B macro programming. You can go as deep as you want to go with macro and it is an incredible tool that most shops don’t even utilize. Nice intro vid!!!!
I've used the book by S.K. Sinha, its great! He's also active on several CNC forums in threads with macros being discussed.
i don't understand it well, mostly bcs english is my 2nd language.....plus I dont have any program/simulator to practise
I wrote a a program using this technique that will corner round or full dish a round puck on a mill. Variables for EM size, speed, stepover, Diameter, Radius, and feed. You can get the machine to do all the trigonometry for you
Yes please add more videos on macro programming. Extremely interested in learning more so I can utilize. Thank you!
We are working on more now, thanks for the feedback!
Very well done sir, hopefully great to look forward too.
Yes please I am an instructor and veteran CNC machinist and I’m always looking for ways to add more control and use ability out of old equipment. Macros are helpful in making smaller code to run complex parts.
Very helpful video. Many greetings from Austria.
Glad it was helpful!
This looks like it would be very useful when combined with canned cycles, or subprograms.
That was a really informative video! Thanks .
Glad you enjoyed it!
Very good video, thanks for making it..
Glad you liked it!
Yes very interesting...Would be great to learn more of this type of programming and when its best to be used
Great videos very informative do you have an engraving macro tutorial or would you make one in the near future? Thanks again keep the vids coming
Thanx for this great video really help full ...Can you include some milling pockets [ macro for z level ] [ drilling and tapping ]..
Will add those to the list! :)
Muito bom exemplo parabéns!
Macros or for me r parameters on siemens is nice way to make some things.
Excellent Video. Thank you.
I love it. More macro videos please!
Will try and get another up soon!
Just ,R#3 !!!
Is that Cimco as installed with Mastercam?
Very interesting
great topic!
Good day sir as always excellent video. Is their a handbook you would recommend for me to get which covers macro programming in detail.
Macro Programming Fundamentals by SK Sinha
Is it possible to create a macroprogram for archimedian spiral or a 3d surface based on curves?
You have to do it in half circles, so you have a macro that runs your positive to negative and one that runs your negative to positive and loops between them, you have to run it through an if then statement or similar for it's stopping point
I saw some examples of macros for. Circular hole paterns. For a 3 axes milling. Help me with this please how can i modified that program for circular pockets around one center thanks. Y meam instead of holes circular pockets thanks in advance..
Can you post the example macro.
I used this to create a face mill program, works great....thank you. But I need help with the step over amount when you give it a wider value for #2(width)......I cant figure out how to get it to add half the cutter for the step over amount(using a 1.6 diameter face mill so .8 step over would be great). Can you help? Thanks so much
Did you watch this livestream where I created a facing macro? Hopefully what's covered in there helps you out.
th-cam.com/video/jXE4ZCv6yiM/w-d-xo.html
@@CamInstructor Thanks so much.....got it working now
Please do some CNC lathe program macros.
Anything specific?
@@CamInstructor anything cool I’m barely getting involved on lathe macros and need some cool ideas to do
@@jerojr7542 have you got anywhere with your macros? Regarding a lathe, a really useful one is a macro program for boring jaws.
@@Hi_Doctor_Nick no I haven’t I would love to have a macro to bore jaws do you have a sample that you can share?
@@jerojr7542
This is a quick program I put together as a demonstration to show our apprentice the basics of a macro. It's also got a bit of programming using incremental movements in the undercut. Rip it apart and make it your own but its a good starting place for you.
‐-‐------------------------------------
Notes about the program,
1, "Depth of jaws" refers to how much you want to hold on.
2, "Depth of cut" If you put a large enough number it'll do the full profile in 1 cut (finish pass)
3, "Stock for finish" how much you want to leave for a finish pass.
4, "undercut" Rough without, but finish with one.
-----------------------------------------
%;
O1234(BORE STANDARD JAWS *MACRO*);
#600=30.(START DIA);
#601=50.(FINISH DIA);
#602=10.(DEPTH OF JAWS);
#603=1(UNDERCUT 1=NO 0=YES);
#604=1.5(DEPTH OF CUT);
#605=0.15(STOCK FOR FINISH);
;
G50S3000;
G28U0W0;
M1;
;
T0101(B/BAR 0.4 RAD);
G96S130M3;
G0X#600Z2.M8;
G71U#604R.5;
G71P100Q150U-[#605*2]W#605F0.15;
N100G0X[#601+1.3];
G1Z0.;
G2X#601Z-0.65R0.65;
G1Z-#602;
N150G1X#600;
;
IF[#603EQ1]GOTO20;
;
(UNDERCUT)S100;
G0X#601Z2.;
U-1.;
Z-[#602-1.];
G1W-0.99F0.06;
U1.25;
W-.16;
U-.45;
W.2;
G0U-.8W.5;
N20;
G0Z2.;
G28U0W0M9;
M5;
M30;
%;
could you help me with some fadal probing macros?
I don't have much experience directly using fadals. I think their macro language is close to macro b?
@@CamInstructor I think it's very similar but I don't think it uses the square brackets
Can u give cimco crack version download link??
Plz micro pocket rouch program
Not sure I follow what you're after
Hi
Hey
Can you explain, please "BRANCHES AND LOOPS"
OBJECTIVE:
Enable participants to plan, execute and simulate CNC programs in 3 axes (milling machines and machining centers) with ISO / DIN structured language and programming.
TARGET AUDIENCE:
Professionals with basic CNC knowledge related to the machining area (CNC operators and programmers).
. PRE REQUIREMENTS:
Take a CNC Basic Milling course
PROGRAM:
Trigonometry Review
Defining the variables
Types of arithmetic functions
Replacement
Addition, Subtraction, Division, Multiplication
Sine function, cosine function, tangent function
Using conditional functions
IF, GO TO, DO, WHILE
EQ = equal
NE = Different
GT = Greater than
LT = Less than
GE = Greater than or equal
LE = Less than or equal
Simulation and practice exercises in a machining center (conical grooves, half spheres, corners of radius parts, ellipses, etc.)
Can you explain, please "BRANCHES AND LOOPS"
IF [ CONDITION IS TRUE ] GOTOn
IF [condition is true] GOTOn
for example,
IF [#7 LT 0] GOTO65 If the value of variable #7 is less than 0, branch to block N65
...
... If the above condition is true, bypass this section up to N65
...
N65 ... Target block of the IF conditional statement
IF [ condition is true ] THEN [ argument ]
Example 2 - Macro control with the IF-THEN structure
#100 = #4006 Check current units (English G20 or Metric G21)
IF[#100 EQ 20.0] THEN #100 = 0.1 Clearance above work is 0.1 inch for G20
IF[#100 EQ 21.0] THEN #100 = 2.0 Clearance above work is 2 mm for G21
...
< ... Macro program continues normally … >
Using the IF-THEN method makes the pro gram shorter by one half and is eas ier to in ter pret.
WHILE Loop Structure
WHILE [condition] DOn
WHILE [... Condition 1 is true ...] DO1
...
...
END1
Start of WHILE loop 1
End of WHILE loop 1
Double Level Loop
WHILE [... Condition 1 is true ...] DO1
...
WHILE [... Condition 2 is true ...] DO2
...
...
END2
...
...
END1
...
Start of WHILE loop 1
Start of WHILE loop 2
End of WHILE loop 2
End of WHILE loop 1
Trible Level Loop
WHILE [... Condition 1 is true ...] DO1
...
...
WHILE [... Condition 2 is true ...] DO2
...
WHILE [... Condition 3 is true ...] DO3
...
...
END3
...
...
END2
...
...
END1
...
Start of WHILE loop 1
Start of WHILE loop 2
Start of WHILE loop 3
End of WHILE loop 3
End of WHILE loop 2
End of WHILE loop 3
O8009 (SINE CURVE MACRO)
#25 = 0 Set initial counter for degrees increment
WHILE [#25 LE 360.0] Loop for each linear segment until 360 degrees are machined
#26 = #1 * SIN[#25] Calculate current Y-location
G90 G01 X#25 Y#26 F#9 Make a linear motion to the calculated XY location
#25 = #25+#4 Increase the counter by specified increment
END1 End of loop
M99 End of macro
O8011 (CLEAR 500+ VARIABLES - BY A MACRO LOOP)
#33 = 500 Initialize counter to the first variable (no # symbol !!!)
WHILE[#33 LE 999] DO1 Loop through variables - shown range is #500-#999
#[#33] = #0 Set the current variable number to null (clear current variable)
#33 = #33+1 Update variable number count by one
END1 End of loop - return to the WHILE block and evaluate again
M99 End of macro
and other.
This video should really be covering syntax of gcode. If this was a book, you have skipped a couple of chapters so I am virtually lost and don't have a clue. Funny thing is I have programmed in Java, Javascript, c++ and others including websites with a couple thousand lines of code using databases and without you covering syntax the only thing I gather from this is g-code has variables to store info and you can use brackets to explain your variables.
Go to the basics please. You might as well be talking French here cause thats about what this is.
This video is not meant to teach you everything possible about the MacroB Language. It was just a practical example of something simple that could be done, in an attempt to peek the interest of those who know machining/programming to look deeper into macros.
@@CamInstructor
Thats like me teaching how to pass a variable inside a function and then naming it part 1.
It would have only taken 3 extra minutes tops for people to catch up with you to follow along! You dont have to teach the whole thing. Every body needs a little background info and you know you didnt do it. Do better. I know you have it in you and youve got a subscriber.
Ngl, the simple math is kinda killing me
Which part. Maybe I can help clarify a bit.