Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Feed rate absent on sub spindle movements - Mill Turn - Siemens 840D

AndyDHarlow
Enthusiast

Feed rate absent on sub spindle movements - Mill Turn - Siemens 840D

AndyDHarlow
Enthusiast
Enthusiast

Hi Guys, I have recently with the help of this forum been able to post sub spindle/part handling code to our DMG CLX450 mill turn machine.

 

The last couple problems I have that I can't seem to make work is the fact that when the sub spindle moves under G01 conditions no feed rate is output and also I don't want the turret to be moved in sub spindle cycles as I will be working close in between chucks on small parts.

 

Post attached.

 

Thank you.

 

Example of code:

; Subspindle Grab1
N35 G53 G0 X450 Y0 Z600 D0
N40 G54
N45 M326
N50 M336 ; UNCLAMP SECONDARY CHUCK
N55 G95
N60 M413
N65 M313
N70 L706         ;DISENGAGE C3-AXIS
N75 L708         ;DISENGAGE C4-AXIS
N80 S4=500 M4=3
N85 S3=500 M3=4
N90 L726(0) ; SPINDLE SYNCHRONIZATION ON
N95 M307 ; CLEANING COOLANT ON
N100 G4 F1
N105 G0 Z3=23
N110 G4 F1
N115 G1 Z3=10 (Feed rate should be here)
N120 M337 ; CLAMP SECONDARY CHUCK
N125 M309 ; CLEANING COOLANT OFF
N130 G4 F1
N135 G17
N145 G53 G0 X450 D0  <-------- Get rid of this section
N150 G53 Y0 D0            <--------
N155 G53 Z600 D0        <---------
N160 M4=5
N165 M3=5
 
