What's new
What's new

Macro Programming Fundamentals

sinha

Stainless
Joined
Sep 25, 2010
Location
india
The parameter would be different on that control.
If you have the soft copy of its parameter manual, search for "language"
 

angelw

Diamond
Joined
Sep 10, 2010
Location
Victoria Australia
angelw Wrote:
Yes. lets hope that you get a reply in a timely manner. With regards to my source being incognito, I will provide his contact details to you, but I doubt that he would appreciate his details being published on a Forum for all and sundry to start contacting him.
Stefan’s Reply
Even in not conservative standards, 2 weeks is way beyond “a timely manner”. As to the “incognito source” – don’t bother, I am not looking to contact him.
angelw reply
Not surprising. When I asked for an official response, I was told that it’s not Fanuc’s policy to answer programming questions and will refer you to the Machine Tool Builder. My contact, where I got my previous statement was on a colleague to colleague basis.

In recent weeks I've contacted the Victorian manager of Renishaw and had a long and unambiguous conversation with him regarding the use of G31; his name is Mike Davies. He confirmed that their practice is to NOT follow a G31 Block with G53.

angelw Wrote:
Thus far the only evidence you have provided has been anecdotal.
Stefan’s Reply
Let me ignore this impertinence.
angelw reply:
You can ignore it all you like, but it doesn’t change the fact that you haven’t offered any example programs and the resulting error you claim, only anecdotes.

Stefan Wrote:
The “CAUTION” extract included in your previous posts indicates exactly the need of Buffer preventing block after G31 move block:
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.

Unfortunately, the example given in this remark is poor and meaningless. As mentioned before, if they would use the N2 #100=#5061 instead of N2 #100=1. , everything would be clear. No NOTE, which with time became !CAUTION, would be needed. But they did not.
angelw reply
All Fanuc Manuals have the following tables, Copied and Pasted from a Fanuc Manual::
System Variables1.JPG

Stefan Wrote:
It also states in Fanuc Manuals that #506_ System Variables can be read during movement.
The operation of touch trigger probe is based on the fact that the data is collected “on the fly”. This is obvious. Once the trigger is executed, the 506* registers are refreshed with the new data. The problem is, which 506* data are used in the next macro statement. In order to prevent the use of old (before the trigger being executed) data, the G53 block is needed.
angelw reply:
The G53 block is NOT needed.

blocks containing M codes for which buffering is suppressed by setting
parameters No.3411 to No.3420, and blocks containing G31 are not preread


What the above means, is that these codes halt buffering. G31 specified on its own, like G53, halts buffering. G31 with arguments halts buffering, is NOT pre-read and therefore, following it with G53 is superfluous.

angelw Wrote:
I've Posted recent program examples, run on a machine and not just text listing of a program, showing that a G31 Block used for the purpose it was designed, does indeed Buffer Prevent.
Stefan Reply
Unfortunately, in none of these examples the data of collected in 506* registers was use in macro sequence following the G31 move, therefore they are meaningless to the matter of this discussion.
angelw reply:
Not so. Its a known fact that G31specified on it's own with no coordinate addresses, can and is used to halt Buffering, that's well documented in Fanuc Manuals. What I was demonstrating was that G31 executed with coordinate addresses, as when used in its design application, performed in exactly the same manner to halt Buffering. But to satisfy you, here you go then, an example program made and tested today reading System Variable #5063.
The pictures I took with the phone of the program screen were rubbish. Accordingly, the following is the listing of the program. I'll take pictures tomorrow with a better camera and update this Post.
%
O0005
(G31 - G53 BUFFER HALT TEST)
N1 G00 G17 G21 G40 G49 G80 G94
G91 G28 Z0.0
G28 X0.0 Y0.0
T11 M06
G90 G00 G55 X0.0 Y0.0
G43 Z140.000 H11
G91 G31 Z-50.000 F1000
/G53
G65 H01 P#104 Q#5063
/G65 H01 P#105 Q#5063
M00
G91 G00 Z10.000
G28 Z0.0
G28 X0.0 Y0.0
M30
%
The picture following shows the result of executing the above program with Block Delete on, so that G53 and the Macro Statement writing to Common Variable #105 are ignored.
Variable Page1A 19-05-22.JPG

and the result of writing the content of System Variable #5063 into Common Variable #104.

