@@ -1056,9 +1056,8 @@ void Mount::startSlewingToTarget() {
1056
1056
1057
1057
// set Slew microsteps for TMC2209 UART // hier
1058
1058
#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);
1062
1061
#endif
1063
1062
1064
1063
// Make sure we're slewing at full speed on a GoTo
@@ -1079,21 +1078,21 @@ void Mount::startSlewingToTarget() {
1079
1078
_totalRAMove = 1 .0f * _stepperRA->distanceToGo ();
1080
1079
LOGV3 (DEBUG_MOUNT, " Mount: RA Dist: %d, DEC Dist: %d" , _stepperRA->distanceToGo (), _stepperDEC->distanceToGo ());
1081
1080
#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
+ }
1097
1096
#endif
1098
1097
}
1099
1098
@@ -1700,17 +1699,17 @@ void Mount::startSlewing(int direction) {
1700
1699
1701
1700
// Set move rate to last commanded slew rate
1702
1701
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
1714
1713
#endif
1715
1714
LOGV1 (DEBUG_STEPPERS, F (" STEP-startSlewing: call moveTo() on stepper" ));
1716
1715
if (direction & NORTH) {
@@ -1948,21 +1947,22 @@ void Mount::loop() {
1948
1947
1949
1948
_currentDECStepperPosition = _stepperDEC->currentPosition ();
1950
1949
_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);
1962
1965
}
1963
- startSlewing (TRACKING);
1964
- }
1965
- // _driverRA->en_spreadCycle(0); // only for audio feedback for quick debug
1966
1966
#endif
1967
1967
if (_correctForBacklash) {
1968
1968
LOGV3 (DEBUG_MOUNT|DEBUG_STEPPERS,F (" Mount::Loop: Reached target at %d. Compensating by %d" ), (int )_currentRAStepperPosition, _backlashCorrectionSteps);
0 commit comments