Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
**V1.13.0 - Updates**
NOTE: Make sure to do a Factory Reset when using this version.
- Sped up ESP32 stepper code.
- Re-instate some defines that were inadvertantly removed.
- Ported some bug fix code from the LCD branch (e.g. track on boot)
- Potentially some DEC guide issues were fixed.
- Inadvertantly removed some default #defines. Put them back.
- Allow new stepper lib to be enabled by via #define
- Added ability to detect new firmware flashed
- Removed/disabled parking offset variable and commands, use home offset instead
- Fixed Park command to slew home and then to the parking position (home offset)
- Re-integrated old stepper library


**V1.12.17 - Updates**
- Fixed a bug that prevented clients from writing the DEC offset.

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

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

**V1.12.10 - Updates**
Expand Down
10 changes: 10 additions & 0 deletions ConfigurationValidation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,3 +434,13 @@
#endif
#endif
#endif

// For OAT, we must have DEC limits defined, otherwise free slew does nto work.
#ifndef OAM
#ifndef DEC_LIMIT_UP
#error "You must set DEC_LIMIT_UP to the number of degrees that your OAT can move upwards from the home position."
#endif
#ifndef DEC_LIMIT_DOWN
#error "You must set DEC_LIMIT_DOWN to the number of degrees that your OAT can move downwards from the home position."
#endif
#endif
15 changes: 11 additions & 4 deletions Configuration_adv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,18 @@
#endif

#ifndef DEC_LIMIT_UP
#define DEC_LIMIT_UP 0.0f
#ifdef OAM
#define DEC_LIMIT_UP 100.0f
#else
#define DEC_LIMIT_UP 0.0f
#endif
#endif
#ifndef DEC_LIMIT_DOWN
#define DEC_LIMIT_DOWN 0.0f
#ifdef OAM
#define DEC_LIMIT_DOWN 100.0f
#else
#define DEC_LIMIT_DOWN 0.0f
#endif
#endif

////////////////////////////
Expand Down Expand Up @@ -318,11 +326,10 @@
#define AZ_STEPPER_ACCELERATION (100 * AZ_MICROSTEPPING)
#endif

// the Circumference of the AZ rotation. 808mm dia.
#ifndef AZ_CIRCUMFERENCE
// the Circumference of the AZ rotation. 808mm dia.
#define AZ_CIRCUMFERENCE 2538.4f
#endif