The picture following shows the result of executing the above program with Block Delete off, so that G53 and the Macro Statement writing to Common Variable #105 are executed.
Variable Page2A 19-05-22.JPG

The result? As can be seen, the value read from System Variable #5063 and written to Common Variables #104 and #105 are the same precisely.

The use of G53 following G31 is tantamount to including G01 in consecutive Linear Interpolation Blocks; it does no harm, but its not necessary and it makes no difference to the performance of the program.
 
Last edited:

Tichy

Aluminum
Joined
Jan 1, 2019
Is there a way to store a parameter while a machine is in motion? (Line feed.)

I want to read the spindle load parameter and store it in a variable at different Z depths in a G1 motion.
 

angelw

Diamond
Joined
Sep 10, 2010
Location
Victoria Australia
Is there a way to store a parameter while a machine is in motion? (Line feed.)

I want to read the spindle load parameter and store it in a variable at different Z depths in a G1 motion.
The short answer is no. The User Macro is not multi-tasking, as is what you would want, a program running in the background polling for changes in the Z position within one Block movement.

However, when one program is being executed, another program can be called by
inputting an interrupt signal from the machine. This is what you would have to do if monitoring and dealing with either axis, or spindle load being outside a set, upper limit.

Regards,

Bill
 

dandrummerman21

Stainless
Joined
Feb 5, 2008
Location
MI, USA
I have a question regarding ASIN

I have a casting that I've ran before on a 18m control, where I have G54 set to the center of a hole (hole doesnt exist yet), and there's a second hole that I need to tap in the middle of an ear.

G54 doesn't change, but the location of the ear changes (castings vary) so I probe it using renishaw macro 9812. After probing, I set the following variables:

#566=#136 (Y LOCATION OF EAR)
#567=ASIN[#566/1.35]

... and use G68 in my program for drilling the hole.

That ran fine in an 18MB control.

Now I've got the same program running on a 0mc control, and after running a couple parts, it is clear the angle isn't calculating correctly.

The last part had #566=.0441 and it calculated the angle #567=.0326667

But it should be about 1.872. Curiously, the angle it calculated seems to be correct, IN RADIANS, not degrees.


But even more curiously, The Smid macro book says this:

ASIN and ACOS functions are not available on 0/16/18/21 model controls !

I don't see limitations mentioned in Sinha's macro book. And the control generates no alarm when trying to use ASIN.


