@@ -37,6 +37,7 @@ char* formatStringsDEC[] = {
37
37
" %c%02d*%02d'%02d#" , // Meade
38
38
" %c%02d %02d'%02d\" " , // Print
39
39
" %c%02d@%02d'%02d\" " , // LCD display only
40
+ " %c%02d%02d%02d" , // Compact
40
41
};
41
42
42
43
char * formatStringsRA[] = {
@@ -45,6 +46,7 @@ char* formatStringsRA[] = {
45
46
" %02d:%02d:%02d#" , // Meade
46
47
" %02dh %02dm %02ds" , // Print
47
48
" %02dh%02dm%02ds" , // LCD display only
49
+ " %02d%02d%02d" , // Compact
48
50
};
49
51
50
52
const float siderealDegreesInHour = 14.95902778 ;
@@ -75,8 +77,8 @@ void Mount::configureRAStepper(byte stepMode, byte pin1, byte pin2, byte pin3, b
75
77
_stepperRA = new AccelStepper (stepMode, pin1, pin2, pin3, pin4);
76
78
_stepperRA->setMaxSpeed (maxSpeed);
77
79
_stepperRA->setAcceleration (maxAcceleration);
78
- // _maxRASpeed = maxSpeed;
79
- // _maxRAAcceleration = maxAcceleration;
80
+ _maxRASpeed = maxSpeed;
81
+ _maxRAAcceleration = maxAcceleration;
80
82
81
83
// Use another AccelStepper to run the RA motor as well. This instance tracks earths rotation.
82
84
_stepperTRK = new AccelStepper (HALFSTEP, pin1, pin2, pin3, pin4);
@@ -264,25 +266,6 @@ void Mount::syncDEC(int degree, int minute, int second) {
264
266
_stepperDEC->setCurrentPosition (targetDEC);
265
267
}
266
268
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
269
// ///////////////////////////////
287
270
//
288
271
// startSlewingToTarget
@@ -307,44 +290,61 @@ void Mount::startSlewingToTarget() {
307
290
_totalRAMove = 1 .0f * _stepperRA->distanceToGo ();
308
291
}
309
292
293
+ // ///////////////////////////////
294
+ //
295
+ // stopGuiding
296
+ //
297
+ // ///////////////////////////////
298
+ void Mount::stopGuiding () {
299
+ _stepperDEC->stop ();
300
+ while (_stepperDEC->isRunning ()) {
301
+ _stepperDEC->run ();
302
+ }
303
+
304
+ _stepperDEC->setMaxSpeed (_maxDECSpeed);
305
+ _stepperDEC->setAcceleration (_maxDECAcceleration);
306
+ _stepperTRK->setMaxSpeed (10 );
307
+ _stepperTRK->setAcceleration (2500 );
308
+ _stepperTRK->setSpeed (_trackingSpeed);
309
+ _mountStatus &= ~STATUS_GUIDE_PULSE_MASK;
310
+ }
311
+
310
312
// ///////////////////////////////
311
313
//
312
314
// guidePulse
313
315
//
314
316
// ///////////////////////////////
315
317
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
-
318
+ // DEC stepper moves at sidereal rate in both directions
319
+ // RA stepper moves at either 2x sidereal rate or stops.
320
+ // TODO: Do we need to adjust with _trackingSpeedCalibration?
323
321
float decTrackingSpeed = _stepsPerDECDegree * siderealDegreesInHour / 3600 .0f ;
324
322
float raTrackingSpeed = _stepsPerRADegree * siderealDegreesInHour / 3600 .0f ;
325
323
326
- long raPos = _stepperRA->currentPosition ();
327
- long decPos = _stepperDEC->currentPosition ();
324
+ // TODO: Do we need to track how many steps the steppers took and add them to the GoHome calculation?
325
+ // If so, we need to remember where we were when we started the guide pulse. Then at the end,
326
+ // we can calculate the difference.
327
+ // long raPos = _stepperTRK->currentPosition();
328
+ // long decPos = _stepperDEC->currentPosition();
328
329
329
330
switch (direction) {
330
331
case NORTH:
332
+ _stepperDEC->setAcceleration (2500 );
331
333
_stepperDEC->setMaxSpeed (decTrackingSpeed * 1.2 );
332
334
_stepperDEC->setSpeed (decTrackingSpeed);
333
- _stepperDEC->moveTo (decPos + decStepsForDuration);
334
335
_mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_DEC ;
335
336
break ;
336
337
337
338
case SOUTH:
339
+ _stepperDEC->setAcceleration (2500 );
338
340
_stepperDEC->setMaxSpeed (decTrackingSpeed * 1.2 );
339
- _stepperDEC->setSpeed (decTrackingSpeed);
340
- _stepperDEC->moveTo (decPos - decStepsForDuration);
341
+ _stepperDEC->setSpeed (-decTrackingSpeed);
341
342
_mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_DEC ;
342
343
break ;
343
344
344
345
case WEST:
345
346
_stepperTRK->setMaxSpeed (raTrackingSpeed * 2.2 );
346
347
_stepperTRK->setSpeed (raTrackingSpeed * 2 );
347
- _stepperTRK->moveTo (raPos + raStepsForDuration);
348
348
_mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_RA;
349
349
break ;
350
350
@@ -358,6 +358,52 @@ void Mount::guidePulse(byte direction, int duration) {
358
358
_guideEndTime = millis () + duration;
359
359
}
360
360
361
+ // ///////////////////////////////
362
+ //
363
+ // runDriftAlignmentPhase
364
+ //
365
+ // Runs one of the phases of the Drift alignment
366
+ // This runs the RA motor 400 steps (about 5.3 arcminutes) in the given duration
367
+ // This function should be callsed 3 times:
368
+ // The first time with EAST, second with WEST and then with 0.
369
+ // ///////////////////////////////
370
+ void Mount::runDriftAlignmentPhase (int direction, int durationSecs) {
371
+ // Calculate the speed at which it takes the given duration to cover 400 steps.
372
+ float speed = 400.0 / durationSecs;
373
+ switch (direction) {
374
+ case EAST:
375
+ // Move 400 steps east at the calculated speed, synchronously
376
+ _stepperRA->setAcceleration (1500 );
377
+ _stepperRA->setMaxSpeed (speed);
378
+ _stepperRA->move (400 );
379
+ _stepperRA->runToPosition ();
380
+
381
+ // Overcome the gearing gap
382
+ _stepperRA->setMaxSpeed (300 );
383
+ _stepperRA->move (-20 );
384
+ _stepperRA->runToPosition ();
385
+ break ;
386
+
387
+ case WEST:
388
+ // Move 400 steps west at the calculated speed, synchronously
389
+ _stepperRA->setMaxSpeed (speed);
390
+ _stepperRA->move (-400 );
391
+ _stepperRA->runToPosition ();
392
+ break ;
393
+
394
+ case 0 :
395
+ // Fix the gearing to go back the other way
396
+ _stepperRA->setMaxSpeed (300 );
397
+ _stepperRA->move (20 );
398
+ _stepperRA->runToPosition ();
399
+
400
+ // Re-configure the stepper to the correct parameters.
401
+ _stepperRA->setAcceleration (_maxRAAcceleration);
402
+ _stepperRA->setMaxSpeed (_maxRASpeed);
403
+ break ;
404
+ }
405
+ }
406
+
361
407
// ///////////////////////////////
362
408
//
363
409
// park
@@ -417,8 +463,8 @@ String Mount::mountStatusString() {
417
463
if (_mountStatus & STATUS_PARKING) {
418
464
disp = " PARKNG " ;
419
465
}
420
- else if (isGuiding ()){
421
- disp = " GUIDING " ;
466
+ else if (isGuiding ()) {
467
+ disp = " GUIDING " ;
422
468
}
423
469
else {
424
470
if (_mountStatus & STATUS_TRACKING) disp += " TRK " ;
@@ -442,6 +488,57 @@ String Mount::mountStatusString() {
442
488
}
443
489
#endif
444
490
491
+ // ///////////////////////////////
492
+ //
493
+ // getStatusString
494
+ //
495
+ // ///////////////////////////////
496
+ String Mount::getStatusString () {
497
+ String status;
498
+ if (_mountStatus == STATUS_PARKED) {
499
+ status = " Parked," ;
500
+ }
501
+ else if (_mountStatus & STATUS_PARKING) {
502
+ status = " Parking," ;
503
+ }
504
+ else if (isGuiding ()) {
505
+ status = " Guiding," ;
506
+ }
507
+ else if (slewStatus () & SLEW_MASK_ANY) {
508
+ if (_mountStatus & STATUS_SLEWING_TO_TARGET) {
509
+ status = " SlewToTarget," ;
510
+ }
511
+ else if (_mountStatus & STATUS_SLEWING_FREE) {
512
+ status = " FreeSlew," ;
513
+ }
514
+ else {
515
+ status = " Idle," ;
516
+ }
517
+ } else {
518
+ status = " Idle," ;
519
+ }
520
+
521
+ String disp = " ---," ;
522
+ if (_mountStatus & STATUS_SLEWING) {
523
+ byte slew = slewStatus ();
524
+ if (slew & SLEWING_RA) disp[0 ] = _stepperRA->speed () < 0 ? ' R' : ' r' ;
525
+ if (slew & SLEWING_DEC) disp[1 ] = _stepperDEC->speed () < 0 ? ' D' : ' d' ;
526
+ if (slew & SLEWING_TRACKING) disp[2 ] = ' T' ;
527
+ } else if (isSlewingTRK ()) {
528
+ disp[2 ] = ' T' ;
529
+ }
530
+
531
+ status += disp;
532
+ status += String (_stepperRA->currentPosition ()) + " ," ;
533
+ status += String (_stepperDEC->currentPosition ()) + " ," ;
534
+ status += String (_stepperTRK->currentPosition ()) + " ," ;
535
+
536
+ status += RAString (COMPACT_STRING | CURRENT_STRING) + " ," ;
537
+ status += DECString (COMPACT_STRING | CURRENT_STRING) + " ," ;
538
+
539
+ return status ;
540
+ }
541
+
445
542
// ///////////////////////////////
446
543
//
447
544
// slewingStatus
@@ -861,8 +958,8 @@ void Mount::moveSteppersTo(float targetRA, float targetDEC) {
861
958
//
862
959
// ///////////////////////////////
863
960
void Mount::displayStepperPosition () {
864
- #ifndef HEADLESS_CLIENT
865
-
961
+ #ifndef HEADLESS_CLIENT
962
+
866
963
String disp ;
867
964
868
965
if ((abs (_totalDECMove) > 0.001 ) && (abs (_totalRAMove) > 0.001 )) {
@@ -893,7 +990,7 @@ void Mount::displayStepperPosition() {
893
990
else {
894
991
#ifdef SUPPORT_SERIAL_CONTROL
895
992
if (inSerialControl) {
896
- sprintf (scratchBuffer, " RA: %s" , RAString (LCD_STRING | CURRENT_STRING).c_str ());
993
+ sprintf (scratchBuffer, " RA: %s" , RAString (LCD_STRING | CURRENT_STRING).c_str ());
897
994
_lcdMenu->setCursor (0 , 0 );
898
995
_lcdMenu->printMenu (scratchBuffer);
899
996
sprintf (scratchBuffer, " DEC: %s" , DECString (LCD_STRING | CURRENT_STRING).c_str ());
@@ -926,13 +1023,13 @@ void Mount::displayStepperPosition() {
926
1023
//
927
1024
// ///////////////////////////////
928
1025
void Mount::displayStepperPositionThrottled () {
929
- #ifndef HEADLESS_CLIENT
1026
+ #ifndef HEADLESS_CLIENT
930
1027
long elapsed = millis () - _lastDisplayUpdate;
931
1028
if (elapsed > DISPLAY_UPDATE_TIME) {
932
1029
displayStepperPosition ();
933
1030
_lastDisplayUpdate = millis ();
934
1031
}
935
- #endif
1032
+ #endif
936
1033
}
937
1034
938
1035
// ///////////////////////////////
0 commit comments