#ifndef AZIMUTH_STEPS_PER_REV
#define AZIMUTH_STEPS_PER_REV \
(AZ_CORRECTION_FACTOR * (AZ_CIRCUMFERENCE / (AZ_PULLEY_TEETH * GT2_BELT_PITCH)) * AZ_STEPPER_SPR \
Expand Down
2 changes: 1 addition & 1 deletion Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
// Also, numbers are interpreted as simple numbers. _ __ _
// So 1.8 is actually 1.08, meaning that 1.12 is a later version than 1.8. \_(..)_/

#define VERSION "V1.12.17"
#define VERSION "V1.13.0"
4 changes: 3 additions & 1 deletion src/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
#include "c_buttons.hpp"
#include "f_serial.hpp"

#ifdef ARDUINO_ARCH_AVR
#ifdef NEW_STEPPER_LIB
#ifdef ARDUINO_ARCH_AVR
ISR(TIMER1_OVF_vect)
{
IntervalInterrupt_AVR<Timer::TIMER_1>::handle_overflow();
Expand Down Expand Up @@ -51,4 +52,5 @@ ISR(TIMER5_COMPA_vect)
{
IntervalInterrupt_AVR<Timer::TIMER_5>::handle_compare_match();
}
#endif
#endif
97 changes: 30 additions & 67 deletions src/EPROMStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,11 @@ void EEPROMStore::displayContents()
LOG(DEBUG_INFO, "[EEPROM]: Stored Longitude: %s", getLongitude().ToString());
LOG(DEBUG_INFO, "[EEPROM]: Stored Pitch Calibration Angle: %f", getPitchCalibrationAngle());
LOG(DEBUG_INFO, "[EEPROM]: Stored Roll Calibration Angle: %f", getRollCalibrationAngle());
LOG(DEBUG_INFO, "[EEPROM]: Stored RA Parking Position: %l", getRAParkingPos());
LOG(DEBUG_INFO, "[EEPROM]: Stored DEC Parking Position: %l", getDECParkingPos());
LOG(DEBUG_INFO, "[EEPROM]: Stored RA Homing Offset: %l", getRAHomingOffset());
LOG(DEBUG_INFO, "[EEPROM]: Stored DEC Homing Offset : %l", getDECHomingOffset());
LOG(DEBUG_INFO, "[EEPROM]: Stored DEC Lower Limit: %l", getDECLowerLimit());
LOG(DEBUG_INFO, "[EEPROM]: Stored DEC Upper Limit: %l", getDECUpperLimit());
LOG(DEBUG_INFO, "[EEPROM]: Stored Last Flashed Version: %d", getLastFlashedVersion());
#endif
}

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

Expand All @@ -430,7 +431,7 @@ float EEPROMStore::getDECStepsPerDegree()
if (isPresentExtended(DEC_NORM_STEPS_MARKER_FLAG))
{
// This version stored 100x steps/deg for 256 MS
const float factor = SteppingStorageNormalized / DEC_GUIDE_MICROSTEPPING;
const float factor = SteppingStorageNormalized / DEC_SLEW_MICROSTEPPING;
decStepsPerDegree = readInt32(DEC_NORM_STEPS_DEGREE_ADDR) / factor;
LOG(DEBUG_EEPROM, "[EEPROM]: DEC Normed Marker Present! DEC steps/deg is %f", decStepsPerDegree);
}
Expand All @@ -451,7 +452,7 @@ float EEPROMStore::getDECStepsPerDegree()
// Store the DEC steps per degree for guiding (actually microsteps per degree).
void EEPROMStore::storeDECStepsPerDegree(float decStepsPerDegree)
{
const float factor = SteppingStorageNormalized / DEC_GUIDE_MICROSTEPPING;
const float factor = SteppingStorageNormalized / DEC_SLEW_MICROSTEPPING;
int32_t val = decStepsPerDegree * factor;
LOG(DEBUG_EEPROM, "[EEPROM]: Storing DEC steps to %l (%f)", val, decStepsPerDegree);

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

int16_t EEPROMStore::getLastFlashedVersion()
{
if (isPresentExtended(LAST_FLASHED_MARKER_FLAG))
{
// This version stored 100x steps/deg for 256 MS
int16_t version = readInt16(LAST_FLASHED_VERSION);
LOG(DEBUG_EEPROM, "[EEPROM]: Last Flashed version Marker Present! last version %d", version);
return version;
}
else
{
LOG(DEBUG_EEPROM, "[EEPROM]: No stored value for Last Flashed Version");
}
return 0;
}

void EEPROMStore::storeLastFlashedVersion(int16_t version)
{
LOG(DEBUG_EEPROM, "[EEPROM]: Storing Last flashed version (%d)", version);
updateInt16(LAST_FLASHED_VERSION, version);
updateFlagsExtended(LAST_FLASHED_MARKER_FLAG);
commit(); // Complete the transaction
}

// Return the Speed Factor scalar (dimensionless).
// If it is not present then the default uncalibrated value of 1.0 is returned.
float EEPROMStore::getSpeedFactor()
Expand Down Expand Up @@ -652,68 +677,6 @@ void EEPROMStore::storeRollCalibrationAngle(float rollCalibrationAngle)
commit(); // Complete the transaction
}

// Return the stored RA Parking Pos (slew microsteps relative to home).
// If it is not present then the default value of 0 steps.
int32_t EEPROMStore::getRAParkingPos()
{
int32_t raParkingPos(0); // microsteps (slew)

// Note that flags doesn't verify that _both_ RA & DEC parking have been written - these should always be stored as a pair
if (isPresentExtended(PARKING_POS_MARKER_FLAG))
{
raParkingPos = readInt32(RA_PARKING_POS_ADDR);
LOG(DEBUG_EEPROM, "[EEPROM]: RA Parking position read as %l", raParkingPos);
}
else
{
LOG(DEBUG_EEPROM, "[EEPROM]: No stored value for Parking position");
}

return raParkingPos; // microsteps (slew)
}

// Store the configured RA Parking Pos (slew microsteps relative to home).
void EEPROMStore::storeRAParkingPos(int32_t raParkingPos)
{
LOG(DEBUG_EEPROM, "[EEPROM]: Updating RA Parking Pos to %l", raParkingPos);

// Note that flags doesn't verify that _both_ RA & DEC parking have been written - these should always be stored as a pair
updateInt32(RA_PARKING_POS_ADDR, raParkingPos);
updateFlagsExtended(PARKING_POS_MARKER_FLAG);
commit(); // Complete the transaction
}

// Return the stored DEC Parking Pos (slew microsteps relative to home).
// If it is not present then the default value of 0 steps.
int32_t EEPROMStore::getDECParkingPos()
{
int32_t decParkingPos(0); // microsteps (slew)

// Note that flags doesn't verify that _both_ RA & DEC parking have been written - these should always be stored as a pair
if (isPresentExtended(PARKING_POS_MARKER_FLAG))
{
decParkingPos = readInt32(DEC_PARKING_POS_ADDR);
LOG(DEBUG_EEPROM, "[EEPROM]: DEC Parking position read as %l", decParkingPos);
}
else
{
LOG(DEBUG_EEPROM, "[EEPROM]: No stored value for Parking position");
}

return decParkingPos; // microsteps (slew)
}

// Store the configured DEC Parking Pos (slew microsteps relative to home).
void EEPROMStore::storeDECParkingPos(int32_t decParkingPos)
{
LOG(DEBUG_EEPROM, "[EEPROM]: Updating DEC Parking Pos to %l", decParkingPos);

// Note that flags doesn't verify that _both_ RA & DEC parking have been written - these should always be stored as a pair
updateInt32(DEC_PARKING_POS_ADDR, decParkingPos);
updateFlagsExtended(PARKING_POS_MARKER_FLAG);
commit(); // Complete the transaction
}

// Return the stored DEC Lower Limit (slew microsteps relative to home).
// If it is not present then the default value of 0 steps (limits are disabled).
float EEPROMStore::getDECLowerLimit()
Expand Down
20 changes: 12 additions & 8 deletions src/EPROMStore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ class EEPROMStore
static float getRollCalibrationAngle();
static void storeRollCalibrationAngle(float rollCalibrationAngle);

static int32_t getRAParkingPos();
static void storeRAParkingPos(int32_t raParkingPos);

static int32_t getDECParkingPos();
static void storeDECParkingPos(int32_t decParkingPos);

static float getDECLowerLimit();
static void storeDECLowerLimit(float decLowerLimit);

Expand All @@ -65,6 +59,9 @@ class EEPROMStore
static int32_t getDECHomingOffset();
static void storeDECHomingOffset(int32_t decHomingOffset);

static int16_t getLastFlashedVersion();
static void storeLastFlashedVersion(int16_t lastVersion);

private:
/////////////////////////////////
//
Expand All @@ -88,11 +85,15 @@ class EEPROMStore
// If Location 5 is 0xCF, then an extended 16-bit flag is stored in 21/22 and
// indicates the additional fields that have been stored: 0000 0000 0000 0000
// ^^^^ ^^^^ ^^^^ ^^^^
// ||||
// |||| ||||
// Last flashed version (56-57) ------------------+||| ||||
// DEC Homing Offet (52-55) -------------------+|| ||||
// DEC Steps/deg, normalized to 256MS (48-51) -------------------+| ||||
// RA Steps/deg, normalized to 256MS (44-47) --------------------+ ||||
// RA Homing Offet (40-43) -----------------------+|||
// UTC Offset (39) ------------------------+||
// DEC lower (31-34) and upper (35-38) limits -------------------------+|
// RA (23-26) and DEC (27-30) Parking offsets --------------------------+
// RA (23-26) and DEC (27-30) Parking offsets --------------------------+ ( ==== Obsolete V1.13.0 and beyond ==== )
//
/////////////////////////////////

Expand Down Expand Up @@ -125,6 +126,7 @@ class EEPROMStore
RA_NORM_STEPS_MARKER_FLAG = 0x0010,
DEC_NORM_STEPS_MARKER_FLAG = 0x0020,
DEC_HOMING_MARKER_FLAG = 0x0040,
LAST_FLASHED_MARKER_FLAG = 0x0080,
};

