Skip to content

Commit 0bce5c0

Browse files
author
OpenAstroTech
committed
V1.8.12 - Updates
- Temporary fix for compile error from 1.8.11 - add different MS modes for DEC slewing/guiding - add UART "noisefeedback" to config - hardcoded guidemultipliers for 28by - stop tracking during a slew with NEMAs to prevent inaccurate slews
1 parent 6f8f4ad commit 0bce5c0

File tree

11 files changed

+99
-129
lines changed

11 files changed

+99
-129
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,3 +368,7 @@ test
368368
bin/
369369
Software/Arduino code/HW_724_TEST
370370
Software/Arduino code/sketch_jun08a
371+
372+
# gh-pages stuff
373+
.jekyll-cache
374+
_site

Software/Arduino code/OpenAstroTracker/Configuration.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
=======================================================================================================================================
1919
*/
2020

21-
String version = "V1.8.11";
21+
String version = "V1.8.12";
2222

2323
///////////////////////////////////////////////////////////////////////////
2424
// Also use Configuration_adv for further adjustments!
@@ -59,7 +59,7 @@ float RACircumference = 1131.0;
5959
int DECacceleration = 400; // High speeds tend to make these cheap steppers unprecice
6060
#elif DEC_STEPPER_TYPE == STEP_NEMA17
6161
float DECStepsPerRevolution = 400; // 28BYJ-48 = 4096 | NEMA 0.9° = 400 | NEMA 1.8° = 200
62-
int DECspeed = 1500; // You can change the speed and acceleration of the steppers here.
62+
int DECspeed = 1300; // You can change the speed and acceleration of the steppers here.
6363
int DECacceleration = 6000;
6464
#else
6565
#error New DEC Stepper type? Define steps per stepper pulley revolution here...

Software/Arduino code/OpenAstroTracker/Configuration_adv.hpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
// Driver selection
3333
#define ULN2003_DRIVER 0
3434
#define GENERIC_DRIVER 1
35-
#define TMC2009_STANDALONE 2
36-
#define TMC2009_UART 3
35+
#define TMC2209_STANDALONE 2
36+
#define TMC2209_UART 3
3737

3838
// GENERIC drivers include A4988 and any Bipolar STEP/DIR based drivers
3939
#define RA_DRIVER_TYPE ULN2003_DRIVER
@@ -47,15 +47,28 @@
4747
#define TRACKING_MICROSTEPPING 64 // Set the MS mode for tracking only. Slew MS is set by SET_MICROSTEPPING above
4848

4949
#define RA_RMSCURRENT 1200 // RMS current in mA. Warning: Peak current will be 1.414 times higher!! Do not exceed your steppers max current!
50-
#define RA_STALL_VALUE 100
51-
//#define RA_SPEED_MULTIPLIER 20 // This value is multiplied with the SLEW microstepping value to get the necessary speed
50+
#define RA_STALL_VALUE 100 // adjust this value if the RA autohoming sequence often false triggers, or triggers too late
5251

53-
#define DEC_MICROSTEPPING 32
54-
#define DEC_STALL_VALUE 10
52+
#define DEC_SLEW_MICROSTEPPING 16 // The microstep mode used for slewing DEC
53+
#define DEC_GUIDE_MICROSTEPPING 64 // The microstep mode used for Guiding DEC only
54+
#define DEC_STALL_VALUE 10 // adjust this value if the RA autohoming sequence often false triggers, or triggers too late
5555
#define DEC_RMSCURRENT 1000 // RMS current in mA. Warning: Peak current will be 1.414 times higher!! Do not exceed your steppers max current!
5656
#define DEC_HOLDCURRENT 20 // [0, ... , 31] x/32 of the run current when standing still. 0=1/32... 31=32/32
5757
#define USE_AUTOHOME 0 // Autohome with TMC2209 stall detection: ON = 1 | OFF = 0
5858
// ^^^ leave at 0 for now, doesnt work properly yet
59+
#define RA_AUDIO_FEEDBACK 0 // If one of these are set to 1, the respective driver will shut off the stealthchop mode, resulting in a audible whine
60+
#define DEC_AUDIO_FEEDBACK 0 // of the stepper coils. Use this to verify that UART is working properly.
61+
//
62+
//
63+
//
64+
////////////////////////////
65+
//
66+
// GUIDE SETTINGS
67+
// This is the multiplier of the normal trackingspeed that a pulse will have
68+
// NEMA steppers only! Doesnt affect 28BY
69+
// standard value: RA 2.0; DEC 1.0
70+
#define RA_PULSE_MULTIPLIER 1.5
71+
#define DEC_PULSE_MULTIPLIER 1.0
5972
//
6073
//
6174
////////////////////////////
@@ -73,21 +86,8 @@
7386
#define NORTHERN_HEMISPHERE 1
7487
//
7588
//
76-
////////////////////////////
7789
//
78-
// GUIDE SETTINGS
79-
// This is the multiplier of the normal trackingspeed that a pulse will have
80-
// standard value: RA 2.2; DEC 1.2
81-
#if RA_STEPPER_TYPE == STEP_28BYJ48
82-
#define RA_PULSE_MULTIPLIER 2.0
83-
#define DEC_PULSE_MULTIPLIER 1.0
84-
#else
85-
#define RA_PULSE_MULTIPLIER 1.5
86-
#define DEC_PULSE_MULTIPLIER 1.2
87-
#endif
88-
89-
90-
90+
//
9191
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
9292
// ////////
9393
// LCD SETTINGS ////////

