Skip to content

Commit 0dc3ea6

Browse files
V1.7.00 - Updates
- Southern hemisphere support is now working correctly. - Swapped DEC motor pins 2 and 3 for ESP8266.
1 parent 99bfe2f commit 0dc3ea6

File tree

6 files changed

+59
-38
lines changed

6 files changed

+59
-38
lines changed

Software/Arduino code/OpenAstroTracker/DayTime.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,21 +219,25 @@ int DegreeTime::getDegrees() {
219219
}
220220

221221
int DegreeTime::getPrintDegrees() const {
222-
return NORTHERN_HEMISPHERE ? hours + 90 : hours - 90;
222+
return NORTHERN_HEMISPHERE ? hours + 90 : -90 - hours;
223223
}
224224

225225
float DegreeTime::getTotalDegrees() const {
226226
return getTotalHours();
227227
}
228228

229229
void DegreeTime::checkHours() {
230-
if (NORTHERN_HEMISPHERE) {
231-
if (hours > 0) hours = 0;
232-
if (hours < -180) hours = -180;
230+
if (hours > 0) {
231+
#ifdef DEBUG_MODE
232+
logv("CheckHours: Degrees is more than 0, clamping");
233+
#endif
234+
hours = 0;
233235
}
234-
else {
235-
if (hours > 180) hours = 180;
236-
if (hours < 0) hours = 0;
236+
if (hours < -180) {
237+
#ifdef DEBUG_MODE
238+
logv("CheckHours: Degrees is less than -180, clamping");
239+
#endif
240+
hours = -180;
237241
}
238242
}
239243

@@ -280,7 +284,7 @@ const char* DegreeTime::ToString() const
280284
*p++ = '0' + (secs % 10);
281285
*p++ = ' ';
282286
*p++ = '(';
283-
strcpy(p, String(NORTHERN_HEMISPHERE ? getTotalHours() + 90 : getTotalHours() - 90, 4).c_str());
287+
strcpy(p, String(NORTHERN_HEMISPHERE ? getTotalHours() + 90 : -90 - getTotalHours(), 4).c_str());
284288
strcat(p, ")");
285289

286290
return achBufDeg;

Software/Arduino code/OpenAstroTracker/Globals.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@ extern int PolarisRAMinute;
2020
extern int PolarisRASecond;
2121
// Comment this out to save some code space
2222
// #define DEBUG_MODE
23-
23+
#ifdef DEBUG_MODE
24+
// #define SEND_PERIODIC_UPDATES
25+
#endif
2426
// Uncomment to run a key diagnostic. No tracker functions are on at all.
2527
// #define LCD_BUTTON_TEST
2628

2729
// Uncomment to reverse the direction of RA motor
28-
//#define INVERT_RA_DIR
30+
// #define INVERT_RA_DIR
2931

3032
// Uncomment to reverse the direction of DEC motor
31-
//#define INVERT_DEC_DIR
33+
// #define INVERT_DEC_DIR
3234

3335
////////////////////////////////////////////////////////////////
3436
//
@@ -87,15 +89,13 @@ extern int PolarisRASecond;
8789
// Uncomment to support CAL menu, allowing you to calibrate various things
8890
#define SUPPORT_CALIBRATION
8991

90-
#endif
91-
// Uncomment to support INFO menu that displays various pieces of information about the mount.
92-
// #define SUPPORT_INFO_DISPLAY
93-
94-
// Uncomment to support Serial Meade LX200 protocol support
95-
// #define SUPPORT_SERIAL_CONTROL
92+
// Uncomment to support INFO menu that displays various pieces of information about the mount.
93+
// #define SUPPORT_INFO_DISPLAY
9694

97-
// If we are making a headleass (no screen, no keyboard) client, always enable Serial.
98-
#ifdef HEADLESS_CLIENT
95+
// Uncomment to support Serial Meade LX200 protocol support
96+
// #define SUPPORT_SERIAL_CONTROL
97+
#else
98+
// If we are making a headleass (no screen, no keyboard) client, always enable Serial.
9999
#define SUPPORT_SERIAL_CONTROL
100100
#endif
101101

Software/Arduino code/OpenAstroTracker/MeadeCommandProcessor.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,17 @@ String MeadeCommandProcessor::handleMeadeSetInfo(String inCmd) {
466466
int sgn = inCmd[1] == '+' ? 1 : -1;
467467
if ((inCmd[4] == '*') && (inCmd[7] == ':'))
468468
{
469-
int deg = inCmd.substring(2, 4).toInt();
470-
_mount->targetDEC().set(sgn * deg + (NORTHERN_HEMISPHERE ? -90 : 90), inCmd.substring(5, 7).toInt(), inCmd.substring(8, 10).toInt());
469+
int deg = sgn * inCmd.substring(2, 4).toInt();
470+
if (NORTHERN_HEMISPHERE) {
471+
deg = deg - 90;
472+
}
473+
else {
474+
deg = -90 - deg;
475+
}
476+
_mount->targetDEC().set(deg, inCmd.substring(5, 7).toInt(), inCmd.substring(8, 10).toInt());
477+
#ifdef DEBUG_MODE
478+
logv("MeadeSetInfo: Received Target DEC: %s", _mount->targetDEC().ToString());
479+
#endif
471480
return "1";
472481
}
473482
else {
@@ -483,6 +492,9 @@ String MeadeCommandProcessor::handleMeadeSetInfo(String inCmd) {
483492
if ((inCmd[3] == ':') && (inCmd[6] == ':'))
484493
{
485494
_mount->targetRA().set(inCmd.substring(1, 3).toInt(), inCmd.substring(4, 6).toInt(), inCmd.substring(7, 9).toInt());
495+
#ifdef DEBUG_MODE
496+
logv("MeadeSetInfo: Received Target RA: %s", _mount->targetRA().ToString());
497+
#endif
486498
return "1";
487499
}
488500
else {
@@ -788,6 +800,7 @@ String MeadeCommandProcessor::handleMeadeSetSlewRate(String inCmd) {
788800
case 'C': // Center - 2nd Slowest
789801
case 'G': // Guide - Slowest
790802
default:
803+
break;
791804
}
792805
return "";
793806
}

Software/Arduino code/OpenAstroTracker/Mount.cpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -373,15 +373,15 @@ void Mount::setLST(const DayTime& lst) {
373373
// setLatitude
374374
//
375375
/////////////////////////////////
376-
void Mount::setLatitude(float lat) {
376+
void Mount::setLatitude(float lat) {
377377
_latitude = lat;
378378
}
379379
/////////////////////////////////
380380
//
381381
// setLongitude
382382
//
383383
/////////////////////////////////
384-
void Mount::setLongitude(float lon) {
384+
void Mount::setLongitude(float lon) {
385385
_longitude = lon;
386386
}
387387

@@ -391,7 +391,7 @@ void Mount::setLongitude(float lon) {
391391
//
392392
/////////////////////////////////
393393
const float Mount::latitude() const {
394-
return _latitude ;
394+
return _latitude;
395395
}
396396
/////////////////////////////////
397397
//
@@ -443,8 +443,8 @@ const DayTime Mount::currentRA() const {
443443
logv("CurrentRA: POS (+zp) : %s", DayTime(hourPos).ToString());
444444
#endif
445445

446-
bool flipRA = NORTHERN_HEMISPHERE ?
447-
_stepperDEC->currentPosition() < 0
446+
bool flipRA = NORTHERN_HEMISPHERE ?
447+
_stepperDEC->currentPosition() < 0
448448
: _stepperDEC->currentPosition() > 0;
449449
if (flipRA)
450450
{
@@ -948,20 +948,21 @@ void Mount::startSlewing(int direction) {
948948
_mountStatus |= STATUS_TRACKING;
949949
}
950950
else {
951+
int sign = NORTHERN_HEMISPHERE ? 1 : -1;
951952
if (direction & NORTH) {
952-
_stepperDEC->moveTo(30000);
953+
_stepperDEC->moveTo(sign * 30000);
953954
_mountStatus |= STATUS_SLEWING;
954955
}
955956
if (direction & SOUTH) {
956-
_stepperDEC->moveTo(-30000);
957+
_stepperDEC->moveTo(-sign * 30000);
957958
_mountStatus |= STATUS_SLEWING;
958959
}
959960
if (direction & EAST) {
960-
_stepperRA->moveTo(-30000);
961+
_stepperRA->moveTo(-sign * 30000);
961962
_mountStatus |= STATUS_SLEWING;
962963
}
963964
if (direction & WEST) {
964-
_stepperRA->moveTo(30000);
965+
_stepperRA->moveTo(sign * 30000);
965966
_mountStatus |= STATUS_SLEWING;
966967
}
967968
}
@@ -1049,7 +1050,7 @@ void Mount::loop() {
10491050
bool decStillRunning = false;
10501051

10511052
unsigned long now = millis();
1052-
#ifdef DEBUG_MODE
1053+
#if defined DEBUG_MODE && defined SEND_PERIODIC_UPDATES
10531054
if (now - _lastMountPrint > 2000) {
10541055
Serial.println(getStatusString());
10551056
_lastMountPrint = now;
@@ -1280,8 +1281,11 @@ void Mount::calculateRAandDECSteppers(float& targetRA, float& targetDEC) {
12801281
#endif
12811282

12821283
float hourPos = raTarget.getTotalHours();
1284+
if (!NORTHERN_HEMISPHERE) {
1285+
hourPos += 12;
1286+
}
12831287
// Map [0 to 24] range to [-12 to +12] range
1284-
if (hourPos > 12) {
1288+
while (hourPos > 12) {
12851289
hourPos = hourPos - 24;
12861290
#ifdef DEBUG_MODE
12871291
logv("Mount::CalcSteppersIn: RA>12 so -24. New Target RA: %s, DEC: %s", DayTime(hourPos).ToString(), _targetDEC.ToString());
@@ -1460,7 +1464,7 @@ String Mount::DECString(byte type, byte active) {
14601464
#ifdef DEBUG_MODE
14611465
logv("DECString: TARGET!");
14621466
#endif
1463-
dec = DegreeTime(_targetDEC);
1467+
dec = _targetDEC;
14641468
}
14651469
else {
14661470
#ifdef DEBUG_MODE

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

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

Software/Arduino code/OpenAstroTracker/a_inits.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@
3636
// DEC Motor pins
3737
#ifdef INVERT_DEC_DIR
3838
#define DECmotorPin1 D5 // IN1 auf ULN2003 driver 2
39-
#define DECmotorPin2 D6 // IN2 auf ULN2003 driver 2
40-
#define DECmotorPin3 D7 // IN3 auf ULN2003 driver 2
39+
#define DECmotorPin3 D6 // IN3 auf ULN2003 driver 2
40+
#define DECmotorPin2 D7 // IN2 auf ULN2003 driver 2
4141
#define DECmotorPin4 D8 // IN4 auf ULN2003 driver 2
4242
#else
4343
#define DECmotorPin1 D8 // IN1 auf ULN2003 driver 2
44-
#define DECmotorPin2 D7 // IN2 auf ULN2003 driver 2
45-
#define DECmotorPin3 D6 // IN3 auf ULN2003 driver 2
44+
#define DECmotorPin3 D7 // IN3 auf ULN2003 driver 2
45+
#define DECmotorPin2 D6 // IN2 auf ULN2003 driver 2
4646
#define DECmotorPin4 D5 // IN4 auf ULN2003 driver 2
4747
#endif
4848

0 commit comments

Comments
 (0)