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:

LaThthe - Next tool spindle speed at retract


Recommended Posts

Hi,

 

For Mori Millturns, I would like to figure out how to add in a "Quick" M-code for the next tool before the retract move.  The code will start ramping the spindle to the next RPM, but the machine won't wait for the command to be completed.

 

 

 

(EXAMPLE)

 

(MACHINIG HERE - END OF TOOL)

 
G3 X1.916 Z-.9147 R.0206
G1 Z-1.09
X1.9584 Z-1.0688
G0 Z.03
(*************************)
G97 S600 M1003 (THIS LINE ADDED IN BASED ON RPM OF NEXT TOOL)
(*************************)
G0 G53 X-2.5 Y0. Z-15. M9
 
 
M01
 
 
 
(.105 O.D. GROOVE GC-4125)
M98 P7000
G54
 
T606
 
G18 G99
G97 S600 M03 (NORMAL SPINDLE ON COMMAND VERIFIES SPINDLE IS AT COMMANDED SPEED)
G0 X1.7235 Y0. Z.03 M8
Z-.167
G1 X1.474 F.002
G0 X1.7235
 
(MORE MACHINING)
 
 
 
 
How do you get the RPM of the next tool?  I would like it to figure out what the RPM would be where the next tool starts cutting also if it is in CSS mode.
 
And if milling is next, have a M1005 on that line before the retract.
 
Thanks.
Brian
 
 
 
 
  • Like 1
Link to comment
Share on other sites

I didn't find out yet how to get the RPM of the next tool.  I Would like to find out, but I put the RPM for the next tool and the retract line at the top of the "ltlchg$" block and commented out the stuff from the "ptoolend$".  I am sure it isn't the most elegant/professional way of doing that, but the code looks like I want it to, and works like I want it to, as far as I can tell so far.  Gotta play around with it some more.  

 

I am still curious though how other people got this to work?

Link to comment
Share on other sites

Brian,

 

This depends a lot on which post you are using, and knowing how MP Processes data.

 

Are you aware of the NCI Pre-Read Loop? This is used by MP to "loop through" the NCI file, and gather data from the tool change events.

 

Most modern posts, like "Generic Fanuc 4X MT_Lathe", use this Pre-Read Loop to assign data to a Buffer file. In the case of that post I just mentioned, the post stores about 30 different variables into this buffer file. There is a lot more to it than that, so it isn't just some easy code to implement getting the "next" spindle speed, which is why I hesitate to get you started.

 

But, you asked, and I always feel like anyone that asks a good question like yours deserves an answer.

 

Buffer 1 has 29 variables. There are two lists of variables above the 'fbuf 1  0  29  0  0' line. These lists of variables each have 29 variables.

 

Each "record" in the buffer is a Row. Each row gets filled with 29 numeric values, at the Tool Change events. This is the "Write" sequence.

 

Now, when you are processing normal "lathe" or "mill" tool change events, there is a call made to 'preadcur_nxt'. This call goes and sets both sets of "current and next" variables.

 

So the variables should basically already be set.

 

The current "spindle speed" would be held in 'c1_ss'. The "next spindle speed" would be held in 'n1_ss'.

 

So that's the answer. Just use the "current and next" variables from buffer 1 in your logic, and you can extract the value, exactly where you need it, in 'ptoolend$'.

  • Like 1
Link to comment
Share on other sites

Cool. Thanks Colin! That made it simple and easy.

 

I added this to my pl_retract:

 

