camInstructor Blog

Macro B Programming - Introduction

2/20/19 6:00 AM / by camInstructor Mike

Macro B Programming doesn't have to be scary! Here's a brief introduction into some of the capabilities of Macro B Programming.

Macro Blog

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...



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.



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...


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!

Macro B Programming Part 2



Want to learn more about CNC? Check out;

camInstructor for Teachers - Independent Learners - Students


Topics: CNC, Setup Operate, Macro

camInstructor Mike

Written by camInstructor Mike

camInstructor Mike is Mike Wearne, an avid machinist, cnc programmer and overall connoisseur of all things machining. Mike is one of camInstructor's resident cad/cam/cnc experts and works part time at his local college teaching aspiring machinists how to program CNC Machines of all types.

    Subscribe to Email Updates

    Recent Posts