What's new
What's new

Probing using G31 (Fanuc)

Denim

Aluminum
Joined
Oct 27, 2007
Location
Norway
Hello folks!
First, let me introduce myself.

I am a 20 year old norwegian cnc operator by trade and I am always interested in learning new technology. (well, new to me anyway ;) )

I am trying to learn how to program custom macros for the Renishaw probe in the Mori Seiki HMC that I run at work, and have searched the net for information, but haven´t really found anything useful.
I understand that you have to use G31 skip feed command, but I´m not sure exactly how to use it.. ;)

I just wrote this sample program for leveling the B-axis in a HMC by probing the tombstone, vise or workpiece, the way I assume/think that the G31 command is being used.
The machine it is for is a 2004 Mori Seiki NH4000 DCG with a Fanuc MSG-501 control.

If anyone could take a look at my code and see if I am completely off the track or not, that would be much appreciated.


This is how I intend it to be used:
Jog the machine to aproximately 15mm over the workpiece with the probe in the spindle and MDI the following line:

G65P6500 X30. (X = incremental distance to the 2. probing point)

O6500
M19
G91 G31 G01 Z-18. F200.
G91 G01 Z15. F1000.
#100=#5061 (1. SKIP READ POSITION X)
#102=#5063 (1. SKIP READ POSITION Z)
G91 G31 G0 Z50.
G91 G31 G0 X#24
G91 G31 G0 Z-50.
G91 G31 G01 Z-18. F200.
G91 G01 Z15. F1000.
#101=#5061 (2. SKIP READ POSITION X)
#103=#5063 (2. SKIP READ POSITION Z)
#104=ATAN[[#102 - #103]/[#101 - #100]] (calculate the measured angle)
G91 G0 Z200.
M0
M11
G91 G0 B#104
M10
M99

Is it correct that the probed Z position will be stored in #5063 and the X in #5061 when the probe contacts the workpiece in the Z- direction, or will only the position of the traveling axis be stored? (only z position stored if Z is moving) :confused:

Thanx! :D
 
I've never done it on the fanuc, but when you touch the piece, immediately after the G31 line, you can store the "current axis position", and that's the location for Z.
For X or Y you will need to add the probe radius. Either current position, or probe touch position, will store all of the axis that are on the machine. By your post, that would be X,Y,Z,B.

I'm sorry to say that I don't follow your example code too well.

If you command a motion move (G1,G2,G3) with a G31, the probe will stop as soon as it makes contact.
If the next line of code has another G31, the probe will not move - it is already touching the workpiece, so it thinks it just made the G31 contact.

You'll need to clear the probe from the piece
before moving for another touch.