[
           [ 
           speed=n1_ss
          if n1_posttype<>c1_posttype,
 
          pbld, n$, [if workofs$=0, "M1005", if workofs$=1, "M1205"], e$
          else, 
           [
          if n1_ss<>c1_ss & n1_css_actv=0,
          pbld, n$, *sg97, *speed, [if workofs$=0, "M1003", if workofs$=1, "M1203"], e$
           ]       
           
          if n1_css_actv=1,          
            [
          speed=n1_ss*3.82/ (******NEED X START POSITION OF NEXT TOOL HERE***********)
          pbld, n$, *sg97, *speed, [if workofs$=0, "M1003", if workofs$=1, "M1203"], e$
            ]            
           ]
 
 
And this to my pm_retract:
 
          speed=n1_ss
          if n1_posttype<>c1_posttype,
          pbld, n$, *sg97, *speed, [if workofs$=0, "M1003", if workofs$=1, "M1203"], e$
 
 
I have two more questions if you don't mind - 
 
1.Is there a variable in the buffer for the start X position of the next tool?  I need that to calculate what RPM if the next toolpath is in CSS mode.
2. Is there a variable to read what work offset number is assigned to the plane that the next tool is using?  I see that the spindle_n0$ variable is available, but that has been spotty for me in the past and I've been using the workofs$ variable for which spindle I'm on.  
 
Thanks Again.
Link to comment
Share on other sites
  1. Not specifically. There are two X variables, 'c1_x_min' and 'c1_x_max' that hold the Min and Max X positions of the current tool. So, by the design of the buffer, 'n1_x_min' and 'n1_x_max' will hold the min and max positions for the "next" tool. This may or may not be the "starting" position of the tool, I'm not sure. You'll have to test it out. Look at 'pgear' and 'pspindle' for some of the "stock" code that uses these variables. I can see in 'pgear' that they are used to figure out the starting position to select the correct gear range, so that may work for what you need. Also, try 'n1_xh' <-- This 'n1_xh' looks like it might get the X position at the tool change.
  2. Short answer: No. But... There is always a but... You can add a variable to the buffer file definition, and modify the logic that stores this buffer data, to add whatever you want to capture. (Assuming it is available inside MP...) There is actually a "brand new" Tool List mechanism inside MP that is very powerful, and could also be used to get what you want, but it is too complex to just say "go ahead and add this code...", with Copy/Paste. Because you have to remove existing code from the post before you can use it.

 

 

So, how would you add the "Work Offset" number to the buffer?

 

  1. Find the buffer definition, and add another variable to each list. (c1, and n1)
c1_op_id     : 0     #Buffer 1
c1_tool_op   : 0     #Buffer 1
c1_workofs   : 0     #Buffer 1    <<<<<< Added a variable here!
 
# Next tool information
n1_gcode     : 0     #Buffer 1
.
.
.
n1_op_id     : 0     #Buffer 1
n1_tool_op   : 0     #Buffer 1
n1_workofs   : 0     #Buffer 1    <<<<<< Added a variable here!

fbuf 1 0 30 0 0      #Buffer 1    <<<<<<< Changed value from '29' to '30'

       2.    Now, we need to capture the variable while the Pre-Read Loop runs. Find 'pcur_recd', and add one line of code just before the 'write' line:

pcur_recd       #Write to the current tool record
      c1_gcode = gcode$
      pmatrix_su
      pset_turret
      pmap_home
      c1_xh = vequ(xabs)
      c1_tox = vmap (tox$, mmtx1)
      c1_cc_pos = cc_pos$
      if gcode$ <> 1003, c1_tool = abs(t$)
      else, c1_tool = zero
      c1_tloffno = tloffno$
      c1_maxss = maxss$
      c1_ss = abs(ss$)
      if cool_w_spd = zero, c1_spdir = spdir$ + one
      else, c1_spdir = (spdir$ + one) + (fsg2(coolant$) * three)
      c1_css_actv = css_actv$
      c1_fr_pos = fr_pos$
      c1_ipr_actv = ipr_actv$
      c1_coolant = coolant$
      c1_nextdc = nextdc$
      c1_posttype = posttype$
      c1_cuttype = cuttype
      c1_lathtype = lathtype
      c1_gcodecc = gcodecc
      c1_lathecc = lathecc
      c1_millcc = millcc
      c1_y_axis = y_axis
      c1_op_id = op_id$
      if opcode$ = 104,
        [
        if face_thd <> two, x_min$ = abs(xmaj_thd)
        else,
          [
          if abs(zstrt_thd) > abs(zend_thd), x_min$ = abs(zstrt_thd)
          else, x_min$ = abs(zend_thd)
          ]
        x_max$ = x_min$
        ]
      c1_workofs = workofs$   #<<<<<< This line of code sets current work offset value to buffer
      c1_gcode = wbuf (one, wc1)

That will write the "current value of the Work Offset variable" to the buffer at each tool change. Because the "next variable read counter" is offset by "1", you will get the Current and Next variable values, at the Tool Change. Just use 'c1_workofs' and 'n1_workofs' as the "current" and "next" values...

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