Skip to content

Commit 8951009

Browse files
Merge pull request #23 from nexdome/release/3.2.0
Release 3.2.0
2 parents 61eb44e + 0015284 commit 8951009

File tree

7 files changed

+57
-30
lines changed

7 files changed

+57
-30
lines changed

Deploy-Firmware.ps1

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ else {
2626
Remove-Item "$DeployDirectory\ReadMe.pdf" -ErrorAction Ignore
2727
}
2828

29-
Copy-Item ".\TA.NexDome.Rotator\Release\TA.NexDome.Rotator.hex" -Destination "$DeployDirectory\" -Force
30-
Copy-Item ".\TA.NexDome.Shutter\Release\TA.NexDome.Shutter.hex" -Destination "$DeployDirectory\" -Force
31-
Copy-Item ".\XBeeFactoryReset\Release\XBeeFactoryReset.hex" -Destination "$DeployDirectory\" -Force
32-
Copy-Item ".\ReadMe.pdf" -Destination "$DeployDirectory\" -Force
29+
Copy-Item ".\TA.NexDome.Rotator\Release\TA.NexDome.Rotator.hex" -Destination "$DeployDirectory\Rotator-$semver.hex" -Force
30+
Copy-Item ".\TA.NexDome.Shutter\Release\TA.NexDome.Shutter.hex" -Destination "$DeployDirectory\Shutter-$semver.hex" -Force
3331

3432
Write-Host "Deploy complete. Now build the ASCOM driver solution."
3533

ReadMe.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ DW | R | ddddd | :DWR# | @DWR,300 | Write Dead-zone in steps [
138138
FR | RS | none | :FRstring# | @FRR | Reads the semantic version (SemVer) string of the firmware.
139139
GA | R | ddd | :GAR# | @GAR,180 | Goto Azimuth (param: integer degrees)
140140
GH | R | none | :GHR# | @GHR | Rotates clockwise until the home sensor is detected and synchronizes the azimuth to the home position.
141+
GS | R | ddddd | :GSR# | @GSR,1000 | Goto whole step position (0 <=param <= @RRR)
141142
HR | R | none | :HRRddddd# | @HRR | Home position Read (steps clockwise from true north)
142143
HW | R | ddddd | :HWR# | @HWR,1000 | Home position Write (seps clockwise from true north)
143144
PR | RS | none | :PRt-dddd# | @PRR | Position Read - get current step position in whole steps (signed integer)

TA.NexDome.Rotator/CommandProcessor.cpp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ Response CommandProcessor::HandleCommand(Command& command) const
105105
if (command.Verb == "FR") return HandleFR(command); // Read firmware version
106106
if (command.Verb == "GA") return HandleGA(command); // Goto Azimuth (rotator only)
107107
if (command.Verb == "GH") return HandleGH(command); // Goto Home Sensor (rotator only)
108+
if (command.Verb == "GS") return HandleGS(command); // Goto step position (rotator only)
108109
if (command.Verb == "HR") return HandleHR(command); // Home position Read (rotator only)
109110
if (command.Verb == "HW") return HandleHW(command); // Home position Write (rotator only)
110111
if (command.Verb == "SW") return HandleSW(command); // Stop motor (emergency stop)
@@ -134,19 +135,30 @@ Response CommandProcessor::HandleAR(Command& command) const
134135
}
135136

136137

138+
void CommandProcessor::rotateToMicrostepPosition(const int32_t target) const {
139+
const auto currentPosition = rotator.getCurrentPosition();
140+
const auto delta = target - currentPosition;
141+
const auto direction = sgn(delta);
142+
if (abs(delta) >= settings.deadZone)
143+
{
144+
HomeSensor::cancelHoming();
145+
sendDirection(direction);
146+
rotator.moveToPosition(target);
147+
}
148+
}
149+
137150
Response CommandProcessor::HandleGA(Command& command) const
138151
{
139152
const auto microstepsPerDegree = settings.home.microstepsPerRotation / 360.0;
140153
const auto target = targetStepPosition(command.StepPosition * microstepsPerDegree);
141-
const auto currentPosition = rotator.getCurrentPosition();
142-
const auto delta = target - currentPosition;
143-
const auto direction = sgn(delta);
144-
if (abs(delta) >= settings.deadZone)
145-
{
146-
HomeSensor::cancelHoming();
147-
sendDirection(direction);
148-
rotator.moveToPosition(target);
149-
}
154+
rotateToMicrostepPosition(target);
155+
return Response::FromSuccessfulCommand(command);
156+
}
157+
158+
Response CommandProcessor::HandleGS(Command& command) const
159+
{
160+
const auto target = targetStepPosition(stepsToMicrosteps(command.StepPosition));
161+
rotateToMicrostepPosition(target);
150162
return Response::FromSuccessfulCommand(command);
151163
}
152164

