What's new
What's new

Macro Programming Fundamentals

tteitgen

Aluminum
Joined
Jun 16, 2013
Location
Muskegon
There is a concept of Previous Block and Running Block in the Fanuc terminology.
Previous block is the block previous to where #1 = #4xxx is commanded.
Running block is the currently executing block.
Because of buffering, the control reads and interprets a number of blocks in advance.
Therefore, the previous block will normally be several blocks ahead of the currently executing block.

Now, if you need to extract modal information, Control Model D gives you an option to extract information both at the running block or at the previous block.
#40xx and #41xx give information at the previous block (as in Model C)
#42xx and $43xx give the same information, but at the running block (not available in Model C).

In your example, since the program number being run is same at the running block and the previous block, both will output the same number (though I am not sure whether it will be 1000 or 9006. I think it should be 9006, once inside the macro. Let Bill confirm).

For a normal application, #40xx and #41xx should be used.

I thought I would report my findings on this matter.

In this example:

%
O9000(TEST)
M98P9019
#103=#4315
G53
#104=#4115

M30
%

#103=9019
#104=9000
But in this example:

%
O9000(TEST)
M98P9019
;
G53
#103=#4315
G53
#104=#4115

M30
%

#103=9000
#104=9000
 

sinha

Stainless
Joined
Sep 25, 2010
Location
india
Thank you for bothering to report your findings. This really helps
Your results are as expected (G53 prevents buffering).
 

angelw

Diamond
Joined
Sep 10, 2010
Location
Victoria Australia
Thank you for bothering to report your findings. This really helps
Your results are as expected (G53 prevents buffering).
Hello Sinha,
In many, later Fanuc Programming Manuals, its explicitly stated that both G31 and G53 can be used to halt buffering.

Regards,

Bill
 

sinha

Stainless
Joined
Sep 25, 2010
Location
india
Hello Sinha,
In many, later Fanuc Programming Manuals, its explicitly stated that both G31 and G53 can be used to halt buffering.

Regards,

Bill

Yes, you told us earlier also.

I have a query about buffering.
It is believed that there should not be two consecutive non-XY-movement blocks in the radius-compensation mode (assuming compensation in G17)
Is this restriction still there if the control is capable of reading a large number of subsequent blocks?
 

PROBE

Hot Rolled
Joined
Jan 23, 2003
Location
Tel Aviv, Israel
The technical facts should be described as clearly as possible, specially if statements are made be forum leaders like Bill and Sinha. To clarify the G31/G53 buffering preventing ability, here is excerpt from my post not long time ago.

Quote from B-63944EN/03 Fanuc 30/31/32 manual, page 556, paragraph 16.8:
"At the blocks containing M00, M01, M02 or M30, blocks containing
M-codes for which buffering is suppressed by setting parameters Nos.
3411 to 3420 and No.3421 to 3432, and blocks containing prevention
buffering G codes such as G31 or G53, the CNC stops to preread the
NC statement after that
. Then, the stop of the macro statement
execution is guaranteed until such M codes or G codes complete its
execution."

In simple words: The buffering preventing starts AFTER the block containing G31 is executed.

Let's assume following sequence:
N1 G31 X10. F10
N2 #100=#5061

The NC statement after G31 is X10. F10. Block N2 is not buffering prevented, and #100 is loaded with arbitrary value of #5061. The correct syntax of the sequence should be:
N1 G31 X10. F10
G53
N2 #100=#5061
Now N2 is buffering prevented by G53, and correct value of #5061 is loaded to #100.

Stefan
Cogito Ergo Sum
 

angelw

Diamond
Joined
Sep 10, 2010
Location
Victoria Australia
In simple words: The buffering preventing starts AFTER the block containing G31 is executed.

Let's assume following sequence:
N1 G31 X10. F10
N2 #100=#5061

The NC statement after G31 is X10. F10. Block N2 is not buffering prevented, and #100 is loaded with arbitrary value of #5061. The correct syntax of the sequence should be:
N1 G31 X10. F10
G53
N2 #100=#5061
Now N2 is buffering prevented by G53, and correct value of #5061 is loaded to #100.

