Skip to content

Commit 66bd629

Browse files
Merge pull request #47 from OpenAstroTech/developautopa
Merge of Developautopa to main Develop branch
2 parents e240f67 + acea79f commit 66bd629

File tree

9 files changed

+304
-26
lines changed

9 files changed

+304
-26
lines changed

Software/Arduino code/OpenAstroTracker/Configuration.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
=======================================================================================================================================
1919
*/
2020

21-
String version = "V1.8.03";
21+
String version = "V1.8.04";
2222

2323
///////////////////////////////////////////////////////////////////////////
2424
// Also use Configuration_adv for further adjustments!

Software/Arduino code/OpenAstroTracker/Configuration_adv.hpp

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,32 @@
109109
#define LCD_BUTTON_TEST 0
110110

111111

112+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
113+
// ///
114+
// HARDWARE EXTENSIONS SUPPORT SECTION ///
115+
// ///
116+
//////////////////////////////////////////
117+
//
118+
// Set this to 1 if the mount has motorized Azimuth and Altitude adjustment. Set pins in configuration_pins.hpp
119+
#define AZIMUTH_ALTITUDE_MOTORS 0
120+
121+
#define AZIMUTH_MAX_SPEED 500
122+
#define AZIMUTH_MAX_ACCEL 400
123+
#define AZIMUTH_ARC_SECONDS_PER_STEP (3.99985f)
124+
#define AZIMUTH_STEPS_PER_ARC_MINUTE (60.0f/AZIMUTH_ARC_SECONDS_PER_STEP)
125+
126+
#define ALTITUDE_MAX_SPEED 500
127+
#define ALTITUDE_MAX_ACCEL 400
128+
#define ALTITUDE_ARC_SECONDS_PER_STEP (0.61761f)
129+
#define ALTITUDE_STEPS_PER_ARC_MINUTE (60.0f/ALTITUDE_ARC_SECONDS_PER_STEP)
130+
131+
//
132+
// Set this to 1 if you are using a NEO6m GPS module for HA/LST and location automatic determination.
133+
//
134+
#define USE_GPS 0
135+
// If supported, download the library https://github.com/mikalhart/TinyGPSPlus/releases and extract it to C:\Users\*you*\Documents\Arduino\libraries
136+
137+
112138

113139
#if HEADLESS_CLIENT == 0 // <-- Ignore this line
114140
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -150,10 +176,6 @@
150176
// Set this to 1 to support Serial Meade LX200 protocol support
151177
#define SUPPORT_SERIAL_CONTROL 1
152178

153-
// Set this to 1 if you are using a NEO6m GPS module
154-
// Download this library https://github.com/mikalhart/TinyGPSPlus/releases and extract it to C:\Users\*you*\Documents\Arduino\libraries
155-
#define USE_GPS 0
156-
157179
#endif // HEADLESS_CLIENT <-- Ignore this
158180

159181

Software/Arduino code/OpenAstroTracker/Configuration_pins.hpp

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,24 @@
3636
#define DEC_SERIAL_PORT Serial3 // HardwareSerial port, wire to TX2 for write-only
3737
#define DEC_DRIVER_ADDRESS 0b01 // Set by MS1/MS2 (MS1 HIGH, MS2 LOW)
3838
#define DEC_DIAG_PIN 41 // only needed for autohome function
39+
40+
#if AZIMUTH_ALTITUDE_MOTORS == 1
41+
// Azimuth and Altitude pins
42+
#define AZ_IN1_PIN 38
43+
#define AZ_IN2_PIN 40
44+
#define AZ_IN3_PIN 42
45+
#define AZ_IN4_PIN 44
46+
#define ALT_IN1_PIN 46
47+
#define ALT_IN2_PIN 48
48+
#define ALT_IN3_PIN 50
49+
#define ALT_IN4_PIN 52
50+
#endif
3951
//---------------
40-
// MISC PINS
41-
#define GPS_SERIAL_PORT Serial1
42-
#define GPS_BAUD_RATE 9600
52+
// MISC PINS amd SETTINGS
53+
#if USE_GPS == 1
54+
#define GPS_SERIAL_PORT Serial1
55+
#define GPS_BAUD_RATE 9600
56+
#endif
4357
#endif //mega
4458

4559
////////////////////////////////////////////////////////////////////
@@ -62,6 +76,17 @@
6276
#define DEC_IN3_PIN 5
6377
#define DEC_IN4_PIN 18
6478