TA.NexDome.Rotator/CommandProcessor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class CommandProcessor
3939
Response HandleAW(Command& command) const; // AW - Acceleration ramp time write
4040
Response HandleFR(Command& command) const; // Firmware version read
4141
Response HandleGA(Command& command) const; // GA - GoTo Azimuth (in degrees).
42+
void rotateToMicrostepPosition(int32_t target) const;
43+
Response HandleGS(Command& command) const; // GS - GoTo Step Position
4244
Response HandleGH(Command& command) const; // Go to home sensor
4345
Response HandleHR(Command& command) const; // Read Home position (steps clockwise from true north)
4446
Response HandleHW(Command& command) const; // Write home position (steps clockwise from true north)

TA.NexDome.Shutter/LimitSwitch.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
//
2-
//
3-
//
1+
//
2+
//
3+
//
44

55
#include <ArduinoSTL.h>
66
#include "LimitSwitch.h"
77
#include "NexDome.h"
88

99

1010
MicrosteppingMotor* LimitSwitch::motor;
11+
volatile bool LimitSwitch::closeTriggered; // static and volatile because accessed in ISR
1112

1213
LimitSwitch::LimitSwitch(MicrosteppingMotor* stepper, uint8_t openLimit, uint8_t closeLimit)
1314
: openLimitPin(openLimit), closedLimitPin(closeLimit)
@@ -27,8 +28,11 @@ bool LimitSwitch::isClosed() const
2728

2829
void LimitSwitch::onCloseLimitReached()
2930
{
31+
if (closeTriggered)
32+
return;
3033
if (motor->getCurrentVelocity() < 0)
3134
{
35+
closeTriggered = true;
3236
motor->SetCurrentPosition(SHUTTER_LIMIT_STOPPING_DISTANCE);
3337
motor->moveToPosition(0);
3438
}
@@ -45,10 +49,16 @@ void LimitSwitch::onOpenLimitReached()
4549
}
4650
}
4751

48-
void LimitSwitch::init()
52+
void LimitSwitch::onMotorStopped()
53+
{
54+
closeTriggered = false;
55+
}
56+
57+
void LimitSwitch::init() const
4958
{
5059
pinMode(openLimitPin, INPUT_PULLUP);
5160
pinMode(closedLimitPin, INPUT_PULLUP);
61+
closeTriggered = false;
5262
attachInterrupt(digitalPinToInterrupt(openLimitPin), onOpenLimitReached, FALLING);
5363
attachInterrupt(digitalPinToInterrupt(closedLimitPin), onCloseLimitReached, FALLING);
5464
}

TA.NexDome.Shutter/LimitSwitch.h

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,22 @@
1212
#include <AdvancedStepper.h>
1313

1414
class LimitSwitch
15-
{
16-
public:
17-
LimitSwitch(MicrosteppingMotor* stepper, uint8_t openLimit, uint8_t closeLimit);
18-
bool isOpen() const;
19-
bool isClosed() const;
20-
void init();
21-
private:
22-
uint8_t openLimitPin;
23-
uint8_t closedLimitPin;
24-
static MicrosteppingMotor * motor;
25-
static void onOpenLimitReached();
26-
static void onCloseLimitReached();
27-
};
15+
{
16+
public:
17+
LimitSwitch(MicrosteppingMotor* stepper, uint8_t openLimit, uint8_t closeLimit);
18+
bool isOpen() const;
19+
bool isClosed() const;
20+
void init() const;
21+
void onMotorStopped();
22+
23+
private:
24+
uint8_t openLimitPin;
25+
uint8_t closedLimitPin;
26+
static volatile bool closeTriggered;
27+
static MicrosteppingMotor* motor;
28+
static void onOpenLimitReached();
29+
static void onCloseLimitReached();
30+
};
2831

2932
#endif
3033

TA.NexDome.Shutter/TA.NexDome.Shutter.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,5 +182,6 @@ void loop()
182182
// Handle the motor stop event from the stepper driver.
183183
void onMotorStopped()
184184
{
185+
limitSwitches.onMotorStopped();
185186
commandProcessor.sendStatus();
186187
}

0 commit comments

Comments
 (0)