Skip to content

Commit 7b3fdef

Browse files
V1.8.42 - Updates
- Fixed bug that turned of tracking when using NEMA17 with a non-UART driver.
1 parent 1a74d4d commit 7b3fdef

File tree

2 files changed

+44
-44
lines changed

2 files changed

+44
-44
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
#define VERSION "V1.8.41"
1+
#define VERSION "V1.8.42"

Software/Arduino code/OpenAstroTracker/src/Mount.cpp

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,9 +1056,8 @@ void Mount::startSlewingToTarget() {
10561056

10571057
// set Slew microsteps for TMC2209 UART // hier
10581058
#if RA_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART
1059-
LOGV2(DEBUG_STEPPERS, F("STEP-startSlewingToTarget: Switching RA driver to microsteps(%d)"), SET_MICROSTEPPING);
1060-
_driverRA->microsteps(SET_MICROSTEPPING);
1061-
//_driverRA->en_spreadCycle(1); //only used as audiofeedback for quick debug
1059+
LOGV2(DEBUG_STEPPERS, F("STEP-startSlewingToTarget: Switching RA driver to microsteps(%d)"), SET_MICROSTEPPING);
1060+
_driverRA->microsteps(SET_MICROSTEPPING);
10621061
#endif
10631062

10641063
// Make sure we're slewing at full speed on a GoTo
@@ -1079,21 +1078,21 @@ void Mount::startSlewingToTarget() {
10791078
_totalRAMove = 1.0f * _stepperRA->distanceToGo();
10801079
LOGV3(DEBUG_MOUNT, "Mount: RA Dist: %d, DEC Dist: %d", _stepperRA->distanceToGo(), _stepperDEC->distanceToGo());
10811080
#if RA_STEPPER_TYPE == STEPPER_TYPE_NEMA17 // tracking while slewing causes audible lagging
1082-
if ((_stepperRA->distanceToGo() != 0) || (_stepperDEC->distanceToGo() != 0)) {
1083-
// Only stop tracking if we're actually going to slew somewhere else, otherwise the
1084-
// mount::loop() code won't detect the end of the slewing operation...
1085-
LOGV1(DEBUG_MOUNT, "Mount: Stop tracking (NEMA steppers)");
1086-
stopSlewing(TRACKING);
1087-
_trackerStoppedAt = millis();
1088-
_compensateForTrackerOff = true;
1089-
LOGV2(DEBUG_STEPPERS, F("STEP-startSlewingToTarget: TRK stopped at %lms"), _trackerStoppedAt);
1090-
} else {
1091-
// Since we won't be moving we need to set microstepping back to tracking
1092-
#if RA_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART
1093-
LOGV2(DEBUG_STEPPERS, F("STEP-startSlewingToTarget: No slew. Switching RA driver to microsteps(%d)"), TRACKING_MICROSTEPPING);
1094-
_driverRA->microsteps(TRACKING_MICROSTEPPING);
1095-
#endif
1096-
}
1081+
if ((_stepperRA->distanceToGo() != 0) || (_stepperDEC->distanceToGo() != 0)) {
1082+
// Only stop tracking if we're actually going to slew somewhere else, otherwise the
1083+
// mount::loop() code won't detect the end of the slewing operation...
1084+
LOGV1(DEBUG_MOUNT, "Mount: Stop tracking (NEMA steppers)");
1085+
stopSlewing(TRACKING);
1086+
_trackerStoppedAt = millis();
1087+
_compensateForTrackerOff = true;
1088+
LOGV2(DEBUG_STEPPERS, F("STEP-startSlewingToTarget: TRK stopped at %lms"), _trackerStoppedAt);
1089+
} else {
1090+
// Since we won't be moving we need to set microstepping back to tracking
1091+
#if RA_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART
1092+
LOGV2(DEBUG_STEPPERS, F("STEP-startSlewingToTarget: No slew. Switching RA driver to microsteps(%d)"), TRACKING_MICROSTEPPING);
1093+
_driverRA->microsteps(TRACKING_MICROSTEPPING);
1094+
#endif
1095+
}
10971096
#endif
10981097
}
10991098

@@ -1700,17 +1699,17 @@ void Mount::startSlewing(int direction) {
17001699

17011700
// Set move rate to last commanded slew rate
17021701
setSlewRate(_moveRate);
1703-
#if RA_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART
1704-
LOGV2(DEBUG_STEPPERS, F("STEP-startSlewing: RA Driver setMicrostep(%d)"), SET_MICROSTEPPING);
1705-
if (isSlewingTRK()){
1706-
stopSlewing(TRACKING);
1707-
_trackerStoppedAt = millis();
1708-
_compensateForTrackerOff = true;
1709-
LOGV2(DEBUG_STEPPERS, F("STEP-startSlewing: stopped TRK at %l"), _trackerStoppedAt);
1710-
}
1711-
_driverRA->microsteps(SET_MICROSTEPPING);
1712-
//_driverRA->en_spreadCycle(1); //only used as audiofeedback for quick debug
1713-
//hier
1702+
#if RA_STEPPER_TYPE == STEPPER_TYPE_NEMA17
1703+
LOGV2(DEBUG_STEPPERS, F("STEP-startSlewing: RA Driver setMicrostep(%d)"), SET_MICROSTEPPING);
1704+
if (isSlewingTRK()){
1705+
stopSlewing(TRACKING);
1706+
_trackerStoppedAt = millis();
1707+
_compensateForTrackerOff = true;
1708+
LOGV2(DEBUG_STEPPERS, F("STEP-startSlewing: stopped TRK at %l"), _trackerStoppedAt);
1709+
}
1710+
#if RA_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART
1711+
_driverRA->microsteps(SET_MICROSTEPPING);
1712+
#endif
17141713
#endif
17151714
LOGV1(DEBUG_STEPPERS, F("STEP-startSlewing: call moveTo() on stepper"));
17161715
if (direction & NORTH) {
@@ -1948,21 +1947,22 @@ void Mount::loop() {
19481947

19491948
_currentDECStepperPosition = _stepperDEC->currentPosition();
19501949
_currentRAStepperPosition = _stepperRA->currentPosition();
1951-
#if RA_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART
1952-
LOGV2(DEBUG_STEPPERS, F("STEP-loop: RA driver setMicrosteps(%d)"), TRACKING_MICROSTEPPING);
1953-
_driverRA->microsteps(TRACKING_MICROSTEPPING);
1954-
if (!isParking()) {
1955-
if (_compensateForTrackerOff) {
1956-
unsigned long now = millis();
1957-
unsigned long elapsed = now - _trackerStoppedAt;
1958-
unsigned long compensationSteps = _trackingSpeed * elapsed / 1000.0;
1959-
LOGV4(DEBUG_STEPPERS,F("STEP-loop: Arrived at %lms. Tracking was off for %lms (%l steps), compensating."), now, elapsed, compensationSteps);
1960-
_stepperTRK->runToNewPosition(_stepperTRK->currentPosition() + compensationSteps);
1961-
_compensateForTrackerOff = false;
1950+
#if RA_STEPPER_TYPE == STEPPER_TYPE_NEMA17
1951+
#if RA_DRIVER_TYPE == DRIVER_TYPE_TMC2209_UART
1952+
LOGV2(DEBUG_STEPPERS, F("STEP-loop: RA driver setMicrosteps(%d)"), TRACKING_MICROSTEPPING);
1953+
_driverRA->microsteps(TRACKING_MICROSTEPPING);
1954+
#endif
1955+
if (!isParking()) {
1956+
if (_compensateForTrackerOff) {
1957+
unsigned long now = millis();
1958+
unsigned long elapsed = now - _trackerStoppedAt;
1959+
unsigned long compensationSteps = _trackingSpeed * elapsed / 1000.0;
1960+
LOGV4(DEBUG_STEPPERS,F("STEP-loop: Arrived at %lms. Tracking was off for %lms (%l steps), compensating."), now, elapsed, compensationSteps);
1961+
_stepperTRK->runToNewPosition(_stepperTRK->currentPosition() + compensationSteps);
1962+
_compensateForTrackerOff = false;
1963+
}
1964+
startSlewing(TRACKING);
19621965
}
1963-
startSlewing(TRACKING);
1964-
}
1965-
//_driverRA->en_spreadCycle(0); // only for audio feedback for quick debug
19661966
#endif
19671967
if (_correctForBacklash) {
19681968
LOGV3(DEBUG_MOUNT|DEBUG_STEPPERS,F("Mount::Loop: Reached target at %d. Compensating by %d"), (int)_currentRAStepperPosition, _backlashCorrectionSteps);

0 commit comments

Comments
 (0)