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:

How do I calculate an angle created by two points in a custom drill cycle?


Recommended Posts

Hello All,

This post is for an Okuma MV460-VE with a OSP-P300MA Controller.

I'm trying to write a custom probing cycle using one of the custom drill cycles in Mastercam 2021. I constantly have to write out by hand a program that probes the location of two dowel holes where one of them is 0,0 and the other is at some angle. The program then compares the actual measured angle to the nominal and makes a correction with work coordinate rotation.

I have written custom drilling cycles to use probing before, but I have never needed the points to make a calculation.

Where I'm stuck is how do I "get" the points inside of my custom drill cycle so that the post can calculate the angle between the points so that it can be posted out with the rest of the code?

Here is my hand written code:

(PROBE DATUM B - SET P1 WORK OFFSET)
(PROBE DATUM C - FIND ACTUAL ANGLE )

(T32 - PROBE)
G116 T32
(STAGE NEXT TOOL HERE)

M201 (LOOK AHEAD OFF)

(PROBE DATUM B - DIA 0.2502 - SET P1)

(POSITION PROBE)

G15 H1
G90 G00 X0.0 Y0.0
G56 HA G00 Z2.0
CALL O9832 (PROBE ON)
CALL O9810 PZ=-0.5 (PROTECTED MOVE INSIDE DATUM A HOLE)
CALL O9814 PD=0.2502 PS=1 (MEASURE DATUM A AND SET P1)
CALL O9810 PZ=0.25 (PROTECTED MOVE OUT OF HOLE)
CALL O9810 PX=9.0720 PY=3.7335 (PROTECTED MOVE TO DATUM C)

(PROBE DATUM C - DIA 0.2502 - FIND ANGLE)

CALL O9810 PZ=-0.5 (PROTECTED MOVE INSIDE DATUM C HOLE)
CALL O9814 PD=0.2502 (MEASURE DATUM C POSTION)
CALL O9810 PZ=0.25 (PROTECTED MOVE OUT OF HOLE)
CALL O9833 (PROBE OFF)
VS120 = VS75 (STORE DATUM C X POSITION)
VS121 = VS76 (STORE DATUM C Y POSITION)

(CALCULATE ACTUAL ANGLE)
VS122 = ATAN[VS76/VS75]

(CALCULATE CORRECTION AMOUNT)
VS123 = 22.369 - VS122

IF[VS123 LT 0]NSKIP
VS124 = VS123

(NEGATIVE ANGLE MATH)
NSKIP
VS124 = [VS123 + 360]


(ROTATE ENTIRE WORK COORDINATE SYSTEM)
G17 G11 X0.0 Y0.0 P=VS124

M202 (LOOK AHEAD ON)

G30 P1

REST OF PROGRAM......

