There are several ways on a Fanuc CNC to count parts, here are a few scenarios and guides.
Standard Cycle - manually loaded part
In this case the machine should count on an M30 or M02. However, some machine tool builders (MTB) like to create their own M-Code to count with. Below you can find out if your machine counts on M30 / M02 or just the MTB's M-Code.
Looping Cycle - robot loaded / pallet change machine / automation
Some of your programs might not have an M30 at the end of the program to count with, they might loop on an M99, therefore they do not count.
In this scenario we have two different solutions to chose from:
- Machine tool builders M-Code
To find out which M-Code you can use, see below.
What is #3901?
Variable 3901 is a Fanuc system variable that is on all Fanuc controls that have Macro B option enabled. System variables are a way for you to access Fanuc data inside the control. #3901 is the part counters in the red box above.
By programming #3901=#3901+1. you are taking the existing value of the part counter (11 in our case) and adding 1 to it.
Where do i add these codes to my program?
You need to add either the M-Code or #3901=#3901+1. on the line before the M99.
How do i find if the machine has a separate M-Code to count with?
This can be found by looking in parameter 6700#0 and 6710. If you are unfamiliar with parameters, consult with a colleague who is or call us and we can guide you through the process.
On the CNC, press the SYSTEM hard key to display the parameters, if they do not appear, press again. Navigate to 6700.
6700#0(PCM)=0 >> The machine will count on M30, M02 or the M-code specified in 6710 (M92 in this image).
6700#0(PCM)=1 >> The machine will only count on the M-code specified in 6710 (M92 in this image).
In the image above the machine will only count when it sees an M92, no other M-Code will count.
We typically recommend 6700#0(PCM)=0 to give you greater options for counting.
To change this parameter, follow this guide.
Testing the Counter
Testing the count is really simple:
- Put the machine into MDI mode.
- Clear any existing MDI contents
- Turn the feed and rapid overrides to zero
- Enter the part count command from are count to use (M30 / M-CODE / #3901=#3901+1).
- Press cycle start and see if the count in the red box increases. If you do not see the count in the red box, you can check the count value in parameter 6711.