Skip to content

Commit 9594d4a

Browse files
author
openastrotech
committed
mump to 1.7.01
1 parent 6bdc67f commit 9594d4a

File tree

6 files changed

+227
-232
lines changed

6 files changed

+227
-232
lines changed

Software/Arduino code/OpenAstroTracker/Globals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ void EEPROMupdate(int loc, byte val);
1313
#define DISPLAY_UPDATE_TIME 200
1414

1515
// Stepper selection ///////////
16-
#define RA_Stepper_TYPE 1 // 28BYJ-48 = 0 | NEMA = 1
16+
#define RA_Stepper_TYPE 0 // 28BYJ-48 = 0 | NEMA = 1
1717
#define DEC_Stepper_TYPE 0 // 28BYJ-48 = 0 | NEMA = 1
1818

1919
// Make some variables in the sketch files available to the C++ code.

Software/Arduino code/OpenAstroTracker/Mount.cpp

Lines changed: 89 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Mount::Mount(int stepsPerRADegree, int stepsPerDECDegree, LcdMenu* lcdMenu) {
6767
_stepperWasRunning = false;
6868
_totalDECMove = 0;
6969
_totalRAMove = 0;
70-
#if RA_Stepper_TYPE == 1
70+
#if RA_Stepper_TYPE == 0
7171
_backlashCorrectionSteps = 16;
7272
#else
7373
_backlashCorrectionSteps = 0;
@@ -147,36 +147,36 @@ void Mount::writePersistentData(int which, int val)
147147
}
148148
switch (which) {
149149
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;
157157
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;
165165
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+
}
172172
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;
180180
}
181181

182182