Section of post:
    switch (cycleType) {
    case "secondary-spindle-grab":
      if (cycle.usePartCatcher) {
        engagePartCatcher(true);
      }
      writeBlock(mFormat.format(currentSection.spindle == SPINDLE_PRIMARY ? 326 : 426)); // check if the opposite spindle is empty
      writeBlock(
        getCode(currentSection.spindle == SPINDLE_PRIMARY ? "UNCLAMP_SECONDARY_CHUCK" : "UNCLAMP_PRIMARY_CHUCK"),
        formatComment(currentSection.spindle == SPINDLE_PRIMARY ? "UNCLAMP SECONDARY CHUCK" : "UNCLAMP PRIMARY CHUCK")
      );
      writeBlock(getCode("FEED_MODE_UNIT_REV")); // mm/rev
      if (cycle.stopSpindle) { // no spindle rotation
        writeBlock(conditional(machineState.mainSpindleIsActive, getCode("STOP_MAIN_SPINDLE")));
        writeBlock(conditional(machineState.subSpindleIsActive, getCode("STOP_SUB_SPINDLE")));
        writeBlock("L705(0)   ;ENGAGE C3-AXIS");
        writeBlock("L707(0)   ;ENGAGE C4-AXIS");
      } else { // spindle rotation
        writeBlock(getCode("MAIN_SPINDLE_BRAKE_OFF"));
        writeBlock(getCode("SUB_SPINDLE_BRAKE_OFF"));
        writeBlock("L706         ;DISENGAGE C3-AXIS");
        writeBlock("L708         ;DISENGAGE C4-AXIS");
        writeBlock("S" + mainSpindleAxisName[1] + "=" + rpmFormat.format(cycle.spindleSpeed), tool.clockwise ? getCode("START_MAIN_SPINDLE_CW") : getCode("START_MAIN_SPINDLE_CCW"));
        writeBlock("S" + subSpindleAxisName[1] + "=" +rpmFormat.format(cycle.spindleSpeed), tool.clockwise ? getCode("START_SUB_SPINDLE_CCW") : getCode("START_SUB_SPINDLE_CW")); // inverted
        writeBlock(getCode("SPINDLE_SYNCHRONIZATION_ON") + "(" + abcFormat.format(cycle.spindleOrientation) + ")", formatComment("SPINDLE SYNCHRONIZATION ON")); // Sync spindles
      }
      // writeBlock(getCode("MAINSPINDLE_AIR_BLAST_ON"), formatComment("MAINSPINDLE AIR BLAST ON"));
      // writeBlock(getCode("SUBSPINDLE_AIR_BLAST_ON"), formatComment("SUBSPINDLE AIR BLAST ON"));
      writeBlock(mFormat.format(currentSection.spindle == SPINDLE_PRIMARY ? 307 : 407), formatComment("CLEANING COOLANT ON"));
      onDwell(cycle.dwell);
      gMotionModal.reset();
      writeBlock(conditional(cycle.useMachineFrame, gFormat.format(53)), gMotionModal.format(0), "Z3=" + spatialFormat.format(cycle.feedPosition));

      onDwell(cycle.dwell);
      writeBlock(conditional(cycle.useMachineFrame, gFormat.format(53)), gMotionModal.format(1), "Z3=" + spatialFormat.format(cycle.chuckPosition), getFeed(cycle.feedrate)); <----------- assume that the problem is here?
      writeBlock(
        getCode(currentSection.spindle == SPINDLE_PRIMARY ? "CLAMP_SECONDARY_CHUCK" : "CLAMP_PRIMARY_CHUCK"),
        formatComment(currentSection.spindle == SPINDLE_PRIMARY ? "CLAMP SECONDARY CHUCK" : "CLAMP PRIMARY CHUCK")
      );
      writeBlock(mFormat.format(currentSection.spindle == SPINDLE_PRIMARY ? 309 : 409), formatComment("CLEANING COOLANT OFF"));
      onDwell(cycle.dwell);
      break;
    case "secondary-spindle-return":
      writeBlock(getCode("FEED_MODE_UNIT_REV")); // mm/rev
      if (cycle.stopSpindle) { // no spindle rotation
        writeBlock(conditional(machineState.mainSpindleIsActive, getCode("STOP_MAIN_SPINDLE")));
        writeBlock(conditional(machineState.subSpindleIsActive, getCode("STOP_SUB_SPINDLE")));
      } else { // spindle rotation
        writeBlock("S" + mainSpindleAxisName[1] + "=" + rpmFormat.format(cycle.spindleSpeed), tool.clockwise ? getCode("START_MAIN_SPINDLE_CW") : getCode("START_MAIN_SPINDLE_CCW"));
        writeBlock("S" + subSpindleAxisName[1] + "=" +rpmFormat.format(cycle.spindleSpeed), tool.clockwise ? getCode("START_SUB_SPINDLE_CCW") : getCode("START_SUB_SPINDLE_CW")); // inverted
      }
      if (!machineState.spindleSynchronizationIsActive) {
        writeBlock(getCode("SPINDLE_SYNCHRONIZATION_ON"), formatComment("SPINDLE SYNCHRONIZATION ON")); // Sync spindles
      }
      switch (cycle.unclampMode) {
      case "unclamp-primary":
        writeBlock(getCode("UNCLAMP_PRIMARY_CHUCK"), formatComment("UNCLAMP PRIMARY CHUCK"));
        break;
      case "unclamp-secondary":
        writeBlock(getCode("UNCLAMP_SECONDARY_CHUCK"), formatComment("UNCLAMP SECONDARY CHUCK"));
        break;
      case "keep-clamped":
        break;
      }
      onDwell(cycle.dwell);
      writeBlock(conditional(cycle.useMachineFrame, gFormat.format(53)), gMotionModal.format(1), "Z3=" + spatialFormat.format(cycle.feedPosition), getFeed(cycle.feedrate));
      writeBlock(gMotionModal.format(0), "Z3=" + spatialFormat.format(1020));
      if (machineState.spindleSynchronizationIsActive) { // spindles are synchronized
        writeBlock(getCode("SPINDLE_SYNCHRONIZATION_OFF"), formatComment("SPINDLE SYNCHRONIZATION OFF")); // disable spindle sync
      }
      break;
    case "secondary-spindle-pull":
      if (cycle.stopSpindle) { // no spindle rotation
        if (machineState.spindleSynchronizationIsActive) { // spindles are synchronized
          writeBlock(getCode("SPINDLE_SYNCHRONIZATION_OFF")); // disable spindle sync
        }
        writeBlock(conditional(machineState.mainSpindleIsActive, getCode("STOP_MAIN_SPINDLE")));
        writeBlock(conditional(machineState.subSpindleIsActive, getCode("STOP_SUB_SPINDLE")));
      } else { // spindle rotation
        writeBlock(sOutput.format(cycle.spindleSpeed), getCode("START_MAIN_SPINDLE_CW"));
        // writeBlock(pOutput.format(cycle.spindleSpeed), mFormat.format(getCode("START_SUB_SPINDLE_CW")));
      }
      writeBlock(getCode("FEED_MODE_UNIT_REV")); // mm/rev
      writeBlock(getCode(currentSection.spindle == SPINDLE_PRIMARY ? "UNCLAMP_PRIMARY_CHUCK" : "UNCLAMP_SECONDARY_CHUCK"));

      onDwell(cycle.dwell);
      writeBlock(gMotionModal.format(1), "Z3=" + spatialFormat.format(cycle.pullingDistance), getFeed(cycle.feedrate));
      writeBlock(getCode(currentSection.spindle == SPINDLE_PRIMARY ? "CLAMP_PRIMARY_CHUCK" : "CLAMP_SECONDARY_CHUCK"));
      onDwell(cycle.dwell);
      if (machineState.spindleSynchronizationIsActive) { // spindles are synchronized
        writeBlock(getCode("SPINDLE_SYNCHRONIZATION_OFF")); // disable spindle sync
      }
      break;
    }

  }
