Skip to content

Commit 440b3b7

Browse files
author
OpenAstroTech
authored
Merge pull request #15 from ClutchplateDude/master
Menu improvements. Up/Down support in HA.
2 parents a7fa930 + 50d7eda commit 440b3b7

24 files changed

+27118
-503
lines changed

STL/All latitudes/DEC_StepperBoardClip.stl

Lines changed: 1206 additions & 0 deletions
Large diffs are not rendered by default.

STL/All latitudes/RA_BearingSupportx2.stl

Lines changed: 24194 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,60 @@
11
/*
22
=======================================================================================================================================
33
4-
Version 1.2.4
4+
Version 1.4.4
55
66
1. Connect your Arduino, under tools choose "Arduino Uno", set the right Port and set "Arduino ISP" as the Programmer.
7-
2. Hit upload
7+
2. Hit upload (Ctrl-U)
88
99
You might need to download the "AccelStepper" library by Mike McCauley
1010
11+
Authors: /u/intercipere
12+
/u/clutchplate
13+
/u/EorEquis
14+
1115
=======================================================================================================================================
1216
*/
13-
boolean north = true; // change this to 'false' if youre in the southern hemisphere
17+
String version = "V1.4.4";
18+
19+
boolean north = true; // change this to 'false' if youre in the southern hemisphere
1420

1521
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.
1622

17-
int RAsteps = 330; // adjust this value to calibrate RA movement
23+
int RAsteps = 330; // adjust this value to calibrate RA movement
1824
int DECsteps = 163;
1925

20-
float RevSteps = 4096;
2126
// This is how many steps your 28BYJ-48 stepper needs for a full rotation. It is almost always 4096.
2227
// This code drives the steppers in halfstep mode
28+
float RevSteps = 4096;
2329

2430
int RAspeed = 400; // You can change the speed and acceleration of the steppers here. Max. Speed = 600. High speeds tend to make
25-
int RAacceleration = 600; // these cheap steppers unprecice
31+
int RAacceleration = 600; // these cheap steppers unprecice
2632
int DECspeed = 800;
2733
int DECacceleration = 400;
2834

35+
// Define some stepper limits to prevent physical damage to the tracker. This assumes that the home
36+
// point (zero point) has been correctly set to be pointing at the celestial pole.
37+
float RAStepperLimit = 15500; // Going much more than this each direction will make the ring fall off the bearings.
38+
39+
// These are for 47N, so they will need adjustment if you're a lot away from that.
40+
// You can use the CTRL menu to find the limits and place them here. I moved it
41+
// down until my lens was horizontal. Note the DEC number. Then move it up until
42+
// the lens is horizontal and note that number. Put those here. Always watch your
43+
// tracker and hit RESET if it approaches a dangerous area.
44+
float DECStepperDownLimit = 10000; // Going much more than this will make the lens collide with the ring
45+
float DECStepperUpLimit = -22000; // Going much more than this is going below the horizon.
46+
2947
// These values are needed to calculate the current position during initial alignment.
30-
int h = 21;
31-
int m = 2;
32-
int s = 25;
48+
int h = 21;
49+
int m = 2;
50+
int s = 25;
3351
// You get these values by calculating 24h minus the current (not J2000) RA of Polaris.
3452
// This changes slightly over weeks, so adjust every couple of months.
3553
// This value is from 27.Nov.19, I suggest next adjustment in mid 2020
3654
// The same could be done for the DEC coordinates but they dont change significantly for the next 5 years
55+
56+
// Comment this out to save some code space
57+
//#define DEBUG_MODE
58+
59+
// Uncomment this to support the heating menu
60+
//#define SUPPORT_HEATING
Lines changed: 63 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,85 @@
11
// If you really want to look through this code, i apologise for my terrible coding
22
//#include <SoftwareSerial.h>
3+
#include <stdarg.h>
34
#include <EEPROM.h>
45
#include <AccelStepper.h>
56
#include <LiquidCrystal.h>
67
#include <SoftwareSerial.h>
8+
79
#define HALFSTEP 8
810
#define FULLSTEP 4
911

1012
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
1113
//SoftwareSerial BT(10,11);
1214

15+
// RA Motor pins
1316
#define motorPin1 2 // IN1 auf ULN2003 driver 1 // 2 / 22
1417
#define motorPin2 3 // IN2 auf ULN2003 driver 1 // 3 / 24
1518
#define motorPin3 11 // IN3 auf ULN2003 driver 1 // 11 / 26
1619
#define motorPin4 12 // IN4 auf ULN2003 driver 1 // 12 / 28
1720

21+
// DEC Motor pins
1822
#define motorPin11 15 // IN1 auf ULN2003 driver 2
1923
#define motorPin12 16 // IN2 auf ULN2003 driver 2
2024
#define motorPin13 17 // IN3 auf ULN2003 driver 2
2125
#define motorPin14 18 // IN4 auf ULN2003 driver 2
2226

27+
// LCD shield buttons
2328
#define btnRIGHT 0
2429
#define btnUP 1
2530
#define btnDOWN 2
2631
#define btnLEFT 3
2732
#define btnSELECT 4
2833
#define btnNONE 5
2934

