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.
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.
SU : Shift User Key
By pressing shift, you can add 4 additionnal macros.
MF : Manual Function
You can affect macros to Manual Functions to have these macros displayed in "MENU", "MANUAL FCTNS".
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".
Select the sub type as "Macro”.
Modify the group mask by replacing the 1 with an asterisk.
Now, let's add the code to the macro.
Repeat the same steps for the second routine named "CM_RELEASE_PART".
Congratulations, our macros are created. Now, we need to configure triggers.
Currently, the macros exist, but no triggers are configured. To do this, navigate to "SETUP," then "Macro".
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:
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.