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

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

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;
    }

  }