FANUC Macro Programming

FANUC Macro Programming

Table of Contents

Programming macros on Fanuc robots may seem difficult initially, but it's actually a powerful tool for automating and streamlining repetitive tasks. In this article, we will delve into what macros are and how to use them effectively.

 

What Is a Macro?

A macro is a small routine that gets executed by a trigger (such as pressing a button on the teach pendant or receiving a command from the PLC). Macros are typically used to control the gripper (open/close the gripper, suction the part, etc.) but can be used for whatever you want. Without macros, manually activating each of the robot outputs can be a time-consuming task, especially during commissioning.

 

Triggers

We have several types of triggers for executing macros.
Here are the main ones:

  • UK : User Key
  • SU : Shift User Key
  • MF : Manual Function
  • DI : Digital Input
 

UK : User Key

There are 4 user keys available.

Fanuc Macro Programming User Keys

SU : Shift User Key

By pressing shift, you can add 4 additionnal macros.

Fanuc Macro Programming  Shift User Key

MF : Manual Function

You can affect macros to Manual Functions to have these macros displayed in "MENU", "MANUAL FCTNS".

Fanuc Macro Manual Function

DI : Digital Input

Digital input can be used as a trigger to execute a macro.

For example, you can use the PLC to control the gripper.

 

Creating Fanuc Macros

As mentioned earlier, a macro is a type of routine.

Let's start by creating two routines for opening and closing the gripper.

Important Note: When working with macros, it's advisable to limit instructions to controlling outputs. It's not recommended to use wait instructions (time delays, sensors) as they serve no purpose and may prevent the execution of other macros until the first one completes.

The first routine is named "CM_GRIP_PART", and I use the prefix "CM" for "Command Macro".

Define a name, then click on "Detail".

Fanuc Macro Programming  Creation

Select the sub type as "Macro”.

Fanuc Macro Sub type

Modify the group mask by replacing the 1 with an asterisk.

Fanuc Macro Group Mast

Now, let's add the code to the macro. 

Fanuc Macro Grip Part

Repeat the same steps for the second routine named "CM_RELEASE_PART".

Fanuc Macro Release Part

Congratulations, our macros are created. Now, we need to configure triggers.

 

Configuring Triggers

Currently, the macros exist, but no triggers are configured. To do this, navigate to "SETUP," then "Macro".

Fanuc Macro Menu

The definition of triggers involves four elements:

  • An instruction name
  • A program to be executed
  • A trigger type
  • And the assignment


Typically, in my programs, I use:

  • 2 teach pendant buttons for opening and closing
  • 2 digital inputs to allow the PLC to control the gripper
  • 2 manual functions to display the commands in the corresponding menu

Here is the configuration:

Fanuc Macro Configuration

 

Testing Fanuc Macros

Now that everything is configured, it's time to validate that it works.

Display the robot outputs view and then press the user keys on the teach pendant or play with manual functions.

Back to blog