Skip to content

Commit 395e659

Browse files
V1.6.26 - Updates
- Added Guiding support.
1 parent 9dc2796 commit 395e659

File tree

5 files changed

+167
-8
lines changed

5 files changed

+167
-8
lines changed

Software/Arduino code/OpenAstroTracker/Globals.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extern bool inSerialControl;
4343
// #define SUPPORT_HEATING
4444

4545
// Uncomment to support Guided Startup
46-
#define SUPPORT_GUIDED_STARTUP
46+
//#define SUPPORT_GUIDED_STARTUP
4747

4848
// Uncomment to support full GO (was POI) menu.
4949
// If this is commented out you still have a GO menu that has Home and Park.
@@ -53,9 +53,9 @@ extern bool inSerialControl;
5353
#define SUPPORT_MANUAL_CONTROL
5454

5555
// Uncomment to support INFO menu that displays various pieces of information about the mount.
56-
#define SUPPORT_INFO_DISPLAY
56+
//#define SUPPORT_INFO_DISPLAY
5757

5858
// Uncomment to support Serial Meade LX200 protocol support
59-
// #define SUPPORT_SERIAL_CONTROL
59+
#define SUPPORT_SERIAL_CONTROL
6060

6161
#endif

Software/Arduino code/OpenAstroTracker/Mount.cpp

Lines changed: 124 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
#define STATUS_SLEWING_FREE B00000010
99
#define STATUS_TRACKING B00001000
1010
#define STATUS_PARKING B00010000
11+
#define STATUS_GUIDE_PULSE B10000000
12+
#define STATUS_GUIDE_PULSE_DIR B01100000
13+
#define STATUS_GUIDE_PULSE_RA B01000000
14+
#define STATUS_GUIDE_PULSE_DEC B00100000
15+
#define STATUS_GUIDE_PULSE_MASK B11100000
1116