Software/Arduino code/OpenAstroTracker/MeadeCommandProcessor.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,13 +656,15 @@ String MeadeCommandProcessor::handleMeadeMovement(String inCmd) {
656656
else if (inCmd[0] == 'A') {
657657
// Move Azimuth or Altitude by given arcminutes
658658
// :MAZ+32.1# or :MAL-32.1#
659+
#if AZIMUTH_ALTITUDE_MOTORS == 1
659660
float arcMinute = inCmd.substring(2).toFloat();
660661
if (inCmd[1] == 'Z'){
661-
_mount->moveBy(AZIMUTH_STEPS, arcMinute);
662+
_mount->moveBy (AZIMUTH_STEPS, arcMinute);
662663
}
663664
else if (inCmd[1] == 'L'){
664-
_mount->moveBy(ALTITUDE_STEPS, arcMinute);
665+
//_mount->moveBy(ALTITUDE_STEPS, arcMinute);
665666
}
667+
#endif
666668
return "";
667669
}
668670
else if (inCmd[0] == 'e') {

Software/Arduino code/OpenAstroTracker/Mount.cpp

Lines changed: 54 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "Utility.hpp"
66
#include "EPROMStore.hpp"
77
#include "Sidereal.cpp"
8+
#include "Configuration_pins.hpp"
89

910
//mountstatus
1011
#define STATUS_PARKED 0B0000000000000000
@@ -77,7 +78,7 @@ Mount::Mount(int stepsPerRADegree, int stepsPerDECDegree, LcdMenu* lcdMenu) {
7778
_stepsPerRADegree = stepsPerRADegree;
7879
#endif
7980
#if DEC_DRIVER_TYPE != ULN2003_DRIVER
80-
_stepsPerDECDegree = stepsPerDECDegree * DEC_MICROSTEPPING;
81+
_stepsPerDECDegree = stepsPerDECDegree * DEC_SLEW_MICROSTEPPING;
8182
#else
8283
_stepsPerDECDegree = stepsPerDECDegree;
8384
#endif
@@ -445,17 +446,19 @@ void Mount::configureDECStepper(byte stepMode, byte pin1, byte pin2, int maxSpee
445446
// configureRAdriver
446447
// TMC2209 UART only
447448
/////////////////////////////////
448-
#if RA_DRIVER_TYPE == TMC2009_UART
449+
#if RA_DRIVER_TYPE == TMC2209_UART
449450
void Mount::configureRAdriver(HardwareSerial *serial, float rsense, byte driveraddress, int rmscurrent, int stallvalue)
450451
{
451452
_driverRA = new TMC2209Stepper(serial, rsense, driveraddress);
452453
_driverRA->begin();
453-
//_driverRA->en_spreadCycle(1);
454+
#if RA_AUDIO_FEEDBACK == 1
455+
_driverRA->en_spreadCycle(1);
456+
#endif
454457
_driverRA->toff(4);
455458
_driverRA->blank_time(24);
456459
_driverRA->rms_current(rmscurrent);
457460
_driverRA->microsteps(TRACKING_MICROSTEPPING);
458-
_driverRA->fclktrim(20);
461+
_driverRA->fclktrim(4);
459462
_driverRA->TCOOLTHRS(0xFFFFF); //xFFFFF);
460463
_driverRA->ihold(1); // its save to assume that the only time RA stands still is during parking and the current can be limited to a minimum
461464
//_driverRA->semin(2);
@@ -472,15 +475,17 @@ void Mount::configureRAdriver(HardwareSerial *serial, float rsense, byte drivera
472475
// configureDECdriver
473476
// TMC2209 UART only
474477
/////////////////////////////////
475-
#if DEC_DRIVER_TYPE == TMC2009_UART
478+
#if DEC_DRIVER_TYPE == TMC2209_UART
476479
void Mount::configureDECdriver(HardwareSerial *serial, float rsense, byte driveraddress, int rmscurrent, int stallvalue)
477480
{
478481
_driverDEC = new TMC2209Stepper(serial, rsense, driveraddress);
479482
_driverDEC->begin();
480483
_driverDEC->blank_time(24);
481-
//_driverDEC->en_spreadCycle(1);
484+
#if DEC_AUDIO_FEEDBACK == 1
485+
_driverDEC->en_spreadCycle(1);
486+
#endif
482487
_driverDEC->rms_current(rmscurrent);
483-
_driverDEC->microsteps(DEC_MICROSTEPPING);
488+
_driverDEC->microsteps(DEC_SLEW_MICROSTEPPING);
484489
_driverDEC->TCOOLTHRS(0xFFFFF);
485490
_driverDEC->semin(5);
486491
_driverDEC->semax(2);
@@ -512,7 +517,7 @@ void Mount::setSpeedCalibration(float val, bool saveToStorage) {
512517

513518
// The tracker simply needs to rotate at 15degrees/hour, adjusted for sidereal
514519
// time (i.e. the 15degrees is per 23h56m04s. 86164s/86400 = 0.99726852. 3590/3600 is the same ratio) So we only go 15 x 0.99726852 in an hour.
515-
#if RA_DRIVER_TYPE == TMC2009_UART
520+
#if RA_DRIVER_TYPE == TMC2209_UART
516521
_trackingSpeed = _trackingSpeedCalibration * ((_stepsPerRADegree / SET_MICROSTEPPING) * TRACKING_MICROSTEPPING) * siderealDegreesInHour / 3600.0f;
517522
#else
518523
_trackingSpeed = _trackingSpeedCalibration * _stepsPerRADegree * siderealDegreesInHour / 3600.0f;
@@ -916,7 +921,7 @@ void Mount::startSlewingToTarget() {
916921
}
917922

918923
// set Slew microsteps for TMC2209 UART // hier
919-
#if RA_DRIVER_TYPE == TMC2009_UART
924+
#if RA_DRIVER_TYPE == TMC2209_UART
920925
_driverRA->microsteps(SET_MICROSTEPPING);
921926
//_driverRA->en_spreadCycle(1); //only used as audiofeedback for quick debug
922927
#endif
@@ -935,6 +940,9 @@ void Mount::startSlewingToTarget() {
935940
_mountStatus |= STATUS_SLEWING | STATUS_SLEWING_TO_TARGET;
936941
_totalDECMove = 1.0f * _stepperDEC->distanceToGo();
937942
_totalRAMove = 1.0f * _stepperRA->distanceToGo();
943+
#if RA_STEPPER_TYPE == STEP_NEMA17 // tracking while slewing causes audible lagging
944+
stopSlewing(TRACKING);
945+
#endif
938946
}
939947

940948
/////////////////////////////////
@@ -985,32 +993,55 @@ void Mount::guidePulse(byte direction, int duration) {
985993

986994
switch (direction) {
987995
case NORTH:
996+
#if DEC_DRIVER_TYPE == TMC2209_UART
997+
_driverDEC->microsteps(DEC_GUIDE_MICROSTEPPING);
998+
#endif
988999
_stepperDEC->setAcceleration(2500);
1000+
#if DEC_STEPPER_TYPE == STEP_28BYJ48
1001+
_stepperDEC->setMaxSpeed(decTrackingSpeed * (1.0 + 0.2));
1002+
_stepperDEC->setSpeed(decTrackingSpeed * 1.0);
1003+
#else // NEMA
9891004
_stepperDEC->setMaxSpeed(decTrackingSpeed * (DEC_PULSE_MULTIPLIER + 0.2));
9901005
_stepperDEC->setSpeed(decTrackingSpeed * DEC_PULSE_MULTIPLIER);
1006+
#endif
9911007
_mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_DEC;
9921008
break;
9931009

9941010
case SOUTH:
1011+
#if DEC_DRIVER_TYPE == TMC2209_UART
1012+
_driverDEC->microsteps(DEC_GUIDE_MICROSTEPPING);
1013+
#endif
9951014
_stepperDEC->setAcceleration(2500);
1015+
#if DEC_STEPPER_TYPE == STEP_28BYJ48
1016+
_stepperDEC->setMaxSpeed(decTrackingSpeed * (1.0 + 0.2));
1017+
_stepperDEC->setSpeed(-decTrackingSpeed * 1.0);
1018+
#else // NEMA
9961019
_stepperDEC->setMaxSpeed(decTrackingSpeed * (DEC_PULSE_MULTIPLIER + 0.2));
9971020
_stepperDEC->setSpeed(-decTrackingSpeed * DEC_PULSE_MULTIPLIER);
1021+
#endif
9981022
_mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_DEC;
9991023
break;
10001024

10011025
case WEST:
1026+
1027+
#if RA_STEPPER_TYPE == STEP_28BYJ48
1028+
_stepperTRK->setMaxSpeed(raTrackingSpeed * 2.2 );
1029+
_stepperTRK->setSpeed(raTrackingSpeed * 2.0);
1030+
#else // NEMA
10021031
_stepperTRK->setMaxSpeed(raTrackingSpeed * (RA_PULSE_MULTIPLIER + 0.2 ));
10031032
_stepperTRK->setSpeed(raTrackingSpeed * RA_PULSE_MULTIPLIER);
1033+
#endif
10041034
_mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_RA;
10051035
break;
10061036

10071037
case EAST:
1008-
_stepperTRK->setMaxSpeed(raTrackingSpeed * (RA_PULSE_MULTIPLIER + 0.2));
10091038
#if RA_STEPPER_TYPE == STEP_28BYJ48
1039+
_stepperTRK->setMaxSpeed(raTrackingSpeed * 2.2 );
10101040
_stepperTRK->setSpeed(0);
1011-
#else
1041+
#else // NEMA
10121042
// Not sure why we don't stop tracking with NEMAs as is customary.....
1013-
_stepperTRK->setSpeed(0.6 * raTrackingSpeed);
1043+
_stepperTRK->setMaxSpeed(raTrackingSpeed * (RA_PULSE_MULTIPLIER + 0.2));
1044+
_stepperTRK->setSpeed(raTrackingSpeed * (RA_PULSE_MULTIPLIER - 1));
10141045
#endif
10151046
_mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_RA;
10161047
break;
@@ -1432,7 +1463,7 @@ void Mount::startSlewing(int direction) {
14321463

14331464
// Set move rate to last commanded slew rate
14341465
setSlewRate(_moveRate);
1435-
#if RA_DRIVER_TYPE == TMC2009_UART
1466+
#if RA_DRIVER_TYPE == TMC2209_UART
14361467
_driverRA->microsteps(SET_MICROSTEPPING);
14371468
//_driverRA->en_spreadCycle(1); //only used as audiofeedback for quick debug
14381469
//hier
@@ -1579,13 +1610,6 @@ void Mount::loop() {
15791610
unsigned long now = millis();
15801611
bool raStillRunning = false;
15811612
bool decStillRunning = false;
1582-
1583-
/*static uint32_t last_time = 0;
1584-
uint32_t ms = millis();
1585-
if ((ms - last_time) > 100) { //run every 0.1s
1586-
last_time = ms;*/
1587-
//Serial.println(_driverRA->mres());
1588-
//}
15891613

15901614
// Since some of the boards cannot process timer interrupts at the required
15911615
// speed (or at all), we'll just stick to deterministic calls here.
@@ -1600,13 +1624,13 @@ void Mount::loop() {
16001624
}
16011625
#endif
16021626

1603-
#if RA_DRIVER_TYPE == TMC2009_UART && DEC_DRIVER_TYPE == TMC2009_UART && USE_AUTOHOME == 1
1627+
#if RA_DRIVER_TYPE == TMC2209_UART && DEC_DRIVER_TYPE == TMC2209_UART && USE_AUTOHOME == 1
16041628
if (isFindingHome()) {
16051629
if (digitalRead(DEC_DIAG_PIN) == HIGH) {
16061630
finishFindingHomeDEC();
16071631
return;
16081632
}
1609-
if (digitalRead(RA_DIAG_PIN) == 52) {
1633+
if (digitalRead(RA_DIAG_PIN) == HIGH) {
16101634
finishFindingHomeRA();
16111635
return;
16121636
}
@@ -1617,6 +1641,9 @@ void Mount::loop() {
16171641
if (isGuiding()) {
16181642
if (millis() > _guideEndTime) {
16191643
stopGuiding();
1644+
#if DEC_DRIVER_TYPE == TMC2209_UART
1645+
_driverDEC->microsteps(DEC_SLEW_MICROSTEPPING);
1646+
#endif
16201647
}
16211648
return;
16221649
}
@@ -1655,8 +1682,9 @@ void Mount::loop() {
16551682

16561683
_currentDECStepperPosition = _stepperDEC->currentPosition();
16571684
_currentRAStepperPosition = _stepperRA->currentPosition();
1658-
#if RA_DRIVER_TYPE == TMC2009_UART
1685+
#if RA_DRIVER_TYPE == TMC2209_UART
16591686
_driverRA->microsteps(TRACKING_MICROSTEPPING);
1687+
startSlewing(TRACKING);
16601688
//_driverRA->en_spreadCycle(0); // only for audio feedback for quick debug
16611689
#endif
16621690
if (_correctForBacklash) {
@@ -1746,11 +1774,8 @@ void Mount::setHome(bool clearZeroPos) {
17461774
// Set RA and DEC to the home position
17471775
/////////////////////////////////
17481776
void Mount::setTargetToHome() {
1749-
#if RA_DRIVER_TYPE != ULN2003_DRIVER
1750-
float trackedSeconds = (_stepperTRK->currentPosition() / _trackingSpeed) * (SET_MICROSTEPPING / TRACKING_MICROSTEPPING); // steps/steps/s
1751-
#else
1777+
17521778
float trackedSeconds = _stepperTRK->currentPosition() / _trackingSpeed; // steps/steps/s
1753-
#endif
17541779

17551780
LOGV2(DEBUG_MOUNT,"Mount::setTargetToHome() called with %fs elapsed tracking", trackedSeconds);
17561781

@@ -2052,7 +2077,7 @@ String Mount::RAString(byte type, byte active) {
20522077
//
20532078
/////////////////////////////////
20542079
// Automatically home the mount. Only with TMC2209 in UART mode
2055-
#if RA_DRIVER_TYPE == TMC2009_UART && DEC_DRIVER_TYPE == TMC2009_UART && USE_AUTOHOME == 1
2080+
#if RA_DRIVER_TYPE == TMC2209_UART && DEC_DRIVER_TYPE == TMC2209_UART && USE_AUTOHOME == 1
20562081

20572082
void Mount::startFindingHomeDEC() {
20582083
_driverDEC->SGTHRS(10);
@@ -2116,7 +2141,7 @@ void Mount::finishFindingHomeRA()
21162141

21172142

21182143
startSlewing(TRACKING);
2119-
setHome();
2144+
setHome(true);
21202145

21212146
}
21222147
#endif

Software/Arduino code/OpenAstroTracker/Mount.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "DayTime.hpp"
88
#include "LcdMenu.hpp"
99

10-
#if RA_DRIVER_TYPE == TMC2009_UART
10+
#if RA_DRIVER_TYPE == TMC2209_UART
1111
#include <TMCStepper.h>
1212
// If you get an error here, download the TMCstepper library from "Tools > Manage Libraries"
1313
#endif
@@ -81,11 +81,11 @@ class Mount {
8181
#endif
8282

8383
// Configure the RA Driver (TMC2209 UART only)
84-
#if RA_DRIVER_TYPE == TMC2009_UART
84+
#if RA_DRIVER_TYPE == TMC2209_UART
8585
void configureRAdriver(HardwareSerial *serial, float rsense, byte driveraddress, int rmscurrent, int stallvalue);
8686
#endif
8787
// Configure the DEC Driver (TMC2209 UART only)
88-
#if DEC_DRIVER_TYPE == TMC2009_UART
88+
#if DEC_DRIVER_TYPE == TMC2209_UART
8989
void configureDECdriver(HardwareSerial *serial, float rsense, byte driveraddress, int rmscurrent, int stallvalue);
9090
#endif
9191

@@ -193,7 +193,7 @@ class Mount {
193193
void setHome(bool clearZeroPos);
194194

195195
// Auto Home with TMC2209 UART
196-
#if RA_DRIVER_TYPE == TMC2009_UART
196+
#if RA_DRIVER_TYPE == TMC2209_UART
197197
void startFindingHomeRA();
198198
void startFindingHomeDEC();
199199
void finishFindingHomeRA();
@@ -315,7 +315,7 @@ class Mount {
315315
AccelStepper* _stepperRA;
316316
AccelStepper* _stepperDEC;
317317
AccelStepper* _stepperTRK;
318-
#if RA_DRIVER_TYPE == TMC2009_UART
318+
#if RA_DRIVER_TYPE == TMC2209_UART
319319
TMC2209Stepper* _driverRA;
320320
TMC2209Stepper* _driverDEC;
321321
#endif

0 commit comments

Comments
 (0)