// These are the offsets to each item stored in the EEPROM
Expand Down Expand Up @@ -187,6 +189,8 @@ class EEPROMStore
_DEC_HOMING_OFFSET_ADDR_1,
_DEC_HOMING_OFFSET_ADDR_2,
_DEC_HOMING_OFFSET_ADDR_3, // Int32
LAST_FLASHED_VERSION = 56,
_LAST_FLASHED_VERSION_1,
STORE_SIZE = 64
};

Expand Down
9 changes: 6 additions & 3 deletions src/InterruptAccelStepper.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
#include <stdint.h>
#include <math.h>

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

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

// minimal stepping frequency (steps/s) based on cpu frequency, timer counter overflow and max amount of overflows
#define MIN_STEPS_PER_SEC (static_cast<float>(F_CPU) / (static_cast<long>(UINT16_MAX) * static_cast<long>(UINT8_MAX)))

template <typename STEPPER> class InterruptAccelStepper
{
Expand Down Expand Up @@ -144,5 +146,6 @@ template <typename STEPPER> class InterruptAccelStepper
return STEPPER::isRunning();
}
};
#endif

#endif //AVR_INTERRUPT_STEPPER_INTERRUPTACCELSTEPPER_H
51 changes: 51 additions & 0 deletions src/InterruptCallback.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include "../Configuration.hpp"
#include "Utility.hpp"
#include "InterruptCallback.hpp"

//////////////////////////////////////
// This is an hardware-independent abstraction layer over
// whatever timer is used for the hardware being run
//////////////////////////////////////

#ifndef NEW_STEPPER_LIB

#if defined ESP32
// We don't support ESP32 boards in interrupt mode
#elif defined __AVR_ATmega2560__ // Arduino Mega
#define USE_TIMER_1 true
#define USE_TIMER_2 true
#define USE_TIMER_3 false
#define USE_TIMER_4 false
#define USE_TIMER_5 false
PUSH_NO_WARNINGS
#include "libs/TimerInterrupt/TimerInterrupt.h"
POP_NO_WARNINGS
#else
#error Unrecognized board selected. Either implement interrupt code or define the board here.
#endif

#if defined(ESP32)

#elif defined __AVR_ATmega2560__

bool InterruptCallback::setInterval(float intervalMs, interrupt_callback_p callback, void *payload)
{
// We have requested to use Timer2 (see above)
ITimer2.init();

// This timer supports the callback with payload
return ITimer2.attachInterruptInterval<void *>(intervalMs, callback, payload, 0UL);
}

void InterruptCallback::stop()
{
ITimer2.stopTimer();
}

void InterruptCallback::start()
{
ITimer2.restartTimer();
}

#endif
#endif
Loading