@@ -75,8 +75,8 @@ void Mount::configureRAStepper(byte stepMode, byte pin1, byte pin2, byte pin3, b
75
75
_stepperRA = new AccelStepper (stepMode, pin1, pin2, pin3, pin4);
76
76
_stepperRA->setMaxSpeed (maxSpeed);
77
77
_stepperRA->setAcceleration (maxAcceleration);
78
- // _maxRASpeed = maxSpeed;
79
- // _maxRAAcceleration = maxAcceleration;
78
+ // _maxRASpeed = maxSpeed;
79
+ // _maxRAAcceleration = maxAcceleration;
80
80
81
81
// Use another AccelStepper to run the RA motor as well. This instance tracks earths rotation.
82
82
_stepperTRK = new AccelStepper (HALFSTEP, pin1, pin2, pin3, pin4);
@@ -264,25 +264,6 @@ void Mount::syncDEC(int degree, int minute, int second) {
264
264
_stepperDEC->setCurrentPosition (targetDEC);
265
265
}
266
266
267
- // ///////////////////////////////
268
- //
269
- // stopGuiding
270
- //
271
- // ///////////////////////////////
272
- void Mount::stopGuiding () {
273
- _stepperDEC->stop ();
274
- while (_stepperDEC->isRunning ()) {
275
- _stepperDEC->run ();
276
- }
277
- _stepperDEC->setMaxSpeed (_maxDECSpeed);
278
- _stepperDEC->setAcceleration (_maxDECAcceleration);
279
- _stepperTRK->setMaxSpeed (10 );
280
- _stepperTRK->setAcceleration (2500 );
281
- _stepperTRK->setSpeed (_trackingSpeed);
282
- _stepperTRK->runSpeed ();
283
- _mountStatus &= ~STATUS_GUIDE_PULSE_MASK;
284
- }
285
-
286
267
// ///////////////////////////////
287
268
//
288
269
// startSlewingToTarget
@@ -307,44 +288,61 @@ void Mount::startSlewingToTarget() {
307
288
_totalRAMove = 1 .0f * _stepperRA->distanceToGo ();
308
289
}
309
290
291
+ // ///////////////////////////////
292
+ //
293
+ // stopGuiding
294
+ //
295
+ // ///////////////////////////////
296
+ void Mount::stopGuiding () {
297
+ _stepperDEC->stop ();
298
+ while (_stepperDEC->isRunning ()) {
299
+ _stepperDEC->run ();
300
+ }
301
+
302
+ _stepperDEC->setMaxSpeed (_maxDECSpeed);
303
+ _stepperDEC->setAcceleration (_maxDECAcceleration);
304
+ _stepperTRK->setMaxSpeed (10 );
305
+ _stepperTRK->setAcceleration (2500 );
306
+ _stepperTRK->setSpeed (_trackingSpeed);
307
+ _mountStatus &= ~STATUS_GUIDE_PULSE_MASK;
308
+ }
309
+
310
310
// ///////////////////////////////
311
311
//
312
312
// guidePulse
313
313
//
314
314
// ///////////////////////////////
315
315
void Mount::guidePulse (byte direction, int duration) {
316
- // How many steps moves the RA ring one sidereal hour along. One sidereal hour moves just shy of 15 degrees
317
- // NOTE: May need to adjust with _trackingSpeedCalibration
318
- float decStepsPerSiderealHour = _stepsPerDECDegree * siderealDegreesInHour;
319
- float decStepsForDuration = decStepsPerSiderealHour * duration / 3600000 ;
320
- float raStepsPerSiderealHour = _stepsPerRADegree * siderealDegreesInHour;
321
- float raStepsForDuration = raStepsPerSiderealHour * duration / 3600000 ;
322
-
316
+ // DEC stepper moves at sidereal rate in both directions
317
+ // RA stepper moves at either 2x sidereal rate or stops.
318
+ // TODO: Do we need to adjust with _trackingSpeedCalibration?
323
319
float decTrackingSpeed = _stepsPerDECDegree * siderealDegreesInHour / 3600 .0f ;
324
320
float raTrackingSpeed = _stepsPerRADegree * siderealDegreesInHour / 3600 .0f ;
325
321
326
- long raPos = _stepperRA->currentPosition ();
327
- long decPos = _stepperDEC->currentPosition ();
322
+ // TODO: Do we need to track how many steps the steppers took and add them to the GoHome calculation?
323
+ // If so, we need to remember where we were when we started the guide pulse. Then at the end,
324
+ // we can calculate the difference.
325
+ // long raPos = _stepperTRK->currentPosition();
326
+ // long decPos = _stepperDEC->currentPosition();
328
327
329
328
switch (direction) {
330
329
case NORTH:
330
+ _stepperDEC->setAcceleration (2500 );
331
331
_stepperDEC->setMaxSpeed (decTrackingSpeed * 1.2 );
332
332
_stepperDEC->setSpeed (decTrackingSpeed);
333
- _stepperDEC->moveTo (decPos + decStepsForDuration);
334
333
_mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_DEC ;
335
334
break ;
336
335
337
336
case SOUTH:
337
+ _stepperDEC->setAcceleration (2500 );
338
338
_stepperDEC->setMaxSpeed (decTrackingSpeed * 1.2 );
339
- _stepperDEC->setSpeed (decTrackingSpeed);
340
- _stepperDEC->moveTo (decPos - decStepsForDuration);
339
+ _stepperDEC->setSpeed (-decTrackingSpeed);
341
340
_mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_DEC ;
342
341
break ;
343
342
344
343
case WEST:
345
344
_stepperTRK->setMaxSpeed (raTrackingSpeed * 2.2 );
346
345
_stepperTRK->setSpeed (raTrackingSpeed * 2 );
347
- _stepperTRK->moveTo (raPos + raStepsForDuration);
348
346
_mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_RA;
349
347
break ;
350
348
@@ -417,8 +415,8 @@ String Mount::mountStatusString() {
417
415
if (_mountStatus & STATUS_PARKING) {
418
416
disp = " PARKNG " ;
419
417
}
420
- else if (isGuiding ()){
421
- disp = " GUIDING " ;
418
+ else if (isGuiding ()) {
419
+ disp = " GUIDING " ;
422
420
}
423
421
else {
424
422
if (_mountStatus & STATUS_TRACKING) disp += " TRK " ;
@@ -861,8 +859,8 @@ void Mount::moveSteppersTo(float targetRA, float targetDEC) {
861
859
//
862
860
// ///////////////////////////////
863
861
void Mount::displayStepperPosition () {
864
- #ifndef HEADLESS_CLIENT
865
-
862
+ #ifndef HEADLESS_CLIENT
863
+
866
864
String disp ;
867
865
868
866
if ((abs (_totalDECMove) > 0.001 ) && (abs (_totalRAMove) > 0.001 )) {
@@ -926,13 +924,13 @@ void Mount::displayStepperPosition() {
926
924
//
927
925
// ///////////////////////////////
928
926
void Mount::displayStepperPositionThrottled () {
929
- #ifndef HEADLESS_CLIENT
927
+ #ifndef HEADLESS_CLIENT
930
928
long elapsed = millis () - _lastDisplayUpdate;
931
929
if (elapsed > DISPLAY_UPDATE_TIME) {
932
930
displayStepperPosition ();
933
931
_lastDisplayUpdate = millis ();
934
932
}
935
- #endif
933
+ #endif
936
934
}
937
935
938
936
// ///////////////////////////////
0 commit comments