8
8
#define STATUS_SLEWING_FREE B00000010
9
9
#define STATUS_TRACKING B00001000
10
10
#define STATUS_PARKING B00010000
11
+ #define STATUS_GUIDE_PULSE B10000000
12
+ #define STATUS_GUIDE_PULSE_DIR B01100000
13
+ #define STATUS_GUIDE_PULSE_RA B01000000
14
+ #define STATUS_GUIDE_PULSE_DEC B00100000
15
+ #define STATUS_GUIDE_PULSE_MASK B11100000
11
16
12
17
// slewingStatus()
13
18
#define SLEWING_DEC B00000010
@@ -69,6 +74,8 @@ void Mount::configureRAStepper(byte stepMode, byte pin1, byte pin2, byte pin3, b
69
74
_stepperRA = new AccelStepper (stepMode, pin1, pin2, pin3, pin4);
70
75
_stepperRA->setMaxSpeed (maxSpeed);
71
76
_stepperRA->setAcceleration (maxAcceleration);
77
+ // _maxRASpeed = maxSpeed;
78
+ // _maxRAAcceleration = maxAcceleration;
72
79
73
80
// Use another AccelStepper to run the RA motor as well. This instance tracks earths rotation.
74
81
_stepperTRK = new AccelStepper (HALFSTEP, pin1, pin2, pin3, pin4);
@@ -86,6 +93,8 @@ void Mount::configureDECStepper(byte stepMode, byte pin1, byte pin2, byte pin3,
86
93
_stepperDEC = new AccelStepper (stepMode, pin4, pin3, pin2, pin1);
87
94
_stepperDEC->setMaxSpeed (maxSpeed);
88
95
_stepperDEC->setAcceleration (maxAcceleration);
96
+ _maxDECSpeed = maxSpeed;
97
+ _maxDECAcceleration = maxAcceleration;
89
98
}
90
99
91
100
float Mount::getSpeedCalibration () {
@@ -254,6 +263,25 @@ void Mount::syncDEC(int degree, int minute, int second) {
254
263
_stepperDEC->setCurrentPosition (targetDEC);
255
264
}
256
265
266
+ // ///////////////////////////////
267
+ //
268
+ // stopGuiding
269
+ //
270
+ // ///////////////////////////////
271
+ void Mount::stopGuiding () {
272
+ _stepperDEC->stop ();
273
+ while (_stepperDEC->isRunning ()) {
274
+ _stepperDEC->run ();
275
+ }
276
+ _stepperDEC->setMaxSpeed (_maxDECSpeed);
277
+ _stepperDEC->setAcceleration (_maxDECAcceleration);
278
+ _stepperTRK->setMaxSpeed (10 );
279
+ _stepperTRK->setAcceleration (2500 );
280
+ _stepperTRK->setSpeed (_trackingSpeed);
281
+ _stepperTRK->runSpeed ();
282
+ _mountStatus &= ~STATUS_GUIDE_PULSE_MASK;
283
+ }
284
+
257
285
// ///////////////////////////////
258
286
//
259
287
// startSlewingToTarget
@@ -262,6 +290,10 @@ void Mount::syncDEC(int degree, int minute, int second) {
262
290
// Calculates movement parameters and program steppers to move
263
291
// there. Must call loop() frequently to actually move.
264
292
void Mount::startSlewingToTarget () {
293
+ if (isGuiding ()) {
294
+ stopGuiding ();
295
+ }
296
+
265
297
// Calculate new RA stepper target (and DEC)
266
298
_currentDECStepperPosition = _stepperDEC->currentPosition ();
267
299
_currentRAStepperPosition = _stepperRA->currentPosition ();
@@ -274,15 +306,66 @@ void Mount::startSlewingToTarget() {
274
306
_totalRAMove = 1 .0f * _stepperRA->distanceToGo ();
275
307
}
276
308
309
+ // ///////////////////////////////
310
+ //
311
+ // guidePulse
312
+ //
313
+ // ///////////////////////////////
314
+ void Mount::guidePulse (byte direction, int duration) {
315
+ // How many steps moves the RA ring one sidereal hour along. One sidereal hour moves just shy of 15 degrees
316
+ // NOTE: May need to adjust with _trackingSpeedCalibration
317
+ float decStepsPerSiderealHour = _stepsPerDECDegree * siderealDegreesInHour;
318
+ float decStepsForDuration = decStepsPerSiderealHour * duration / 3600000 ;
319
+ float raStepsPerSiderealHour = _stepsPerRADegree * siderealDegreesInHour;
320
+ float raStepsForDuration = raStepsPerSiderealHour * duration / 3600000 ;
321
+
322
+ float decTrackingSpeed = _stepsPerDECDegree * siderealDegreesInHour / 3600 .0f ;
323
+ float raTrackingSpeed = _stepsPerRADegree * siderealDegreesInHour / 3600 .0f ;
324
+
325
+ long raPos = _stepperRA->currentPosition ();
326
+ long decPos = _stepperDEC->currentPosition ();
327
+
328
+ switch (direction) {
329
+ case NORTH:
330
+ _stepperDEC->setMaxSpeed (decTrackingSpeed * 1.2 );
331
+ _stepperDEC->setSpeed (decTrackingSpeed);
332
+ _stepperDEC->moveTo (decPos + decStepsForDuration);
333
+ _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_DEC ;
334
+ break ;
335
+
336
+ case SOUTH:
337
+ _stepperDEC->setMaxSpeed (decTrackingSpeed * 1.2 );
338
+ _stepperDEC->setSpeed (decTrackingSpeed);
339
+ _stepperDEC->moveTo (decPos - decStepsForDuration);
340
+ _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_DEC ;
341
+ break ;
342
+
343
+ case WEST:
344
+ _stepperTRK->setMaxSpeed (raTrackingSpeed * 2.2 );
345
+ _stepperTRK->setSpeed (raTrackingSpeed * 2 );
346
+ _stepperTRK->moveTo (raPos + raStepsForDuration);
347
+ _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_RA;
348
+ break ;
349
+
350
+ case EAST:
351
+ _stepperTRK->setMaxSpeed (raTrackingSpeed * 2.2 );
352
+ _stepperTRK->setSpeed (0 );
353
+ _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_RA;
354
+ break ;
355
+ }
356
+
357
+ _guideEndTime = millis () + duration;
358
+ }
359
+
277
360
// ///////////////////////////////
278
361
//
279
362
// park
280
363
//
281
- // Targets the mount to move to the home position and
364
+ // Targets the mount to move to the home position and
282
365
// turns off all motors once it gets there.
283
366
// ///////////////////////////////
284
- void Mount::park ()
285
- {
367
+ void Mount::park () {
368
+ stopGuiding ();
286
369
stopSlewing (ALL_DIRECTIONS | TRACKING);
287
370
waitUntilStopped (ALL_DIRECTIONS);
288
371
setTargetToHome ();
@@ -294,11 +377,12 @@ void Mount::park()
294
377
//
295
378
// goHome
296
379
//
297
- // Synchronously moves mount to home position and
380
+ // Synchronously moves mount to home position and
298
381
// sets Tracking mode according to argument
299
382
// ///////////////////////////////
300
383
void Mount::goHome (bool tracking)
301
384
{
385
+ stopGuiding ();
302
386
stopSlewing (TRACKING);
303
387
setTargetToHome ();
304
388
startSlewingToTarget ();
@@ -332,6 +416,9 @@ String Mount::mountStatusString() {
332
416
if (_mountStatus & STATUS_PARKING) {
333
417
disp = " PARKNG " ;
334
418
}
419
+ else if (isGuiding ()){
420
+ disp = " GUIDING " ;
421
+ }
335
422
else {
336
423
if (_mountStatus & STATUS_TRACKING) disp += " TRK " ;
337
424
if (_mountStatus & STATUS_SLEWING) disp += " SLW " ;
@@ -365,13 +452,26 @@ byte Mount::slewStatus() {
365
452
if (_mountStatus == STATUS_PARKED) {
366
453
return NOT_SLEWING;
367
454
}
455
+ if (isGuiding ()) {
456
+ return NOT_SLEWING;
457
+ }
368
458
byte slewState = _stepperRA->isRunning () ? SLEWING_RA : NOT_SLEWING;
369
459
slewState |= _stepperDEC->isRunning () ? SLEWING_DEC : NOT_SLEWING;
370
460
371
461
slewState |= (_mountStatus & STATUS_TRACKING) ? SLEWING_TRACKING : NOT_SLEWING;
372
462
return slewState;
373
463
}
374
464
465
+ // ///////////////////////////////
466
+ //
467
+ // isGuiding
468
+ //
469
+ // ///////////////////////////////
470
+ bool Mount::isGuiding ()
471
+ {
472
+ return (_mountStatus & STATUS_GUIDE_PULSE);
473
+ }
474
+
375
475
// ///////////////////////////////
376
476
//
377
477
// isSlewingDEC
@@ -449,6 +549,10 @@ bool Mount::isParking() {
449
549
void Mount::startSlewing (int direction) {
450
550
if (!isParking ())
451
551
{
552
+ if (isGuiding ()) {
553
+ stopGuiding ();
554
+ }
555
+
452
556
if (direction & TRACKING) {
453
557
_stepperTRK->setSpeed (_trackingSpeed);
454
558
@@ -561,6 +665,22 @@ void Mount::loop() {
561
665
_lastMountPrint = now;
562
666
}
563
667
#endif
668
+ if (isGuiding ()) {
669
+ if (millis () > _guideEndTime) {
670
+ stopGuiding ();
671
+ }
672
+ else
673
+ {
674
+ if (_mountStatus & STATUS_GUIDE_PULSE_RA) {
675
+ _stepperTRK->runSpeed ();
676
+ }
677
+ if (_mountStatus & STATUS_GUIDE_PULSE_DEC) {
678
+ _stepperDEC->runSpeed ();
679
+ }
680
+ }
681
+ return ;
682
+ }
683
+
564
684
if (_mountStatus & STATUS_TRACKING) {
565
685
_stepperTRK->runSpeed ();
566
686
}
0 commit comments