@@ -67,7 +67,11 @@ 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
71
_backlashCorrectionSteps = 16 ;
72
+ #else
73
+ _backlashCorrectionSteps = 0 ;
74
+ #endif
71
75
_correctForBacklash = false ;
72
76
_slewingToHome = false ;
73
77
readPersistentData ();
@@ -145,36 +149,36 @@ void Mount::writePersistentData(int which, int val)
145
149
}
146
150
switch (which) {
147
151
case RA_STEPS:
148
- {
149
- // ... set bit 0 to indicate RA value has been written to 6/7
150
- flag |= 0x01 ;
151
- loByteLocation = 6 ;
152
- hiByteLocation = 7 ;
153
- }
154
- break ;
152
+ {
153
+ // ... set bit 0 to indicate RA value has been written to 6/7
154
+ flag |= 0x01 ;
155
+ loByteLocation = 6 ;
156
+ hiByteLocation = 7 ;
157
+ }
158
+ break ;
155
159
case DEC_STEPS:
156
- {
157
- // ... set bit 1 to indicate DEC value has been written to 8/9
158
- flag |= 0x02 ;
159
- loByteLocation = 8 ;
160
- hiByteLocation = 9 ;
161
- }
162
- break ;
160
+ {
161
+ // ... set bit 1 to indicate DEC value has been written to 8/9
162
+ flag |= 0x02 ;
163
+ loByteLocation = 8 ;
164
+ hiByteLocation = 9 ;
165
+ }
166
+ break ;
163
167
case SPEED_FACTOR_DECIMALS:
164
- {
165
- // ... set bit 2 to indicate speed factor value has been written to 0/3
166
- flag |= 0x04 ;
167
- loByteLocation = 0 ;
168
- hiByteLocation = 3 ;
169
- }
168
+ {
169
+ // ... set bit 2 to indicate speed factor value has been written to 0/3
170
+ flag |= 0x04 ;
171
+ loByteLocation = 0 ;
172
+ hiByteLocation = 3 ;
173
+ }
170
174
case BACKLASH_CORRECTION:
171
- {
172
- // ... set bit 2 to indicate speed factor value has been written to 0/3
173
- flag |= 0x08 ;
174
- loByteLocation = 10 ;
175
- hiByteLocation = 11 ;
176
- }
177
- break ;
175
+ {
176
+ // ... set bit 2 to indicate speed factor value has been written to 0/3
177
+ flag |= 0x08 ;
178
+ loByteLocation = 10 ;
179
+ hiByteLocation = 11 ;
180
+ }
181
+ break ;
178
182
}
179
183
180
184
@@ -190,6 +194,8 @@ void Mount::writePersistentData(int which, int val)
190
194
// configureRAStepper
191
195
//
192
196
// ///////////////////////////////
197
+
198
+ #if RA_Stepper_TYPE == 0 // 28BYJ
193
199
void Mount::configureRAStepper (byte stepMode, byte pin1, byte pin2, byte pin3, byte pin4, int maxSpeed, int maxAcceleration)
194
200
{
195
201
_stepperRA = new AccelStepper (stepMode, pin1, pin2, pin3, pin4);
@@ -203,12 +209,30 @@ void Mount::configureRAStepper(byte stepMode, byte pin1, byte pin2, byte pin3, b
203
209
_stepperTRK->setMaxSpeed (10 );
204
210
_stepperTRK->setAcceleration (2500 );
205
211
}
212
+ #endif
213
+ #if RA_Stepper_TYPE == 1 // NEMA
214
+ void Mount::configureRAStepper (byte stepMode, byte pin1, byte pin2, int maxSpeed, int maxAcceleration)
215
+ {
216
+ _stepperRA = new AccelStepper (stepMode, pin1, pin2);
217
+ _stepperRA->setMaxSpeed (maxSpeed);
218
+ _stepperRA->setAcceleration (maxAcceleration);
219
+ _maxRASpeed = maxSpeed;
220
+ _maxRAAcceleration = maxAcceleration;
221
+
222
+ // Use another AccelStepper to run the RA motor as well. This instance tracks earths rotation.
223
+ _stepperTRK = new AccelStepper (DRIVER, pin1, pin2);
224
+ _stepperTRK->setMaxSpeed (10 );
225
+ _stepperTRK->setAcceleration (2500 );
226
+ }
227
+ #endif
206
228
207
229
// ///////////////////////////////
208
230
//
209
231
// configureDECStepper
210
232
//
211
233
// ///////////////////////////////
234
+
235
+ #if DEC_Stepper_TYPE == 0
212
236
void Mount::configureDECStepper (byte stepMode, byte pin1, byte pin2, byte pin3, byte pin4, int maxSpeed, int maxAcceleration)
213
237
{
214
238
_stepperDEC = new AccelStepper (stepMode, pin4, pin3, pin2, pin1);
@@ -217,6 +241,17 @@ void Mount::configureDECStepper(byte stepMode, byte pin1, byte pin2, byte pin3,
217
241
_maxDECSpeed = maxSpeed;
218
242
_maxDECAcceleration = maxAcceleration;
219
243
}
244
+ #endif
245
+ #if DEC_Stepper_TYPE == 1
246
+ void Mount::configureDECStepper (byte stepMode, byte pin1, byte pin2, int maxSpeed, int maxAcceleration)
247
+ {
248
+ _stepperDEC = new AccelStepper (stepMode, pin2, pin1);
249
+ _stepperDEC->setMaxSpeed (maxSpeed);
250
+ _stepperDEC->setAcceleration (maxAcceleration);
251
+ _maxDECSpeed = maxSpeed;
252
+ _maxDECAcceleration = maxAcceleration;
253
+ }
254
+ #endif
220
255
221
256
// ///////////////////////////////
222
257
//
@@ -328,7 +363,7 @@ const DayTime Mount::HA() const {
328
363
#ifdef DEBUG_MODE
329
364
logv (" Mount: Get HA." );
330
365
logv (" Mount: Polaris adjust: %s" , DayTime (PolarisRAHour, PolarisRAMinute, PolarisRASecond).ToString ());
331
- #endif
366
+ #endif
332
367
DayTime ha = _LST;
333
368
#ifdef DEBUG_MODE
334
369
logv (" Mount: LST: %s" , _LST.ToString ());
@@ -424,7 +459,7 @@ const DegreeTime Mount::currentDEC() const {
424
459
// syncPosition
425
460
//
426
461
// ///////////////////////////////
427
- // Set the current RA and DEC position to be the given coordinate. We do this by settign the stepper motor coordinate
462
+ // Set the current RA and DEC position to be the given coordinate. We do this by settign the stepper motor coordinate
428
463
// to be at the calculated positions (that they would be if we were slewing there).
429
464
void Mount::syncPosition (int raHour, int raMinute, int raSecond, int decDegree, int decMinute, int decSecond)
430
465
{
@@ -501,30 +536,30 @@ void Mount::guidePulse(byte direction, int duration) {
501
536
502
537
switch (direction) {
503
538
case NORTH:
504
- _stepperDEC->setAcceleration (2500 );
505
- _stepperDEC->setMaxSpeed (decTrackingSpeed * 1.2 );
506
- _stepperDEC->setSpeed (decTrackingSpeed);
507
- _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_DEC;
508
- break ;
539
+ _stepperDEC->setAcceleration (2500 );
540
+ _stepperDEC->setMaxSpeed (decTrackingSpeed * 1.2 );
541
+ _stepperDEC->setSpeed (decTrackingSpeed);
542
+ _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_DEC;
543
+ break ;
509
544
510
545
case SOUTH:
511
- _stepperDEC->setAcceleration (2500 );
512
- _stepperDEC->setMaxSpeed (decTrackingSpeed * 1.2 );
513
- _stepperDEC->setSpeed (-decTrackingSpeed);
514
- _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_DEC;
515
- break ;
546
+ _stepperDEC->setAcceleration (2500 );
547
+ _stepperDEC->setMaxSpeed (decTrackingSpeed * 1.2 );
548
+ _stepperDEC->setSpeed (-decTrackingSpeed);
549
+ _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_DEC;
550
+ break ;
516
551
517
552
case WEST:
518
- _stepperTRK->setMaxSpeed (raTrackingSpeed * 2.2 );
519
- _stepperTRK->setSpeed (raTrackingSpeed * 2 );
520
- _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_RA;
521
- break ;
553
+ _stepperTRK->setMaxSpeed (raTrackingSpeed * 2.2 );
554
+ _stepperTRK->setSpeed (raTrackingSpeed * 2 );
555
+ _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_RA;
556
+ break ;
522
557
523
558
case EAST:
524
- _stepperTRK->setMaxSpeed (raTrackingSpeed * 2.2 );
525
- _stepperTRK->setSpeed (0 );
526
- _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_RA;
527
- break ;
559
+ _stepperTRK->setMaxSpeed (raTrackingSpeed * 2.2 );
560
+ _stepperTRK->setSpeed (0 );
561
+ _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_RA;
562
+ break ;
528
563
}
529
564
530
565
_guideEndTime = millis () + duration;
@@ -544,43 +579,43 @@ void Mount::runDriftAlignmentPhase(int direction, int durationSecs) {
544
579
float speed = 400.0 / durationSecs;
545
580
switch (direction) {
546
581
case EAST:
547
- // Move 400 steps east at the calculated speed, synchronously
548
- _stepperRA->setAcceleration (1500 );
549
- _stepperRA->setMaxSpeed (speed);
550
- _stepperRA->move (400 );
551
- while (_stepperRA->run ()) {
552
- yield ();
553
- }
582
+ // Move 400 steps east at the calculated speed, synchronously
583
+ _stepperRA->setAcceleration (1500 );
584
+ _stepperRA->setMaxSpeed (speed);
585
+ _stepperRA->move (400 );
586
+ while (_stepperRA->run ()) {
587
+ yield ();
588
+ }
554
589
555
- // Overcome the gearing gap
556
- _stepperRA->setMaxSpeed (300 );
557
- _stepperRA->move (-20 );
558
- while (_stepperRA->run ()) {
559
- yield ();
560
- }
561
- break ;
590
+ // Overcome the gearing gap
591
+ _stepperRA->setMaxSpeed (300 );
592
+ _stepperRA->move (-20 );
593
+ while (_stepperRA->run ()) {
594
+ yield ();
595
+ }
596
+ break ;
562
597
563
598
case WEST:
564
- // Move 400 steps west at the calculated speed, synchronously
565
- _stepperRA->setMaxSpeed (speed);
566
- _stepperRA->move (-400 );
567
- while (_stepperRA->run ()) {
568
- yield ();
569
- }
570
- break ;
599
+ // Move 400 steps west at the calculated speed, synchronously
600
+ _stepperRA->setMaxSpeed (speed);
601
+ _stepperRA->move (-400 );
602
+ while (_stepperRA->run ()) {
603
+ yield ();
604
+ }
605
+ break ;
571
606
572
607
case 0 :
573
- // Fix the gearing to go back the other way
574
- _stepperRA->setMaxSpeed (300 );
575
- _stepperRA->move (20 );
576
- while (_stepperRA->run ()) {
577
- yield ();
578
- }
608
+ // Fix the gearing to go back the other way
609
+ _stepperRA->setMaxSpeed (300 );
610
+ _stepperRA->move (20 );
611
+ while (_stepperRA->run ()) {
612
+ yield ();
613
+ }
579
614
580
- // Re-configure the stepper to the correct parameters.
581
- _stepperRA->setAcceleration (_maxRAAcceleration);
582
- _stepperRA->setMaxSpeed (_maxRASpeed);
583
- break ;
615
+ // Re-configure the stepper to the correct parameters.
616
+ _stepperRA->setAcceleration (_maxRAAcceleration);
617
+ _stepperRA->setMaxSpeed (_maxRASpeed);
618
+ break ;
584
619
}
585
620
}
586
621
@@ -643,7 +678,7 @@ void Mount::park() {
643
678
//
644
679
// goHome
645
680
//
646
- // Synchronously moves mount to home position
681
+ // Synchronously moves mount to home position
647
682
// ///////////////////////////////
648
683
void Mount::goHome ()
649
684
{
@@ -928,7 +963,7 @@ void Mount::waitUntilStopped(byte direction) {
928
963
while (((direction & (EAST | WEST)) && _stepperRA->isRunning ())
929
964
|| ((direction & (NORTH | SOUTH)) && _stepperDEC->isRunning ())
930
965
|| ((direction & TRACKING) && (((_mountStatus & STATUS_TRACKING) == 0 ) && _stepperTRK->isRunning ()))
931
- ) {
966
+ ) {
932
967
loop ();
933
968
yield ();
934
969
}
@@ -1149,7 +1184,7 @@ void Mount::setTargetToHome() {
1149
1184
// Set DEC to pole
1150
1185
_targetDEC.set (0 , 0 , 0 );
1151
1186
_slewingToHome = true ;
1152
- // Stop the tracking stepper
1187
+ // Stop the tracking stepper
1153
1188
stopSlewing (TRACKING);
1154
1189
}
1155
1190
@@ -1205,8 +1240,11 @@ void Mount::calculateRAandDECSteppers(float& targetRA, float& targetDEC) {
1205
1240
float stepsPerSiderealHour = _stepsPerRADegree * siderealDegreesInHour;
1206
1241
1207
1242
// Where do we want to move RA to?
1243
+ #if RA_Stepper_TYPE == 0
1208
1244
float moveRA = hourPos * stepsPerSiderealHour / 2 ;
1209
-
1245
+ #else
1246
+ float moveRA = hourPos * stepsPerSiderealHour;
1247
+ #endif
1210
1248
// Where do we want to move DEC to?
1211
1249
// the variable targetDEC 0deg for the celestial pole (90deg), and goes negative only.
1212
1250
float moveDEC = -_targetDEC.getTotalDegrees () * _stepsPerDECDegree;
@@ -1217,8 +1255,11 @@ void Mount::calculateRAandDECSteppers(float& targetRA, float& targetDEC) {
1217
1255
#endif
1218
1256
1219
1257
// We can move 6 hours in either direction. Outside of that we need to flip directions.
1258
+ #if RA_Stepper_TYPE == 0
1220
1259
float RALimit = (6 .0f * stepsPerSiderealHour / 2 );
1221
-
1260
+ #else
1261
+ float RALimit = (6 .0f * stepsPerSiderealHour);
1262
+ #endif
1222
1263
// If we reach the limit in the positive direction ...
1223
1264
if (moveRA > RALimit) {
1224
1265
#ifdef DEBUG_MODE
@@ -1227,7 +1268,11 @@ void Mount::calculateRAandDECSteppers(float& targetRA, float& targetDEC) {
1227
1268
1228
1269
// ... turn both RA and DEC axis around
1229
1270
float oldRA = moveRA;
1271
+ #if RA_Stepper_TYPE == 0
1230
1272
moveRA -= long (12 .0f * stepsPerSiderealHour / 2 );
1273
+ #else
1274
+ moveRA -= long (12 .0f * stepsPerSiderealHour);
1275
+ #endif
1231
1276
moveDEC = -moveDEC;
1232
1277
#ifdef DEBUG_MODE
1233
1278
logv (" Mount::CalcSteppers: Adjusted Target Step pos RA: %f, DEC: %f" , moveRA, moveDEC);
@@ -1240,7 +1285,11 @@ void Mount::calculateRAandDECSteppers(float& targetRA, float& targetDEC) {
1240
1285
#endif
1241
1286
// ... turn both RA and DEC axis around
1242
1287
float oldRA = moveRA;
1288
+ #if RA_Stepper_TYPE == 0
1243
1289
moveRA += long (12 .0f * stepsPerSiderealHour / 2 );
1290
+ #else
1291
+ moveRA += long (12 .0f * stepsPerSiderealHour);
1292
+ #endif
1244
1293
moveDEC = -moveDEC;
1245
1294
#ifdef DEBUG_MODE
1246
1295
logv (" Mount::CalcSteppers: Adjusted Target Step pos RA: %f, DEC: %f" , moveRA, moveDEC);
0 commit comments