30-
int lcd_key = 0;
31-
int adc_key_in = 0;
32-
int read_LCD_buttons() {
33-
adc_key_in = analogRead(0);
34-
if (adc_key_in > 1000) return btnNONE;
35-
if (adc_key_in < 50) return btnRIGHT;
36-
if (adc_key_in < 250) return btnUP;
37-
if (adc_key_in < 450) return btnDOWN;
38-
if (adc_key_in < 600) return btnLEFT;
39-
if (adc_key_in < 920) return btnSELECT;
40-
//return btnNONE;
41-
}
42-
43-
String inString = "";
44-
35+
// Menu IDs
36+
#define RA_Menu 0
37+
#define DEC_Menu 1
38+
#define HA_Menu 2
39+
#define Polaris_Menu 3
40+
#define Heat_Menu 4
41+
#define Calibration_Menu 5
42+
#define Control_Menu 6
43+
#define Home_Menu 7
44+
#define POI_Menu 8
45+
46+
// Stepper control for RA and DEV.
47+
// TRK is used for live tracking and runs in parallel with RA.
48+
// GUIDE is used for Stellarium control
4549
AccelStepper stepperRA(FULLSTEP, motorPin1, motorPin3, motorPin2, motorPin4);
4650
AccelStepper stepperDEC(HALFSTEP, motorPin11, motorPin13, motorPin12, motorPin14);
4751
AccelStepper stepperTRK(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4); //yes, this is the same motor as stepperRA, dont ask why
4852
AccelStepper stepperGUIDE(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4);
4953

54+
int lcd_key = 0; // The current key state
55+
int adc_key_in = 0; // The analog value of the keys
56+
57+
String inString = "";
58+
59+
bool inStartup = true; // Start with a guided startup
60+
61+
int calDelay = 150; // The current delay when changing calibration value. The longer a button is depressed, the samller this gets.
62+
63+
bool waitForButtonRelease = false; // When a button is pressed should we wait for its release before another loop?
64+
65+
// Variables for use in the CONTROL menu
66+
int StateMaskDEC = 0x0011; // Is the DEC stepper running?
67+
int StateMaskUp = 0x0001; // Is the DEC stepper moving upwards?
68+
int StateMaskDown = 0x0010; // Is the DEC stepper moving downwards?
69+
int StateMaskRA = 0x1100; // Is the RA stepper running?
70+
int StateMaskLeft = 0x0100; // Is the RA stepper moving left (CW)?
71+
int StateMaskRight = 0x1000; // Is the RA stepper moving right (CCW)?
72+
73+
int controlState = 0x0000; // The current state of the steppers (combination of above values)
74+
int controlDisplay = 0; // How many loop cycles left before updating the display
75+
bool inControlMode = false; // Is manual control enabled
76+
77+
int lastKey = btnNONE; // The key state when we last came through the loop
78+
79+
float totalDECMove = 0; // The number of DEC steps we asked for
80+
float totalRAMove = 0;
81+
bool isUnreachable = false;
82+
5083
//String inCmd;
5184
//String inputString = "";
5285
//String commandString = "";
@@ -58,10 +91,9 @@ String logString;
5891
boolean isPulseGuiding = true;
5992

6093
unsigned long Zeit;
61-
float onehour;
94+
float stepsPerHour;
6295

6396
boolean pcControl = false;
64-
int menu = 2;
6597
int currentSecs;
6698
int currentMins;
6799
float inputcal;
@@ -75,15 +107,9 @@ int mPolarisPosition;
75107
int tracking = 1;
76108
float trackingspeed;
77109

78-
//RA stuff
79-
float hourRA;
80-
float minRA = 0;
81-
float secRA = 0;
110+
// RA stuff
82111
float moveRA;
83112
int RAselect;
84-
int hourRAprint;
85-
int minRAprint;
86-
int secRAprint;
87113

88114
//DEC stuff
89115
int degreeDEC;
@@ -93,29 +119,27 @@ float moveDEC;
93119
int DECselect;
94120
int printdegDEC;
95121

96-
//Hour correction
97-
int hourHA = 0;
98-
int minHA = 0;
122+
//Hour stuff
99123
int HAselect;
100-
int hHAcorrection;
101-
int mHAcorrection = -5 ; //wenn minus dann hHAcorrection -1
102-
int sHAcorrection;
103-
int hourHAzeit;
104-
int minHAzeit;
105124

106-
int heatselect;
107-
int RAheat = 0;
108-
int DECheat = 1;
125+
// HEAT menu settings
126+
int heatselect; // Which stepper are we changing?
127+
int RAheat = 0; // Are we heating the RA stepper?
128+
int DECheat = 0; // Are we heating the DEC stepper?
109129

110-
//Stellarium
130+
//Stellarium
111131
char current_RA[9];
112132
char current_DEC[10];
113133
int HAh_save;
114134
int HAm_save;
115135
float slew_RA;
116136
float slew_DEC;
117137

118-
byte DEG[8] = {
138+
// LCD special chars
139+
int leftArrow = 3;
140+
int rightArrow = 4;
141+
142+
byte DegreesBitmap[8] = {
119143
B01100,
120144
B10010,
121145
B10010,
@@ -126,7 +150,7 @@ byte DEG[8] = {
126150
B00000
127151
};
128152

129-
byte min[] = {
153+
byte MinutesBitmap[] = {
130154
B10000,
131155
B10000,
132156
B10000,
@@ -137,7 +161,7 @@ byte min[] = {
137161
B00000
138162
};
139163

140-
byte sec[] = {
164+
byte SecondsBitmap[] = {
141165
B10100,
142166
B10100,
143167
B10100,
@@ -148,6 +172,5 @@ byte sec[] = {
148172
B00000
149173
};
150174

151-
152175
//debugging
153176
String inBT;

0 commit comments

Comments
 (0)