Here is the custom probe cycle I wrote that works ( it's probably sloppy but it works):

     if drillcyc$ = 8,

      [

      pcom_moveb

      probe_Dia = peck1$
      tool_wear = peck2$
      probe_zvalDepth = depth$
      probe_Feed = feed
      probe_zvalRetract = refht$
      noform_probeDia = peck1$
      noform_Tool = peck2$

      pbld, n$, "M201 (LOOK AHEAD OFF)", e$

      pbld, n$,"(POSTION PROBE)", e$

      pbld, n$, pxout, pyout, e$

      pbld, n$, "CALL O9832 (Probe On)", e$

      pbld, n$, "CALL O9810", *probe_zvalDepth, *probe_Feed, "(Protected Move to Bore Measurement Height)" e$

      pbld, n$, "CALL O9814", *probe_Dia, "(Measure Diameter)", e$

      pbld, n$, "VC120 = VS78", e$

      pbld, n$,    "CALL O9810", *probe_zvalRetract, *probe_Feed, "(Protected Move out)" e$

      pbld, n$, "CALL O9833 (Probe Off)", e$

      pbld, n$, *sg00, initht$, e$


      pbld, n$, "(CALCULATE DIAMETER OFFSET ADJUST T",*noform_Tool,")", e$

      pbld, n$, "VC121 = VC120 - ", *noform_probeDia, e$

      pbld, n$, *tool_wear, "= [VC121/2] +", *tool_wear, e$

      pbld, e$

     pbld, n$, "M202 (LOOK AHEAD ON)", e$

      #pcom_movea

      ]

      pcom_movea

 

Basically I just need to figure out how I can have the post calculate the "22.369 deg" in my hand written code and then I can figure out the rest.

 

Thanks for any help, I'm really scratching my head because I'm not a computer programmer by any means!!

 

Link to comment
Share on other sites
16 hours ago, JParis said:

If you're trying to feed a probing macro info for a G68 coordinate rotation, let the control handle the math

You can have the post out the G68#141   (assuming #141 is the value the macro solves the angle)

 

But I need the nominal angle to be able to make a correction and I want the post to calculate it using the two points I select in MC.

(CALCULATE ACTUAL ANGLE)
VS122 = ATAN[VS76/VS75]  <-------- Here I'm calculating the actual measured angle

(CALCULATE CORRECTION AMOUNT)
VS123 = 22.369 - VS122 <--------- Here I'm comparing it to the nominal angle - I want the post to come up with the 22.369 (using the two points selected in MC) on its own, but I don't know how to call the points without printing them (something other than pxout, pfout, pyout, pfyout, etc.

IF[VS123 LT 0]NSKIP
VS124 = VS123

(NEGATIVE ANGLE MATH)
NSKIP
VS124 = [VS123 + 360]

Is there a matrix or string or something of all the points that are selected for a particle drill cycle that you can pull from in the post?

Also a side note that this is an Okuma controller and G11 is the coordinate rotation G-code. It only works with a positive angle and can only rotate in the counter clockwise direction. The dowel holes could be in a negative or positive position in relation to the nominal angle.

Link to comment
Share on other sites
  • 4 months later...

Just curious, but this sounds like situations I find myself in quite often with BC heat/table machines.  If you're looking to correct minimal angle changes due to work piece setup, using the probe to define offsets in the control has worked very well for me.  Can you post pics of the issue in the machine?  It seems you're reinventing the wheel on problems that many of us have solved over and over.  Maybe with a better explanation of the problem we can offer better help.

Tidbit - yes the angle info is in the posted NCI BUT using that data is difficult.  If you can handle matrix math you can handle it.

What post are you using?

Link to comment
Share on other sites
  • 3 weeks later...

The "First Point" you drill at, is based on the particular Drill Cycle you are using.

Do you intend to use one of the first 8 "pre-defined" Drill Cycles, or are you using one of the Custom Cycles? < That makes a difference.

For example, if you were using the normal "Drill Cycle", then the Post would call:

  • 'pdrill$' for the 1st Drill Point
  • pdrill_2$ for the 2nd Drill Point

If you use "Custom Cycle #1", this is really "Drill Cycle #9", in the Cycle Drop-Down.

  • pdrlcst   < Gets called for your 1st Drill Point. (Must query 'drillcyc$' to get the actual "cycle number" in the drop-down menu.)
  • pdrlcst_2$ < Gets called for any 'subsequent' drill point, contained in a Drill Operation. (regardless of the Cycle Number.)
Link to comment
Share on other sites

So, to better answer your question:

  1. I would add logic to 'pdrlcst', to capture the "first point X value" and store it in variable. (Same for Y)
  2. I would add logic to 'pdrlcst_2' to capture the "2nd point X value" and store it in a variable. (Same for Y)
  3. I would then add my logic to pdrlcst_2$, to calculate the 3D distance, and then be able to calculate the angle between the 3D Distances.
  4. Don't forget: 'pcanceldc$' will get called for any of the 20 drill cycles. (Cycles 0-7 = the first 8 "canned drill cycles". If 'drillcyc$ = 8, that is the "9th drill cycle" in the drop down list. You will need to modify the logic in 'pcanceldc$', so that you don't get "G80" after your custom cycle.

(For example, change this:

pcanceldc$       #Cancel canned drill cycle
      result = newfs (three, zinc)
      if drillref = 0, zabs = initht_a               #Make the initht the modal Z value
      else, zabs = refht_a
      prv_zia = zabs
      !zabs
      ps_inc_calc
      prv_gcode$ = zero
      if cool_zmove = yes$ & (nextop$=1003 | (nextop$=1011 & t$<>abs(nexttool))), coolant$ = zero
      pcan
      if drillcyc$ <> 8, pcan1, pbld, n$, "G80", scoolant, strcantext, e$
      if num_pts = 1 & zabs <> initht_a,
        [
        gcode$ = 0
        zabs = initht_a
        pbld, n$, sgcode, pfzout, e$
        ]
      pbld, n$, sgfeed, e$
      pcan2

To this:

pcanceldc$       #Cancel canned drill cycle
      result = newfs (three, zinc)
      if drillref = 0, zabs = initht_a               #Make the initht the modal Z value
      else, zabs = refht_a
      prv_zia = zabs
      !zabs
      ps_inc_calc
      prv_gcode$ = zero
      if cool_zmove = yes$ & (nextop$=1003 | (nextop$=1011 & t$<>abs(nexttool))), coolant$ = zero
      pcan
      if drillcyc$ < 8, pcan1, pbld, n$, "G80", scoolant, strcantext, e$
      if num_pts = 1 & zabs <> initht_a,
        [
        gcode$ = 0
        zabs = initht_a
        pbld, n$, sgcode, pfzout, e$
        ]
      pbld, n$, sgfeed, e$
      pcan2

Making that change to "less than 8", rather than "not equal to 8", makes sure that if your Drill Cycle = 9 or higher, that you don't get "G80" coming out for any of the Custom Drill Cycles.

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...