Skip to content

Commit d98c9cc

Browse files
V1.6.23 - Updates
- Added park() function to mount that stops current slew and starts slew to mount parking position/home. Once reached, all motors stop. Use HOME to restart tracking.
1 parent 2509aba commit d98c9cc

File tree

4 files changed

+84
-48
lines changed

4 files changed

+84
-48
lines changed

Software/Arduino code/OpenAstroTracker/Mount.cpp

Lines changed: 78 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#define STATUS_SLEWING_TO_TARGET B00000100
88
#define STATUS_SLEWING_FREE B00000010
99
#define STATUS_TRACKING B00001000
10+
#define STATUS_PARKING B00010000
1011

1112
// slewingStatus()
1213
#define SLEWING_DEC B00000010
@@ -273,6 +274,20 @@ void Mount::startSlewingToTarget() {
273274
_totalRAMove = 1.0f * _stepperRA->distanceToGo();
274275
}
275276

277+
/////////////////////////////////
278+
//
279+
// park
280+
//
281+
/////////////////////////////////
282+
void Mount::park()
283+
{
284+
stopSlewing(ALL_DIRECTIONS | TRACKING);
285+
waitUntilStopped(ALL_DIRECTIONS);
286+
setTargetToHome();
287+
startSlewingToTarget();
288+
_mountStatus |= STATUS_PARKING;
289+
}
290+
276291
/////////////////////////////////
277292
//
278293
// mountStatus
@@ -290,19 +305,24 @@ byte Mount::mountStatus() {
290305
/////////////////////////////////
291306
String Mount::mountStatusString() {
292307
if (_mountStatus == STATUS_PARKED) {
293-
return "PRKD";
308+
return "PARKED";
294309
}
295310
String disp = "";
296-
if (_mountStatus & STATUS_TRACKING) disp += "TRK ";
297-
if (_mountStatus & STATUS_SLEWING) disp += "SLW ";
298-
if (_mountStatus & STATUS_SLEWING_TO_TARGET) disp += "2TRG ";
299-
if (_mountStatus & STATUS_SLEWING_FREE) disp += "FR ";
300-
301-
if (_mountStatus & STATUS_SLEWING) {
302-
byte slew = slewStatus();
303-
if (slew & SLEWING_RA) disp += " SRA ";
304-
if (slew & SLEWING_DEC) disp += " SDEC ";
305-
if (slew & SLEWING_TRACKING) disp += " STRK ";
311+
if (_mountStatus & STATUS_PARKING) {
312+
disp = "PARKNG ";
313+
}
314+
else {
315+
if (_mountStatus & STATUS_TRACKING) disp += "TRK ";
316+
if (_mountStatus & STATUS_SLEWING) disp += "SLW ";
317+
if (_mountStatus & STATUS_SLEWING_TO_TARGET) disp += "2TRG ";
318+
if (_mountStatus & STATUS_SLEWING_FREE) disp += "FR ";
319+
320+
if (_mountStatus & STATUS_SLEWING) {
321+
byte slew = slewStatus();
322+
if (slew & SLEWING_RA) disp += " SRA ";
323+
if (slew & SLEWING_DEC) disp += " SDEC ";
324+
if (slew & SLEWING_TRACKING) disp += " STRK ";
325+
}
306326
}
307327

308328
disp += " RA:" + String(_stepperRA->currentPosition());
@@ -337,6 +357,7 @@ byte Mount::slewStatus() {
337357
//
338358
/////////////////////////////////
339359
bool Mount::isSlewingDEC() {
360+
if (isParking()) return true;
340361
return (slewStatus() & SLEWING_DEC) != 0;
341362
}
342363

@@ -346,6 +367,7 @@ bool Mount::isSlewingDEC() {
346367
//
347368
/////////////////////////////////
348369
bool Mount::isSlewingRA() {
370+
if (isParking()) return true;
349371
return (slewStatus() & SLEWING_RA) != 0;
350372
}
351373

@@ -355,6 +377,7 @@ bool Mount::isSlewingRA() {
355377
//
356378
/////////////////////////////////
357379
bool Mount::isSlewingRAorDEC() {
380+
if (isParking()) return true;
358381
return (slewStatus() & (SLEWING_DEC | SLEWING_RA)) != 0;
359382
}
360383

@@ -364,6 +387,7 @@ bool Mount::isSlewingRAorDEC() {
364387
//
365388
/////////////////////////////////
366389
bool Mount::isSlewingIdle() {
390+
if (isParking()) return false;
367391
return (slewStatus() & (SLEWING_DEC | SLEWING_RA)) == 0;
368392
}
369393

@@ -382,38 +406,51 @@ bool Mount::isSlewingTRK() {
382406
//
383407
/////////////////////////////////
384408
bool Mount::isParked() {
385-
return slewStatus() == NOT_SLEWING;
409+
return (slewStatus() == NOT_SLEWING) && (_mountStatus == STATUS_PARKED);
410+
}
411+
412+
/////////////////////////////////
413+
//
414+
// isParking
415+
//
416+
/////////////////////////////////
417+
bool Mount::isParking() {
418+
return _mountStatus & STATUS_PARKING;
386419
}
387420

388421
/////////////////////////////////
389422
//
390423
// startSlewing
391424
//
392-
// Starts manual slewing in one of eight directions or tracking
425+
// Starts manual slewing in one of eight directions or
426+
// tracking, but only if not currently parking!
393427
/////////////////////////////////
394428
void Mount::startSlewing(int direction) {
395-
if (direction & TRACKING) {
396-
_stepperTRK->setSpeed(_trackingSpeed);
429+
if (!isParking())
430+
{
431+
if (direction & TRACKING) {
432+
_stepperTRK->setSpeed(_trackingSpeed);
397433

398-
// Turn on tracking
399-
_mountStatus |= STATUS_TRACKING;
400-
}
401-
else {
402-
if (direction & NORTH) {
403-
_stepperDEC->moveTo(30000);
404-
_mountStatus |= STATUS_SLEWING;
405-
}
406-
if (direction & SOUTH ) {
407-
_stepperDEC->moveTo(-30000);
408-
_mountStatus |= STATUS_SLEWING;
409-
}
410-
if (direction & EAST ) {
411-
_stepperRA->moveTo(-30000);
412-
_mountStatus |= STATUS_SLEWING;
434+
// Turn on tracking
435+
_mountStatus |= STATUS_TRACKING;
413436
}
414-
if (direction & WEST) {
415-
_stepperRA->moveTo(30000);
416-
_mountStatus |= STATUS_SLEWING;
437+
else {
438+
if (direction & NORTH) {
439+
_stepperDEC->moveTo(30000);
440+
_mountStatus |= STATUS_SLEWING;
441+
}
442+
if (direction & SOUTH ) {
443+
_stepperDEC->moveTo(-30000);
444+
_mountStatus |= STATUS_SLEWING;
445+
}
446+
if (direction & EAST ) {
447+
_stepperRA->moveTo(-30000);
448+
_mountStatus |= STATUS_SLEWING;
449+
}
450+
if (direction & WEST) {
451+
_stepperRA->moveTo(30000);
452+
_mountStatus |= STATUS_SLEWING;
453+
}
417454
}
418455
}
419456
}
@@ -450,7 +487,6 @@ void Mount::waitUntilStopped(byte direction) {
450487
|| ((direction & (NORTH | SOUTH)) && _stepperDEC->isRunning())
451488
|| ((direction & TRACKING) && (((_mountStatus & STATUS_TRACKING) == 0) && _stepperTRK->isRunning()))
452489
) {
453-
// //Serial.print("W4Stp: ");
454490
loop();
455491
}
456492
}
@@ -536,6 +572,14 @@ void Mount::loop() {
536572
// Mount is at Target!
537573
_currentRA = _targetRA;
538574
_currentDEC = _targetDEC;
575+
576+
// If we we're parking, we just reached home. Clear the flag, reset the motors and stop tracking.
577+
if (isParking()) {
578+
_mountStatus &= ~STATUS_PARKING;
579+
stopSlewing(TRACKING);
580+
setHome();
581+
}
582+
539583
_currentDECStepperPosition = _stepperDEC->currentPosition();
540584
_currentRAStepperPosition = _stepperRA->currentPosition();
541585
_totalDECMove = _totalRAMove = 0;
@@ -560,7 +604,6 @@ void Mount::setHome() {
560604
_stepperRA->setCurrentPosition(0);
561605
_stepperDEC->setCurrentPosition(0);
562606
_stepperTRK->setCurrentPosition(0);
563-
startSlewing(TRACKING);
564607
}
565608

566609
/////////////////////////////////

Software/Arduino code/OpenAstroTracker/Mount.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class Mount {
7979
bool isSlewingIdle();
8080
bool isSlewingTRK();
8181
bool isParked();
82+
bool isParking();
8283

8384
// Starts manual slewing in one of eight directions or tracking
8485
void startSlewing(int direction);
@@ -110,6 +111,9 @@ class Mount {
110111
// Set the current stepper positions to be home.
111112
void setHome();
112113

114+
// Asynchronously parks the mount. Moves to the home position and stops all motors.
115+
void park();
116+
113117
// Return a string of DEC in the given format. For LCDSTRING, active determines where the cursor is
114118
String DECString(byte type, byte active = 0);
115119

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.22";
19+
String version = "V1.6.23";
2020

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

Software/Arduino code/OpenAstroTracker/f_serial.ino

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,6 @@
9696
// Returns: 1
9797
//
9898
// -- MOVEMENT Extensions --
99-
// :MSy#
100-
// Slew to Target Synchronously
101-
// This slews the scope to the target RA and DEC coordinates before returning.
102-
// Returns: 1
10399
//
104100
// :MTs#
105101
// Set Tracking mode
@@ -266,9 +262,6 @@ void handleMeadeSetInfo(String inCmd) {
266262
void handleMeadeMovement(String inCmd) {
267263
if (inCmd[0] == 'S') {
268264
mount.startSlewingToTarget();
269-
if ((inCmd.length() > 1) && (inCmd[1] == 'y')) {
270-
mount.waitUntilStopped(ALL_DIRECTIONS); // Excludes TRK
271-
}
272265
Serial.print("1");
273266
}
274267
else if (inCmd[0] == 'T') {
@@ -293,11 +286,7 @@ void handleMeadeMovement(String inCmd) {
293286
/////////////////////////////
294287
void handleMeadeHome(String inCmd) {
295288
if (inCmd[0] == 'P') { // Park
296-
mount.setTargetToHome();
297-
mount.startSlewingToTarget();
298-
mount.waitUntilStopped(ALL_DIRECTIONS);
299-
mount.setHome();
300-
mount.stopSlewing(TRACKING);
289+
mount.park();
301290
Serial.print("1");
302291
}
303292
else if (inCmd[0] == 'U') { // Unpark

0 commit comments

Comments
 (0)