Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement BABYSTEPPING for COREXY and COREXZ #3127

Merged
merged 2 commits into from
Mar 19, 2016

Conversation

thinkyhead
Copy link
Member

Background: The BABYSTEPPING feature allows you to use the LCD controller to apply steps and adjust positioning at any time, even during a print in progress. The low-level part of this feature applies directly to steppers ("ABC"). The user interface and configuration are both specified to move the "XYZ" axes. So BABYSTEPPING is a "convenience" feature, not a "hack" feature. This PR "breaks" the single-stepper aspect of BABYSTEPPING but it does the right thing that you would want on a CoreXY or CoreXZ machine, namely applying babysteps to more than one stepper.

This change is applied in the _lcd_babystep function and doesn't touch the babystepping handler in the temperature.cpp ISR(TIMER0_COMPB_vect). For a more universal and transparent application of BABYSTEPPING the low-level babystep handler could be changed instead. I've left that code alone because there may be reasons we want to keep "untranslated" babystepping for individual steppers in place for a later feature.

References: #2935, #3060

@thinkyhead
Copy link
Member Author

The alternative code in the ISR –affecting all babystepping features– would look like this:

#if ENABLED(BABYSTEPPING)
  #if ENABLED(COREXY) || ENABLED(COREXZ)
    int babysteps_abc[] = {
      #if (COREXY)
        babystepsTodo[X_AXIS] + babystepsTodo[Y_AXIS],
        babystepsTodo[X_AXIS] - babystepsTodo[Y_AXIS],
        babystepsTodo[Z_AXIS]
      #else
        babystepsTodo[X_AXIS] + babystepsTodo[Y_AXIS],
        babystepsTodo[Y_AXIS],
        babystepsTodo[X_AXIS] - babystepsTodo[Z_AXIS]
      #endif
    };
    for (uint8_t axis = A_AXIS; axis <= C_AXIS; axis++) {
      int curTodo = babysteps_abc[axis]; //non-volatile for performance
      if (curTodo != 0) {
        babystep(axis, curTodo > 0);
        if (axis != CORE_AXIS_3) babystep(axis, curTodo > 0);
      }
    }
    for (uint8_t axis = X_AXIS; axis <= Z_AXIS; axis++) {
      int curTodo = babystepsTodo[axis];
      if (curTodo != 0) { if (curTodo > 0) babystepsTodo[axis]--; else babystepsTodo[axis]++; }
    }
  #else
    for (uint8_t axis = X_AXIS; axis <= Z_AXIS; axis++) {
      int curTodo = babystepsTodo[axis]; //non-volatile for performance
      if (curTodo != 0) {
        if (curTodo > 0) {
          babystep(axis, true); // forward
          babystepsTodo[axis]--;
        }
        else {
          babystep(axis, false); // backward
          babystepsTodo[axis]++;
        }
      }
    }
  #endif
#endif //BABYSTEPPING

thinkyhead added a commit that referenced this pull request Mar 19, 2016
Implement BABYSTEPPING for COREXY and COREXZ
@thinkyhead thinkyhead merged commit 9bf87aa into MarlinFirmware:RCBugFix Mar 19, 2016
@thinkyhead thinkyhead mentioned this pull request Mar 19, 2016
@thinkyhead thinkyhead deleted the rc_core_babystepping branch March 24, 2016 07:42
@jbrazio jbrazio modified the milestone: 1.1.0 Jul 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants