Skip to content

Commit b90eb70

Browse files
author
OpenAstroTech
authored
Merge pull request #29 from ClutchplateDude/oopthescope
Changes since V1.6.28 and new ASCOM Driver
2 parents a9bbf88 + 6e793d9 commit b90eb70

File tree

78 files changed

+4467
-4109
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+4467
-4109
lines changed

Software/Arduino code/OpenAstroTracker/Globals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ extern bool inSerialControl;
5757
#define SUPPORT_MANUAL_CONTROL
5858

5959
// Uncomment to support INFO menu that displays various pieces of information about the mount.
60-
#define SUPPORT_INFO_DISPLAY
60+
// #define SUPPORT_INFO_DISPLAY
6161

6262
// Uncomment to support Serial Meade LX200 protocol support
6363
// #define SUPPORT_SERIAL_CONTROL

Software/Arduino code/OpenAstroTracker/Mount.cpp

Lines changed: 138 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ char* formatStringsDEC[] = {
3737
"%c%02d*%02d'%02d#", // Meade
3838
"%c%02d %02d'%02d\"", // Print
3939
"%c%02d@%02d'%02d\"", // LCD display only
40+
"%c%02d%02d%02d", // Compact
4041
};
4142

4243
char* formatStringsRA[] = {
@@ -45,6 +46,7 @@ char* formatStringsRA[] = {
4546
"%02d:%02d:%02d#", // Meade
4647
"%02dh %02dm %02ds", // Print
4748
"%02dh%02dm%02ds", // LCD display only
49+
"%02d%02d%02d", // Compact
4850
};
4951

5052
const float siderealDegreesInHour = 14.95902778;
@@ -75,8 +77,8 @@ void Mount::configureRAStepper(byte stepMode, byte pin1, byte pin2, byte pin3, b
7577
_stepperRA = new AccelStepper(stepMode, pin1, pin2, pin3, pin4);
7678
_stepperRA->setMaxSpeed(maxSpeed);
7779
_stepperRA->setAcceleration(maxAcceleration);
78-
// _maxRASpeed = maxSpeed;
79-
// _maxRAAcceleration = maxAcceleration;
80+
_maxRASpeed = maxSpeed;
81+
_maxRAAcceleration = maxAcceleration;
8082

8183
// Use another AccelStepper to run the RA motor as well. This instance tracks earths rotation.
8284
_stepperTRK = new AccelStepper(HALFSTEP, pin1, pin2, pin3, pin4);
@@ -264,25 +266,6 @@ void Mount::syncDEC(int degree, int minute, int second) {
264266
_stepperDEC->setCurrentPosition(targetDEC);
265267
}
266268

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-
286269
/////////////////////////////////
287270
//
288271
// startSlewingToTarget
@@ -307,44 +290,61 @@ void Mount::startSlewingToTarget() {
307290
_totalRAMove = 1.0f * _stepperRA->distanceToGo();
308291
}
309292

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+
310312
/////////////////////////////////
311313
//
312314
// guidePulse
313315
//
314316
/////////////////////////////////
315317
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?
323321
float decTrackingSpeed = _stepsPerDECDegree * siderealDegreesInHour / 3600.0f;
324322
float raTrackingSpeed = _stepsPerRADegree * siderealDegreesInHour / 3600.0f;
325323

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();
328329

329330
switch (direction) {
330331
case NORTH:
332+
_stepperDEC->setAcceleration(2500);
331333
_stepperDEC->setMaxSpeed(decTrackingSpeed * 1.2);
332334
_stepperDEC->setSpeed(decTrackingSpeed);
333-
_stepperDEC->moveTo(decPos + decStepsForDuration);
334335
_mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_DEC ;
335336
break;
336337

337338
case SOUTH:
339+
_stepperDEC->setAcceleration(2500);
338340
_stepperDEC->setMaxSpeed(decTrackingSpeed * 1.2);
339-
_stepperDEC->setSpeed(decTrackingSpeed);
340-
_stepperDEC->moveTo(decPos - decStepsForDuration);
341+
_stepperDEC->setSpeed(-decTrackingSpeed);
341342
_mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_DEC ;
342343
break;
343344

344345
case WEST:
345346
_stepperTRK->setMaxSpeed(raTrackingSpeed * 2.2);
346347
_stepperTRK->setSpeed(raTrackingSpeed * 2);
347-
_stepperTRK->moveTo(raPos + raStepsForDuration);
348348
_mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_RA;
349349
break;
350350

@@ -358,6 +358,52 @@ void Mount::guidePulse(byte direction, int duration) {
358358
_guideEndTime = millis() + duration;
359359
}
360360

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+
361407
/////////////////////////////////
362408
//
363409
// park
@@ -417,8 +463,8 @@ String Mount::mountStatusString() {
417463
if (_mountStatus & STATUS_PARKING) {
418464
disp = "PARKNG ";
419465
}
420-
else if (isGuiding()){
421-
disp = "GUIDING ";
466+
else if (isGuiding()) {
467+
disp = "GUIDING ";
422468
}
423469
else {
424470
if (_mountStatus & STATUS_TRACKING) disp += "TRK ";
@@ -442,6 +488,57 @@ String Mount::mountStatusString() {
442488
}
443489
#endif
444490

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+
445542
/////////////////////////////////
446543
//
447544
// slewingStatus
@@ -861,8 +958,8 @@ void Mount::moveSteppersTo(float targetRA, float targetDEC) {
861958
//
862959
/////////////////////////////////
863960
void Mount::displayStepperPosition() {
864-
#ifndef HEADLESS_CLIENT
865-
961+
#ifndef HEADLESS_CLIENT
962+
866963
String disp ;
867964

868965
if ((abs(_totalDECMove) > 0.001) && (abs(_totalRAMove) > 0.001)) {
@@ -893,7 +990,7 @@ void Mount::displayStepperPosition() {
893990
else {
894991
#ifdef SUPPORT_SERIAL_CONTROL
895992
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());
897994
_lcdMenu->setCursor(0, 0);
898995
_lcdMenu->printMenu(scratchBuffer);
899996
sprintf(scratchBuffer, "DEC: %s", DECString(LCD_STRING | CURRENT_STRING).c_str());
@@ -926,13 +1023,13 @@ void Mount::displayStepperPosition() {
9261023
//
9271024
/////////////////////////////////
9281025
void Mount::displayStepperPositionThrottled() {
929-
#ifndef HEADLESS_CLIENT
1026+
#ifndef HEADLESS_CLIENT
9301027
long elapsed = millis() - _lastDisplayUpdate;
9311028
if (elapsed > DISPLAY_UPDATE_TIME) {
9321029
displayStepperPosition();
9331030
_lastDisplayUpdate = millis();
9341031
}
935-
#endif
1032+
#endif
9361033
}
9371034

9381035
/////////////////////////////////

Software/Arduino code/OpenAstroTracker/Mount.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#define MEADE_STRING B0010
1919
#define PRINT_STRING B0011
2020
#define LCD_STRING B0100
21+
#define COMPACT_STRING B0101
2122
#define FORMAT_STRING_MASK B0111
2223

2324
#define TARGET_STRING B01000
@@ -124,11 +125,16 @@ class Mount {
124125
// Return a string of DEC in the given format. For LCDSTRING, active determines where the cursor is
125126
String RAString(byte type, byte active = 0);
126127

128+
// Returns a comma-delimited string with all the mounts' information
129+
String getStatusString();
130+
127131
// Get the current speed of the stepper. NORTH, WEST, TRACKING
128132
float getSpeed(int direction);
129133

130134
void displayStepperPositionThrottled();
131135

136+
void runDriftAlignmentPhase(int direction, int durationSecs);
137+
132138
private:
133139
void calculateRAandDECSteppers(float& targetRA, float& targetDEC);
134140
void displayStepperPosition();
@@ -150,9 +156,9 @@ class Mount {
150156
LcdMenu* _lcdMenu;
151157
int _stepsPerRADegree;
152158
int _stepsPerDECDegree;
153-
//int _maxRASpeed;
159+
int _maxRASpeed;
154160
int _maxDECSpeed;
155-
//int _maxRAAcceleration;
161+
int _maxRAAcceleration;
156162
int _maxDECAcceleration;
157163

158164
long _lastHASet;

Software/Arduino code/OpenAstroTracker/OpenAstroTracker.ino

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
#include "Globals.h"
1818

19-
String version = "V1.6.28";
19+
String version = "V1.6.33";
2020

2121
///////////////////////////////////////////////////////////////////////////
2222
// Please see the Globals.h file for configuration of the firmware.
@@ -69,10 +69,10 @@ float DECStepperDownLimit = 10000; // Going much more than this will make the
6969
float DECStepperUpLimit = -22000; // Going much more than this is going below the horizon.
7070

7171
// These values are needed to calculate the current position during initial alignment.
72-
int PolarisRAHour = 21;
73-
int PolarisRAMinute = 2;
74-
int PolarisRASecond = 25;
75-
// You get these values by calculating 24h minus the current (not J2000) RA of Polaris.
72+
int PolarisRAHour = 2;
73+
int PolarisRAMinute = 58;
74+
int PolarisRASecond = 0;
75+
// Use something like Stellarium to look up the RA of Polaris in JNow (on date) variant.
7676
// This changes slightly over weeks, so adjust every couple of months.
77-
// This value is from 27.Nov.19, I suggest next adjustment in mid 2020
77+
// This value is from 18.Apr.2020, next adjustment suggested at end 2020
7878
// The same could be done for the DEC coordinates but they dont change significantly for the next 5 years

Software/Arduino code/OpenAstroTracker/b_setup.ino

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
LcdMenu lcdMenu(16, 2, MAXMENUITEMS);
33
LcdButtons lcdButtons(0);
44

5-
// Create the variables to track RA time, RA display time and HA time
6-
//DayTime RATime;
7-
//DayTime RADisplayTime;
8-
//DayTime HATime;
9-
//DayTime HACorrection;
10-
115
Mount mount(RAStepsPerDegree, DECStepsPerDegree, &lcdMenu);
126

137
void setup() {
@@ -35,7 +29,9 @@ void setup() {
3529

3630
// Configure the mount
3731
// Set the global HA correction
38-
mount.setHACorrection(PolarisRAHour, PolarisRAMinute, PolarisRASecond);
32+
DayTime polaris = DayTime(24,0,0);
33+
polaris.subtractTime(DayTime(PolarisRAHour, PolarisRAMinute, PolarisRASecond));
34+
mount.setHACorrection(polaris.getHours(), polaris.getMinutes(), polaris.getSeconds());
3935

4036
// Set the stepper motor parameters
4137
mount.configureRAStepper(FULLSTEP, RAmotorPin1, RAmotorPin2, RAmotorPin3, RAmotorPin4, RAspeed, RAacceleration);

Software/Arduino code/OpenAstroTracker/c722_menuPOI.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct PointOfInterest {
1313
PointOfInterest pointOfInterest[] = {
1414
// Name (15chars) RA (hms) DEC (dms)
1515
// 012345678901234
16-
{ ">Polaris" , 2, 57, 56, 89, 21, 2 },
16+
{ ">Polaris" , PolarisRAHour, PolarisRAMinute, PolarisRASecond, 89, 21, 2 },
1717
{ ">Big Dipper" , 12, 16, 26, 56, 55, 7 },
1818
{ ">M31 Andromeda" , 0, 43, 52, 41, 22, 53 },
1919
{ ">M42 Orion Nbula", 5, 36, 18, -5, 22, 44 },

0 commit comments

Comments
 (0)