One procedure I use with high speed skip, G31.1, awesome option if you have it. Please pardon the inch units:
G1 G91 Z-.1 F50. (rapid touch of the workpiece
G31 Z-.010 F10. (overdrive to be certain the probe is well triggered)
G31.1 Z+.1 F1. (lift the Z slowly until contact is lost)
#V10=AZ (stores the axis location)
G1 G91 Z+1. (go 1" above workpiece)

hope this was of some help.
 
Thanx man! I´m not sure if the machine has G31.1 or not, but I´m gonna browse through the manual on monday and see what I can find.

I did lift the probe from the contact point with a G91 G01 Z15. F1000. after the touch. I out the G31 in the following blocks just to stop the machine if the probe touches anything while moving to the next spot, so it would not break the stylus on impact.

I am under the impression that on a fanuc, when you command a G01 G31 z-20. F200 for example, the probe will move up to 20mm´s until contact, and then store the contact positon in #5063 automatically. (#5063 = skip read Z axis)

Can someone verify this?
 
Normally Renishaw will supply all the common macro's with the unit, When you do a rapid move to position with the unit loaded, or in between measuring points, it should always be done with a 'protected move' G31 macro, just in case of collisions.
The normal measuring move procedure is to initially move in fairly rapid with a G31, and as soon as the probe registers, back off the amount of the probe deflection, then advance in at slow feed with a G31 and capture the position, the parameters you refer to are the Fanuc pre-assigned axis positions parameters and can be read through the macro command as you have done.
There are two types of G31 in a Fanuc, one is relatively slow capture, through the PMC and the other is a High speed skip capture option card.
If the probe was purchased new, it should have come with a selection of pre-written Macro's
M.
 
That makes sense!

When the probe touches and sends a signal to the control, is the position entered for all the axis on the machine (#5061 = X, #5062 = Y, #5063 = Z, #5064 = B), or is only the position of the moving axis entered? If the probe does not make contact with it´s target in a G31 move before the programmed travel is over, will the variables for the skip signal positions be left blank? (ex. #5063 = #0 if no signal is detected)

The machine did indeed come with the probe from the factory, and has some of renishaws macros already set, but it seems like only the "basic" macros like bore, boss, and pockets are installed, and I want to use it for other "custom" stuff ;)

When I re-calibrated the probe last week, I did notice that "high speed skip signal" was turned off in the menu. This probably means that the machine does not have the high speed skip option, right?
 
"is the position entered for all the axis on the machine (#5061 = X, #5062 = Y, #5063 = Z, #5064 = B)"

That is correct. It will record all axis positions at that location - not just the one that was moving.


My apologies for misreading your code above, sounds like you are on the right track.

G31.1 is high speed, and it will record the position on retract (no longer touching). Without high speed, G31 will only record touching on contact.


And one thing to keep in mind - G31 will only stop motion when the stylus is contacted.

There are a few things G31 will NOT do.
1) If the probe body touches something, it gets very expensive very quickly.
2) If you do make contact with the probe tip on a G31 move, the control will stop that command and move to the next line. Be sure that the next line (or line following a string of G31s) moves you in a safe direction. Typically Z+, but that may vary in some cases.
 