@@ -192,7 +192,6 @@ void Mount::writePersistentData(int which, int val)
192192
// configureRAStepper
193193
//
194194
/////////////////////////////////
195-
196195
#if RA_Stepper_TYPE == 0 // 28BYJ
197196
void Mount::configureRAStepper(byte stepMode, byte pin1, byte pin2, byte pin3, byte pin4, int maxSpeed, int maxAcceleration)
198197
{
@@ -216,6 +215,7 @@ void Mount::configureRAStepper(byte stepMode, byte pin1, byte pin2, byte pin3, b
216215
_stepperTRK->setAcceleration(2500);
217216
}
218217
#endif
218+
219219
#if RA_Stepper_TYPE == 1 //NEMA
220220
void Mount::configureRAStepper(byte stepMode, byte pin1, byte pin2, int maxSpeed, int maxAcceleration)
221221
{
@@ -237,8 +237,7 @@ void Mount::configureRAStepper(byte stepMode, byte pin1, byte pin2, int maxSpeed
237237
// configureDECStepper
238238
//
239239
/////////////////////////////////
240-
241-
#if DEC_Stepper_TYPE == 0
240+
#if DEC_Stepper_TYPE == 0 // 28BYJ
242241
void Mount::configureDECStepper(byte stepMode, byte pin1, byte pin2, byte pin3, byte pin4, int maxSpeed, int maxAcceleration)
243242
{
244243
#if NORTHERN_HEMISPHERE
@@ -252,7 +251,8 @@ void Mount::configureDECStepper(byte stepMode, byte pin1, byte pin2, byte pin3,
252251
_maxDECAcceleration = maxAcceleration;
253252
}
254253
#endif
255-
#if DEC_Stepper_TYPE == 1
254+
255+
#if DEC_Stepper_TYPE == 1 // NEMA
256256
void Mount::configureDECStepper(byte stepMode, byte pin1, byte pin2, int maxSpeed, int maxAcceleration)
257257
{
258258
_stepperDEC = new AccelStepper(stepMode, pin2, pin1);
@@ -262,7 +262,6 @@ void Mount::configureDECStepper(byte stepMode, byte pin1, byte pin2, int maxSpee
262262
_maxDECAcceleration = maxAcceleration;
263263
}
264264
#endif
265-
266265
/////////////////////////////////
267266
//
268267
// getSpeedCalibration
@@ -373,7 +372,7 @@ const DayTime Mount::HA() const {
373372
#ifdef DEBUG_MODE
374373
logv("Mount: Get HA.");
375374
logv("Mount: Polaris adjust: %s", DayTime(PolarisRAHour, PolarisRAMinute, PolarisRASecond).ToString());
376-
#endif
375+
#endif
377376
DayTime ha = _LST;
378377
#ifdef DEBUG_MODE
379378
logv("Mount: LST: %s", _LST.ToString());
@@ -534,7 +533,7 @@ const DegreeTime Mount::currentDEC() const {
534533
// syncPosition
535534
//
536535
/////////////////////////////////
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
538537
// to be at the calculated positions (that they would be if we were slewing there).
539538
void Mount::syncPosition(int raHour, int raMinute, int raSecond, int decDegree, int decMinute, int decSecond)
540539
{
@@ -611,30 +610,30 @@ void Mount::guidePulse(byte direction, int duration) {
611610

612611
switch (direction) {
613612
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;
619618

620619
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;
626625

627626
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;
632631

633632
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;
638637
}
639638

640639
_guideEndTime = millis() + duration;
@@ -654,43 +653,43 @@ void Mount::runDriftAlignmentPhase(int direction, int durationSecs) {
654653
float speed = 400.0 / durationSecs;
655654
switch (direction) {
656655
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+
}
664663

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;
672671

673672
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;
681680

682681
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+
}
689688

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;
694693
}
695694
}
696695

@@ -753,7 +752,7 @@ void Mount::park() {
753752
//
754753
// goHome
755754
//
756-
// Synchronously moves mount to home position
755+
// Synchronously moves mount to home position
757756
/////////////////////////////////
758757
void Mount::goHome()
759758
{
@@ -1040,7 +1039,7 @@ void Mount::waitUntilStopped(byte direction) {
10401039
while (((direction & (EAST | WEST)) && _stepperRA->isRunning())
10411040
|| ((direction & (NORTH | SOUTH)) && _stepperDEC->isRunning())
10421041
|| ((direction & TRACKING) && (((_mountStatus & STATUS_TRACKING) == 0) && _stepperTRK->isRunning()))
1043-
) {
1042+
) {
10441043
loop();
10451044
yield();
10461045
}
@@ -1275,7 +1274,7 @@ void Mount::setTargetToHome() {
12751274
// Set DEC to pole
12761275
_targetDEC.set(0, 0, 0);
12771276
_slewingToHome = true;
1278-
// Stop the tracking stepper
1277+
// Stop the tracking stepper
12791278
stopSlewing(TRACKING);
12801279
}
12811280

@@ -1335,11 +1334,12 @@ void Mount::calculateRAandDECSteppers(float& targetRA, float& targetDEC) {
13351334
float stepsPerSiderealHour = _stepsPerRADegree * siderealDegreesInHour;
13361335

13371336
// Where do we want to move RA to?
1338-
#if RA_Stepper_TYPE == 0
1337+
#if RA_Stepper_TYPE == 0
13391338
float moveRA = hourPos * stepsPerSiderealHour / 2;
13401339
#else
13411340
float moveRA = hourPos * stepsPerSiderealHour;
13421341
#endif
1342+
13431343
// Where do we want to move DEC to?
13441344
// the variable targetDEC 0deg for the celestial pole (90deg), and goes negative only.
13451345
float moveDEC = -_targetDEC.getTotalDegrees() * _stepsPerDECDegree;
@@ -1355,6 +1355,7 @@ void Mount::calculateRAandDECSteppers(float& targetRA, float& targetDEC) {
13551355
#else
13561356
float RALimit = (6.0f * stepsPerSiderealHour);
13571357
#endif
1358+
13581359
// If we reach the limit in the positive direction ...
13591360
if (moveRA > RALimit) {
13601361
#ifdef DEBUG_MODE

0 commit comments

Comments
 (0)