Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

MACRO: Hole center by 3 points


Simtech
 Share

Recommended Posts

Hi all,

I recently received a request to create a macro program to extract the center point of a hole (or cylinder) given 3 points along the hole or cylinder's edge (by using an edge finder for example).

 

In Fanuc style, this is what I've come up with.

 

Run program O9101 when probe is in first position (stores X and Y in #111 and #112)

Run program O9102 when probe is in second position (stores X and Y in #121 and #122)

Run program O9103 when probe is in third position (stores X and Y in #131 and #132 retracts and moves to center)

Use machine coordinates to enter Work Offset.

 

Any comments are welcome!

 

Regards,

 

Luc

 

O9101

#111=#5021 (POSITION OF MACHINE X AXIS - POINT 1)

#112=#5022 (POSITION OF MACHINE Y AXIS - POINT 1)

M30

 

O9102

#121=#5021 (POSITION OF MACHINE X AXIS - POINT 2)

#122=#5022 (POSITION OF MACHINE Y AXIS - POINT 2)

M30

 

 

O9103(CIRCLE CENTER FROM 3 POINTS)

(O9101: USED TO STORE POINT 1 IN #111 AND #112)

(09102: USED TO STORE POINT 2 IN #121 AND #122)

(#131=#5021 (POSITION OF MACHINE X AXIS))

(#132=#5022 (POSITION OF MACHINE Y AXIS))

(#100: SLOPE OF LINE A)

(#101: SLOPE OF LINE B)

(#102: SLOPE OF LINE PERP TO A)

(#103: SLOPE OF LINE PERP TO B - NOT USED)

(#104: SLOPE A TIMES SLOPE B)

(#105: Y1-Y3)

(#106: X1+X2)

(#107: X2+X3)

(#108: SLOPE B - SLOPE A)

(#109: Y1+Y2)

(#110: X-#106/2)

(#141: POINT X OF CENTER)

(#142: POINT Y OF CENTER)

(***** VARIABLE CALCULATIONS *****)

#100=(#122-#112)/(#121-#111)

#101=(#132-#122)/(#131-#121)

#102=(-1/#100)

#103=(-1/#101)

#104=(#100*#101)

#105=(#112-#132)

#106=(#111+#121)

#107=(#121+#131)

#108=(#101-#100)

#109=(#112+#122)

#141=((#104*#105)+(#101*#106)-(#100*#107))/(2*#108)

#110=(#141-(#106/2))

#142=(*#102*#110)+(#109/2)

(***** MACHINE MOUVEMENT *****)

G91 G00 Z5.0

G53 G01 X#141 Y#142 F10.0

(***** END OF MACRO *****)

M30

%

Link to comment
Share on other sites

Oops, remove parenthesis on these lines

 

#131=#5021 (POSITION OF MACHINE X AXIS)

#132=#5022 (POSITION OF MACHINE Y AXIS)

 

Corrected below!!!

 

 

Hi all,

I recently received a request to create a macro program to extract the center point of a hole (or cylinder) given 3 points along the hole or cylinder's edge (by using an edge finder for example).

 

In Fanuc style, this is what I've come up with.

 

Run program O9101 when probe is in first position (stores X and Y in #111 and #112)

Run program O9102 when probe is in second position (stores X and Y in #121 and #122)

Run program O9103 when probe is in third position (stores X and Y in #131 and #132 retracts and moves to center)

Use machine coordinates to enter Work Offset.

 

Any comments are welcome!

 

Regards,

 

Luc

 

O9101

#111=#5021 (POSITION OF MACHINE X AXIS - POINT 1)

#112=#5022 (POSITION OF MACHINE Y AXIS - POINT 1)

M30

 

O9102

#121=#5021 (POSITION OF MACHINE X AXIS - POINT 2)

#122=#5022 (POSITION OF MACHINE Y AXIS - POINT 2)

M30

 

 

O9103(CIRCLE CENTER FROM 3 POINTS)

(O9101: USED TO STORE POINT 1 IN #111 AND #112)

(09102: USED TO STORE POINT 2 IN #121 AND #122)

#131=#5021 (POSITION OF MACHINE X AXIS)

#132=#5022 (POSITION OF MACHINE Y AXIS)

(#100: SLOPE OF LINE A)

(#101: SLOPE OF LINE B)

(#102: SLOPE OF LINE PERP TO A)

(#103: SLOPE OF LINE PERP TO B - NOT USED)

(#104: SLOPE A TIMES SLOPE B)

(#105: Y1-Y3)

(#106: X1+X2)

(#107: X2+X3)

(#108: SLOPE B - SLOPE A)

(#109: Y1+Y2)

(#110: X-#106/2)

(#141: POINT X OF CENTER)

(#142: POINT Y OF CENTER)

(***** VARIABLE CALCULATIONS *****)

#100=(#122-#112)/(#121-#111)

#101=(#132-#122)/(#131-#121)

#102=(-1/#100)

#103=(-1/#101)

#104=(#100*#101)

#105=(#112-#132)

#106=(#111+#121)

#107=(#121+#131)

#108=(#101-#100)

#109=(#112+#122)

#141=((#104*#105)+(#101*#106)-(#100*#107))/(2*#108)

#110=(#141-(#106/2))

#142=(*#102*#110)+(#109/2)

(***** MACHINE MOUVEMENT *****)

G91 G00 Z5.0

G53 G01 X#141 Y#142 F10.0

(***** END OF MACRO *****)

M30

%

Link to comment
Share on other sites

Oops, remove parenthesis on these lines

 

#131=#5021 (POSITION OF MACHINE X AXIS)

#132=#5022 (POSITION OF MACHINE Y AXIS)

 

Corrected below!!!

 

nice code.... although I dont think my control is new enough to take the 'Smiley Face' GCodes that showed up in the second post.

I'm not sure about compatability on this one, but couldnt you put all 3 routines together, and prompt the user using "#3001=1 [PROMPT STRING]" for the user to touch off each edge ?

Link to comment
Share on other sites

Smiley Face comes from the new forum app, I'm not used to it yet. Need to deactivate Smiley Faces I guess.

Not sure about the #3001=1 on the Fanuc, will look it up, it would be much easier, thanks!

 

nice code.... although I dont think my control is new enough to take the 'Smiley Face' GCodes that showed up in the second post.

I'm not sure about compatability on this one, but couldnt you put all 3 routines together, and prompt the user using "#3001=1 [PROMPT STRING]" for the user to touch off each edge ?

Link to comment
Share on other sites

This is what I'm thinking:

The #3000=1(MESSAGE) will stop the program execution with the MESSAGE appearing in the Alarm Screen Display. Once the program has been stopped, we need to exit the program, to get back in the JOG or HANDLE modes to move the machine axis to the following position.

After that, we need to re-execute a program to get the coordinates of the next point.

Thats why I split it up in 3 different programs.

 

Maybe there's a better way???

 

Smiley Face comes from the new forum app, I'm not used to it yet. Need to deactivate Smiley Faces I guess.

Not sure about the #3001=1 on the Fanuc, will look it up, it would be much easier, thanks!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...