0 Likes
Reply
Accepted solutions (2)
485 Views
8 Replies
Replies (8)

rushikesh_nagalkar
Autodesk
Autodesk
Accepted solution

Hi Andy,

I’ve reviewed the issue with the “getfeed” function. It appears that the section for part transfer isn’t detecting a movement. To resolve this quickly, we need to define a separate format statement and update the code as shown in the image. Please let me know if this solution works for you.
The Format statement :

rushikesh_nagalkar_0-1728325277721.png
The Code : 
rushikesh_nagalkar_1-1728325526318.png

Regarding the removal of the G53 section, I have a few follow-up questions. Could you please elaborate on the specific scenarios where the G53 section is currently being used? Additionally, I assume that the G53 section is not needed only in the case of “secondary-spindle-grab.” Is this correct? Please provide more details so we can ensure the solution is comprehensive

 


 

 

1 Like

AndyDHarlow
Enthusiast
Enthusiast

Hi @rushikesh_nagalkar thank you for the reply.

 

I can confirm that in the case of a sub spindle grab this is now working for me, thank you very much, however I cannot get it to work on a "bar pull" or "sub spindle return" I still get a G01 with no feed rate in those cases.

 

I have tried editing a copy of the post in a similar way using the new format statement but I am just guessing at the solution and it does not work.

 

Sub spindle return.

      writeBlock(conditional(cycle.useMachineFrame, gFormat.format(53)), gMotionModal.format(1), "Z3=" + spatialFormat.format(cycle.feedPosition),
      conditional(cycle.feedrate,TransfeedOutput.format(cycle.feedrate)));
 
Sub spindle pull.
      writeBlock(conditional(cycle.useMachineFrame, gFormat.format(53)), gMotionModal.format(1), "Z3=" + spatialFormat.format(cycle.pullingDistance),
      conditional(cycle.feedrate,TransfeedOutput.format(cycle.feedrate)));
 
With regards to the G53 section I am going to monitor this for a while longer before making any changes. The G53 section being in the code seems to depend on what I am asking the machine to do before and after the sub spindle grab, I need to experiment some more with it to find a patten of behaviour I can predict.
 
EDIT:
 
I have had another think about it and created a format statement for each case of sub spindle movement it seems to work now in all 3 cases. Do you foresee any issues with this at all Rushikesh?
 
var SSGrabfeedOutput = createVariable({prefix:"F"}, feedFormat);
var SSReturnfeedOutput = createVariable({prefix:"F"}, feedFormat);
var SSPullfeedOutput = createVariable({prefix:"F"}, feedFormat);
 
Thanks
Andy

 

0 Likes

rushikesh_nagalkar
Autodesk
Autodesk

Hi,