Now, can I (should I) just convert the values it's giving me to degrees? I haven't wandered back to the control to see if it is consistantly giving radians for different amounts. Or should I calculate the angle differently using ATAN (which I know works because I've used it for different situations on a 0m control.) Also, the difference between ASIN and ATAN should be very small since I don't expect the angle to exceed 2 or 3 degrees in the worst case scenario and it looks like the error would be very small (on the order of .02 degrees or less)

Another note, I find it odd that my 18 control worked flawlessly even though the note says it doesn't work on an 18 either...

Insight would be appreciated.


Edit: I also just learned that ATAN needs to be written as ATAN[#566]/[1.35]. Also, ATAN works perfectly and that's actually more mathematically correct for how I'm locating the probe for checking location. So this is what I'm going with.
 
Last edited:

sinha

Stainless
Joined
Sep 25, 2010
Location
india
Smid's book is not for i-series controls. Therefore, there can be some differences in descriptions if you are working on an i-series.

I had tested these functions on an i-series control. Everything was in degrees. Maybe, on older controls, radian is being used. However, I find it odd that ASIN outputs radian and ATAN outputs degree. Both should be same.

Since -x/y is mathematically same as x/-y, and x/y is same as -x/-y, ASIN and ACOS may not output the correct angle in all cases. These are mainly useful if the angle is expected to lie in the first quadrant (0 to 90 degree). Therefore, it is always better to use ATAN which always outputs the correct angle, in all four quadrants. It has the format ATAN[Perpendicular]/[Base]
 

dandrummerman21

Stainless
Joined
Feb 5, 2008
Location
MI, USA
It is not an i series control, it is a 0m.

And yeah, when I wrote the program a couple years ago, I got my soh cah toa mixed up. 1.35 isn't the hypotenuse, it's the adjacent (base), and the probed value is the opposite (perpindicular), so ATAN is what I should have used from the getgo.

Also, the 0m control doesn't seem to be actually giving ASIN values in radians. It's actually a coincidence that the values it calculated are so close to the radian values.

I just had the 0m control evaluate ASIN[1] which should be pi/2 or ~1.57 in radians, but it simply evaluates it as 1. Pretty dumb that the machine can evaluate ASIN without generating an alarm, while generating a wrong value!
 

sinha

Stainless
Joined
Sep 25, 2010
Location
india
So, Smid is right!
ASIN is "not available" on 0 series control.

Of course, it is available on 0i
 

tteitgen

Aluminum
Joined
Jun 16, 2013
Location
Muskegon
Does anyone know if the "Q" option below is available on a 18i-TB Fanuc controller?
What Model did they add the Q option?

M98P2000Q20. (Goto sub program 2000 Line Number 20).
 

angelw

Diamond
Joined
Sep 10, 2010
Location
Victoria Australia
Does anyone know if the "Q" option below is available on a 18i-TB Fanuc controller?
What Model did they add the Q option?

M98P2000Q20. (Goto sub program 2000 Line Number 20).
Yes. The method of being able to call a Local Subprogram with the "Q" address was introduced with the FS16i control. If the control has the Local Subprogram function, it will also have the facility to call an External Subprogram and specify a Sequence Number to start from within the Subprogram with the syntax shown in your example.

Regards,

Bill
 

tteitgen

Aluminum
Joined
Jun 16, 2013
Location
Muskegon
Yes. The method of being able to call a Local Subprogram with the "Q" address was introduced with the FS16i control. If the control has the Local Subprogram function, it will also have the facility to call an External Subprogram and specify a Sequence Number to start from within the Subprogram with the syntax shown in your example.

Regards,

Bill
Thanks Bill
 

sinha

Stainless
Joined
Sep 25, 2010
Location
india
Bill explained this 10 years back.
(Post # 10)
 

angelw

Diamond
Joined
Sep 10, 2010
Location
Victoria Australia

BARCOL IMPRESSOR​

The Barcol Impressor is a hand-held portable hardness tester. It is a convenient tool for testing the hardness of aluminum, aluminum alloys, copper, brass and other materials including plastics and fiberglass. The Impressor is designed for use on fabricated parts and assemblies as well as on raw stock.

You can get the product at any of your places, at your doorstep in Pakistan.

Just my luck. I don't live in Pakistan, otherwise I would get ten. Without bad luck, I'd have no luck at all.
 

Billet454

Plastic
Joined
Jul 16, 2021
Okay all you Macro Gu-Ru's out there, I could use some help. I have a Matsuura 600 H 40 PC2S, Yasnac MX3 control. In an unrelated incident Yaskawa had me re generate the machine system because of a communication issue. The end result was I can no longer use the pallet changer and or index the pallet, despite the fact that I have restored the macro program and all the machine parameters to there original state. I did discover a few typos in the manual with regards to the macro, which I was able to figure out and correct, but the pallet still wont index as it did before. When I give the command G190 BXXX., it unlocks the pallet, then immediately locks the pallet but docent index. The index is controlled by the X axis servo, and a gear that slides into place while traversing along the axis. The program in the manual is as below. Thank you very much in advance.

%
O9010 (N-010-01-MEN)
#3003=1
IF[#2EQ#0]GOTO100
IF[#2EQ0.]GOTO010
IF[#2LT1.]GOTO104
#4=FIX[#2]
#2=#4
IF[#LT0]GOTO102
IF[#GE360.]GOTO103
N010IF[4007NE40]GOTO106 changed to [#4007NE40]
IF[#1001EQ1.]GOTO105
IF[#100EQ1.]GOTO008
IF[13EQ#0]GOTO001
IF[#13NE6]GOTO101
M106
N001#30=#2-#550
IF[#30EQ0]GOTO030
#3=#4001
#5=#4003
G00G90
#6=#5021
IF[#30GT0]GOTO002
IF[#30GT-180]GOTO003
#30=#30+360
GOTO003
N002IF[#30LE180]GOTO003
#30=#30-360
N002IF[#4006EQ20]GOTO20
#31=ROUND[#30*1780.2358]/1000
#32=#5021+#31
IF[#32GTO.]GOTO004 changed to [#32GT0.]
IF[#32GT-610.]GOTO006
#33=-610.-#31
#32=-610.
GOTO005
N020#31=ROUND[#30*700.88025]/10000
#32=#5021+#31
IF[#32GTO.]GOTO004 changed to [#32GT0.]
IF[#32GT-24.01575]GOTO006
#33=-24.01575-#31
#32=-24.01575
GOTO005
N004#33=0.-#31
#32=0.
N005G53X#33
N006M123
G04P300
M122
G04P300
G53X#32
M121
M124
IF[#5EQ90]GOTO0011
G53X#6
N011G#3G#5
N030IF[#NE0]GOTO007
M120
N007#550=#2
IF[#13EQ#0]GOTO008
M107
N008#3003=0
M99
N100#3003=0
#3000=500(B ERROR NO B COMMAND)
N101#3003=0
#3000=501 (M CODE ERROR)
N102#3003=0
#3000=502 (B ERROR B MINUS)
N103#3003=0
#3000=503 (B ERROR 360 OVER)
N104#3003=0
#3000=504 (B ERROR NO DECIMAL POINT)
N105#3003=0
#3000=505 (X-AXIS MIRROR IMAGE ON ERROR)
N106#3003=0
#3000=506 (G41/G42 MODE ERROR
%
 

angelw

Diamond
Joined
Sep 10, 2010
Location
Victoria Australia
%
O9010 (N-010-01-MEN)
#3003=1
IF[#2EQ#0]GOTO100
IF[#2EQ0.]GOTO010
IF[#2LT1.]GOTO104
#4=FIX[#2]
#2=#4
IF[#LT0]GOTO102
IF[#GE360.]GOTO103

N010IF[4007NE40]GOTO106 changed to [#4007NE40]
IF[#1001EQ1.]GOTO105
IF[#100EQ1.]GOTO008
IF[13EQ#0]GOTO001
IF[#13NE6]GOTO101
M106
N001#30=#2-#550
IF[#30EQ0]GOTO030
#3=#4001
#5=#4003
G00G90
#6=#5021
IF[#30GT0]GOTO002
IF[#30GT-180]GOTO003
#30=#30+360
GOTO003
N002IF[#30LE180]GOTO003
#30=#30-360
N002IF[#4006EQ20]GOTO20
#31=ROUND[#30*1780.2358]/1000
#32=#5021+#31
IF[#32GTO.]GOTO004 changed to [#32GT0.]
IF[#32GT-610.]GOTO006
#33=-610.-#31
#32=-610.
GOTO005
N020#31=ROUND[#30*700.88025]/10000
#32=#5021+#31
IF[#32GTO.]GOTO004 changed to [#32GT0.]
IF[#32GT-24.01575]GOTO006
#33=-24.01575-#31
#32=-24.01575
GOTO005
N004#33=0.-#31
#32=0.
N005G53X#33
N006M123
G04P300
M122
G04P300
G53X#32
M121
M124
IF[#5EQ90]GOTO0011
G53X#6
N011G#3G#5
N030IF[#NE0]GOTO007
M120
N007#550=#2
IF[#13EQ#0]GOTO008
M107
N008#3003=0
M99
N100#3003=0
#3000=500(B ERROR NO B COMMAND)
N101#3003=0
#3000=501 (M CODE ERROR)
N102#3003=0
#3000=502 (B ERROR B MINUS)
N103#3003=0
#3000=503 (B ERROR 360 OVER)
N104#3003=0
#3000=504 (B ERROR NO DECIMAL POINT)
N105#3003=0
#3000=505 (X-AXIS MIRROR IMAGE ON ERROR)
N106#3003=0
#3000=506 (G41/G42 MODE ERROR
%
Before digging into the logic of the above Macro Program, you need to correct the Blocks I've highlighted in Red

Regards,

Bill
 

Billet454

Plastic
Joined
Jul 16, 2021
Not sure what to correct them to. This is out of Matsuura’s program book for this machine. I have called and emailed them several times and the have not responded.
 

angelw

Diamond
Joined
Sep 10, 2010
Location
Victoria Australia
Not sure what to correct them to. This is out of Matsuura’s program book for this machine. I have called and emailed them several times and the have not responded.

I suspect that the correct Variable to use may be #2. The reason for this thinking is that the Error Trap results refer to the "B" axis and your Call Block "G190 BXXX" is passing an Argument to Local Variable #2 (B) in the Macro.


Regards,

Bill
 
Last edited:








 
Top