If the probe does not make contact with it´s target in a G31 move before the programmed travel is over, will the variables for the skip signal positions be left blank? (ex. #5063 = #0 if no signal is detected)
A line with a G31 in it will cancel the current move in the line it is in and fall through to the next line, if the skip is not seen, then the line will complete as normal and then go to the next instruction line. The 5000 variables will always contain the current posn. whether you read it or not, skip or not.
The point about a collision getting expensive is that if the protected move is performed, if the probe is activated during a non-measure move, it will freeze the axis in motion at that point.
Correction: I see that refers to the probe body and not the probe tip.
M.
 
This was covered in a recent past post..
To expand a little on what Damon just said, and looking at your program, you cannot just use the G31 moves with the assumption that if the probe has a collision, it will stop.
It will stop, but then it will just make the next move anyway, since you don't do a comparison to see if the block finished at the intended destination, or stopeed halfway there with a collision.
You need to make up a macro that you send the destination of the move to, and it moves via a G31. The next line of code in the macro then has to check to see if the variables captured from the G31 move match the intended destination, or not. If not, then it assumes a collision, and needs to take action, IOW stop!

The code you had in a previous post was just a string of G31 moves. This will not protect from a collision, because it there is a collision, the move will stop at that point, but since there is no logic to detect that there was a collision, it will then start to the next destination point, from where the current collision is at..
 
Thanks for the input! I really appreciate it!


I see the point about how the machine will continue with the next block after a G31 touch has been recorded.

I edited the program a little and added a macro call for X Y Z rapid positioning that checks if the desired position have been reached without triggering the probe stylus.

G65P6500 X30. (X = incremental distance to the 2. probing point)

O6500 (PROBE B-AXIS LEVELING)
M19
G91 G31 G01 Z-18. F200.
#100=#5061 (1. SKIP READ POSITION X)
#102=#5063 (1. SKIP READ POSITION Z)
G91 G01 Z15. F1000.
G65 P6501 Z50. (rapids z50)
G65 P6501 X#24 (rapids x30)
G65 P6501 Z-50. (rapids z-50)
G91 G31 G01 Z-18. F200.
#101=#5061 (2. SKIP READ POSITION X)
#103=#5063 (2. SKIP READ POSITION Z)
G91 G01 Z15. F1000.
#104=ATAN[[#102 - #103]/[#101 - #100]]
G91 G0 Z200.
M0
M11
G91 G0 B#104
M10
M99


O6501 (REF O6500. RAPID MOVE SAFETY)
#105 = #5041 (SET INITIAL X POSITION)
#107 = #5042 (SET INITIAL Y POSITION)
#109 = #5043 (SET INITIAL Z POSITION)
G91 G31 G0 X#24 Y#25 Z#26
#106 = #5041 (SET X POSITION AFTER MOVE)
#108 = #5042 (SET Y POSITION AFTER MOVE)
#110 = #5043 (SET Z POSITION AFTER MOVE)
IF [#106 - #24]NE#105 GOTO 9999
IF [#108 - #25]NE#107 GOTO 9999
IF [#110 - #26]NE#109 GOTO 9999
#24 = #0
#25 = #0
#26 = #0
M99
N9999
#3001=1(PROBE STYLUS COLLITION DETECTED)
M30

Since the new macro call has it´s own set of cleared local variables (#1 to #33), only the specified axis will move.

Does this look better?

[ 10-28-2007, 06:24 AM: Message edited by: Denim ]
 
Looks okay to my eye, but be sure to run it in single step with your hand on the stop button!

one thing though, I would really suggest two touches for each measure point.

Initial Z move as G31 F1000 (mm/min!!), then a G91 Z+0.02 mm , then G31 G91 Z-.1 F40.

Something like this:
G91 G1 G31 Z-18. F1000. (mm/min)
G91 Z+.2 F200.
G91 G31 Z-.1 F40

One other thing - not sure if it is all controllers or just mine, but it wont take a G31 & G91 on the same line. Works ok calling a G91 then the G1/G31 sequence though.

Lookin' good.
 
That makes sense about the probe measuring more accurate at slow feeds.

I will also add a macro that checks if probe concact have been made during the measuring travel.
This will indeed be tested in single block mode with the feed overide turned to zero at the start of every block.
Don´t want no expencive crash by forgetting some stupid little detail in the program. :D
 
Denim,
One question about your Subroutine O6501
The G31 move is specified as a G91. Does it always have to be used as a G91, not as a G90?

OK, I see that the X,Y, or Z could potentially not be specified in the call, so with the G91, it will be safely ignored. Won't it?

So I raise the generic question about how would that routine be written to handle G90 mode, when the calling sequence does not specify all X,Y,Z variables?

Sorry to digress..
 
3t3d,
In G91, all other moves than the one specified would be 0, and therefore not move.
If the subroutine were called up without passing any values to the local variables, nothing would move. (If I remember correctly, all local variables for the new sub is cleared as it is called up. If not, then some logic to clear the variables will be required)

If I understand correctly, you want to use G91 for the actual probing, but G90 for the positioning to the next point(s)?

If the subroutine is written like the one below, I think it will work for both G90 and G91.
If, for instance, this command is entered (G90 or G91) G65 P6501 X50. Y50. Z50. Is called, the machine will first move the Z axis, and then X and Y. If only 1 axis is specified in the call, then the part in the sub that moves the other axis will be skipped.

This is not a proved code btw.. ..it´s been a long day and my brain is tired :D

O6501 (REF O6500. RAPID POSITIONING SAFETY)
#105 = #5041 (SET INITIAL X POSITION)
#106 = #5042 (SET INITIAL Y POSITION)
#107 = #5043 (SET INITIAL Z POSITION)
#108 = 1. (COUNTER)
N5
IF [#108 EQ 1.] GOTO 10
IF [#108 EQ 2.] GOTO 20
IF [#108 EQ 3.] GOTO 30
N10
#108 = #108+1.
IF [#26 NE #0] GOTO 40 (Z AXIS)
GOTO 5
N20
#108 = #108+1.
IF [#24 NE #0] AND [#25 NE #0] GOTO 50 (X AND Y AXIS)
IF [#24 NE #0] GOTO 60 (X AXIS)
GOTO 5
N30
IF [#25 NE #0] GOTO 70 (Y AXIS)
GOTO 80
N40 G31 G0 Z#26 (Z AXIS ONLY)
GOTO 5
N50 G31 G0 X#24 Y#25 (X AND Y AXIS)
GOTO 80
N60 G31 G0 X#24 (X AXIS ONLY)
GOTO 5
N70 G31 G0 Y#25 (Y AXIS ONLY)
N80
IF [[#5041 - #24]NE#105] GOTO 9999
IF [[#5042 - #25]NE#106] GOTO 9999
IF [[#4043 - #26]NE#107] GOTO 9999
#24 = #0
#25 = #0
#26 = #0
M99
N9999
#3000=1(PROBE STYLUS COLLITION DETECTED)
M30

[ 10-29-2007, 05:31 PM: Message edited by: Denim ]
 
I would suggest to be very careful using G90 while probing. The tool offset issue is extremely important, I saw many probes smashed to the root just because somebody forgot the G43 line or used incorrect offset number.

In order to get accurate and repeatable readings the probing speed must be constant. Therefore, in order to avoid the influence of the feedrate potentiometer position, it is good practice to use the
#3004=2
line just before the probing move, and
#3004=0
once the probing move is finished. This command disables the feedrate potentiometer and the movement is executed in programmed feed.
 
Probe, thanks for the tip!


I tested the macro in the machine today, and after fixing a couple of typos and macro format errors, it worked almost perfectly. :cool:

I love it when a plan comes together! :D
 
Well, lets take a close look on the code above.

N40 G31 G0 Z#26 (Z AXIS ONLY)
GOTO 5
N50 G31 G0 X#24 Y#25 (X AND Y AXIS)
GOTO 80
N60 G31 G0 X#24 (X AXIS ONLY)
GOTO 5
N70 G31 G0 Y#25 (Y AXIS ONLY)
N80

it is clearly seen, that if we have collision at XZ motion, the machine will not be stopped immediately. After unsuccessful processing of Z motion, we are going to line N5, than machine will try to move along X axis. Because there is no security check after Z motion. The routine is designed to work with G91 only. Of course syntactics could be better. And of course G0 with G31 is not the best idea at least. But still, idea is very good, and work that done by Denim is excellent.
The next code was tested on MoriSeiki NH 6300 DCG. It`s free of trying to move after collision, and able to work under G90 as well as with G91

%
O9810 (PROBE POSITIONING SAFETY)
(ANATOLI PANCHENKO)
M46(PROBE ON)
M144(OPTICAL SENSOR ON)
G4 X0.5 (WAIT)

IF[#4003EQ91]GOTO10
IF[#4003EQ90]GOTO20

N10(INC MOOVE)
#105 = #5041 (SET INITIAL X POSITION)
#106 = #5042 (SET INITIAL Y POSITION)
#107 = #5043 (SET INITIAL Z POSITION)
#108 = 1. (COUNTER)
N11
IF[#108EQ1.]GOTO12
IF[#108EQ2.]GOTO13
IF[#108EQ3.]GOTO14
N12
#108=#108+1.
IF[#26NE#0]GOTO15 (Z AXIS)
GOTO 11
N13
#108=#108+1.
IF[#24NE#0]AND[#25 NE #0]GOTO16 (X AND Y AXIS)
IF[#24NE#0]GOTO17 (X AXIS)
GOTO 11
N14
IF[#25NE#0]GOTO18 (Y AXIS)
GOTO 19
N15 G31 Z#26 F#9 (Z AXIS ONLY)
IF[[#5043-#26]NE#107]GOTO999
GOTO 11
N16 G31 X#24 Y#25 F#9 (X AND Y AXIS)
IF[[#5041-#24]NE#105]GOTO999
IF[[#5042-#25]NE#106]GOTO999
GOTO 19
N17 G31 X#24 F#9 (X AXIS ONLY)
IF[[#5041-#24]NE#105]GOTO999
GOTO 11
N18 G31 Y#25 F#9 (Y AXIS ONLY)
IF[[#5042-#25]NE#106]GOTO999
N19
#24=#0
#25=#0
#26=#0
#108=#0
GOTO1000


N20(ABS MOOVE)
#108 = 1. (COUNTER)
N5
IF[#108EQ1.]GOTO10
IF[#108EQ2.]GOTO20
IF[#108EQ3.]GOTO30
N10
#108=#108+1.
IF[#26NE#0]GOTO40 (Z AXIS)
GOTO 5
N20
#108=#108+1.
IF[#24NE#0]AND[#25 NE #0]GOTO50 (X AND Y AXIS)
IF[#24NE#0]GOTO60 (X AXIS)
GOTO 5
N30
IF[#25NE#0]GOTO70 (Y AXIS)
GOTO 80
N40 G31 Z#26 F#9 (Z AXIS ONLY)
IF[[#26NE#0]AND[#5043NE#26]]GOTO999
GOTO 5
N50 G31 X#24 Y#25 F#9 (X AND Y AXIS)
IF[[#24NE#0]AND[#5041NE#24]]GOTO999
IF[[#25NE#0]AND[#5042NE#25]]GOTO999
GOTO 80
N60 G31 X#24 F#9 (X AXIS ONLY)
IF[[#24NE#0]AND[#5041NE#24]]GOTO999
GOTO 5
N70 G31 Y#25 F#9 (Y AXIS ONLY)
IF[[#25NE#0]AND[#5042NE#25]]GOTO999
N80 (RESET PARAMETERS)
#24=#0
#25=#0
#26=#0
#108=#0
GOTO1000 (TO EXIT)

N999
#3000=1(PROBE STYLUS COLLITION DETECTED)
N1000
M99
%

Next improvement can be made, by realisation of clever movement sequence algorithm. The code above is always starting from move along Z axis. It's ok for retract motion, but not safe for approach. My idea is to add ability to that macro to analyse motion direction, than to choose what's axis to move first. Such if we going down - move XY first, if we going up - move Z first.
N20(ABS MOOVE)
(#105 = #5041 (SET INITIAL X POSITION)
(#106 = #5042 (SET INITIAL Y POSITION)
#107 = #5043 (SET INITIAL Z POSITION)
#108 = 1. (COUNTER)
N5
IF[#108EQ4.]GOTO80 (-)
IF[#107LT#26]GOTO9 (Z FIRST-)
IF[#107GT#26]GOTO7 (Z LAST-)
N7(-)
IF[#108EQ1.]GOTO20(-)
IF[#108EQ2.]GOTO30(-)
IF[#108EQ3.]GOTO10(-)
N9 (-)
IF[#108EQ1.]GOTO10
IF[#108EQ2.]GOTO20
IF[#108EQ3.]GOTO30
N10
#108=#108+1.
IF[#26NE#0]GOTO40 (Z AXIS)
GOTO 5
N20
#108=#108+1.
IF[#24NE#0]AND[#25 NE #0]GOTO50 (X AND Y AXIS)
IF[#24NE#0]GOTO60 (X AXIS)
GOTO 5
N30
#108=#108+1.
IF[#25NE#0]GOTO70 (Y AXIS)
GOTO 5(80)
N40 G31 Z#26 F#9 (Z AXIS ONLY)
IF[[#26NE#0]AND[#5043NE#26]]GOTO999
GOTO 5
N50 G31 X#24 Y#25 F#9 (X AND Y AXIS)
IF[[#24NE#0]AND[#5041NE#24]]GOTO999
IF[[#25NE#0]AND[#5042NE#25]]GOTO999
GOTO 5(80)
N60 G31 X#24 F#9 (X AXIS ONLY)
IF[[#24NE#0]AND[#5041NE#24]]GOTO999
GOTO 5
N70 G31 Y#25 F#9 (Y AXIS ONLY)
IF[[#25NE#0]AND[#5042NE#25]]GOTO999
GOTO 5()
N80 (RESET PARAMETERS)
#24=#0
#25=#0
#26=#0
#108=#0
GOTO1000 (TO EXIT)

N999
#3000=1(PROBE STYLUS COLLITION DETECTED)
N1000
M99
%
This was not tested on machine yet, but looks good on simulation.
 
But still to be actual for everyone, who starting to deal with custom probe macros. Neither Renishaw nor Blum did not made their probe macros available free of charge to everyone.
 
OK, so to translate this skip macro to the Okuma user task language do you think this will work?

OSKP

(PROBE POSITIONING SAFETY)
(ANATOLI PANCHENKO)
CALL OO18 (PROBE ON)
G4 X0.5 (WAIT)

M130

IF [VGCOD[12] EQ 91] GOTO N10
IF [VGCOD[12] EQ 90] GOTO N20

N10(INC MOOVE)
VC105 = VWKAX (SET INITIAL X POSITION)
VC106 = VWKAY (SET INITIAL Y POSITION)
VC107 = VWKAZ (SET INITIAL Z POSITION)
VC108 = 1. (COUNTER)

N11
IF [VC108 EQ 1.] GOTO 12
IF [VC108 EQ 2.] GOTO 13
IF [VC108 EQ 3.] GOTO 14

N12
VC108 = VC108 + 1.
IF [VC26 NE 0] GOTO 15 (Z AXIS)
GOTO 11

N13
VC108 = VC108 + 1.
IF [VC24 NE 0] AND [VC25 NE 0] GOTO 16 (X AND Y AXIS)
IF [VC24 NE 0] GOTO 17 (X AXIS)
GOTO 11

N14
IF [VC25 NE 0] GOTO 18 (Y AXIS)
GOTO 19

N15 G31 Z=VC26 F=VC9 (Z AXIS ONLY)
IF [[VWKAZ-VC26] NE VC107] GOTO N999
GOTO 11

N16 G31 X=VC24 Y=VC25 F=VC9 (X AND Y AXIS)
IF [[VWKAX-VC24] NE VC105] GOTO N999
IF [[VWKAY-VC25] NE VC106] GOTO N999
GOTO 19

N17 G31 X=VC24 F=VC9 (X AXIS ONLY)
IF [[VWKAX-VC24] NE VC105] GOTO N999
GOTO 11

N18 G31 Y=VC25 F=VC9 (Y AXIS ONLY)
IF [[VWKAY-VC25] NE VC106] GOTO N999

N19
VC24=0
VC25=0
VC26=0
VC108=0
GOTO N1000

N20(ABS MOOVE)
VC105 = VWKAX (SET INITIAL X POSITION)
VC106 = VWKAY (SET INITIAL Y POSITION)
VC107 = VWKAZ (SET INITIAL Z POSITION)
VC108 = 1. (COUNTER)

N5
IF[VC108 EQ 4.] GOTO N80 (-)
IF[VC107 LT VC26] GOTO N9 (Z FIRST-)
IF[VC107 GT VC26] GOTO N7 (Z LAST-)

N7(-)
IF[VC108 EQ 1.] GOTO N20(-)
IF[VC108 EQ 2.] GOTO N30(-)
IF[VC108 EQ 3.] GOTO N10(-)

N9 (-)
IF[VC108 EQ 1.] GOTO N10
IF[VC108 EQ 2.] GOTO N20
IF[VC108 EQ 3.] GOTO N30

N10
VC108 = VC108 + 1.
IF[VC26 NE 0] GOTO N40 (Z AXIS)
GOTO N5

N20
VC108 = VC108 + 1.
IF[VC24 NE 0] AND [VC25 NE 0] GOTO N50 (X AND Y AXIS)
IF[VC24 NE 0] GOTO N60 (X AXIS)
GOTO N5

N30
VC108 = VC108 + 1.
IF[VC25 NE 0] GOTO N70 (Y AXIS)
GOTO N5(80)

N40 G31 Z=VC26 F=VC9 (Z AXIS ONLY)
IF[[VC26 NE 0] AND [VWKAZ NE VC26]] GOTO N999
GOTO N5

N50 G31 X=VC24 Y=VC25 F=VC9 (X AND Y AXIS)
IF[[VC24 NE 0] AND [VWKAX NE VC24]] GOTO N999
IF[[VC25 NE 0] AND [VWKAY NE VC25]] GOTO N999
GOTO N5(80)

N60 G31 X=VC24 F=VC9 (X AXIS ONLY)
IF[[VC24 NE 0] AND [VWKAX NE #24]] GOTO N999
GOTO N5

N70 G31 Y=VC25 F=VC9 (Y AXIS ONLY)
IF[[VC25 NE 0] AND [VWKAY NE VC25]] GOTO N999
GOTO N5()

N80 (RESET PARAMETERS)
VC24=0
VC25=0
VC26=0
VC108=0

GOTO N1000 (TO EXIT)

N999

VUACM[1]=’COLLISION’

VDOUT[993]=1234

N1000

M02
 
I have no big experience with ocuma controls, but these similar to fanuc. If you don't missed something, this should to work. It is good idea to test that code by running the probe on air. Just hit you stylus with the finger to see the effect. Try different axes combinations.
 








 
Back
Top