1217
// slewingStatus()
1318
#define SLEWING_DEC B00000010
@@ -69,6 +74,8 @@ void Mount::configureRAStepper(byte stepMode, byte pin1, byte pin2, byte pin3, b
6974
_stepperRA = new AccelStepper(stepMode, pin1, pin2, pin3, pin4);
7075
_stepperRA->setMaxSpeed(maxSpeed);
7176
_stepperRA->setAcceleration(maxAcceleration);
77+
// _maxRASpeed = maxSpeed;
78+
// _maxRAAcceleration = maxAcceleration;
7279

7380
// Use another AccelStepper to run the RA motor as well. This instance tracks earths rotation.
7481
_stepperTRK = new AccelStepper(HALFSTEP, pin1, pin2, pin3, pin4);
@@ -86,6 +93,8 @@ void Mount::configureDECStepper(byte stepMode, byte pin1, byte pin2, byte pin3,
8693
_stepperDEC = new AccelStepper(stepMode, pin4, pin3, pin2, pin1);
8794
_stepperDEC->setMaxSpeed(maxSpeed);
8895
_stepperDEC->setAcceleration(maxAcceleration);
96+
_maxDECSpeed = maxSpeed;
97+
_maxDECAcceleration = maxAcceleration;
8998
}
9099

91100
float Mount::getSpeedCalibration() {
@@ -254,6 +263,25 @@ void Mount::syncDEC(int degree, int minute, int second) {
254263
_stepperDEC->setCurrentPosition(targetDEC);
255264
}
256265

266+
/////////////////////////////////
267+
//
268+
// stopGuiding
269+
//
270+
/////////////////////////////////
271+
void Mount::stopGuiding() {
272+
_stepperDEC->stop();
273+
while (_stepperDEC->isRunning()) {
274+
_stepperDEC->run();
275+
}
276+
_stepperDEC->setMaxSpeed(_maxDECSpeed);
277+
_stepperDEC->setAcceleration(_maxDECAcceleration);
278+
_stepperTRK->setMaxSpeed(10);
279+
_stepperTRK->setAcceleration(2500);
280+
_stepperTRK->setSpeed(_trackingSpeed);
281+
_stepperTRK->runSpeed();
282+
_mountStatus &= ~STATUS_GUIDE_PULSE_MASK;
283+
}
284+
257285
/////////////////////////////////
258286
//
259287
// startSlewingToTarget
@@ -262,6 +290,10 @@ void Mount::syncDEC(int degree, int minute, int second) {
262290
// Calculates movement parameters and program steppers to move
263291
// there. Must call loop() frequently to actually move.
264292
void Mount::startSlewingToTarget() {
293+
if (isGuiding()) {
294+
stopGuiding();
295+
}
296+
265297
// Calculate new RA stepper target (and DEC)
266298
_currentDECStepperPosition = _stepperDEC->currentPosition();
267299
_currentRAStepperPosition = _stepperRA->currentPosition();
@@ -274,15 +306,66 @@ void Mount::startSlewingToTarget() {
274306
_totalRAMove = 1.0f * _stepperRA->distanceToGo();
275307
}
276308

309+
/////////////////////////////////
310+
//
311+
// guidePulse
312+
//
313+
/////////////////////////////////
314+
void Mount::guidePulse(byte direction, int duration) {
315+
// How many steps moves the RA ring one sidereal hour along. One sidereal hour moves just shy of 15 degrees
316+
// NOTE: May need to adjust with _trackingSpeedCalibration
317+
float decStepsPerSiderealHour = _stepsPerDECDegree * siderealDegreesInHour;
318+
float decStepsForDuration = decStepsPerSiderealHour * duration / 3600000;
319+
float raStepsPerSiderealHour = _stepsPerRADegree * siderealDegreesInHour;
320+
float raStepsForDuration = raStepsPerSiderealHour * duration / 3600000;
321+
322+
float decTrackingSpeed = _stepsPerDECDegree * siderealDegreesInHour / 3600.0f;
323+
float raTrackingSpeed = _stepsPerRADegree * siderealDegreesInHour / 3600.0f;
324+
325+
long raPos = _stepperRA->currentPosition();
326+
long decPos = _stepperDEC->currentPosition();
327+
328+
switch (direction) {
329+
case NORTH:
330+
_stepperDEC->setMaxSpeed(decTrackingSpeed * 1.2);
331+
_stepperDEC->setSpeed(decTrackingSpeed);
332+
_stepperDEC->moveTo(decPos + decStepsForDuration);
333+
_mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_DEC ;
334+
break;
335+
336+
case SOUTH:
337+
_stepperDEC->setMaxSpeed(decTrackingSpeed * 1.2);
338+
_stepperDEC->setSpeed(decTrackingSpeed);
339+
_stepperDEC->moveTo(decPos - decStepsForDuration);
340+
_mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_DEC ;
341+
break;
342+
343+
case WEST:
344+
_stepperTRK->setMaxSpeed(raTrackingSpeed * 2.2);
345+
_stepperTRK->setSpeed(raTrackingSpeed * 2);
346+
_stepperTRK->moveTo(raPos + raStepsForDuration);
347+
_mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_RA;
348+
break;
349+
350+
case EAST:
351+
_stepperTRK->setMaxSpeed(raTrackingSpeed * 2.2);
352+
_stepperTRK->setSpeed(0);
353+
_mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_RA;
354+
break;
355+
}
356+
357+
_guideEndTime = millis() + duration;
358+
}
359+
277360
/////////////////////////////////
278361
//
279362
// park
280363
//
281-
// Targets the mount to move to the home position and
364+
// Targets the mount to move to the home position and
282365
// turns off all motors once it gets there.
283366
/////////////////////////////////
284-
void Mount::park()
285-
{
367+
void Mount::park() {
368+
stopGuiding();
286369
stopSlewing(ALL_DIRECTIONS | TRACKING);
287370
waitUntilStopped(ALL_DIRECTIONS);
288371
setTargetToHome();
@@ -294,11 +377,12 @@ void Mount::park()
294377
//
295378
// goHome
296379
//
297-
// Synchronously moves mount to home position and
380+
// Synchronously moves mount to home position and
298381
// sets Tracking mode according to argument
299382
/////////////////////////////////
300383
void Mount::goHome(bool tracking)
301384
{
385+
stopGuiding();
302386
stopSlewing(TRACKING);
303387
setTargetToHome();
304388
startSlewingToTarget();
@@ -332,6 +416,9 @@ String Mount::mountStatusString() {
332416
if (_mountStatus & STATUS_PARKING) {
333417
disp = "PARKNG ";
334418
}
419+
else if (isGuiding()){
420+
disp = "GUIDING ";
421+
}
335422
else {
336423
if (_mountStatus & STATUS_TRACKING) disp += "TRK ";
337424
if (_mountStatus & STATUS_SLEWING) disp += "SLW ";
@@ -365,13 +452,26 @@ byte Mount::slewStatus() {
365452
if (_mountStatus == STATUS_PARKED) {
366453
return NOT_SLEWING;
367454
}
455+
if (isGuiding()) {
456+
return NOT_SLEWING;
457+
}
368458
byte slewState = _stepperRA->isRunning() ? SLEWING_RA : NOT_SLEWING;
369459
slewState |= _stepperDEC->isRunning() ? SLEWING_DEC : NOT_SLEWING;
370460

371461
slewState |= (_mountStatus & STATUS_TRACKING) ? SLEWING_TRACKING : NOT_SLEWING;
372462
return slewState;
373463
}
374464

465+
/////////////////////////////////
466+
//
467+
// isGuiding
468+
//
469+
/////////////////////////////////
470+
bool Mount::isGuiding()
471+
{
472+
return (_mountStatus & STATUS_GUIDE_PULSE);
473+
}
474+
375475
/////////////////////////////////
376476
//
377477
// isSlewingDEC
@@ -449,6 +549,10 @@ bool Mount::isParking() {
449549
void Mount::startSlewing(int direction) {
450550
if (!isParking())
451551
{
552+
if (isGuiding()) {
553+
stopGuiding();
554+
}
555+
452556
if (direction & TRACKING) {
453557
_stepperTRK->setSpeed(_trackingSpeed);
454558

@@ -561,6 +665,22 @@ void Mount::loop() {
561665
_lastMountPrint = now;
562666
}
563667
#endif
668+
if (isGuiding()) {
669+
if (millis() > _guideEndTime) {
670+
stopGuiding();
671+
}
672+
else
673+
{
674+
if (_mountStatus & STATUS_GUIDE_PULSE_RA) {
675+
_stepperTRK->runSpeed();
676+
}
677+
if (_mountStatus & STATUS_GUIDE_PULSE_DEC) {
678+
_stepperDEC->runSpeed();
679+
}
680+
}
681+
return;
682+
}
683+
564684
if (_mountStatus & STATUS_TRACKING) {
565685
_stepperTRK->runSpeed();
566686
}

Software/Arduino code/OpenAstroTracker/Mount.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class Mount {
8080
bool isSlewingTRK();
8181
bool isParked();
8282
bool isParking();
83+
bool isGuiding();
8384

8485
// Starts manual slewing in one of eight directions or tracking
8586
void startSlewing(int direction);
@@ -111,6 +112,11 @@ class Mount {
111112
// Asynchronously parks the mount. Moves to the home position and stops all motors.
112113
void park();
113114

115+
// Runs the RA motor at twice the speed (or stops it), or the DEC motor at tracking speed for the given duration in ms.
116+
void guidePulse(byte direction, int duration);
117+
118+
// Stops any guide operation in progress.
119+
void stopGuiding();
114120

115121
// Return a string of DEC in the given format. For LCDSTRING, active determines where the cursor is
116122
String DECString(byte type, byte active = 0);
@@ -144,6 +150,11 @@ class Mount {
144150
LcdMenu* _lcdMenu;
145151
int _stepsPerRADegree;
146152
int _stepsPerDECDegree;
153+
//int _maxRASpeed;
154+
int _maxDECSpeed;
155+
//int _maxRAAcceleration;
156+
int _maxDECAcceleration;
157+
147158
long _lastHASet;
148159
DayTime _HAAdjust;
149160

@@ -163,6 +174,7 @@ class Mount {
163174
AccelStepper* _stepperDEC;
164175
AccelStepper* _stepperTRK;
165176

177+
unsigned long _guideEndTime;
166178
unsigned long _lastMountPrint = 0;
167179
DayTime _HATime;
168180
DayTime _HACorrection;

Software/Arduino code/OpenAstroTracker/OpenAstroTracker.ino

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

19-
String version = "V1.6.25";
19+
String version = "V1.6.26";
2020

2121
///////////////////////////////////////////////////////////////////////////
2222
// Please see the Globals.h file for configuration of the firmware.

Software/Arduino code/OpenAstroTracker/f_serial.ino

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
// Get Tracking
6060
// Returns: 1 if tracking is on. 0 if not.
6161
//
62+
// :GIG#
63+
// Get Guiding
64+
// Returns: 1 if currently guiding. 0 if not.
65+
//
6266
//------------------------------------------------------------------
6367
// SET FAMILY
6468
//
@@ -97,6 +101,12 @@
97101
//
98102
// -- MOVEMENT Extensions --
99103
//
104+
// :MGdnnnn#
105+
// Run a Guide pulse
106+
// This runs the motors for a short period of time.
107+
// Where d is one of 'N', 'E', 'W', or 'S' and nnnn is the duration in ms.
108+
// Returns: nothing
109+
//
100110
// :MTs#
101111
// Set Tracking mode
102112
// This turns the scopes tracking mode on or off.
@@ -188,6 +198,9 @@ void handleMeadeGetInfo(String inCmd) {
188198
else if (cmdTwo == 'T') {
189199
Serial.print(mount.isSlewingTRK() ? "1" : "0");
190200
}
201+
else if (cmdTwo == 'G') {
202+
Serial.print(mount.isGuiding() ? "1" : "0");
203+
}
191204
Serial.print("#");
192205
}
193206
break;
@@ -279,6 +292,20 @@ void handleMeadeMovement(String inCmd) {
279292
Serial.print("0");
280293
}
281294
}
295+
else if (inCmd[0] == 'G') {
296+
// Guide pulse
297+
// 012345678901
298+
// :MGd0403
299+
if (inCmd.length() == 6) {
300+
byte direction = EAST;
301+
if (inCmd[1] == 'N') direction = NORTH;
302+
else if (inCmd[1] == 'S') direction = SOUTH;
303+
else if (inCmd[1] == 'E') direction = EAST;
304+
else if (inCmd[1] == 'W') direction = WEST;
305+
int duration = (inCmd[2] - '0') * 1000 + (inCmd[3] - '0') * 100 + (inCmd[4] - '0') * 10 + (inCmd[5] - '0');
306+
mount.guidePulse(direction, duration);
307+
}
308+
}
282309
}
283310

284311
/////////////////////////////

0 commit comments

Comments
 (0)