What's new
What's new

Need to create a counter for old Fanuc

TJ88

Plastic
Joined
Nov 17, 2011
Location
IL USA
I would like to create a counter on a turning production run that is independent from the easily manipulated window display. Is there a line of code that I can simply insert before the M30 in the running cnc program that will input a count into a parameter? In the control I did find the following parameters: 6710 Count Up M-Code, 6711 Parts Count, 6712 Parts Total. All have a current value of zero. Control is Fanuc 21-T. Is there anyone out there who can give me the specific line of code to insert before the M30?
 
The parameters you are referring to are for the Run Time Parts Counter which is a FANUC option on the majority of machines and appears to be on your machine as well. You could try it and use the M code specified in parameter 6710, if there is no M code set in 6710 try using something like 97 and call a M97 prior to your M30. The other solution is to use a macro variable, assuming your machine has Macro B capability. At the end of your program prior to the M30 program in the following
#500=#500+1
Make sure that Macro variable #500 is not used for anything else and insure it is set to zero prior to starting. This command will take whatever value is in variable #500 and add 1 to it every time the line is read. If #500 is used for something else find a 500 series variable that is not being used and use that value in the same format

Tom
 
It doesn't look like it has macro B capability since I could not find the #500 variables anywhere in System mode. Parameter 6710 was initially set at zero so I changed it to 97 and inserted M97; in the program before M30. After running a cycle this did not seem to work and it alarmed out. Then I changed both to M95 and the cycle completed with no advance in the counter in Settings. The Settings page shows counter at zero and this is the counter I want activated. Currently, we are using M25 to advance our window display counter. I want to advance the counter in Settings also. I then went back to 6710 and input 25 but that did not work either. I must be missing something.
 
I finally found the macro page and followed your instructions. My counter is all set up and working fine. Thanks Tom!
 
I finally found the macro page and followed your instructions. My counter is all set up and working fine. Thanks Tom!

Hello TJ88,
Did you end up using the System Counter, or the Common, Nonvolatile Macro variable solution? In Tom's example using just #500 = #500 + 1 you would have to periodically look at the value of the variable in the Macro Variable registry. If you have the Parts Counter Option enabled, but for some reason M30, M02 or other M code set in parameters is not working, you can access the counter directly through System Variables #3901, Number of machined parts completed and #3902, Number of parts required.

A custom M code could be created to call a Counter Macro to increment #3901 and to set the Parts Required System variable. Something like the following:

M101 A100.0 B0.0(Custom M code used with argument to set the Parts Required and Parts Completed System Variables, both of which are optional arguments in the Macro)

O9020
IF [#1 EQ #0] GOTO10 (DON'T SET THE PARTS REQUIRED)
#3902 = #1
IF [#2 NE #0]TH #3901 = #2 (RESET PARTS COMPLETED IF ARGUMENT B IS PASSED)
GOTO20
N10
#3901 = #3901 + 1
N20
M99

Regards,

Bill
 
Last edited:
I went with the macro variable solution. The idea is to periodically audit the actual count in the macro page, which is unknown to the operators. I will file your code for future reference as I plan on coding our Mazatrol programs with an EIA sub as well. That is, if it is possible to do so.
 








 
Back
Top