Skip to content

Commit ea731a0

Browse files
V1.13 Firmware updates (#239)
1 parent 8454990 commit ea731a0

21 files changed

+1799
-335
lines changed

Changelog.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
**V1.13.0 - Updates**
2+
NOTE: Make sure to do a Factory Reset when using this version.
3+
- Sped up ESP32 stepper code.
4+
- Re-instate some defines that were inadvertantly removed.
5+
- Ported some bug fix code from the LCD branch (e.g. track on boot)
6+
- Potentially some DEC guide issues were fixed.
7+
- Inadvertantly removed some default #defines. Put them back.
8+
- Allow new stepper lib to be enabled by via #define
9+
- Added ability to detect new firmware flashed
10+
- Removed/disabled parking offset variable and commands, use home offset instead
11+
- Fixed Park command to slew home and then to the parking position (home offset)
12+
- Re-integrated old stepper library
13+
14+
115
**V1.12.17 - Updates**
216
- Fixed a bug that prevented clients from writing the DEC offset.
317

@@ -29,7 +43,7 @@
2943
**V1.12.12 - Updates**
3044
- Change MKS Gen L v1.0, v2.0, v2.1 default separate debug serial port from `Serial3` to `Serial2`.
3145

32-
- **V1.12.11 - Updates**
46+
**V1.12.11 - Updates**
3347
- Allowed the active state of the hall sensors for auto homing RA and DEC to be configured.
3448

3549
**V1.12.10 - Updates**

ConfigurationValidation.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,3 +434,13 @@
434434
#endif
435435
#endif
436436
#endif
437+
438+
// For OAT, we must have DEC limits defined, otherwise free slew does nto work.
439+
#ifndef OAM
440+
#ifndef DEC_LIMIT_UP
441+
#error "You must set DEC_LIMIT_UP to the number of degrees that your OAT can move upwards from the home position."
442+
#endif
443+
#ifndef DEC_LIMIT_DOWN
444+
#error "You must set DEC_LIMIT_DOWN to the number of degrees that your OAT can move downwards from the home position."
445+
#endif
446+
#endif

Configuration_adv.hpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,18 @@
226226
#endif
227227

228228
#ifndef DEC_LIMIT_UP
229-
#define DEC_LIMIT_UP 0.0f
229+
#ifdef OAM
230+
#define DEC_LIMIT_UP 100.0f
231+
#else
232+
#define DEC_LIMIT_UP 0.0f
233+
#endif
230234
#endif
231235
#ifndef DEC_LIMIT_DOWN
232-
#define DEC_LIMIT_DOWN 0.0f
236+
#ifdef OAM
237+
#define DEC_LIMIT_DOWN 100.0f
238+
#else
239+
#define DEC_LIMIT_DOWN 0.0f
240+
#endif
233241
#endif
234242

235243
////////////////////////////
@@ -318,11 +326,10 @@
318326
#define AZ_STEPPER_ACCELERATION (100 * AZ_MICROSTEPPING)
319327
#endif
320328

329+
// the Circumference of the AZ rotation. 808mm dia.
321330
#ifndef AZ_CIRCUMFERENCE
322-
// the Circumference of the AZ rotation. 808mm dia.
323331
#define AZ_CIRCUMFERENCE 2538.4f
324332
#endif
325-
326333
#ifndef AZIMUTH_STEPS_PER_REV
327334
#define AZIMUTH_STEPS_PER_REV \
328335
(AZ_CORRECTION_FACTOR * (AZ_CIRCUMFERENCE / (AZ_PULLEY_TEETH * GT2_BELT_PITCH)) * AZ_STEPPER_SPR \

Version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
// Also, numbers are interpreted as simple numbers. _ __ _
44
// So 1.8 is actually 1.08, meaning that 1.12 is a later version than 1.8. \_(..)_/
55

6-
#define VERSION "V1.12.17"
6+
#define VERSION "V1.13.0"

src/Core.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
#include "c_buttons.hpp"
1919
#include "f_serial.hpp"
2020

21-
#ifdef ARDUINO_ARCH_AVR
21+
#ifdef NEW_STEPPER_LIB
22+
#ifdef ARDUINO_ARCH_AVR
2223
ISR(TIMER1_OVF_vect)
2324
{
2425
IntervalInterrupt_AVR<Timer::TIMER_1>::handle_overflow();
@@ -51,4 +52,5 @@ ISR(TIMER5_COMPA_vect)
5152
{
5253
IntervalInterrupt_AVR<Timer::TIMER_5>::handle_compare_match();
5354
}
55+
#endif
5456
#endif

src/EPROMStore.cpp

Lines changed: 30 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,11 @@ void EEPROMStore::displayContents()
138138
LOG(DEBUG_INFO, "[EEPROM]: Stored Longitude: %s", getLongitude().ToString());
139139
LOG(DEBUG_INFO, "[EEPROM]: Stored Pitch Calibration Angle: %f", getPitchCalibrationAngle());
140140
LOG(DEBUG_INFO, "[EEPROM]: Stored Roll Calibration Angle: %f", getRollCalibrationAngle());
141-
LOG(DEBUG_INFO, "[EEPROM]: Stored RA Parking Position: %l", getRAParkingPos());
142-
LOG(DEBUG_INFO, "[EEPROM]: Stored DEC Parking Position: %l", getDECParkingPos());
141+
LOG(DEBUG_INFO, "[EEPROM]: Stored RA Homing Offset: %l", getRAHomingOffset());
142+
LOG(DEBUG_INFO, "[EEPROM]: Stored DEC Homing Offset : %l", getDECHomingOffset());
143143
LOG(DEBUG_INFO, "[EEPROM]: Stored DEC Lower Limit: %l", getDECLowerLimit());
144144
LOG(DEBUG_INFO, "[EEPROM]: Stored DEC Upper Limit: %l", getDECUpperLimit());
145+
LOG(DEBUG_INFO, "[EEPROM]: Stored Last Flashed Version: %d", getLastFlashedVersion());
145146
#endif
146147
}
147148

@@ -412,7 +413,7 @@ float EEPROMStore::getRAStepsPerDegree()
412413
void EEPROMStore::storeRAStepsPerDegree(float raStepsPerDegree)
413414
{
414415
// Store steps as 100x steps/deg at 256 MS.
415-
const float factor = SteppingStorageNormalized / RA_TRACKING_MICROSTEPPING;
416+
const float factor = SteppingStorageNormalized / RA_SLEW_MICROSTEPPING;
416417
int32_t val = raStepsPerDegree * factor;
417418
LOG(DEBUG_EEPROM, "[EEPROM]: Storing RA steps to %l (%f)", val, raStepsPerDegree);
418419

@@ -430,7 +431,7 @@ float EEPROMStore::getDECStepsPerDegree()
430431
if (isPresentExtended(DEC_NORM_STEPS_MARKER_FLAG))
431432
{
432433
// This version stored 100x steps/deg for 256 MS
433-
const float factor = SteppingStorageNormalized / DEC_GUIDE_MICROSTEPPING;
434+
const float factor = SteppingStorageNormalized / DEC_SLEW_MICROSTEPPING;
434435
decStepsPerDegree = readInt32(DEC_NORM_STEPS_DEGREE_ADDR) / factor;
435436
LOG(DEBUG_EEPROM, "[EEPROM]: DEC Normed Marker Present! DEC steps/deg is %f", decStepsPerDegree);
436437
}
@@ -451,7 +452,7 @@ float EEPROMStore::getDECStepsPerDegree()
451452
// Store the DEC steps per degree for guiding (actually microsteps per degree).
452453
void EEPROMStore::storeDECStepsPerDegree(float decStepsPerDegree)
453454
{
454-
const float factor = SteppingStorageNormalized / DEC_GUIDE_MICROSTEPPING;
455+
const float factor = SteppingStorageNormalized / DEC_SLEW_MICROSTEPPING;
455456
int32_t val = decStepsPerDegree * factor;
456457
LOG(DEBUG_EEPROM, "[EEPROM]: Storing DEC steps to %l (%f)", val, decStepsPerDegree);
457458

@@ -460,6 +461,30 @@ void EEPROMStore::storeDECStepsPerDegree(float decStepsPerDegree)
460461
commit(); // Complete the transaction
461462
}
462463

464+
int16_t EEPROMStore::getLastFlashedVersion()
465+
{
466+
if (isPresentExtended(LAST_FLASHED_MARKER_FLAG))
467+
{
468+
// This version stored 100x steps/deg for 256 MS
469+
int16_t version = readInt16(LAST_FLASHED_VERSION);
470+
LOG(DEBUG_EEPROM, "[EEPROM]: Last Flashed version Marker Present! last version %d", version);
471+
return version;
472+
}
473+
else
474+
{
475+
LOG(DEBUG_EEPROM, "[EEPROM]: No stored value for Last Flashed Version");
476+
}
477+
return 0;
478+
}
479+
480+
void EEPROMStore::storeLastFlashedVersion(int16_t version)
481+
{
482+
LOG(DEBUG_EEPROM, "[EEPROM]: Storing Last flashed version (%d)", version);
483+
updateInt16(LAST_FLASHED_VERSION, version);
484+
updateFlagsExtended(LAST_FLASHED_MARKER_FLAG);
485+
commit(); // Complete the transaction
486+
}
487+
463488
// Return the Speed Factor scalar (dimensionless).
464489
// If it is not present then the default uncalibrated value of 1.0 is returned.
465490
float EEPROMStore::getSpeedFactor()
@@ -652,68 +677,6 @@ void EEPROMStore::storeRollCalibrationAngle(float rollCalibrationAngle)
652677
commit(); // Complete the transaction
653678
}
654679

655-
// Return the stored RA Parking Pos (slew microsteps relative to home).
656-
// If it is not present then the default value of 0 steps.
657-
int32_t EEPROMStore::getRAParkingPos()
658-
{
659-
int32_t raParkingPos(0); // microsteps (slew)
660-
661-
// Note that flags doesn't verify that _both_ RA & DEC parking have been written - these should always be stored as a pair
662-
if (isPresentExtended(PARKING_POS_MARKER_FLAG))
663-
{
664-
raParkingPos = readInt32(RA_PARKING_POS_ADDR);
665-
LOG(DEBUG_EEPROM, "[EEPROM]: RA Parking position read as %l", raParkingPos);
666-
}
667-
else
668-
{
669-
LOG(DEBUG_EEPROM, "[EEPROM]: No stored value for Parking position");
670-
}
671-
672-
return raParkingPos; // microsteps (slew)
673-
}
674-
675-
// Store the configured RA Parking Pos (slew microsteps relative to home).
676-
void EEPROMStore::storeRAParkingPos(int32_t raParkingPos)
677-
{
678-
LOG(DEBUG_EEPROM, "[EEPROM]: Updating RA Parking Pos to %l", raParkingPos);
679-
680-
// Note that flags doesn't verify that _both_ RA & DEC parking have been written - these should always be stored as a pair
681-
updateInt32(RA_PARKING_POS_ADDR, raParkingPos);
682-
updateFlagsExtended(PARKING_POS_MARKER_FLAG);
683-
commit(); // Complete the transaction
684-
}
685-
686-
// Return the stored DEC Parking Pos (slew microsteps relative to home).
687-
// If it is not present then the default value of 0 steps.
688-
int32_t EEPROMStore::getDECParkingPos()
689-
{
690-
int32_t decParkingPos(0); // microsteps (slew)
691-
692-
// Note that flags doesn't verify that _both_ RA & DEC parking have been written - these should always be stored as a pair
693-
if (isPresentExtended(PARKING_POS_MARKER_FLAG))
694-
{
695-
decParkingPos = readInt32(DEC_PARKING_POS_ADDR);
696-
LOG(DEBUG_EEPROM, "[EEPROM]: DEC Parking position read as %l", decParkingPos);
697-
}
698-
else
699-
{
700-
LOG(DEBUG_EEPROM, "[EEPROM]: No stored value for Parking position");
701-
}
702-
703-
return decParkingPos; // microsteps (slew)
704-
}
705-
706-
// Store the configured DEC Parking Pos (slew microsteps relative to home).
707-
void EEPROMStore::storeDECParkingPos(int32_t decParkingPos)
708-
{
709-
LOG(DEBUG_EEPROM, "[EEPROM]: Updating DEC Parking Pos to %l", decParkingPos);
710-
711-
// Note that flags doesn't verify that _both_ RA & DEC parking have been written - these should always be stored as a pair
712-
updateInt32(DEC_PARKING_POS_ADDR, decParkingPos);
713-
updateFlagsExtended(PARKING_POS_MARKER_FLAG);
714-
commit(); // Complete the transaction
715-
}
716-
717680
// Return the stored DEC Lower Limit (slew microsteps relative to home).
718681
// If it is not present then the default value of 0 steps (limits are disabled).
719682
float EEPROMStore::getDECLowerLimit()

src/EPROMStore.hpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@ class EEPROMStore
4747
static float getRollCalibrationAngle();
4848
static void storeRollCalibrationAngle(float rollCalibrationAngle);
4949

50-
static int32_t getRAParkingPos();
51-
static void storeRAParkingPos(int32_t raParkingPos);
52-
53-
static int32_t getDECParkingPos();
54-
static void storeDECParkingPos(int32_t decParkingPos);
55-
5650
static float getDECLowerLimit();
5751
static void storeDECLowerLimit(float decLowerLimit);
5852

@@ -65,6 +59,9 @@ class EEPROMStore
6559
static int32_t getDECHomingOffset();
6660
static void storeDECHomingOffset(int32_t decHomingOffset);
6761

62+
static int16_t getLastFlashedVersion();
63+
static void storeLastFlashedVersion(int16_t lastVersion);
64+
6865
private:
6966
/////////////////////////////////
7067
//
@@ -88,11 +85,15 @@ class EEPROMStore
8885
// If Location 5 is 0xCF, then an extended 16-bit flag is stored in 21/22 and
8986
// indicates the additional fields that have been stored: 0000 0000 0000 0000
9087
// ^^^^ ^^^^ ^^^^ ^^^^
91-
// ||||
88+
// |||| ||||
89+
// Last flashed version (56-57) ------------------+||| ||||
90+
// DEC Homing Offet (52-55) -------------------+|| ||||
91+
// DEC Steps/deg, normalized to 256MS (48-51) -------------------+| ||||
92+
// RA Steps/deg, normalized to 256MS (44-47) --------------------+ ||||
9293
// RA Homing Offet (40-43) -----------------------+|||
9394
// UTC Offset (39) ------------------------+||
9495
// DEC lower (31-34) and upper (35-38) limits -------------------------+|
95-
// RA (23-26) and DEC (27-30) Parking offsets --------------------------+
96+
// RA (23-26) and DEC (27-30) Parking offsets --------------------------+ ( ==== Obsolete V1.13.0 and beyond ==== )
9697
//
9798
/////////////////////////////////
9899

@@ -125,6 +126,7 @@ class EEPROMStore
125126
RA_NORM_STEPS_MARKER_FLAG = 0x0010,
126127
DEC_NORM_STEPS_MARKER_FLAG = 0x0020,
127128
DEC_HOMING_MARKER_FLAG = 0x0040,
129+
LAST_FLASHED_MARKER_FLAG = 0x0080,
128130
};
129131

130132
// These are the offsets to each item stored in the EEPROM
@@ -187,6 +189,8 @@ class EEPROMStore
187189
_DEC_HOMING_OFFSET_ADDR_1,
188190
_DEC_HOMING_OFFSET_ADDR_2,
189191
_DEC_HOMING_OFFSET_ADDR_3, // Int32
192+
LAST_FLASHED_VERSION = 56,
193+
_LAST_FLASHED_VERSION_1,
190194
STORE_SIZE = 64
191195
};
192196