Stefan
Cogito Ergo Sum

Hello Stefan,
That is simply not correct. Both examples will have the exact same result.

Purely as a method of halting buffering, where you don't want the program to actually halt, which would be the case if M00 is used, either G31 or G53 can be used.

In your examples above, you're using G31 in the way it was designed for and that is to skip to the next block if a Skip Signal is detected.

There are some Positioning System Variables that can and can't be read during movement. The following picture, copied from a Fanuc Manual, is unambiguous as to which can and can't be read during movement.

G31.JPG

In the following example of reading the Machine Coordinate System for the Z axis, which can't be read during movement:

G43 Z10.0 H01
#1 = #5023

assuming the axis movement is starting from the Z Reference Return Position, the System Variable #5023 would be read within milliseconds of the command being executed and #1 would take on a value of probably only circa -0.010mm or so.

G43 Z10.0 H01
G31 (or G53)
#1 = #5023

will result in #1 taking on the value of #5023 after the command block G43 Z10.0 H01 has completed its movement.

In your following example:

N1 G31 X10. F10
N2 #100=#5061

the Skip Signal Work Coordinate System for X (#5061) will be the position value when the Skip Signal is detected and won't vary by executing any delay, or any other Buffering Halt function post the Skip Signal. Accordingly, both of your examples will net the same result.

Regards,

Bill
 

sinha

Stainless
Joined
Sep 25, 2010
Location
india
I have not actually tested, but I believe Bill is correct.
Both the examples of Probe should give the same result.
Look at the explanation copied from a Fanuc manual:

Buffering with G31.JPG

In the first case, the macro statement next to the G31 block is evaluated only after execution of G31 is complete. The second case is different because G31 or any other buffering-preventing function has not been used.
 

PROBE

Hot Rolled
Joined
Jan 23, 2003
Location
Tel Aviv, Israel
Bill and Sinha,
Unfortunately the examples which you brought from Fanuc manuals are completely irrelevant to the case we are dealing with, as the block following the G31 in this examples does not include any data based on probing result. I do not know how to paste the picture copied from the manual to this text, but I can quote the statement from page 555 of the FANUC-30i-63944EN operating manual, which appears immediately after explanation brought by Sinha:
CAUTION
In case that you need to execute the macro
statement after completing the block just before the
macro statement, specify M code or G code that is
not buffered just before the macro statement.
Specially, in case of reading/writing the system
variables to control signals, coordinates, offset
value, etc., it may different system variable data by
the timing of the NC statement execution. To avoid
this phenomenon, specify such M codes or G
codes before the macro statement, if necessary.


I believe there is no need for more detailed directive and explanation of the necessity of using buffering prevention code (G53 or any other) between the G31 move command and the following macro statement.

Stefan
Cogito Ergo Sum
 

sinha

Stainless
Joined
Sep 25, 2010
Location
india
Probe,
Your highlighted statements do not contradict what I stated.
G53 and G31 both prevent buffering. Therefore, if G31 has been used, there is no need for G53.

How do you explain the example-1?
The control does not process N2 till N1 is completed.
It is shown graphically also.
Therefore, whether N2 has #5061 or anything else, is hardly important.
The control will never know it because it will not read it till N1 is complete.
Please conduct a small experiment and share the results.
 

angelw

Diamond
Joined
Sep 10, 2010
Location
Victoria Australia
Bill and Sinha,
Unfortunately the examples which you brought from Fanuc manuals are completely irrelevant to the case we are dealing with, as the block following the G31 in this examples does not include any data based on probing result.

Hello Stefan,

Sinha and I were making comments in reply to the OP's Post regarding the different results achieved when not using and using a code to halt buffering, when reading the System Variables for Program Numbers. The OP used G53 in his example, I stated that G31 could also be used.

With regards to timing, Feed Rate makes a difference to the actual position registered in the Skip Function System Variable (also varied by the Skip Function Used - High Speed or not), but it does not affect the value read from the Skip Function System Variables after the Skip Function has been executed. There may be a different value in the Skip Function Variable due to the precise moment when the Skip Function was executed, but definitely not to the value read from that Variable after the Skip Function.

Regards,

Bill
 

tteitgen

Aluminum
Joined
Jun 16, 2013
Location
Muskegon
Probe,
Your highlighted statements do not contradict what I stated.
G53 and G31 both prevent buffering. Therefore, if G31 has been used, there is no need for G53.

How do you explain the example-1?
The control does not process N2 till N1 is completed.
It is shown graphically also.
Therefore, whether N2 has #5061 or anything else, is hardly important.
The control will never know it because it will not read it till N1 is complete.
Please conduct a small experiment and share the results.

Running the above examples in my Fanuc simulation software, the G31 is buffering the statement as expected. The Fanuc manual states:
Screenshot 2022-04-04 181408.jpg
 

PROBE

Hot Rolled
Joined
Jan 23, 2003
Location
Tel Aviv, Israel
1. Sinha,
I have experienced this phenomenon so many times, no need to run it once more.

2. Bill, tteigen,
I would read very carefully the content of the CAUTION remark, included in tteigen post. I emphasized for you the important topics:

CAUTION
In case that you need to execute the macro
statement after completing the block just before the
macro statement, specify M code or G code that is
not buffered just before the macro statement.
Specially, in case of reading/writing the system
variables to control signals, coordinates, offset
value, etc., it may different system variable data by
the timing of the NC statement execution. To avoid
this phenomenon
, specify such M codes or G
codes before the macro statement, if necessary.

It says, it is not happening always, but it may happen. Therefore the necessity is obvious. The tools to prevent it (G53 for example) are given. The investment and/or effort to implement them are negligible. For me good engineering means make any effort to avoid problems. And it means - use these tools.

Stefan
Cogito Ergo Sum
 

PROBE

Hot Rolled
Joined
Jan 23, 2003
Location
Tel Aviv, Israel
Hi Sinha,
You and Bill explained in excellent way the Fanuc graphics. I couldn't add anything. Unfortunately, these graphics have nothing to do with our case, as the macro expression in block N2 (#1=100.) is not using any variables, and content of the #1 will always be 100, no matter if buffered or not. Fanuc have been aware about this problem and added in CAUTION remark: ... specify M code or G code that is not buffered just before the macro statement. Specially, in case of reading/writing the system variables to control signals, coordinates, offset value, etc.
Interesting is, that in previous revisions of Fanuc operating manuals this remark appeared under NOTE title. Seems that the importance of the issue caused them to change the title to !CAUTION, emphasized by exclamation mark.

I do believe that you yourself, Bill and, with all humbleness, me myself, our role is to be mentors to forum members, each of us in field of his expertise. I am always giving my best effort to explain to my audients what is a good, correct practice in engineering. In this particular case using the G53 statement in block immediately following the G31 statement costs nothing, but avoids potential serious problems. And that's what GOOD PRACTICE is all about.

Stefan
Cogito Ergo Sum
 

angelw

Diamond
Joined
Sep 10, 2010
Location
Victoria Australia
1. Sinha,
I have experienced this phenomenon so many times, no need to run it once more.

2. Bill, tteigen,
I would read very carefully the content of the CAUTION remark, included in tteigen post. I emphasized for you the important topics:

CAUTION
In case that you need to execute the macro
statement after completing the block just before the
macro statement, specify M code or G code that is
not buffered just before the macro statement.
Specially, in case of reading/writing the system
variables to control signals, coordinates, offset
value, etc., it may different system variable data by
the timing of the NC statement execution. To avoid
this phenomenon
, specify such M codes or G
codes before the macro statement, if necessary.

It says, it is not happening always, but it may happen. Therefore the necessity is obvious. The tools to prevent it (G53 for example) are given. The investment and/or effort to implement them are negligible. For me good engineering means make any effort to avoid problems. And it means - use these tools.

Stefan
Cogito Ergo Sum

Stefan,
You're missing the point that G31 is one of those Codes that are NOT buffered. The G31 function will complete before the Skip Function System Variable is read if its the next block after the Skip Function. The Caution above does NOT apply to the G31 Skip Function, for it is NOT buffered.

Like you, I've executed Skip Function code many times but without any error. Unlike you, I carried out Sinha's test some years back and Posted the result here on this Forum and I did it again today, with the result Posted below.

I apologize for the poor quality pictures; they were taken with the only mobile phone that was available and the camera resolution is rubbish.

For clarification of the simple program, the code for with and without G53 is shown in Text following:

Without G53 included after the Skip Function

Without G53.JPG

O6014
(BUFFER HALT TEST)
N1 G17 G21 G40 G49 G80 G90 G94
G91 G28 Z0.0
G28 X0.0 Y0.0
G90 G00 G54 X-246.0 Y170.0
G43 Z50.0 H08
G91 G31 X50.0 F500
G65 H01 P#100 Q#5061 (COMMON VARIABLE #100 ACCEPTS THE VALUE)
G91 G00 X-10.0
G91 G28 Z0.0
G28 X0.0 Y0.0
M30
%

With G53 included after the Skip Function

With G53.JPG

O6014
(BUFFER HALT TEST)
N1 G17 G21 G40 G49 G80 G90 G94
G91 G28 Z0.0
G28 X0.0 Y0.0
G90 G00 G54 X-246.0 Y170.0
G43 Z50.0 H08
G91 G31 X50.0 F500
G53 (G53 ADDED)
G65 H01 P#101 Q#5061 (COMMON VARIABLE #101 ACCEPTS THE VALUE)
G91 G00 X-10.0
G91 G28 Z0.0
G28 X0.0 Y0.0
M30
%

The result of executing the two programs above is shown below, with Common Variable #100 and #101 reading the value of System Variable #5061 without and with, receptively, G53 included immediately after the G31 Function.

X Skip Function Variable1.JPG

An additional Buffering Halt Code is NOT required after a G31 Skip Function, when the Next Block, or one following soon after is to read the Skip Function System Variable.

The timing issue does NOT apply to the G31 Skip Function when reading the data from the Skip Function System Variable, because the value is secure in the System Variable before the program Skips to the next Block. The Value in the Skip Function System Variable may vary due to timing, but it will be the same value when read by the next, or subsequent Blocks. This has Zero to do with Buffering when related to the G31 Skip Function.

Regards,

Bill
 

angelw

Diamond
Joined
Sep 10, 2010
Location
Victoria Australia
Hi Sinha,
You and Bill explained in excellent way the Fanuc graphics. I couldn't add anything. Unfortunately, these graphics have nothing to do with our case, as the macro expression in block N2 (#1=100.) is not using any variables, and content of the #1 will always be 100, no matter if buffered or not.

I have no idea what you're talking about. In this recent discussion with tteigen, it's been about reading System Variables and he has discovered that the halt of Buffering is sometimes required.

You started your recent involvement with tteigen's Post with:

The technical facts should be described as clearly as possible, specially if statements are made be forum leaders like Bill and Sinha. To clarify the G31/G53 buffering preventing ability, here is excerpt from my post not long time ago.

The fact is, your description of the requirement of Buffer Prevention after a G31 Ship Function and before reading from the associated Skip Function System Variable, is not technically or otherwise correct.

I don't disagree with including code for safety sake; all of the programs I wright myself have much code that many may consider superfluous, but each tool operation is able to stand as a stand alone program; accordingly, when having to repeat an operation (for whatever purpose), its difficult to go wrong. But I balk at placing a sting of code that effectively has the same purpose, that is, having numerous Buffering Prevent codes following one another as in the case of G53 following G31. Sure, it won't hurt, but for accuracy sake for those that are learning, its NOT required.

Regards,

Bill
 

PROBE

Hot Rolled
Joined
Jan 23, 2003
Location
Tel Aviv, Israel
Hi Bill,
Seems that now we are facing the problem of interpretation of written text. Although, contrary to you, English is not my mother tongue, I believe that I understand quite well written text, specially if it is in my fields of interest (thanks God, not engineering only).
The example given in Fanuc manual is very clear and straight forward.
N1 G31 X100.0
N2 #100=1
Simple and conforms with your theory.

But if so, why Fanuc decided to place framed remark in bolt text under !CAUTION title, elaborating that In case that you need to execute the macro statement after completing the block just before the macro statement, specify M code or G code that is not buffered just before the macro statement. Specially, in case of reading/writing the system variables to control signals, coordinates, offset value, etc. Apparently it seems to them too, that it is not so simple when values like probing results are evaluated. Now, let's try to understand the Japanese English: In my opinion they clearly say, that you have to put the buffer preventing G or M function "after completing the block just before the macro statement", i.e. G53 or stand alone G31 or dedicated M between the G31 move block.

Stefan
Cogito nErgo Sum
 

sinha

Stainless
Joined
Sep 25, 2010
Location
india
Probe,

Nobody is contradicting what is written as Caution.
This applies when buffering-preventing code is not used.
Since G31 prevents buffering, no additional buffering-preventing code such as G53 is needed.

To repeat what I said earlier, and as CLEARLY explained in graphic in Fanuc manual, the code next to G31 block is NOT read by the control till G31 is complete. Therefore, it is hardly important what is contained in the block following G31 block. It will not be read till G31 is complete.

The thing is, both you and the Fanuc manual cannot be correct at the same time.

But, I do agree that inserting an additional buffering-preventing code, G53, after G31 block, will do no harm.


Note: There are some mistakes in Fanuc manuals also. I did discuss a few things with Fanuc Japan, long time back, and they admitted the mistakes. Therefore, there is a possibility that you may have found that G53 after G31 is needed in some cases, which Fanuc does not know.
 

PROBE

Hot Rolled
Joined
Jan 23, 2003
Location
Tel Aviv, Israel
Therefore, there is a possibility that you may have found that G53 after G31 is needed in some cases, which Fanuc does not know.

Hi Sinha,
I am not a sort of Don Quijote fighting with wind mills. The problem exists. Not me only is aware about that. In many of Renishaw, Marposs and Blum known to me measuring programs for Fanuc the "additional" G53 is used.

Having debate with Fanuc ? Not me. These guys (and not they only) "per defintio" never fail. I as engineer am obliged to discover the problem, understand its cause and find the solution. And I did.

Stefan
Cogito Ergo Sum
 

PROBE

Hot Rolled
Joined
Jan 23, 2003
Location
Tel Aviv, Israel
Excerpt from Blum Inspection:
%
O9704(MEASURE)
(V2AC 23.02.07 DJ COPYRIGHT BLUM-NOVOTEST GMBH 2007)
IF[[#130AND16]EQ0]GOTO1
G53
IF[#1013NE1]THEN#121=30
(IF[OUT3NE0]THEN#121=30)
IF[#1012NE1]THEN#121=30
IF[#121EQ0]GOTO1
M[99]
N1IF[#26NE#0]GOTO2
IF[#17GT#[#135+0]]THEN#17=#17-#[#135+0]
N2G53
#1=#5041
#2=#5042
#3=#5043-[#122*[[#130AND32]/32]]
IF[#24EQ#0]THEN#24=#1
IF[#25EQ#0]THEN#25=#2
IF[#26EQ#0]THEN#26=#3
#21=0
N3#27=#24-#1
#28=#25-#2
#29=#26-#3
#14=SQRT[[#27*#27]+[#28*#28]+[#29*#29]]
#4=#24+[#17*#27/#14]
#5=#25+[#17*#28/#14]
#6=#26+[#17*#29/#14]
IF[#127GT[200./#131]]GOTO50
G31X#4Y#5Z#6F[#128*0.3]
G53
#7=#5061-[#[#135+4]*#27/#14]
#8=#5062-[#[#135+4]*#28/#14]
#9=#5063-[#122*[[#130AND32]/32]]-[#[#135+4]*#29/#14]
#30=#5061-#4


Stefan
Cogito Ergo Sum
 








 
Top