@@ -67,7 +67,7 @@ Mount::Mount(int stepsPerRADegree, int stepsPerDECDegree, LcdMenu* lcdMenu) {
67
67
_stepperWasRunning = false ;
68
68
_totalDECMove = 0 ;
69
69
_totalRAMove = 0 ;
70
- #if RA_Stepper_TYPE == 1
70
+ #if RA_Stepper_TYPE == 0
71
71
_backlashCorrectionSteps = 16 ;
72
72
#else
73
73
_backlashCorrectionSteps = 0 ;
@@ -147,36 +147,36 @@ void Mount::writePersistentData(int which, int val)
147
147
}
148
148
switch (which) {
149
149
case RA_STEPS:
150
- {
151
- // ... set bit 0 to indicate RA value has been written to 6/7
152
- flag |= 0x01 ;
153
- loByteLocation = 6 ;
154
- hiByteLocation = 7 ;
155
- }
156
- break ;
150
+ {
151
+ // ... set bit 0 to indicate RA value has been written to 6/7
152
+ flag |= 0x01 ;
153
+ loByteLocation = 6 ;
154
+ hiByteLocation = 7 ;
155
+ }
156
+ break ;
157
157
case DEC_STEPS:
158
- {
159
- // ... set bit 1 to indicate DEC value has been written to 8/9
160
- flag |= 0x02 ;
161
- loByteLocation = 8 ;
162
- hiByteLocation = 9 ;
163
- }
164
- break ;
158
+ {
159
+ // ... set bit 1 to indicate DEC value has been written to 8/9
160
+ flag |= 0x02 ;
161
+ loByteLocation = 8 ;
162
+ hiByteLocation = 9 ;
163
+ }
164
+ break ;
165
165
case SPEED_FACTOR_DECIMALS:
166
- {
167
- // ... set bit 2 to indicate speed factor value has been written to 0/3
168
- flag |= 0x04 ;
169
- loByteLocation = 0 ;
170
- hiByteLocation = 3 ;
171
- }
166
+ {
167
+ // ... set bit 2 to indicate speed factor value has been written to 0/3
168
+ flag |= 0x04 ;
169
+ loByteLocation = 0 ;
170
+ hiByteLocation = 3 ;
171
+ }
172
172
case BACKLASH_CORRECTION:
173
- {
174
- // ... set bit 2 to indicate speed factor value has been written to 0/3
175
- flag |= 0x08 ;
176
- loByteLocation = 10 ;
177
- hiByteLocation = 11 ;
178
- }
179
- break ;
173
+ {
174
+ // ... set bit 2 to indicate speed factor value has been written to 0/3
175
+ flag |= 0x08 ;
176
+ loByteLocation = 10 ;
177
+ hiByteLocation = 11 ;
178
+ }
179
+ break ;
180
180
}
181
181
182
182
@@ -192,7 +192,6 @@ void Mount::writePersistentData(int which, int val)
192
192
// configureRAStepper
193
193
//
194
194
// ///////////////////////////////
195
-
196
195
#if RA_Stepper_TYPE == 0 // 28BYJ
197
196
void Mount::configureRAStepper (byte stepMode, byte pin1, byte pin2, byte pin3, byte pin4, int maxSpeed, int maxAcceleration)
198
197
{
@@ -216,6 +215,7 @@ void Mount::configureRAStepper(byte stepMode, byte pin1, byte pin2, byte pin3, b
216
215
_stepperTRK->setAcceleration (2500 );
217
216
}
218
217
#endif
218
+
219
219
#if RA_Stepper_TYPE == 1 // NEMA
220
220
void Mount::configureRAStepper (byte stepMode, byte pin1, byte pin2, int maxSpeed, int maxAcceleration)
221
221
{
@@ -237,8 +237,7 @@ void Mount::configureRAStepper(byte stepMode, byte pin1, byte pin2, int maxSpeed
237
237
// configureDECStepper
238
238
//
239
239
// ///////////////////////////////
240
-
241
- #if DEC_Stepper_TYPE == 0
240
+ #if DEC_Stepper_TYPE == 0 // 28BYJ
242
241
void Mount::configureDECStepper (byte stepMode, byte pin1, byte pin2, byte pin3, byte pin4, int maxSpeed, int maxAcceleration)
243
242
{
244
243
#if NORTHERN_HEMISPHERE
@@ -252,7 +251,8 @@ void Mount::configureDECStepper(byte stepMode, byte pin1, byte pin2, byte pin3,
252
251
_maxDECAcceleration = maxAcceleration;
253
252
}
254
253
#endif
255
- #if DEC_Stepper_TYPE == 1
254
+
255
+ #if DEC_Stepper_TYPE == 1 // NEMA
256
256
void Mount::configureDECStepper (byte stepMode, byte pin1, byte pin2, int maxSpeed, int maxAcceleration)
257
257
{
258
258
_stepperDEC = new AccelStepper (stepMode, pin2, pin1);
@@ -262,7 +262,6 @@ void Mount::configureDECStepper(byte stepMode, byte pin1, byte pin2, int maxSpee
262
262
_maxDECAcceleration = maxAcceleration;
263
263
}
264
264
#endif
265
-
266
265
// ///////////////////////////////
267
266
//
268
267
// getSpeedCalibration
@@ -373,7 +372,7 @@ const DayTime Mount::HA() const {
373
372
#ifdef DEBUG_MODE
374
373
logv (" Mount: Get HA." );
375
374
logv (" Mount: Polaris adjust: %s" , DayTime (PolarisRAHour, PolarisRAMinute, PolarisRASecond).ToString ());
376
- #endif
375
+ #endif
377
376
DayTime ha = _LST;
378
377
#ifdef DEBUG_MODE
379
378
logv (" Mount: LST: %s" , _LST.ToString ());
@@ -534,7 +533,7 @@ const DegreeTime Mount::currentDEC() const {
534
533
// syncPosition
535
534
//
536
535
// ///////////////////////////////
537
- // Set the current RA and DEC position to be the given coordinate. We do this by settign the stepper motor coordinate
536
+ // Set the current RA and DEC position to be the given coordinate. We do this by settign the stepper motor coordinate
538
537
// to be at the calculated positions (that they would be if we were slewing there).
539
538
void Mount::syncPosition (int raHour, int raMinute, int raSecond, int decDegree, int decMinute, int decSecond)
540
539
{
@@ -611,30 +610,30 @@ void Mount::guidePulse(byte direction, int duration) {
611
610
612
611
switch (direction) {
613
612
case NORTH:
614
- _stepperDEC->setAcceleration (2500 );
615
- _stepperDEC->setMaxSpeed (decTrackingSpeed * 1.2 );
616
- _stepperDEC->setSpeed (decTrackingSpeed);
617
- _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_DEC;
618
- break ;
613
+ _stepperDEC->setAcceleration (2500 );
614
+ _stepperDEC->setMaxSpeed (decTrackingSpeed * 1.2 );
615
+ _stepperDEC->setSpeed (decTrackingSpeed);
616
+ _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_DEC;
617
+ break ;
619
618
620
619
case SOUTH:
621
- _stepperDEC->setAcceleration (2500 );
622
- _stepperDEC->setMaxSpeed (decTrackingSpeed * 1.2 );
623
- _stepperDEC->setSpeed (-decTrackingSpeed);
624
- _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_DEC;
625
- break ;
620
+ _stepperDEC->setAcceleration (2500 );
621
+ _stepperDEC->setMaxSpeed (decTrackingSpeed * 1.2 );
622
+ _stepperDEC->setSpeed (-decTrackingSpeed);
623
+ _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_DEC;
624
+ break ;
626
625
627
626
case WEST:
628
- _stepperTRK->setMaxSpeed (raTrackingSpeed * 2.2 );
629
- _stepperTRK->setSpeed (raTrackingSpeed * 2 );
630
- _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_RA;
631
- break ;
627
+ _stepperTRK->setMaxSpeed (raTrackingSpeed * 2.2 );
628
+ _stepperTRK->setSpeed (raTrackingSpeed * 2 );
629
+ _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_RA;
630
+ break ;
632
631
633
632
case EAST:
634
- _stepperTRK->setMaxSpeed (raTrackingSpeed * 2.2 );
635
- _stepperTRK->setSpeed (0 );
636
- _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_RA;
637
- break ;
633
+ _stepperTRK->setMaxSpeed (raTrackingSpeed * 2.2 );
634
+ _stepperTRK->setSpeed (0 );
635
+ _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_RA;
636
+ break ;
638
637
}
639
638
640
639
_guideEndTime = millis () + duration;
@@ -654,43 +653,43 @@ void Mount::runDriftAlignmentPhase(int direction, int durationSecs) {
654
653
float speed = 400.0 / durationSecs;
655
654
switch (direction) {
656
655
case EAST:
657
- // Move 400 steps east at the calculated speed, synchronously
658
- _stepperRA->setAcceleration (1500 );
659
- _stepperRA->setMaxSpeed (speed);
660
- _stepperRA->move (400 );
661
- while (_stepperRA->run ()) {
662
- yield ();
663
- }
656
+ // Move 400 steps east at the calculated speed, synchronously
657
+ _stepperRA->setAcceleration (1500 );
658
+ _stepperRA->setMaxSpeed (speed);
659
+ _stepperRA->move (400 );
660
+ while (_stepperRA->run ()) {
661
+ yield ();
662
+ }
664
663
665
- // Overcome the gearing gap
666
- _stepperRA->setMaxSpeed (300 );
667
- _stepperRA->move (-20 );
668
- while (_stepperRA->run ()) {
669
- yield ();
670
- }
671
- break ;
664
+ // Overcome the gearing gap
665
+ _stepperRA->setMaxSpeed (300 );
666
+ _stepperRA->move (-20 );
667
+ while (_stepperRA->run ()) {
668
+ yield ();
669
+ }
670
+ break ;
672
671
673
672
case WEST:
674
- // Move 400 steps west at the calculated speed, synchronously
675
- _stepperRA->setMaxSpeed (speed);
676
- _stepperRA->move (-400 );
677
- while (_stepperRA->run ()) {
678
- yield ();
679
- }
680
- break ;
673
+ // Move 400 steps west at the calculated speed, synchronously
674
+ _stepperRA->setMaxSpeed (speed);
675
+ _stepperRA->move (-400 );
676
+ while (_stepperRA->run ()) {
677
+ yield ();
678
+ }
679
+ break ;
681
680
682
681
case 0 :
683
- // Fix the gearing to go back the other way
684
- _stepperRA->setMaxSpeed (300 );
685
- _stepperRA->move (20 );
686
- while (_stepperRA->run ()) {
687
- yield ();
688
- }
682
+ // Fix the gearing to go back the other way
683
+ _stepperRA->setMaxSpeed (300 );
684
+ _stepperRA->move (20 );
685
+ while (_stepperRA->run ()) {
686
+ yield ();
687
+ }
689
688
690
- // Re-configure the stepper to the correct parameters.
691
- _stepperRA->setAcceleration (_maxRAAcceleration);
692
- _stepperRA->setMaxSpeed (_maxRASpeed);
693
- break ;
689
+ // Re-configure the stepper to the correct parameters.
690
+ _stepperRA->setAcceleration (_maxRAAcceleration);
691
+ _stepperRA->setMaxSpeed (_maxRASpeed);
692
+ break ;
694
693
}
695
694
}
696
695
@@ -753,7 +752,7 @@ void Mount::park() {
753
752
//
754
753
// goHome
755
754
//
756
- // Synchronously moves mount to home position
755
+ // Synchronously moves mount to home position
757
756
// ///////////////////////////////
758
757
void Mount::goHome ()
759
758
{
@@ -1040,7 +1039,7 @@ void Mount::waitUntilStopped(byte direction) {
1040
1039
while (((direction & (EAST | WEST)) && _stepperRA->isRunning ())
1041
1040
|| ((direction & (NORTH | SOUTH)) && _stepperDEC->isRunning ())
1042
1041
|| ((direction & TRACKING) && (((_mountStatus & STATUS_TRACKING) == 0 ) && _stepperTRK->isRunning ()))
1043
- ) {
1042
+ ) {
1044
1043
loop ();
1045
1044
yield ();
1046
1045
}
@@ -1275,7 +1274,7 @@ void Mount::setTargetToHome() {
1275
1274
// Set DEC to pole
1276
1275
_targetDEC.set (0 , 0 , 0 );
1277
1276
_slewingToHome = true ;
1278
- // Stop the tracking stepper
1277
+ // Stop the tracking stepper
1279
1278
stopSlewing (TRACKING);
1280
1279
}
1281
1280
@@ -1335,11 +1334,12 @@ void Mount::calculateRAandDECSteppers(float& targetRA, float& targetDEC) {
1335
1334
float stepsPerSiderealHour = _stepsPerRADegree * siderealDegreesInHour;
1336
1335
1337
1336
// Where do we want to move RA to?
1338
- #if RA_Stepper_TYPE == 0
1337
+ #if RA_Stepper_TYPE == 0
1339
1338
float moveRA = hourPos * stepsPerSiderealHour / 2 ;
1340
1339
#else
1341
1340
float moveRA = hourPos * stepsPerSiderealHour;
1342
1341
#endif
1342
+
1343
1343
// Where do we want to move DEC to?
1344
1344
// the variable targetDEC 0deg for the celestial pole (90deg), and goes negative only.
1345
1345
float moveDEC = -_targetDEC.getTotalDegrees () * _stepsPerDECDegree;
@@ -1355,6 +1355,7 @@ void Mount::calculateRAandDECSteppers(float& targetRA, float& targetDEC) {
1355
1355
#else
1356
1356
float RALimit = (6 .0f * stepsPerSiderealHour);
1357
1357
#endif
1358
+
1358
1359
// If we reach the limit in the positive direction ...
1359
1360
if (moveRA > RALimit) {
1360
1361
#ifdef DEBUG_MODE
0 commit comments