Skip to content

Commit b9c7265

Browse files
V1.5.21 - Updates
- Updated and added more comments - Adjusted tracker speed for sidereal rate and adjusted for TRK stepper being half-stepped. - Moved the LCD screen into the LcdMenu class, so that devs use that to update the menu. Ensures support for special chars (arrows, degrees). - Moved functions file from b1 to b3, so that it knows about LcdMenu. - Consolidated RA and DEC output to one function (saves string space and ensure consistency). - Added support for LEFT and SELECT to change INFO display for RA and DEC from stepper units to time/degrees and toggle TRK speed and TRP steps. - Changed Meade command [:Qq#] to not stop steppers and [:Q#] to stop steppers. Both calls quit serial control mode.
1 parent a621a1b commit b9c7265

File tree

12 files changed

+129
-131
lines changed

12 files changed

+129
-131
lines changed

Software/Arduino code/OpenAstroTracker/OpenAstroTracker.ino

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
1515
=======================================================================================================================================
1616
*/
17-
String version = "V1.5.20";
17+
String version = "V1.5.21";
1818

1919
boolean north = true; // change this to 'false' if youre in the southern hemisphere
2020

2121
float speed = 1.000; // Use this value to slightly increase or decrese tracking speed. The values from the "CAL" menu will be added to this.
2222

23+
// The radius of the surface that the belt runs on (in V1 of the ring) was 168.24mm.
2324
// Belt moves 40mm for one stepper revolution (2mm pitch, 20 teeth).
2425
// RA wheel is 2 x PI x 168.24mm circumference = 1057.1mm
2526
// One RA revolution needs 26.43 (1057.1mm / 40mm) stepper revolutions
@@ -35,7 +36,7 @@ int RAStepsPerDegree = 300; // adjust this value to calibrate RA movement
3536
int DECStepsPerDegree = 161; // Number of steps needed to move DEC motor 1 degree.
3637

3738
// This is how many steps your 28BYJ-48 stepper needs for a full rotation. It is almost always 4096.
38-
// This code drives the steppers in halfstep mode
39+
// This code drives the steppers in halfstep mode for TRK and DEC, and full step for RA
3940
float StepsPerRevolution = 4096;
4041

4142
int RAspeed = 400; // You can change the speed and acceleration of the steppers here. Max. Speed = 600. High speeds tend to make
@@ -65,10 +66,10 @@ int s = 25;
6566
// The same could be done for the DEC coordinates but they dont change significantly for the next 5 years
6667

6768
// Comment this out to save some code space
68-
//#define DEBUG_MODE
69+
// #define DEBUG_MODE
6970

7071
// Uncomment this to support the heating menu
71-
//#define SUPPORT_HEATING
72+
// #define SUPPORT_HEATING
7273

7374
// Uncomment to run a key diagnostic
7475
// #define LCD_BUTTON_TEST

Software/Arduino code/OpenAstroTracker/a_inits.ino

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#define HALFSTEP 8
1010
#define FULLSTEP 4
1111

12-
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
1312
//SoftwareSerial BT(10,11);
1413

1514
// RA Motor pins
@@ -134,47 +133,12 @@ int RAheat = 0; // Are we heating the RA stepper?
134133
int DECheat = 0; // Are we heating the DEC stepper?
135134

136135
// Stellarium variables
137-
char current_RA[10];
138-
char current_DEC[12];
136+
char current_RA[16];
137+
char current_DEC[16];
139138
int HAh_save;
140139
int HAm_save;
141140
float slew_RA;
142141
float slew_DEC;
143142

144-
145-
// LCD Character bitmaps
146-
byte DegreesBitmap[8] = {
147-
B01100,
148-
B10010,
149-
B10010,
150-
B01100,
151-
B00000,
152-
B00000,
153-
B00000,
154-
B00000
155-
};
156-
157-
byte MinutesBitmap[] = {
158-
B10000,
159-
B10000,
160-
B10000,
161-
B00000,
162-
B00000,
163-
B00000,
164-
B00000,
165-
B00000
166-
};
167-
168-
byte SecondsBitmap[] = {
169-
B10100,
170-
B10100,
171-
B10100,
172-
B00000,
173-
B00000,
174-
B00000,
175-
B00000,
176-
B00000
177-
};
178-
179143
//debugging
180144
String inBT;

Software/Arduino code/OpenAstroTracker/b1_menu.ino

Lines changed: 56 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,32 @@ class LcdMenu {
4040
int _longestDisplay; // The number of characters in the longest menu item
4141
int _columns; // The number of columns in the LCD display
4242

43+
int _degrees = 1;
44+
int _minutes = 2;
4345
int _leftArrow = 3;
4446
int _rightArrow = 4;
4547
int _upArrow = 5;
4648
int _downArrow = 6;
4749

4850
public:
49-
// Create a new menu, using the given LCD screen and using the given number of LCD display columns
50-
LcdMenu(LiquidCrystal* lcd, int cols) {
51+
// Create a new menu, using the given number of LCD display columns and rows
52+
LcdMenu(int cols, int rows) {
53+
_lcd = new LiquidCrystal(8, 9, 4, 5, 6, 7);
54+
_lcd->begin(cols, rows);
55+
5156
_activeId = 0;
52-
_lcd = lcd;
5357
_firstItem = NULL;
5458
_lastItem = NULL;
5559
_longestDisplay = 0;
5660
_columns = cols;
57-
lcd->createChar(_leftArrow, LeftArr);
58-
lcd->createChar(_rightArrow, RightArr);
59-
lcd->createChar(_upArrow, UpArr);
60-
lcd->createChar(_downArrow, DownArr);
61+
62+
// Create special characters for degrees and arrows
63+
_lcd->createChar(_degrees, DegreesBitmap);
64+
_lcd->createChar(_minutes, MinutesBitmap);
65+
_lcd->createChar(_leftArrow, LeftArrowBitmap);
66+
_lcd->createChar(_rightArrow, RightArrowBitmap);
67+
_lcd->createChar(_upArrow, UpArrowBitmap);
68+
_lcd->createChar(_downArrow, DownArrowBitmap);
6169
}
6270

6371
// Find a menu item by its ID
@@ -169,6 +177,7 @@ class LcdMenu {
169177

170178
// Display the actual menu string
171179
String displayString = menuString.substring(offsetIntoString, offsetIntoString + _columns);
180+
172181
// Pad the end with spaces so the display is cleared when getting to the last item(s).
173182
while (displayString.length() < _columns) {
174183
displayString += " ";
@@ -187,17 +196,17 @@ class LcdMenu {
187196
leastCount++;
188197
if (*i == '>') {
189198
_lcd->write(_rightArrow);
190-
}
191-
else if (*i == '<') {
199+
} else if (*i == '<') {
192200
_lcd->write(_leftArrow);
193-
}
194-
else if (*i == '^') {
201+
} else if (*i == '^') {
195202
_lcd->write(_upArrow);
196-
}
197-
else if (*i == '~') {
203+
} else if (*i == '~') {
198204
_lcd->write(_downArrow);
199-
}
200-
else {
205+
} else if (*i == '@') {
206+
_lcd->write(_degrees);
207+
} else if (*i == '\'') {
208+
_lcd->write(_minutes);
209+
} else {
201210
_lcd->print(*i);
202211
}
203212
continue;
@@ -245,6 +254,12 @@ class LcdMenu {
245254
else if (line[i] == '~') {
246255
_lcd->write(_downArrow);
247256
}
257+
else if (line[i] == '@') {
258+
_lcd->write(_degrees);
259+
}
260+
else if (line[i] == '\'') {
261+
_lcd->write(_minutes);
262+
}
248263
else {
249264
_lcd->print(line[i]);
250265
}
@@ -258,7 +273,7 @@ class LcdMenu {
258273
}
259274

260275
// The right arrow bitmap
261-
byte RightArr[8] = {
276+
byte RightArrowBitmap[8] = {
262277
B00000,
263278
B01000,
264279
B01100,
@@ -270,7 +285,7 @@ class LcdMenu {
270285
};
271286

272287
// The left arrow bitmap
273-
byte LeftArr[8] = {
288+
byte LeftArrowBitmap[8] = {
274289
B00000,
275290
B00010,
276291
B00110,
@@ -281,7 +296,7 @@ class LcdMenu {
281296
B00000
282297
};
283298

284-
byte UpArr[8] = {
299+
byte UpArrowBitmap[8] = {
285300
B00100,
286301
B01110,
287302
B11111,
@@ -292,7 +307,7 @@ class LcdMenu {
292307
B00100
293308
};
294309

295-
byte DownArr[8] = {
310+
byte DownArrowBitmap[8] = {
296311
B000100,
297312
B000100,
298313
B000100,
@@ -302,4 +317,26 @@ class LcdMenu {
302317
B001110,
303318
B000100
304319
};
320+
321+
byte DegreesBitmap[8] = {
322+
B01100,
323+
B10010,
324+
B10010,
325+
B01100,
326+
B00000,
327+
B00000,
328+
B00000,
329+
B00000
330+
};
331+
332+
byte MinutesBitmap[8] = {
333+
B01000,
334+
B01000,
335+
B01000,
336+
B00000,
337+
B00000,
338+
B00000,
339+
B00000,
340+
B00000
341+
};
305342
};

Software/Arduino code/OpenAstroTracker/b0_functions.ino renamed to Software/Arduino code/OpenAstroTracker/b3_functions.ino

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ int adjustWrap(int current, int adjustBy, int minVal, int maxVal)
1515
{
1616
current += adjustBy;
1717
if (current > maxVal) current -= (maxVal + 1 - minVal);
18-
if (current < minVal) current += (maxVal + 1 - minVal
19-
);
18+
if (current < minVal) current += (maxVal + 1 - minVal);
2019
return current;
2120
}
2221

@@ -82,6 +81,9 @@ void logv(const char* input, ...) {
8281
va_end(argp);
8382

8483
}
84+
//String formatRA(DayTime ratime) {
85+
// return String(ratime.ToString());
86+
//}
8587

8688
String format(const char* input, ...) {
8789
va_list argp;
@@ -153,3 +155,23 @@ String formatArg(const char* input, va_list args) {
153155
return String(achBuffer);
154156
}
155157
#endif
158+
159+
String formatRA(DayTime* ratime, int act = -1); // The Arduino IDEs auto generation does not handle custom datatypes
160+
String formatRA(DayTime* ratime, int act = -1) {
161+
sprintf(current_RA, " %02dh %02dm %02ds", ratime->getHours(), ratime->getMinutes(), ratime->getSeconds());
162+
switch (act){
163+
case 0: current_RA[0]='>'; break;
164+
case 1: current_RA[4]='>'; break;
165+
case 2: current_RA[8]='>'; break;
166+
}
167+
return String(current_RA);
168+
}
169+
String formatDEC(int degree, int minute, int second, int act = -1) {
170+
sprintf(current_DEC, "%c%02d@ %02d' %02d\"", degree > 0 ? '+' : '-', int(fabs(degree)), minute, second);
171+
switch (act){
172+
case 0: current_DEC[0]='>'; break;
173+
case 1: current_DEC[4]='>'; break;
174+
case 2: current_DEC[8]='>'; break;
175+
}
176+
return String(current_DEC);
177+
}

Software/Arduino code/OpenAstroTracker/b_setup.ino

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
2-
// Create the menu variable
3-
LcdMenu lcdMenu(&lcd, 16);
1+
// Create the LCD menu variable and initialize the LCD (16x2 characters)
2+
LcdMenu lcdMenu(16, 2);
43

54
// Create the variables to track RA time, RA display time and HA time
65
DayTime RATime;
@@ -18,14 +17,6 @@ void setup() {
1817
log("Hello World!");
1918
#endif
2019

21-
// Initialize the LCD (16x2 characters)
22-
lcd.begin(16, 2);
23-
24-
// Create special characters for degrees, minutes, seconds
25-
lcd.createChar(0, DegreesBitmap);
26-
lcd.createChar(1, MinutesBitmap);
27-
lcd.createChar(2, SecondsBitmap);
28-
2920
// Not sure if this is neeeded
3021
pinMode(A1, OUTPUT);
3122
pinMode(A2, OUTPUT);
@@ -49,7 +40,7 @@ void setup() {
4940
HACorrection.set(HATime);
5041
HACorrection.addTime(-h, -m, -s);
5142
lastHAset = millis();
52-
43+
5344
#ifdef DEBUG_MODE
5445
logv("HATime = %s", HATime.ToString().c_str());
5546
#endif
@@ -68,10 +59,10 @@ void setup() {
6859
lcdMenu.addItem("INFO", Status_Menu);
6960

7061
// Show a splash screen
71-
lcd.setCursor(0, 0);
72-
lcd.print("OpenAstroTracker");
73-
lcd.setCursor(0, 1);
74-
lcd.print(" " + version);
62+
lcdMenu.setCursor(0, 0);
63+
lcdMenu.printMenu("OpenAstroTracker");
64+
lcdMenu.setCursor(0, 1);
65+
lcdMenu.printMenu(" " + version);
7566
delay(1750);
7667

7768
doCalculations();

Software/Arduino code/OpenAstroTracker/c5_calcStepperPos.ino

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,13 @@ void handleDECandRACalculations()
2929
float oldRA = moveRA;
3030
moveRA -= long(12.0f * stepsPerHour / 2);
3131
moveDEC = -moveDEC;
32-
//Serial.println(format("> %s HRPos: %f MoveRA: %f newMoveRA: %f RALimit: %f", RATime.ToString().c_str(), hourPos, oldRA, moveRA, RALimit));
3332
}
3433
// If we reach the limit in the negative direction...
3534
else if (moveRA < -RALimit) {
3635
// ... turn both RA and DEC axis around
3736
float oldRA = moveRA;
3837
moveRA += long(12.0f * stepsPerHour / 2);
3938
moveDEC = -moveDEC;
40-
//Serial.println(format("< %s HRPos: %f MoveRA: %f newMoveRA: %f RALimit: %f", RATime.ToString().c_str(), hourPos, oldRA, moveRA, RALimit));
41-
} else {
42-
//Serial.println(format("= %s HRPos: %f MoveRA: %f newMoveRA: %f RALimit: %f", RATime.ToString().c_str(), hourPos, moveRA, moveRA, RALimit));
4339
}
4440

4541
float targetRA = clamp(-moveRA, -RAStepperLimit, RAStepperLimit);
@@ -70,8 +66,10 @@ void doCalculations() {
7066
// What are these magic numbers??? 335.14? 288? 3590?
7167
//trackingSpeed = ((((335.1417 / 288.0) * StepsPerRevolution) / 3590)) - 1 + float(speedCalibration);
7268

73-
// The tracker simply needs to rotate at 15degrees/hour
74-
trackingSpeed = speedCalibration * RAStepsPerDegree * 15.0f / 3600.0f;
69+
// The tracker simply needs to rotate at 15degrees/hour, adjusted for sidereal
70+
// time (i.e. the 15degrees is per 23h56m04s. 3590/3600 is the same ratio).
71+
// And multiplied by 2 because TRK stepper is halfstepped, whereas RA stepper is fullstepped.
72+
trackingSpeed = speedCalibration * 2 * RAStepsPerDegree * 15.0f / 3590.0f;
7573
stepperTRK.setSpeed(trackingSpeed);
7674

7775
RADisplayTime.set(RATime);

Software/Arduino code/OpenAstroTracker/c70_menuRA.ino

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -191,25 +191,5 @@ void processRAKeys(int key)
191191

192192
void printRASubmenu()
193193
{
194-
195-
//Serial.println("HA:" + HATime.ToString() + " HA(corr):" + HACorrection.ToString() + " RA:" + RATime.ToString() + " RA(corr):" + RADisplayTime.ToString());
196-
if (RAselect == 0)
197-
{
198-
lcdMenu.printMenuArg(">%dh %dm %ds", RADisplayTime.getHours(), RADisplayTime.getMinutes(), RADisplayTime.getSeconds());
199-
200-
//lcd.print(int(diamCorrection)); //for debugging
201-
//lcd.print("");
202-
//lcd.print(trackingSpeed);
203-
//lcd.print(" ");
204-
}
205-
206-
if (RAselect == 1)
207-
{
208-
lcdMenu.printMenuArg(" %dh>%dm %ds", RADisplayTime.getHours(), RADisplayTime.getMinutes(), RADisplayTime.getSeconds());
209-
}
210-
211-
if (RAselect == 2)
212-
{
213-
lcdMenu.printMenuArg(" %dh %dm>%ds", RADisplayTime.getHours(), RADisplayTime.getMinutes(), RADisplayTime.getSeconds());
214-
}
194+
lcdMenu.printMenu(formatRA(&RADisplayTime, RAselect));
215195
}

0 commit comments

Comments
 (0)