src/InterruptAccelStepper.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
#include <stdint.h>
99
#include <math.h>
1010

11-
#define SIGN(x) ((x >= 0) ? 1 : -1)
11+
#ifdef NEW_STEPPER_LIB
1212

13-
// minimal stepping frequency (steps/s) based on cpu frequency, timer counter overflow and max amount of overflows
14-
#define MIN_STEPS_PER_SEC (static_cast<float>(F_CPU) / (static_cast<long>(UINT16_MAX) * static_cast<long>(UINT8_MAX)))
13+
#define SIGN(x) ((x >= 0) ? 1 : -1)
14+
15+
// minimal stepping frequency (steps/s) based on cpu frequency, timer counter overflow and max amount of overflows
16+
#define MIN_STEPS_PER_SEC (static_cast<float>(F_CPU) / (static_cast<long>(UINT16_MAX) * static_cast<long>(UINT8_MAX)))
1517

1618
template <typename STEPPER> class InterruptAccelStepper
1719
{
@@ -144,5 +146,6 @@ template <typename STEPPER> class InterruptAccelStepper
144146
return STEPPER::isRunning();
145147
}
146148
};
149+
#endif
147150

148151
#endif //AVR_INTERRUPT_STEPPER_INTERRUPTACCELSTEPPER_H