I have edited the post similarly to your first trial for “bar pull” or “sub spindle return.” It is working fine for me, as shown in the image below.

rushikesh_nagalkar_1-1728395191222.png

 

Regarding the second method you tried, I believe it is also acceptable as long as we do not interfere with the formatting of other statements. The name should be unique for format statements, so please be mindful of the placement. However, it seems unnecessary to define this many format statements.



 

1 Like

AndyDHarlow
Enthusiast
Enthusiast

That's strange that it didn't work for me, I can only guess that I didn't input the code correctly in the "bar pull" & "sub spindle return" areas, could you possibly share your code with me so I can compare the 2?

0 Likes

rushikesh_nagalkar
Autodesk
Autodesk

well I have just taken the codes form your script and give it a try. The code looks ok to me and working as well. Just for sake of Trial here is 

"secondary-spindle-return" :
writeBlock(gMotionModal.format(1), "Z3=" + spatialFormat.format(cycle.pullingDistance),conditional(cycle.feedrate,TransfeedOutput.format(cycle.feedrate)));

The problem here is you have "F
EED_MODE_UNIT_REV" as "ON" i.e mm/rev. Is it  necessary to have feed in mm/rev for part transfer operation ??? Let me know your thoughts on it. May be we could try another way to fix this from roots.
1 Like

AndyDHarlow
Enthusiast
Enthusiast

I don't need feed/rev for part transfer but I tried changing "FEED_MODE_UNIT_REV" to "FEED_MODE_UNIT_MIN" , it didn't make any difference to the outputted code.

 

I think I am going to leave this now, I have the feed rates outputted correctly using this method:

 var SSGrabfeedOutput = createVariable({prefix:"F"}, feedFormat);

var SSReturnfeedOutput = createVariable({prefix:"F"}, feedFormat);
var SSPullfeedOutput = createVariable({prefix:"F"}, feedFormat);
 
As you say it isn't the most elegant solution but it is working for me.
Thank you very much for all your help.
0 Likes

rushikesh_nagalkar
Autodesk
Autodesk
Accepted solution

Hiii @AndyDHarlow ,
I have worked on proper solution for you. Kindly refer this and make the necessary changes to your post. Kindly undo/remove all previous changes mentioned above from Post.
Update the getfeed Function as per code below.

 

function getFeed(f) {

  // This lime of code makes sures that value is passed on s_Spindle in case of Part Transfer
  //START--------------------------------------------------------------------------------------------------------------
  var s_Spindle = spindleSpeed;
  var strategies = ["turningSecondarySpindleReturn", "turningSecondarySpindlePull", "turningSecondarySpindleGrab"];
  if (strategies.indexOf(getParameter("operation-strategy")) != -1) {
    s_Spindle = cycle.spindleSpeed;
  }
  //END---------------------------------------------------------------------------------------------------------------
  _f = (currentSection.feedMode != FEED_PER_REVOLUTION && machineState.feedPerRevolution) ? f / s_Spindle : f;
  if (activeMovements) {
    var feedContext = activeMovements[movement];
    if (feedContext != undefined) {
      if (!feedFormat.areDifferent(feedContext.feed, _f)) {
        if (feedContext.id == currentFeedId) {
          return ""; // nothing has changed
        }
        forceFeed();
        currentFeedId = feedContext.id;
        return "F=R" + (firstFeedParameter + feedContext.id);
      }
    }
    currentFeedId = undefined; // force Q feed next time
  }
  return feedOutput.format(_f); // use feed value
}

 

 Also remove the below line of code from these cases    case " secondary-spindle-grab"case "secondary-spindle-return" and case "secondary-spindle-pull"  

writeBlock(getCode("FEED_MODE_UNIT_REV")); // mm/rev    ##REMOVE THIS LINE

 and Replace with the code below :

 

gFeedModeModal.reset();
writeBlock(getCode("FEED_MODE_UNIT_MIN"));

 

Note : Take care about the positioning of "G94". Adjust to it as per requirement.

1 Like

AndyDHarlow
Enthusiast
Enthusiast

HI @rushikesh_nagalkar , I have done as instructed.

 

I can confirm that this is now working, once again thank you very much, it goes without saying I will be testing very carefully on the machine.

0 Likes