Skip to content

Commit 0a68601

Browse files
V1.6.54 - Updates
- Changed Sync command on Mount to sync both coordinates at the same time, since individual syncs cause issues (related to flipping). - Go Home command is now asynchronous.
1 parent 895bec5 commit 0a68601

File tree

7 files changed

+59
-59
lines changed

7 files changed

+59
-59
lines changed

Software/Arduino code/OpenAstroTracker/MeadeCommandProcessor.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,7 @@ String MeadeCommandProcessor::handleMeadeGetInfo(String inCmd) {
345345
/////////////////////////////
346346
String MeadeCommandProcessor::handleMeadeSyncControl(String inCmd) {
347347
if (inCmd[0] == 'M') {
348-
_mount->syncDEC(_mount->targetDEC().getHours(), _mount->targetDEC().getMinutes(), _mount->targetDEC().getSeconds());
349-
_mount->syncRA(_mount->targetRA().getHours(), _mount->targetRA().getMinutes(), _mount->targetRA().getSeconds());
348+
_mount->syncPosition(_mount->targetRA().getHours(), _mount->targetRA().getMinutes(), _mount->targetRA().getSeconds(), _mount->targetDEC().getHours(), _mount->targetDEC().getMinutes(), _mount->targetDEC().getSeconds());
350349
return "NONE#";
351350
}
352351

@@ -429,8 +428,7 @@ String MeadeCommandProcessor::handleMeadeSetInfo(String inCmd) {
429428
int sgn = inCmd[1] == '+' ? 1 : -1;
430429
if ((inCmd[4] == '*') && (inCmd[7] == ':') && (inCmd[10] == '.') && (inCmd[13] == ':') && (inCmd[16] == ':')) {
431430
int deg = inCmd.substring(2, 4).toInt();
432-
_mount->syncDEC(sgn * deg + (NORTHERN_HEMISPHERE ? -90 : 90), inCmd.substring(5, 7).toInt(), inCmd.substring(8, 10).toInt());
433-
_mount->syncRA(inCmd.substring(11, 13).toInt(), inCmd.substring(14, 16).toInt(), inCmd.substring(17, 19).toInt());
431+
_mount->syncPosition(inCmd.substring(11, 13).toInt(), inCmd.substring(14, 16).toInt(), inCmd.substring(17, 19).toInt(),sgn * deg + (NORTHERN_HEMISPHERE ? -90 : 90), inCmd.substring(5, 7).toInt(), inCmd.substring(8, 10).toInt());
434432
return "1";
435433
}
436434
else {
@@ -527,7 +525,7 @@ String MeadeCommandProcessor::handleMeadeHome(String inCmd) {
527525
_mount->park();
528526
}
529527
else if (inCmd[0] == 'F') { // Home
530-
_mount->goHome(true);
528+
_mount->goHome();
531529
}
532530
else if (inCmd[0] == 'U') { // Unpark
533531
_mount->startSlewing(TRACKING);

Software/Arduino code/OpenAstroTracker/Mount.cpp

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ void Mount::setHA(const DayTime& haTime) {
288288
const DayTime Mount::HA() const {
289289
#ifdef DEBUG_MODE
290290
logv("Mount: Get HA.");
291-
logv("Mount: Polaris adjust: %d:%d:%d", PolarisRAHour,PolarisRAMinute, PolarisRASecond);
291+
logv("Mount: Polaris adjust: %d:%d:%d", PolarisRAHour, PolarisRAMinute, PolarisRASecond);
292292
#endif
293293
DayTime ha = _LST;
294294
#ifdef DEBUG_MODE
@@ -382,39 +382,20 @@ const DegreeTime Mount::currentDEC() const {
382382

383383
/////////////////////////////////
384384
//
385-
// syncRA
385+
// syncPosition
386386
//
387387
/////////////////////////////////
388-
// Set the current RA position to be the given time. We do this by adjusting HA by the
389-
// difference between the current RA and the RA that we were told we were actually at.
390-
void Mount::syncRA(int hour, int minute, int second) {
388+
// Set the current RA and DEC position to be the given coordinate. We do this by settign the stepper motor coordinate
389+
// to be at the calculated positions (that they would be if we were slewing there).
390+
void Mount::syncPosition(int raHour, int raMinute, int raSecond, int decDegree, int decMinute, int decSecond)
391+
{
391392
// Given the display RA coordinates...
392-
DayTime newRA = DayTime(hour, minute, second);
393-
394-
// Calculate the difference between the new system RA and the current system RA
395-
DayTime deltaRA = DayTime(newRA);
396-
deltaRA.subtractTime(currentRA());
397-
398-
// Now add this difference to HA.
399-
DayTime newHA = DayTime(HA());
400-
newHA.addTime(deltaRA);
401-
setHA(newHA);
393+
DayTime newRA = DayTime(raHour, raMinute, raSecond);
394+
DayTime newDEC = DayTime(decDegree, decMinute, decSecond);
402395

403396
float targetRA, targetDEC;
404397
calculateRAandDECSteppers(targetRA, targetDEC);
405398
_stepperRA->setCurrentPosition(targetRA);
406-
}
407-
408-
/////////////////////////////////
409-
//
410-
// syncDEC
411-
//
412-
/////////////////////////////////
413-
// Set the current DEC position to be the given degrees (which are 0 .. -180 for Northern Hemisphere)
414-
void Mount::syncDEC(int degree, int minute, int second) {
415-
_targetDEC = DegreeTime(degree, minute, second);;
416-
float targetRA, targetDEC;
417-
calculateRAandDECSteppers(targetRA, targetDEC);
418399
_stepperDEC->setCurrentPosition(targetDEC);
419400
}
420401

@@ -623,20 +604,13 @@ void Mount::park() {
623604
//
624605
// goHome
625606
//
626-
// Synchronously moves mount to home position and
627-
// sets Tracking mode according to argument
607+
// Synchronously moves mount to home position
628608
/////////////////////////////////
629-
void Mount::goHome(bool tracking)
609+
void Mount::goHome()
630610
{
631611
stopGuiding();
632-
stopSlewing(TRACKING);
633612
setTargetToHome();
634613
startSlewingToTarget();
635-
waitUntilStopped(ALL_DIRECTIONS);
636-
setHome();
637-
if (tracking) {
638-
startSlewing(TRACKING);
639-
}
640614
}
641615

642616
/////////////////////////////////
@@ -714,7 +688,7 @@ String Mount::getStatusString() {
714688
else if (_mountStatus & STATUS_SLEWING_MANUAL) {
715689
status = "ManualSlew,";
716690
}
717-
else if (slewStatus()& SLEWING_TRACKING){
691+
else if (slewStatus() & SLEWING_TRACKING) {
718692
status = "Tracking,";
719693
}
720694
}
@@ -1251,7 +1225,7 @@ void Mount::displayStepperPosition() {
12511225
_lcdMenu->printMenu(scratchBuffer);
12521226
}
12531227
#else
1254-
sprintf(scratchBuffer, "R%s D%s", RAString(COMPACT_STRING | CURRENT_STRING).c_str(), DECString(COMPACT_STRING | CURRENT_STRING).c_str());
1228+
sprintf(scratchBuffer, "R%s D%s", RAString(COMPACT_STRING | CURRENT_STRING).c_str(), DECString(COMPACT_STRING | CURRENT_STRING).c_str());
12551229
_lcdMenu->setCursor(0, 1);
12561230
_lcdMenu->printMenu(scratchBuffer);
12571231
#endif

Software/Arduino code/OpenAstroTracker/Mount.hpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,8 @@ class Mount {
7979
// Get current DEC value.
8080
const DegreeTime currentDEC() const;
8181

82-
// Set the current RA position to be the given time
83-
void syncRA(int hour, int minute, int second);
84-
85-
// Set the current DEC position to be the given degrees
86-
void syncDEC(int degree, int minute, int second);
87-
82+
// Set the current RA and DEC position to be the given coordinates
83+
void syncPosition(int raHour, int raMinute, int raSecond, int decDegree, int decMinute, int decSecond);
8884

8985
// Calculates movement parameters and program steppers to move
9086
// there. Must call loop() frequently to actually move.
@@ -121,8 +117,8 @@ class Mount {
121117
// Set RA and DEC to the home position
122118
void setTargetToHome();
123119

124-
// Synchronously slews the mount to the home position and sets tracking to argument.
125-
void goHome(bool tracking);
120+
// Asynchronously slews the mount to the home position
121+
void goHome();
126122

127123
// Set the current stepper positions to be home.
128124
void setHome();

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

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

Software/Arduino code/OpenAstroTracker/a_inits.ino

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,42 @@
2525

2626
// DEC Motor pins
2727
#define DECmotorPin1 D5 // IN1 auf ULN2003 driver 2
28-
#define DECmotorPin2 D7 // IN2 auf ULN2003 driver 2
2928
#define DECmotorPin3 D6 // IN3 auf ULN2003 driver 2
29+
#define DECmotorPin2 D7 // IN2 auf ULN2003 driver 2
3030
#define DECmotorPin4 D8 // IN4 auf ULN2003 driver 2
3131

3232
// ST4 Input Pins - TODO.
3333
#define st4North SD0
3434
#define st4South SD1
3535
#define st4West SD2
3636
#define st4East SD3
37+
#endif
3738

38-
#else // normal Arduino Mapping
39+
#ifdef __AVR_ATmega328P__ // normal Arduino Mapping
3940
#define RAmotorPin1 2 // IN1 auf ULN2003 driver 1 // 2 / 22
4041
#define RAmotorPin3 3 // IN2 auf ULN2003 driver 1 // 3 / 24
4142
#define RAmotorPin2 11 // IN3 auf ULN2003 driver 1 // 11 / 26
4243
#define RAmotorPin4 12 // IN4 auf ULN2003 driver 1 // 12 / 28
4344

4445
// DEC Motor pins
4546
#define DECmotorPin1 15 // IN1 auf ULN2003 driver 2
46-
#define DECmotorPin2 17 // IN2 auf ULN2003 driver 2
4747
#define DECmotorPin3 16 // IN3 auf ULN2003 driver 2
48+
#define DECmotorPin2 17 // IN2 auf ULN2003 driver 2
4849
#define DECmotorPin4 18 // IN4 auf ULN2003 driver 2
4950
#endif
5051

52+
#ifdef __AVR_ATmega2560__ // Arduino Mega
53+
#define RAmotorPin1 22 // IN1 auf ULN2003 driver 1 // 2 / 22
54+
#define RAmotorPin3 24 // IN2 auf ULN2003 driver 1 // 3 / 24
55+
#define RAmotorPin2 26 // IN3 auf ULN2003 driver 1 // 11 / 26
56+
#define RAmotorPin4 28 // IN4 auf ULN2003 driver 1 // 12 / 28
57+
58+
#define DECmotorPin1 30 // IN1 auf ULN2003 driver 2
59+
#define DECmotorPin3 32 // IN3 auf ULN2003 driver 2
60+
#define DECmotorPin2 34 // IN2 auf ULN2003 driver 2
61+
#define DECmotorPin4 36 // IN4 auf ULN2003 driver 2
62+
#endif
63+
5164
// Menu IDs
5265
#define RA_Menu 1
5366
#define DEC_Menu 2

Software/OATMobile/OATCommunications/TelescopeCommandHandlers/OatmealTelescopeCommandHandlers.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,24 @@ public async Task<bool> Slew(TelescopePosition position) {
122122
var result = await SendCommand(string.Format(":Sd{0}{1:00}*{2:00}:{3:00}#,#", sign, deg, min, sec));
123123
if (!result.Success || result.Data != "1") return false;
124124
FloatToHMS(Math.Abs(position.RightAscension), out hour, out min, out sec);
125-
await SendCommand(string.Format(":Sr{0:00}:{1:00}:{2:00}#,#", hour, min, sec));
125+
result = await SendCommand(string.Format(":Sr{0:00}:{1:00}:{2:00}#,#", hour, min, sec));
126126
if (!result.Success || result.Data != "1") return false;
127-
await SendCommand($":MS#");
127+
result = await SendCommand($":MS#");
128128
return result.Success;
129129
}
130130

131-
public Task<bool> Sync(TelescopePosition position) {
132-
throw new NotImplementedException();
131+
public async Task<bool> Sync(TelescopePosition position) {
132+
int deg, hour, min, sec;
133+
134+
FloatToHMS(Math.Abs(position.Declination), out deg, out min, out sec);
135+
string sign = position.Declination < 0 ? "-" : "+";
136+
var result = await SendCommand(string.Format(":Sd{0}{1:00}*{2:00}:{3:00}#,#", sign, deg, min, sec));
137+
if (!result.Success || result.Data != "1") return false;
138+
FloatToHMS(Math.Abs(position.RightAscension), out hour, out min, out sec);
139+
result = await SendCommand(string.Format(":Sr{0:00}:{1:00}:{2:00}#,#", hour, min, sec));
140+
if (!result.Success || result.Data != "1") return false;
141+
result = await SendCommand($":CM#");
142+
return result.Success;
133143
}
134144

135145
public async Task<bool> GoHome() {

Software/OpenAstroTracker ASCOM/OATControl/ViewModels/MountVM.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public class MountVM : ViewModelBase
6868
DelegateCommand _chooseScopeCommand;
6969
DelegateCommand _connectScopeCommand;
7070
DelegateCommand _slewToTargetCommand;
71+
DelegateCommand _syncToTargetCommand;
7172
DelegateCommand _startSlewingCommand;
7273
DelegateCommand _stopSlewingCommand;
7374
DelegateCommand _homeCommand;
@@ -102,6 +103,7 @@ public MountVM()
102103
_chooseScopeCommand = new DelegateCommand(() => OnChooseTelescope());
103104
_connectScopeCommand = new DelegateCommand(() => OnConnectToTelescope(), () => _oatMount != null);
104105
_slewToTargetCommand = new DelegateCommand(async () => await OnSlewToTarget(), () => MountConnected);
106+
_syncToTargetCommand = new DelegateCommand(async () => await OnSyncToTarget(), () => MountConnected);
105107
_startSlewingCommand = new DelegateCommand(async s => await OnStartSlewing(s.ToString()), () => MountConnected);
106108
_stopSlewingCommand = new DelegateCommand(async () => await OnStopSlewing('a'), () => MountConnected);
107109
_homeCommand = new DelegateCommand(async () => await OnHome(), () => MountConnected);
@@ -327,6 +329,11 @@ private async Task OnSlewToTarget()
327329
await _oatMount.Slew(new TelescopePosition(1.0 * TargetRASecond / 3600.0 + 1.0 * TargetRAMinute / 60.0 + TargetRAHour, 1.0 * TargetDECSecond / 3600.0 + 1.0 * TargetDECMinute / 60.0 + TargetDECDegree, Epoch.JNOW));
328330
}
329331

332+
private async Task OnSyncToTarget()
333+
{
334+
await _oatMount.Sync(new TelescopePosition(1.0 * TargetRASecond / 3600.0 + 1.0 * TargetRAMinute / 60.0 + TargetRAHour, 1.0 * TargetDECSecond / 3600.0 + 1.0 * TargetDECMinute / 60.0 + TargetDECDegree, Epoch.JNOW));
335+
}
336+
330337
private void FloatToHMS(double val, out int h, out int m, out int s)
331338
{
332339
h = (int)Math.Floor(val);
@@ -450,6 +457,7 @@ private void RequeryCommands()
450457
{
451458
_connectScopeCommand.Requery();
452459
_slewToTargetCommand.Requery();
460+
_syncToTargetCommand.Requery();
453461
_startSlewingCommand.Requery();
454462
_stopSlewingCommand.Requery();
455463
_homeCommand.Requery();
@@ -533,6 +541,7 @@ private void OnAdjustTarget(string command)
533541
public ICommand ChooseScopeCommand { get { return _chooseScopeCommand; } }
534542
public ICommand ConnectScopeCommand { get { return _connectScopeCommand; } }
535543
public ICommand SlewToTargetCommand { get { return _slewToTargetCommand; } }
544+
public ICommand SyncToTargetCommand { get { return _syncToTargetCommand; } }
536545
public ICommand StartSlewingCommand { get { return _startSlewingCommand; } }
537546
public ICommand StopSlewingCommand { get { return _stopSlewingCommand; } }
538547
public ICommand HomeCommand { get { return _homeCommand; } }

0 commit comments

Comments
 (0)