src/InterruptCallback.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#include "../Configuration.hpp"
2+
#include "Utility.hpp"
3+
#include "InterruptCallback.hpp"
4+
5+
//////////////////////////////////////
6+
// This is an hardware-independent abstraction layer over
7+
// whatever timer is used for the hardware being run
8+
//////////////////////////////////////
9+
10+
#ifndef NEW_STEPPER_LIB
11+
12+
#if defined ESP32
13+
// We don't support ESP32 boards in interrupt mode
14+
#elif defined __AVR_ATmega2560__ // Arduino Mega
15+
#define USE_TIMER_1 true
16+
#define USE_TIMER_2 true
17+
#define USE_TIMER_3 false
18+
#define USE_TIMER_4 false
19+
#define USE_TIMER_5 false
20+
PUSH_NO_WARNINGS
21+
#include "libs/TimerInterrupt/TimerInterrupt.h"
22+
POP_NO_WARNINGS
23+
#else
24+
#error Unrecognized board selected. Either implement interrupt code or define the board here.
25+
#endif
26+
27+
#if defined(ESP32)
28+
29+
#elif defined __AVR_ATmega2560__
30+
31+
bool InterruptCallback::setInterval(float intervalMs, interrupt_callback_p callback, void *payload)
32+
{
33+
// We have requested to use Timer2 (see above)
34+
ITimer2.init();
35+
36+
// This timer supports the callback with payload
37+
return ITimer2.attachInterruptInterval<void *>(intervalMs, callback, payload, 0UL);
38+
}
39+
40+
void InterruptCallback::stop()
41+
{
42+
ITimer2.stopTimer();
43+
}
44+
45+
void InterruptCallback::start()
46+
{
47+
ITimer2.restartTimer();
48+
}
49+
50+
#endif
51+
#endif

0 commit comments

Comments
 (0)