79+
#if AZIMUTH_ALTITUDE_MOTORS == 1
80+
#define AZ_IN1_PIN 38
81+
#define AZ_IN2_PIN 40
82+
#define AZ_IN3_PIN 42
83+
#define AZ_IN4_PIN 44
84+
#define ALT_IN1_PIN 46
85+
#define ALT_IN2_PIN 48
86+
#define ALT_IN3_PIN 50
87+
#define ALT_IN4_PIN 52
88+
#endif
89+
6590
// ST4 Input Pins - TODO.
6691
/*#define st4North SD0
6792
#define st4South SD1
@@ -90,6 +115,9 @@
90115
#define DEC_IN3_PIN 16
91116
#define DEC_IN4_PIN 15
92117

118+
#if AZIMUTH_ALTITUDE_MOTORS == 1
119+
#error Azimuth / Altitude motors not currently configured/supported in ESP32
120+
#endif
93121
#if USE_GPS == 1
94122
#error GPS module not currently configured/supported in ESP32
95123
#endif

Software/Arduino code/OpenAstroTracker/MeadeCommandProcessor.cpp

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,25 @@
8585
// :GX#
8686
// Get Mount Status
8787
// Returns: string reflecting the mounts' status. The string is a comma-delimited list of statuses:
88-
// Idle,--T,11219,0,927,071906,+900000,#
89-
// | | | | | | |
90-
// | | | | | | |
91-
// | | | | | | |
92-
// | | | | | | +------------------ [6] The current DEC position
93-
// | | | | | +------------------------- [5] The current RA position
94-
// | | | | +------------------------------- [4] The Tracking stepper position
95-
// | | | +---------------------------------- [3] The DEC stepper position
96-
// | | +-------------------------------------- [2] The RA stepper position
97-
// | +------------------------------------------- [1] The motion state.
98-
// | First character is RA slewing state ('R' is East, 'r' is West, '-' is stopped).
99-
// | Second character is DEC slewing state ('d' is North, 'D' is South, '-' is stopped).
100-
// | Third character is TRK slewing state ('T' is Tracking, '-' is stopped).
101-
// +----------------------------------------------- [0] The mount status. One of 'Idle', 'Parked', 'Parking', 'Guiding', 'SlewToTarget', 'FreeSlew', 'ManualSlew', 'Tracking'
88+
// Idle,--T--,11219,0,927,071906,+900000,#
89+
// | | | | | | |
90+
// | | | | | | |
91+
// | | | | | | |
92+
// | | | | | | +------------------ [6] The current DEC position
93+
// | | | | | +------------------------- [5] The current RA position
94+
// | | | | +------------------------------- [4] The Tracking stepper position
95+
// | | | +---------------------------------- [3] The DEC stepper position
96+
// | | +-------------------------------------- [2] The RA stepper position
97+
// | +-------------------------------------------- [1] The motion state.
98+
// | First character is RA slewing state ('R' is East, 'r' is West, '-' is stopped).
99+
// | Second character is DEC slewing state ('d' is North, 'D' is South, '-' is stopped).
100+
// | Third character is TRK slewing state ('T' is Tracking, '-' is stopped).
101+
// | * Fourth character is AZ slewing state ('Z' and 'z' is adjusting, '-' is stopped).
102+
// | * Fifth character is ALT slewing state ('A' and 'a' is adjusting, '-' is stopped).
103+
// +------------------------------------------------- [0] The mount status. One of 'Idle', 'Parked', 'Parking', 'Guiding', 'SlewToTarget', 'FreeSlew', 'ManualSlew', 'Tracking', 'Homing'
104+
//
105+
// * Az and Alt are optional. The string may only be 3 characters long
106+
//
102107
//
103108
// : Gt#
104109
// Get Site Latitude
@@ -217,6 +222,18 @@
217222
// Where c is one of 'n', 'e', 'w', or 's'.
218223
// Returns: nothing
219224
//
225+
// :MAZn.nn#
226+
// Move Azimuth
227+
// If the scope supports automated azimuth operation, move azimuth by n.nn arcminutes
228+
// Where n.nn is a signed floating point number representing the number of arcminutes to move the mount left or right.
229+
// Returns: nothing
230+
//
231+
// :MALn.nn#
232+
// Move Altitude
233+
// If the scope supports automated altitude operation, move altitude by n.nn arcminutes
234+
// Where n.nn is a signed floating point number representing the number of arcminutes to raise or lower the mount.
235+
// Returns: nothing
236+
//
220237
//------------------------------------------------------------------
221238
// SYNC FAMILY
222239
//
@@ -636,6 +653,18 @@ String MeadeCommandProcessor::handleMeadeMovement(String inCmd) {
636653
return "1";
637654
}
638655
}
656+
else if (inCmd[0] == 'A') {
657+
// Move Azimuth or Altitude by given arcminutes
658+
// :MAZ+32.1# or :MAL-32.1#
659+
float arcMinute = inCmd.substring(2).toFloat();
660+
if (inCmd[1] == 'Z'){
661+
_mount->moveBy(AZIMUTH_STEPS, arcMinute);
662+
}
663+
else if (inCmd[1] == 'L'){
664+
_mount->moveBy(ALTITUDE_STEPS, arcMinute);
665+
}
666+
return "";
667+
}
639668
else if (inCmd[0] == 'e') {
640669
_mount->startSlewing(EAST);
641670
return "";

Software/Arduino code/OpenAstroTracker/Mount.cpp

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,24 @@ void Mount::configureDECStepper(byte stepMode, byte pin1, byte pin2, byte pin3,
332332
}
333333
#endif
334334

335+
#if AZIMUTH_ALTITUDE_MOTORS == 1
336+
void Mount::configureAzStepper(byte stepMode, byte pin1, byte pin2, byte pin3, byte pin4, int maxSpeed, int maxAcceleration)
337+
{
338+
_stepperAZ = new AccelStepper(HALFSTEP, pin1, pin2, pin3, pin4);
339+
_stepperAZ->setSpeed(0);
340+
_stepperAZ->setMaxSpeed(maxSpeed);
341+
_stepperAZ->setAcceleration(maxAcceleration);
342+
}
343+
344+
void Mount::configureAltStepper(byte stepMode, byte pin1, byte pin2, byte pin3, byte pin4, int maxSpeed, int maxAcceleration)
345+
{
346+
_stepperALT = new AccelStepper(FULLSTEP, pin1, pin2, pin3, pin4);
347+
_stepperALT->setSpeed(0);
348+
_stepperALT->setMaxSpeed(maxSpeed);
349+
_stepperALT->setAcceleration(maxAcceleration);
350+
}
351+
#endif
352+
335353
#if DEC_STEPPER_TYPE == STEP_NEMA17
336354
void Mount::configureDECStepper(byte stepMode, byte pin1, byte pin2, int maxSpeed, int maxAcceleration)
337355
{
@@ -525,6 +543,18 @@ String Mount::getMountHardwareInfo()
525543
ret += String(DecPulleyTeeth)+"|";
526544
ret += String(DECStepsPerRevolution)+",";
527545

546+
#if USE_GPS == 1
547+
ret += "GPS,";
548+
#else
549+
ret += "NO_GPS,";
550+
#endif
551+
552+
#if AZIMUTH_ALTITUDE_MOTORS == 1
553+
ret += "AUTO_AZ_ALT,";
554+
#else
555+
ret += "NO_AZ_ALT,";
556+
#endif
557+
528558
return ret;
529559
}
530560

@@ -975,6 +1005,25 @@ void Mount::goHome()
9751005
_slewingToHome = true;
9761006
}
9771007

1008+
/////////////////////////////////
1009+
//
1010+
// moveBy
1011+
//
1012+
/////////////////////////////////
1013+
void Mount::moveBy(int direction, float arcMinutes)
1014+
{
1015+
#if AZIMUTH_ALTITUDE_MOTORS == 1
1016+
if (direction == AZIMUTH_STEPS){
1017+
int stepsToMove = 2.0f * arcMinutes * AZIMUTH_STEPS_PER_ARC_MINUTE;
1018+
_stepperAZ->move(stepsToMove);
1019+
}
1020+
else if (direction == ALTITUDE_STEPS){
1021+
int stepsToMove = arcMinutes * ALTITUDE_STEPS_PER_ARC_MINUTE;
1022+
_stepperALT->move(stepsToMove);
1023+
}
1024+
#endif
1025+
}
1026+
9781027
/////////////////////////////////
9791028
//
9801029
// mountStatus
@@ -1040,6 +1089,9 @@ String Mount::getStatusString() {
10401089
else if (isGuiding()) {
10411090
status = "Guiding,";
10421091
}
1092+
else if (isFindingHome()) {
1093+
status = "Homing,";
1094+
}
10431095
else if (slewStatus() & SLEW_MASK_ANY) {
10441096
if (_mountStatus & STATUS_SLEWING_TO_TARGET) {
10451097
status = "SlewToTarget,";
@@ -1058,12 +1110,16 @@ String Mount::getStatusString() {
10581110
status = "Idle,";
10591111
}
10601112

1061-
String disp = "---,";
1113+
String disp = "-----,";
10621114
if (_mountStatus & STATUS_SLEWING) {
10631115
byte slew = slewStatus();
10641116
if (slew & SLEWING_RA) disp[0] = _stepperRA->speed() < 0 ? 'R' : 'r';
10651117
if (slew & SLEWING_DEC) disp[1] = _stepperDEC->speed() < 0 ? 'D' : 'd';
10661118
if (slew & SLEWING_TRACKING) disp[2] = 'T';
1119+
#if AZIMUTH_ALTITUDE_MOTORS == 1
1120+
if (_stepperAZ->isRunning()) disp[3] = _stepperAZ->speed() < 0 ? 'Z' : 'z';
1121+
if (_stepperALT->isRunning()) disp[4] = _stepperALT->speed() < 0 ? 'A' : 'a';
1122+
#endif
10671123
}
10681124
else if (isSlewingTRK()) {
10691125
disp[2] = 'T';
@@ -1343,6 +1399,12 @@ void Mount::interruptLoop()
13431399
_stepperRA->run();
13441400
}
13451401
}
1402+
1403+
#if AZIMUTH_ALTITUDE_MOTORS == 1
1404+
_stepperAZ->run();
1405+
_stepperALT->run();
1406+
#endif
1407+
13461408
}
13471409

13481410
/////////////////////////////////

Software/Arduino code/OpenAstroTracker/Mount.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
#define DEC_STEPS 2
3737
#define SPEED_FACTOR_DECIMALS 3
3838
#define BACKLASH_CORRECTION 4
39+
#define AZIMUTH_STEPS 5
40+
#define ALTITUDE_STEPS 6
3941

4042
//////////////////////////////////////////////////////////////////
4143
//
@@ -62,6 +64,11 @@ class Mount {
6264
void configureDECStepper(byte stepMode, byte pin1, byte pin2, int maxSpeed, int maxAcceleration);
6365
#endif
6466

67+
#if AZIMUTH_ALTITUDE_MOTORS == 1
68+
void configureAzStepper(byte stepMode, byte pin1, byte pin2, byte pin3, byte pin4, int maxSpeed, int maxAcceleration);
69+
void configureAltStepper(byte stepMode, byte pin1, byte pin2, byte pin3, byte pin4, int maxSpeed, int maxAcceleration);
70+
#endif
71+
6572
// Configure the RA Driver (TMC2209 UART only)
6673
#if RA_DRIVER_TYPE == TMC2009_UART
6774
void configureRAdriver(HardwareSerial *serial, float rsense, byte driveraddress, int rmscurrent, int stallvalue);
@@ -201,6 +208,9 @@ class Mount {
201208
// Set the speed of the given motor
202209
void setSpeed(int which, float speed);
203210

211+
// Support for moving the mount in azimuth and altitude (requires extra hardware)
212+
void moveBy(int direction, float arcMinutes);
213+
204214
// Set the number of steps to use for backlash correction
205215
void setBacklashCorrection(int steps);
206216

@@ -273,6 +283,10 @@ class Mount {
273283
#if RA_DRIVER_TYPE == TMC2009_UART
274284
TMC2209Stepper* _driverRA;
275285
TMC2209Stepper* _driverDEC;
286+
#endif
287+
#if AZIMUTH_ALTITUDE_MOTORS == 1
288+
AccelStepper* _stepperAZ;
289+
AccelStepper* _stepperALT;
276290
#endif
277291

278292
unsigned long _guideEndTime;

Software/Arduino code/OpenAstroTracker/a_inits.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@
6262
#define DECmotorPin1 DEC_STEP_PIN
6363
#define DECmotorPin2 DEC_DIR_PIN
6464
#endif
65+
66+
#if AZIMUTH_ALTITUDE_MOTORS == 1
67+
#define AZmotorPin1 AZ_IN1_PIN
68+
#define AZmotorPin3 AZ_IN2_PIN
69+
#define AZmotorPin2 AZ_IN3_PIN
70+
#define AZmotorPin4 AZ_IN4_PIN
71+
72+
#define ALTmotorPin1 ALT_IN1_PIN
73+
#define ALTmotorPin3 ALT_IN2_PIN
74+
#define ALTmotorPin2 ALT_IN3_PIN
75+
#define ALTmotorPin4 ALT_IN4_PIN
76+
#endif
6577
// End Stepper Definitions //////////////
6678
/////////////////////////////////////////
6779

Software/Arduino code/OpenAstroTracker/b_setup.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ void finishSetup()
217217
mount.configureDECdriver(&DEC_SERIAL_PORT, R_SENSE, DEC_DRIVER_ADDRESS, DEC_RMSCURRENT, DEC_STALL_VALUE);
218218
#endif
219219

220+
#if AZIMUTH_ALTITUDE_MOTORS == 1
221+
mount.configureAzStepper(HALFSTEP, AZmotorPin1, AZmotorPin2, AZmotorPin3, AZmotorPin4, AZIMUTH_MAX_SPEED, AZIMUTH_MAX_ACCEL);
222+
mount.configureAltStepper(FULLSTEP, ALTmotorPin1, ALTmotorPin2, ALTmotorPin3, ALTmotorPin4, ALTITUDE_MAX_SPEED, ALTITUDE_MAX_ACCEL);
223+
#endif
224+
220225
// The mount uses EEPROM storage locations 0-10 that it reads during construction
221226
// The LCD uses EEPROM storage location 11
222227
mount.readConfiguration();

0 commit comments

Comments
 (0)